Radish alpha
r
Radicle CI broker
Radicle
Git (anonymous pull)
Log in to clone via SSH
test: document and test the step to create and configure a node
Lars Wirzenius committed 1 year ago
commit d802be2a69d2ccbd84abe962a1c2b1c87b9682fe
parent d7428e5f94f9b3ad4b56b08e27a1b3bb462790c8
1 file changed +99 -0
modified ci-broker.md
@@ -206,6 +206,105 @@ rad inspect --identity
rad id list
~~~

+
# Custom scenario steps
+

+
In this document we use scenarios to show how to verify that the CI
+
broker does what we expect of it. For this, we define several custom
+
scenario steps. In this chapter we describe those steps, and also
+
verify that the steps work.
+

+
## Set up a node
+

+
This step creates a Radicle node, the Radicle CI broker, and a CI
+
adapter.
+

+
> `given a Radicle node, with CI configured with {config} and adapter {adapter}`
+

+
The captured parts of the step are:
+

+
* `config` — the name of the embedded file (somewhere in this
+
  document) with the configuration for the CI broker
+
* `adapter` — the name of the embedded file with the CI adapter
+
  implementation; we use simple shell script dummy adapter
+
  implementations, as in this document we only care about the
+
  broker/adapter interface, not that the adapter actually performs a
+
  CI run
+

+
This step installs binaries (or makes them available to be run), and
+
creates some files. It doesn't not start long-lived processes, in
+
particular not the Radicle node process.
+

+
We verify that this scenario works by examining the results. For
+
clarity, we split the scenario into many snippets.
+

+
~~~scenario
+
given a Radicle node, with CI configured with broker.yaml and adapter dummy.sh
+
~~~
+

+
The programs we'll need are available to run. To check this, we use a
+
helper shell script to verify that. This avoids us to work around
+
limitations in Subplot for command parsing: Subplot does not parse
+
steps the way the shell does, so there is no way to pass text that
+
contains space characters to command as a single argument.
+

+
~~~scenario
+
given file which.sh
+
when I run bash which.sh rad
+
when I run bash which.sh cib
+
when I run bash which.sh cibtool
+
when I run bash which.sh synthetic-events
+
then command is successful
+
~~~
+

+
~~~{#which.sh .file .sh}
+
#!/bin/bash
+
# We use Bash build-in command as that's portable. "which" is not.
+
command -v "$1"
+
~~~
+

+
The configuration file must now exist.
+

+
~~~scenario
+
then file broker.yaml exists
+
~~~
+

+
The adapter is to be installed as `adapter.sh` and it must be
+
executable.
+

+
~~~scenario
+
then file adapter.sh exists
+
when I run ls -l adapter.sh
+
then stdout matches regex ^-rwx
+
~~~
+

+
There is a Radicle home directory.
+

+
~~~scenario
+
then directory .radicle exists
+
then directory .radicle/keys exists
+
then file .radicle/keys/radicle exists
+
then file .radicle/keys/radicle.pub exists
+
then directory .radicle/storage exists
+
then file .radicle/config.json exists
+
~~~
+

+
We also need way to set up environment variables for commands we run,
+
especially for `rad` to use the right node. Subplot does not have
+
built in support for this (at least not yet), but we work around that
+
by creating a shell script `env.sh` that sets them up.
+

+
~~~scenario
+
then file env.sh exists
+
when I run ls -l env.sh
+
then stdout matches regex ^-rwx
+
when I run ./env.sh env
+
then stdout matches regex ^PATH=
+
then stdout matches regex ^HOME=
+
then stdout matches regex ^RAD_HOME=
+
then stdout matches regex ^RAD_PASSPHRASE=
+
then stdout matches regex ^RAD_SOCKET=
+
~~~
+

# Acceptance criteria

## Shows config as JSON