summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2022-11-02 16:03:52 +0200
committerLars Wirzenius <liw@liw.fi>2022-11-02 16:03:52 +0200
commite9f991060e3c0577a999f427e84b255d68d25a9b (patch)
tree5c9c6144b1408c99eed2dbfe5f75809d5fcc9aa7
downloaddebian-subplot-e9f991060e3c0577a999f427e84b255d68d25a9b.tar.gz
feat: first minimal scenario
Sponsored-by: author
-rw-r--r--debian.md23
-rw-r--r--debian.py27
-rw-r--r--debian.subplot13
-rw-r--r--debian.yaml9
4 files changed, 72 insertions, 0 deletions
diff --git a/debian.md b/debian.md
new file mode 100644
index 0000000..da26c56
--- /dev/null
+++ b/debian.md
@@ -0,0 +1,23 @@
+# Introduction
+
+How do you know a machine running [Debian](https://debian.org) works,
+or at least looks repairable? This is a description minimal
+requirements for a working or repairable Debian system. It also
+specifies how to verify those requirements are met.
+
+This document is meant to be processed by the
+[Subplot](https://subplot.tech) tool, which can produce a test program
+to verify the acceptance criteria, based on scenarios specified here.
+
+# Acceptance criteria
+
+## Can log in via SSH as the `debian` user and become root with sudo
+
+_Requirement: The system administrator can log in and do things as
+root._
+
+~~~scenario
+given a Debian system
+when I run, as debian, sudo id -u
+then stdout is exactly "0\n"
+~~~
diff --git a/debian.py b/debian.py
new file mode 100644
index 0000000..7456d8a
--- /dev/null
+++ b/debian.py
@@ -0,0 +1,27 @@
+import json
+import logging
+import os
+import random
+import shlex
+import socket
+import stat
+import yaml
+
+
+def debian_system(ctx, hostname=None):
+ hostname = os.environ["DEBIAN_HOST"]
+ logging.debug(f"remember Debian host {hostname}")
+ ctx["hostname"] = hostname
+
+
+def run_as_on_host(ctx, username=None, argv0=None, args=None):
+ runcmd_run = globals()["runcmd_run"]
+ runcmd_exit_code_is_zero = globals()["runcmd_exit_code_is_zero"]
+
+ logging.debug(f"run_as_on_host: username={username!r}")
+ logging.debug(f"run_as_on_host: argv0={argv0!r}")
+ logging.debug(f"run_as_on_host: args={args!r}")
+ target = f"{username}@{ctx['hostname']}"
+ argv = ["ssh", target, "--", shlex.quote(argv0)] + shlex.split(args)
+ runcmd_run(ctx, argv)
+ runcmd_exit_code_is_zero(ctx)
diff --git a/debian.subplot b/debian.subplot
new file mode 100644
index 0000000..3a88c53
--- /dev/null
+++ b/debian.subplot
@@ -0,0 +1,13 @@
+title: "Debian system"
+subtitle: "A test suite"
+authors:
+ - Lars Wirzenius
+markdowns:
+ - debian.md
+bindings:
+ - debian.yaml
+ - lib/runcmd.yaml
+impls:
+ python:
+ - debian.py
+ - lib/runcmd.py
diff --git a/debian.yaml b/debian.yaml
new file mode 100644
index 0000000..45497ee
--- /dev/null
+++ b/debian.yaml
@@ -0,0 +1,9 @@
+- given: a Debian system
+ impl:
+ python:
+ function: debian_system
+
+- when: I run, as {username}, {argv0}{args:text}
+ impl:
+ python:
+ function: run_as_on_host