Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tasks: Add local mock PR run to run-local.sh #584

Closed
wants to merge 6 commits into from
Closed

Conversation

martinpitt
Copy link
Member

@martinpitt martinpitt commented Mar 4, 2024

This is an "almost end to end" test which runs fully locally and requires no
GitHub interaction or token. Add a little mock GitHub server (utilizing bots'
task.test_mock_server) to respond to the required GitHub APIs for handling an
"opened PR" webhook event.

This is useful for playing around with our AMQP queue/job execution engine
locally (when using the mock GH server in interactive mode), or
validating changes to run-queue/AMQP structure.

@martinpitt
Copy link
Member Author

This is getting close -- the inner test fails because that run-queue is running in parallel with the cockpit-tasks main loop. We want to get rid of that anyway, though. I tried kill -STOP 1, but that unfortunately doesn't work (we can STOP the sleep 10, but ugh).

For `run-local.sh` and possibly other purposes it is useful to be able
to run this more than once. I.e. for starting the container, running
`setup-tasks`, interactively doing some things and then starting the
`cockpit-tasks` main loop.
Prerequisite for the next commit which will make `run-local.sh` use
`setup-tasks` directly.
We already overwrite the entry point in the webhook container and on
OpenShift, and we are going to for the impending job-runner/job split.

So drop it from the image, and instead set it explicitly in the systemd
unit.

Rework run-local.sh accordingly: Replace the async "wait for
initialization" loop with a synchronous call to setup-tasks, and only
run the `cockpit-tasks` main loop for `test_pr()` (so that we keep
covering that script) -- the other tests don't need it. This paves the
way for adding a test which covers `run-queue` with custom parameters
(against a mock GitHub API), which we will introduce in a follow-up PR.
It also gets rid of the "check out bots" code duplication for
interactive mode.
This makes them symmetric with /run/secrets/webhook. Also move the symlink
setup from `Containerfile` to `setup-tasks` - that way all the secrets setup is
in one place, and it's also more fungible (e.g. it's simple to bind-mount an
updated `setup-tasks` script without rebuilding the image).
This is an "almost end to end" test which runs fully locally and requires no
GitHub interaction or token. Add a little mock GitHub server (utilizing bots'
`task.test_mock_server`) to respond to the required GitHub APIs for handling an
"opened PR" webhook event.

This is useful for playing around with our AMQP queue/job execution engine
locally (when using the mock GH server in interactive mode), or
validating changes to run-queue/AMQP structure.
@martinpitt
Copy link
Member Author

OK, #585 is working, let's merge this new test there. No reason to drag around two PRs.

@martinpitt martinpitt closed this Mar 5, 2024
@martinpitt martinpitt deleted the amqp-tests branch March 5, 2024 05:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant