-
Notifications
You must be signed in to change notification settings - Fork 680
tests: add snap version invariant during restore phase of testing #16465
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
Open
maykathm
wants to merge
9
commits into
canonical:master
Choose a base branch
from
maykathm:maykathm/SNAPDENG-36186-add-version-invariant-in-tests
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
51de3ca
tests: add snapd version check as restore invariant
maykathm a6b7b7b
tests: only check snap version if snapd socket and service are active
maykathm 43c2f00
tests: check for testing version
maykathm 8ba5d3a
tests: skip nested
maykathm e17974c
tests: remove duplicate check
maykathm b8fa7fe
Revert "tests: check for testing version"
maykathm 8fa52f3
spread: only add/remove symlink in cross-distro-reexec if not amazon
maykathm 7b2ae67
tests: use tests.invariant set
maykathm 8c7e324
tests: quote string
maykathm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,6 +11,7 @@ show_help() { | |
| echo " leftover-defer-sh: defer.sh must not be left over by tests" | ||
| echo " broken-snaps: snaps must not be left around that are in a broken state" | ||
| echo " segmentation-violations: snapd must not have segmentation-violation errors in journal logs" | ||
| echo " snapd-version: the version of snapd during restore must be the same as during project prepare" | ||
| echo " snap-mount-dir: assert that reported snap mount directory is the same as at test start" | ||
| echo | ||
| echo "Supported invariants for 'set' action:" | ||
|
|
@@ -261,6 +262,26 @@ check_snap_mount_dir() { | |
| fi | ||
| } | ||
|
|
||
| set_snapd_version() { | ||
| echo "$1" > "$TESTSTMP/tests.invariant.snapd-version" | ||
| } | ||
|
|
||
| check_snapd_version() { | ||
| if tests.nested is-nested; then | ||
| return 0 | ||
| fi | ||
| if command -v snap && systemctl is-active snapd.socket && systemctl is-active snapd.service; then | ||
| if tests.info is-snapd-from-archive && not tests.info is-reexec-enabled; then | ||
| # re-exec may be explicitly disabled in the test variant, in which case the version will not match | ||
| return 0 | ||
| fi | ||
|
Comment on lines
+274
to
+277
Contributor
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. do we still need this branch?
Contributor
Author
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. Yes, because some tests disable re-exec |
||
| snap version | grep snapd | grep -qF "$(cat "${TESTSTMP}"/tests.invariant.snapd-version)" || { | ||
| echo "tests.invariant: snapd version mismatch, expected $(cat "${TESTSTMP}"/tests.invariant.snapd-version) but got $(snap version | grep snapd | awk '{print $2}')" >&2 | ||
| return 1 | ||
| } | ||
| fi | ||
| } | ||
|
|
||
| check_invariant() { | ||
| case "$1" in | ||
| root-files-in-home) | ||
|
|
@@ -296,6 +317,9 @@ check_invariant() { | |
| snap-mount-dir) | ||
| check_snap_mount_dir "$1" | ||
| ;; | ||
| snapd-version) | ||
| check_snapd_version | ||
| ;; | ||
| *) | ||
| echo "tests.invariant: unknown invariant $1" >&2 | ||
| exit 1 | ||
|
|
@@ -316,6 +340,7 @@ main() { | |
| segmentation-violations | ||
| check-fakestore-cleaned | ||
| snap-mount-dir | ||
| snapd-version | ||
| " | ||
|
|
||
| case "$action" in | ||
|
|
@@ -345,6 +370,10 @@ main() { | |
| shift | ||
| set_snap_mount_dir "$*" | ||
| ;; | ||
| snapd-version) | ||
| shift | ||
| set_snapd_version "$*" | ||
| ;; | ||
| *) | ||
| echo "tests.invariant: unsupported set action" | ||
| exit 1 | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
why is this needed for this change?
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.
Amazon should have the cleanup in its packaging so this is a correction. It's needed for this change because without it during cleanup in the cross-distro-reexec suite when the
/snapdir is removed, snapd from the RPM package is used instead of the snap.