Commit Graph
127 Commits
Author SHA1 Message Date
Lars Wirzenius 1fbb4ccbd5 chore: add new modules to src/lib.rs 2024-07-02 19:56:05 +03:00
Lars Wirzenius 56c212a8ca feat: module to process events in event queue 2024-07-02 19:56:05 +03:00
Lars Wirzenius 77d08d3fcc feat: module to insert events into event queue
Make BrokerEvent de-serializable so that we can store them as JSON in
the database in the persistent event queue.

Signed-off-by: Lars Wirzenius <liw@liw.fi>
2024-07-02 19:55:42 +03:00
Lars Wirzenius 6e5c0d0290 fix: adapt src/broker.rs to new database abstraction 2024-07-02 19:55:35 +03:00
Lars Wirzenius 1386c94189 feat: rewrite database abstraction
Add a "counter" table, to enable a rudimentary concurrency test. Used
this to verify that multiple processes can safely update the same
database. Multi-process concurrency can result in temporary, short
lived lock conflicts in transactions: deal with this by re-trying for
a short duration.

Add a persistent event queue. Add methods to the Db type to deal with
counters and event queue.

Add a new error type to allow Db methods to return errors that do not
come from SQLite.

Restructure the internals a bit to make them easier for me to follow.
2024-07-02 19:55:35 +03:00
Lars Wirzenius 969f4fb2fb feat: serialize a configuration as JSON
This will allow the CI broker to show the full actual configuration to
the user.
2024-07-02 19:55:35 +03:00
Lars Wirzenius fc5a466426 feat: teach synthetic-event to repeat events
This allows for simplistic performance testing.
2024-07-02 19:55:35 +03:00
Lars Wirzenius 61cbf9e236 feat: log the name of the adapter binary
This turned out to be helpful when debugging a problem.
2024-07-02 19:55:35 +03:00
Lars Wirzenius 74862206fb fix: parsing of ref strings for NID; also add tests
I don't understand how the old could ever have worked. Maybe I don't
understand what's going on. The tests should help, in the future.

Signed-off-by: Lars Wirzenius <liw@liw.fi>
2024-07-02 19:55:06 +03:00
Lars Wirzenius 0266df7e21 feat! remove BrokerEvent::is_allowed from its public API
Nobody in the CI broker was using it, so no other changes.

Signed-off-by: Lars Wirzenius <liw@liw.fi>
2024-07-02 19:52:55 +03:00
Lars Wirzenius 1010100c29 refactor: remove unnecessary variable
Signed-off-by: Lars Wirzenius <liw@liw.fi>
2024-06-18 20:36:22 +03:00
Lars Wirzenius c69c4c44ca refactor: rename variables for clarity
Signed-off-by: Lars Wirzenius <liw@liw.fi>
2024-06-18 20:36:22 +03:00
Lars Wirzenius b1820f3c2a refactor: simplify creating Result::Trigger
I find this easier to follow than keeping track of so many variables.

Signed-off-by: Lars Wirzenius <liw@liw.fi>
2024-06-18 20:36:22 +03:00
Lars Wirzenius 3a9f8ff3e2 refactor: simplify handling of parse_ref result
Signed-off-by: Lars Wirzenius <liw@liw.fi>
2024-06-18 20:36:22 +03:00
Lars Wirzenius e842e01ac1 refactor: make variable have an initial value
Clearer for me.

Signed-off-by: Lars Wirzenius <liw@liw.fi>
2024-06-18 20:36:22 +03:00
Lars Wirzenius b4484b946d refactor: move PatchEvent creation to its own function
For clarity.

Signed-off-by: Lars Wirzenius <liw@liw.fi>
2024-06-18 20:36:22 +03:00
Lars Wirzenius f38697e2d9 refactor: move creation of PushEvent to its own function
This is clearer for me.

Signed-off-by: Lars Wirzenius <liw@liw.fi>
2024-06-18 20:36:22 +03:00
Lars Wirzenius d84eccdcb6 refactor: drop unnecessary PathAction conversion from string
Signed-off-by: Lars Wirzenius <liw@liw.fi>
2024-06-18 20:36:22 +03:00
Lars Wirzenius 5fa43fc325 refactor: simplify how common fields Repository is created
Signed-off-by: Lars Wirzenius <liw@liw.fi>
2024-06-18 20:36:22 +03:00
Lars Wirzenius a216b84bd1 refactor: drop debug logging, to make code easier to grok
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>
2024-06-18 20:35:14 +03:00
Lars Wirzenius c82fc3f657 fix: use the latest commit in a patch or push change
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>
2024-06-06 14:40:02 +03:00
Lars Wirzenius 645c5436cb feat: improve logging of event filtering
This makes it a little easier for me to read what's happening in the
filtering.

Signed-off-by: Lars Wirzenius <liw@liw.fi>
2024-06-06 14:39:45 +03:00
Lars Wirzenius e16308414b chore: update dependency on radicle to 0.11.0
Small fixes to adapt to API changes in the radicle crate.

Signed-off-by: Lars Wirzenius <liw@liw.fi>
2024-06-06 14:39:45 +03:00
Michalis Zampetakis e3a90dfc19 Provide a parser function for parsing reference.
Currently supported handlers for puch and patch events.
2024-05-24 22:26:39 +03:00
Michalis Zampetakis 8adca82fe3 Change the way that the broker perceives a patch
Instead of checking for changes in patch cob, check if push is at
`/refs/heads/patches/`.

Adds AnyPushRef filter.
2024-05-23 21:15:43 +03:00
Lars Wirzenius 3a0ef23cd5 fix: typo in error message
Signed-off-by: Lars Wirzenius <liw@liw.fi>
2024-05-20 17:59:19 +03:00
Lars Wirzenius 95b7b44a18 fix: space between information elements
Signed-off-by: Lars Wirzenius <liw@liw.fi>
2024-05-20 17:39:21 +03:00
Lars Wirzenius fb51ce2bd9 feat: allow adapter to report an optional URL for a run
Also verify that the URL ends up in the HTML pages generated by the CI
broker.

Signed-off-by: Lars Wirzenius <liw@liw.fi>
2024-05-20 17:24:57 +03:00
Lars Wirzenius e529ffbb5c feat: add helper program to parse response messages
This is useful for me for debugging. May be useful for others.

Signed-off-by: Lars Wirzenius <liw@liw.fi>
2024-05-20 17:24:54 +03:00
Lars Wirzenius f6d61de9a5 tests: verify that the CI broker always writes the report page
Signed-off-by: Lars Wirzenius <liw@liw.fi>
2024-05-20 16:32:54 +03:00
Lars Wirzenius d4ab0af114 feat(broker.rs): log underlying errors when running an adapter fail
Also, in unit tests that run the adapter, read the request before
sending responses.

Signed-off-by: Lars Wirzenius <liw@liw.fi>
2024-05-13 12:47:28 +03:00
Lars Wirzenius 742824f07d feat(adapter.rs):
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>
2024-05-13 12:47:28 +03:00
Lars Wirzenius 730d6abcb7 tests(synthetic-events): make more reliable
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>
2024-05-13 12:47:19 +03:00
Lars Wirzenius af0bac1ec1 refactor: avoid unnecessary let/variable
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>
2024-05-09 16:04:09 +03:00
Lars Wirzenius 1f1e0c72b7 tests: add subplot to capture acceptance criteria and verification
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>
2024-05-07 19:32:51 +03:00
Lars Wirzenius c3eda6c3f1 tests: add helper program to send node events to fake control socket
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>
2024-05-07 19:26:40 +03:00
Lars Wirzenius bb24029ff5 feat: add helper program to output node events
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>
2024-05-07 19:26:40 +03:00
Lars Wirzenius 1a44586eac feat: add more verbose errors and debug logging to event reading
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>
2024-05-07 19:23:06 +03:00
Lars Wirzenius e243687658 feat: add shutdown event and debug logging for trigger building
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>
2024-05-07 19:17:56 +03:00
Lars Wirzenius 6897866977 fix: if there's an error, exit non-zero
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>
2024-05-07 18:59:25 +03:00
Lars Wirzenius f74baba14d Merge branch 'patch/c095a06' 2024-04-16 08:13:45 +03:00
Lars Wirzenius a59b2dba82 refactor: use enum for patch action variants
Stringly typed things tend to break.

Signed-off-by: Lars Wirzenius <liw@liw.fi>
2024-04-15 20:44:00 +03:00
Lars Wirzenius 9791d80792 fix: terminate the CI broker if the connection to the node breaks
Something else, e.g., systemd, can restart the broker.

Signed-off-by: Lars Wirzenius <liw@liw.fi>
2024-04-15 20:06:38 +03:00
Lars Wirzenius f834f3ee5f fix: handle adapter process exiting non-zero
Signed-off-by: Lars Wirzenius <liw@liw.fi>
2024-04-15 16:57:03 +03:00
Michalis Zampetakis 6b4c93146f Removes unused imports 2024-04-15 10:21:26 +03:00
Michalis Zampetakis 2fe966abf3 Adds different error for second message 2024-04-15 10:18:52 +03:00
Lars Wirzenius db73047f48 Merge branch 'patch/30271be' 2024-04-12 16:14:02 +03:00
Lars Wirzenius b42745093c refactor: apply suggestion from clippy to be more idiomatic 2024-04-12 16:13:42 +03:00
Lars Wirzenius d8a1035da0 refactor: use .with_class instead of .with_attribute to set class
It's shorter and easier to grasp.

Signed-off-by: Lars Wirzenius <liw@liw.fi>
2024-04-11 09:37:56 +03:00
Lars Wirzenius 9085ada0db chore: update to html-gen API changes
Signed-off-by: Lars Wirzenius <liw@liw.fi>
2024-04-11 09:37:56 +03:00