-
Notifications
You must be signed in to change notification settings - Fork 35
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
run-local.sh: Various cleanups, prepare for job-runner #589
Changes from all commits
1171746
c5cb65e
d85f0a1
6d8f6ae
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/bin/sh | ||
# used in integration test where we can't/don't want to push back to origin | ||
set -eu | ||
if [ "$1" = push ]; then | ||
echo "$@" >> "${TEST_ATTACHMENTS}/git-push.log" | ||
exit 0 | ||
fi | ||
exec /usr/bin/git "$@" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not crazy about this, but it's probably the best option for the time being... In a certain sense, this is mocking in its purest form... |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,8 @@ S3_URL_POD=https://localhost.localdomain:9000 | |
S3_URL_HOST=https://localhost.localdomain:$S3_PORT | ||
# AMQP address from inside the cockpituous pod | ||
AMQP_POD=localhost:5671 | ||
# mock GitHub API running in tasks pod | ||
GHAPI_URL_POD="http://127.0.0.7:8443" | ||
|
||
# CLI option defaults/values | ||
PR= | ||
|
@@ -257,8 +259,8 @@ test_mock_pr() { | |
# start mock GH server | ||
PYTHONPATH=. ./mock-github cockpit-project/bots \$SHA & | ||
GH_MOCK_PID=\$! | ||
export GITHUB_API=http://127.0.0.7:8443 | ||
until curl --silent \$GITHUB_API; do sleep 0.1; done | ||
export GITHUB_API=$GHAPI_URL_POD | ||
until curl --silent --fail \$GITHUB_API/repos/cockpit-project/bots; do sleep 0.1; done | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I almost commented here that hardcoding this was bad, for example, but that's obviously non-sense in this case. Sometimes I think it would be better to have named this repository something different. I always get confused about things on the real GitHub (which should allow for generalization based on which fork is running the tests) vs. our mocked-up stuff. This is officially a drive-by. |
||
|
||
# simulate GitHub webhook event, put that into the webhook queue | ||
PYTHONPATH=. ./mock-github --print-pr-event cockpit-project/bots \$SHA | \ | ||
|
@@ -344,26 +346,18 @@ test_pr() { | |
|
||
test_mock_image_refresh() { | ||
podman cp "$MYDIR/mock-github" cockpituous-tasks:/work/bots/mock-github | ||
|
||
# the last step of an image refresh is to push the branch back to origin; we can't nor | ||
# want to do that here, so divert "git push" to a log file and check that | ||
cat <<EOF | podman exec -i -u root cockpituous-tasks sh -euxc "cat > /usr/local/bin/git; chmod +x /usr/local/bin/git" | ||
#!/bin/sh | ||
if [ "\$1" = push ]; then | ||
echo "\$@" >> /work/git-push.log | ||
exit 0 | ||
fi | ||
exec /usr/bin/git "\$@" | ||
EOF | ||
podman cp "$MYDIR/mock-git-push" cockpituous-tasks:/usr/local/bin/git | ||
|
||
podman exec -i cockpituous-tasks sh -euxc " | ||
cd bots | ||
# start mock GH server; use a mock SHA, only used for posting statuses | ||
SHA=123abc | ||
# test mock PR against our checkout, so that cloning will work | ||
SHA=\$(git rev-parse HEAD) | ||
|
||
# start mock GH server | ||
PYTHONPATH=. ./mock-github cockpit-project/bots \$SHA & | ||
GH_MOCK_PID=\$! | ||
export GITHUB_API=http://127.0.0.7:8443 | ||
until curl --silent \$GITHUB_API; do sleep 0.1; done | ||
export GITHUB_API=$GHAPI_URL_POD | ||
until curl --silent --fail \$GITHUB_API/repos/cockpit-project/bots; do sleep 0.1; done | ||
|
||
# simulate GitHub webhook event, put that into the webhook queue | ||
PYTHONPATH=. ./mock-github --print-image-refresh-event cockpit-project/bots \$SHA | \ | ||
|
@@ -395,20 +389,24 @@ EOF | |
assert_in 'Success.' "$LOG" | ||
|
||
# branch was (mock) pushed | ||
PUSH_LOG="$(podman exec -i cockpituous-tasks cat /work/git-push.log)" | ||
PUSH_LOG_MATCH="$($CURL $LOGS_URL| grep -o "image-refresh-foonux-[[:alnum:]-]*/git-push.log<")" | ||
PUSH_LOG="$($CURL "${LOGS_URL}${PUSH_LOG_MATCH%<}")" | ||
assert_in 'push origin +HEAD:refs/heads/image-refresh-foonux-' "$PUSH_LOG" | ||
podman exec -i cockpituous-tasks rm /work/git-push.log | ||
podman exec -i -u root cockpituous-tasks rm /usr/local/bin/git | ||
|
||
podman exec -i cockpituous-tasks sh -euxc ' | ||
# image is on the S3 server | ||
cd bots | ||
name=$(python3 -m lib.s3 ls '$S3_URL_POD'/images/ | grep -o "foonux.*qcow2") | ||
|
||
# download image (it was not pushed to git, so need to use --state) | ||
rm -f /cache/images/foonux* | ||
./image-download --store $COCKPIT_IMAGE_UPLOAD_STORE --state "$name" | ||
|
||
# validate image contents | ||
qemu-img convert /cache/images/foonux-*.qcow2 /tmp/foonux.raw | ||
grep "^fakeimage" /tmp/foonux.raw | ||
rm /tmp/foonux.raw | ||
|
||
# image is on the S3 server | ||
cd bots | ||
python3 -m lib.s3 ls '$S3_URL_POD'/images/ | grep "foonux.*qcow" | ||
' | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is starting to beg for a separate
tasks/container/
directory...