I want to debug the trigger message creation, and the `build_trigger`
method is long, and hard to follow. So I'll refactor it to be easier
for me to understand. First step: remove the `debug!` calls to make
the code shorter.
Signed-off-by: Lars Wirzenius <liw@liw.fi>
The commits in the trigger event are newest-first. When I wrote the
code I thought they were oldest-first. Mea culpa.
Signed-off-by: Lars Wirzenius <liw@liw.fi>
This works around a limitation in the native CI adapter, which checks
out the commit, but doesn't tell the CI run from which branch it came
from.
Signed-off-by: Lars Wirzenius <liw@liw.fi>
Make error messages be more specific, to enable user to debug more
effectively. Instead of a generic "message error", for example, we now
tell the user if it was a JSON parsing error, or request message write
error.
Also change the unit tests to actually read the request message before
writing response messages.
Make unit tests handle correctly different situations that they should
deal as successful, and also write to stderr results from running an
adapter before checking them, to allow unit test failures to be
debugged better.
Signed-off-by: Lars Wirzenius <liw@liw.fi>
In daemon, write a log file to enable debugging. Shut down the write
end of the socket in the daemon, to let the other end detect that
we're not sending anything else (they'll get an EOF, instead of
waiting indefinitely). Read from to the end of the socket, but with a
timeout, so that we don't wait indefinitely for the other end to close
_their_ write end. These changes make the tests using this helper be
less flaky.
Signed-off-by: Lars Wirzenius <liw@liw.fi>
This fixes a clippy warning.
Also, disable, for now, most verification scenarios in the subplot, as
something makes the CI broker too unreliable in tests to be tested,
and pretty much all test scenarios are so flaky they're useless.
Signed-off-by: Lars Wirzenius <liw@liw.fi>
Add a markdown document to document acceptance criteria for the CI
broker, and also how to verify they are being met. The document is
used by the Subplot software, and the verification is run as part of
"cargo test".
Signed-off-by: Lars Wirzenius <liw@liw.fi>
For testing the CI broker it will be helpful to have a way to send
synthetic node events, via a fake node control socket. This makes
tests easier to control than trying to convince the real node to emit
the right events, and only those events, for testing purposes.
Signed-off-by: Lars Wirzenius <liw@liw.fi>
This mostly useful for development, but serves as a way to show a
valid JSON representation of a node event.
Signed-off-by: Lars Wirzenius <liw@liw.fi>
Add more verbose logging when there's an error reading events from the
node control socket, and more verbose debug logging in general. This
helps figure out what's going on when something fails.
Handle the failure to subscribe (e.g., socket doesn't exist) and
failure to read an event from an open socket (e.g., node was stopped)
as separate errors. This makes troubleshooting easier.
Add a shutdown message, to allow tests to shut down the CI broker
cleanly.
Signed-off-by: Lars Wirzenius <liw@liw.fi>
Add a shutdown event to allow a clean shutdown of the CI broker, which
is useful for tests.
The added logging helps figure out what's going on, when there's a
problem communicating with the node or something else breaks when a
trigger message is constructed.
Also, handle the directory for status page not existing by silently
not writing a status page.
Signed-off-by: Lars Wirzenius <liw@liw.fi>
Prepare Cargo.toml for an upcoming change to add an integration and
acceptance testing suite. Update Cargo.lock as well. This commit
brings no functional changes.
Signed-off-by: Lars Wirzenius <liw@liw.fi>
Oops. We were exiting zero if there were errors. This is embarrassing.
A zero exit code should always indicate the program ran successfully.
Signed-off-by: Lars Wirzenius <liw@liw.fi>