Skip to content

tests: run the reset.sh helper and check test invariants while the test is restored#10033

Merged
bboozzoo merged 4 commits intocanonical:masterfrom
sergiocazzolato:tests-reset-during-restore-2
Mar 16, 2021
Merged

tests: run the reset.sh helper and check test invariants while the test is restored#10033
bboozzoo merged 4 commits intocanonical:masterfrom
sergiocazzolato:tests-reset-during-restore-2

Conversation

@sergiocazzolato
Copy link
Copy Markdown
Contributor

The idea of this change is to validate all the tests restore the environment during the restore phase.

So each test should start in a clean environment, then prepare, execute and restore the test, and then clean up the environment and check the invariants, so the next test can run in a clean environment as well.

@sergiocazzolato
Copy link
Copy Markdown
Contributor Author

With this change when the invariant check fails we know the problem is in the current test and it is not related to previous executions.

Copy link
Copy Markdown
Contributor

@stolowski stolowski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm slightly confused (but maybe I don't understand the full picture); this change only moves the reset logic around (from prepare to restore - which I think makes sense), but other than that the call to tests.invariant check remains in prepare - so it's not going to help us narrow problems to current test, it can still be any other test that ran before and didn't reset properly? Am I missing something? Should invariant check be done at the end of reset too?

@sergiocazzolato
Copy link
Copy Markdown
Contributor Author

@stolowski thanks for the review, I did the change yesterday but forgot to push that.
New the invariant check is done also as part of the restore.

if [[ "$variant" = full ]]; then
"$TESTSTOOLS"/cleanup-state pre-invariant
fi
tests.invariant check
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to keep this check too (in case prepare does something wrong) or is it useless after these changes?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done, sorry, forgot to push that part

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sergiocazzolato are you sure you pushed the change, I still don't see tests.invariant check being run in the prepare_suite_each function in this file

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree here. I think it's ok to move the cleanup to restore, but keep the invariant check both here and in restore. The check does not look too expensive compared to actual tests, and by keeping it in both places we make sure that we start with a good system, and nothing slips through the cracks between restore and prepare.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the review, so now the invariant check is done as part of the prepare and restore of each test. It is a quick check so it should not affect on performance.

This is removed beacuse the bug
systemd/systemd#11502 is already closed.

Also de degraded test was failing because of this:

Error: 2021-03-12 11:28:01 Error executing
google:debian-sid-64:tests/main/degraded (mar121119-891844) :
-----
+ . /home/gopath/src/github.com/snapcore/snapd/tests/lib/systemd.sh
+ wait_for_service multi-user.target
+ local service_name=multi-user.target
+ local state=active
++ seq 300
+ for i in $(seq 300)
+ grep -q ActiveState=active
+ systemctl show -p ActiveState multi-user.target
+ return
+ case "$SPREAD_SYSTEM" in
+ grep 'State: [d]egraded'
+ systemctl status
    State: degraded
+ echo 'systemctl reports the system is in degraded mode'
systemctl reports the system is in degraded mode
+ systemctl --failed
  UNIT                          LOAD   ACTIVE SUB    DESCRIPTION
● systemd-journal-flush.service loaded failed failed Flush Journal to
Persistent Storage
@sergiocazzolato sergiocazzolato added the Simple 😃 A small PR which can be reviewed quickly label Mar 12, 2021
New the invariante clean up and check is done as part of the prepare and
restore of each test
Copy link
Copy Markdown
Contributor

@stolowski stolowski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM; the commit message may need a tweak before landing this to reflect actual changes. Thank you

Copy link
Copy Markdown
Contributor

@anonymouse64 anonymouse64 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, let's just squash merge this with a clear commit message

@anonymouse64 anonymouse64 added the Squash-merge Please squash this PR when merging. label Mar 16, 2021
Copy link
Copy Markdown
Contributor

@bboozzoo bboozzoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@bboozzoo bboozzoo merged commit 3c9436a into canonical:master Mar 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Simple 😃 A small PR which can be reviewed quickly Squash-merge Please squash this PR when merging.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants