Radish alpha
r
rad:zwTxygwuz5LDGBq255RA2CbNGrz8
Radicle CI broker
Radicle
Git
test(ci-broker.md): change shutdown scenario to verify cleanliness
Lars Wirzenius committed 6 months ago
commit e8217e8c80d8860f12f0946ead79b12b8203f9fb
parent 92f309a
1 file changed +15 -15
modified ci-broker.md
@@ -151,6 +151,8 @@ of the adapter.
set -eu
cat > /dev/null
echo '{"response":"triggered","run_id":{"id":"xyzzy"}}'
+
# Simulate a CI run that takes a while.
+
sleep 2
echo '{"response":"finished","result":"success"}'
(
echo "This is an adapter error: Mordor" 
@@ -977,30 +979,28 @@ then command is successful
~~~


-
## Shuts down when requested
+
## Can shut down cleanly

-
_Want:_ The test suite can request the CI broker to shut down
-
cleanly, and it doesn't result in an error.
+
_Want:_ The node operator can instrut the running CI broker to shut down after
+
currently executing runs finish.

-
_Why:_ In the integration test suite, we need to start and
-
stop the CI broker many times. We need to easily detect errors.
+
_Why:_This is useful for both the CI broker test suite and for operators to
+
shut down service for maintenance.

-
_Who:_ `cib-devs`
+
_Who:_ `cib-devs`, `node-ops`

-
We use a special magic fake node event to signal shutdown: a
-
`RefsFetched` event with a skipped update for a ref "`shutdown`" and
-
an object id of all zeros. This should be sufficiently impossible to
-
happen in real life.
+
We verify this by starting a relatively long-running CI run and also telling
+
`cib` to shut down, and then verifying the CI run finished successfully.

~~~scenario
given a Radicle node, with CI configured with broker.yaml and adapter dummy.sh
given a Git repository xyzzy in the Radicle node
-
given the Radicle node emits a refsUpdated event for xyzzy
-
when I run ./env.sh synthetic-events synt.sock event.json --log log.txt
-
when I try to run ./env.sh cib --config broker.yaml insert
+
when I run cibtool --db ci-broker.db trigger --repo xyzzy --commit HEAD
+
when I run cibtool --db ci-broker.db event shutdown
+
when I try to run ./env.sh cib --config broker.yaml queued
then command is successful
-
when I run cibtool --db ci-broker.db run list
-
then stdout is empty
+
when I run cibtool --db ci-broker.db run list --json
+
then stdout contains "success"
~~~