-
Notifications
You must be signed in to change notification settings - Fork 111
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
test: check package versions and downgrades #609
Changes from all commits
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,74 @@ | ||
#!/bin/bash | ||
set -xeuo pipefail | ||
|
||
# kola: { "architectures": "!s390x ppc64le", "minMemory": 2048, "tags": "needs-internet" } | ||
|
||
ok() { | ||
echo "ok" "$@" | ||
exit 0 | ||
} | ||
|
||
fatal() { | ||
echo "$@" | ||
exit 1 | ||
} | ||
|
||
# Verify all rhaos packages contain the same OpenShift version | ||
test_package_versions() { | ||
if [[ $(rpm -qa | grep rhaos | grep -v $OPENSHIFT_VERSION) ]]; then | ||
fatal "Error: rhaos packages do not match OpenShift version" | ||
fi | ||
} | ||
|
||
# Verify there are no downgraded packages | ||
test_downgraded_packages() { | ||
RELEASE=$OPENSHIFT_VERSION | ||
STREAM=fast-$RELEASE | ||
GRAPH=$(curl -sfH "Accept:application/json" "https://api.openshift.com/api/upgrades_info/v1/graph?channel=$STREAM") | ||
if [[ $? -ne 0 ]]; then | ||
fatal "Unable to get graph" | ||
fi | ||
Comment on lines
+27
to
+30
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. Interestingly, if you provide a non-existent channel as an arg to that URL, it will still return a result:
So unless the infra is down, your return code is always going to be a success. Also, since the script uses |
||
|
||
# There are no released builds on master so no need to check downgraded packages | ||
if [[ $(echo $GRAPH | jq 'has("nodes") and has("edges") and (.nodes | length == 0)') =~ "true" ]]; then | ||
ok "No released stream" | ||
fi | ||
|
||
# The cincinatti graph defines nodes as a list of objects and edges as a list | ||
# of list of two integers. Nodes are releases, and edges are updates. | ||
# [x, y] is [from release index, to release index]. The release index can | ||
# change every request for the cincinatti graph! | ||
# | ||
# Use jq to find the node that contains no "from release index" edge. | ||
# 1. Find all the unique "from release indexes" | ||
# 2. Find all the release indexes | ||
# 3. Get the difference between all the releases and the "from release | ||
# indexes". This is the latest because there is no update from this | ||
# release. | ||
PAYLOAD=$(echo $GRAPH | jq -r '. as $graph | [$graph.edges[][0]] | unique as $from | $graph.nodes | to_entries as $indexed | [$indexed[].key] | unique as $nodes | ($nodes - $from)[] as $latest | $indexed[] | select(.key == $latest) | .value.payload') | ||
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. This is some veritable jq sorcery. |
||
VERSION=$(oc adm release info $PAYLOAD -o json | jq -r '.displayVersions."machine-os".Version') | ||
OCP_COMMIT=$(curl -sSL https://art-rhcos-ci.s3.amazonaws.com/releases/rhcos-$RELEASE/$VERSION/x86_64/meta.json | jq -r '."ostree-commit"') | ||
|
||
curl -SL https://art-rhcos-ci.s3.amazonaws.com/releases/rhcos-$RELEASE/$VERSION/x86_64/rhcos-$VERSION-ostree.x86_64.tar -o $STREAM.tar | ||
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. This will break after we try again with #593 I think it'd be a bit cleaner to download the Also avoid duplicating the URL would be good. 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. @cgwalters it looks like the version of Some ideas:
I also saw that in the future the container may contain a http server. Would anything need to change in the oci-archive or would it just ab an additional http server to serve the ostree repo? 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. There's more alternatives:
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. Either way, this is basically the same thing as coreos/fedora-coreos-config#892 right? So if we deduplicate in either coreos-assembler or rpm-ostree it would be a win (less pipeline code, more easily reproduced outside of pipelines, etc.) I kind of like the 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. jlebon's comment may apply here because it would be checking from the last build and not the last release. Maybe this test should be scrapped and changed to an upgrade test from the previous releases and db diff instead of just doing a db diff. 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 think going the For RHCOS, that's harder to do without lockfiles because unexpected downgrades could happen anytime up to and including during the prod pipeline build. So it's much harder to make it as lightweight as in FCOS. |
||
|
||
mkdir -p repo && tar xvf $STREAM.tar -C $_ && rm -rf $STREAM.tar | ||
|
||
ostree pull-local repo | ||
|
||
RHCOS_COMMIT=$(rpm-ostree status --json | jq -r .deployments[0].checksum) | ||
|
||
if [[ $(rpm-ostree db diff $OCP_COMMIT $RHCOS_COMMIT | grep -A1000 Downgraded) ]]; then | ||
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. Hm, we should add something like |
||
fatal "Error: downgraded packages were found." | ||
fi | ||
} | ||
|
||
|
||
main() { | ||
cd $(mktemp -d) | ||
source /etc/os-release | ||
test_package_versions | ||
test_downgraded_packages | ||
} | ||
|
||
main | ||
|
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.
Do we care if this function causes the test to exit and not do the downgrade check? Or should the test try to accumulate errors?
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.
accumulating errors is probably better so we catch everything but we don't seem to do it on any of our tests