tests: restoring the /etc/environment and service units config for each test #3433

Merged
merged 12 commits into from Jun 8, 2017

Conversation

Projects
None yet
4 participants
Contributor

sergiocazzolato commented Jun 5, 2017

To make sure each test leaves the environment as clean as possible, this
branch is adding the restore mechanism to cleanup the snapd service
units config and the /etc/environment to its initial state. Currently
the responsability is on each test.

codecov-io commented Jun 5, 2017

Codecov Report

Merging #3433 into master will increase coverage by 0.01%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3433      +/-   ##
==========================================
+ Coverage   77.24%   77.25%   +0.01%     
==========================================
  Files         371      371              
  Lines       25519    25519              
==========================================
+ Hits        19711    19714       +3     
+ Misses       4058     4055       -3     
  Partials     1750     1750
Impacted Files Coverage Δ
interfaces/sorting.go 93.33% <0%> (ø) ⬆️
overlord/ifacestate/helpers.go 65.54% <0%> (ø) ⬆️
httputil/retry.go 93.22% <0%> (+5.08%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 556642c...dde4d14. Read the comment docs.

mvo5 approved these changes Jun 6, 2017

Looks good, thanks for this. The restore-each on each suite feels a bit repetitive but I guess there is nothing we can do about it(?) (i.e. there is no global restore-each?).

Contributor

sergiocazzolato commented Jun 6, 2017

@mvo5 thanks for the review, the change is done.

Contributor

sergiocazzolato commented Jun 6, 2017

Reverting the last change due to it is breaking the upgrade tests which don't need the prepare_each_classic

tests/lib/prepare.sh
+
+restore_classic() {
+ if [ -f /etc/environment.bak ]; then
+ rm -f /etc/environment.bak
@zyga

zyga Jun 7, 2017

Contributor

Could this file instead be fused into $SPREAD_TEST/snapd-state.tar.gz? I was thinking that we should just capture the environment fully once and then on each test iteration, overwrite the current state with what is in the tarball. There has to be some careful coding to ensure we don't leave garbage around (new files will linger but should be removed) but I'm sure we can overcome that.

@sergiocazzolato

sergiocazzolato Jun 7, 2017

Contributor

Agree with the idea, perhaps we could store initial configurations in $SPREAD_PATH/state/ and then restore from there instead of packing this inside the tar for those things are not exclusive of snapd, what do you think?

@sergiocazzolato

sergiocazzolato Jun 7, 2017

Contributor

@zyga the change is pushed.

sergiocazzolato added some commits Jun 5, 2017

Restoring the /etc/environment and service units config for each test
To make sure each test leaves the environment as clean as possible, this
branch is adding the restore mechanism to cleanup the snapd service
units config and the /etc/environment to its initial state. Currently
the responsability is on each test.
tests: apt auto-clean mechanism
This branch adds a mechanism to make an autoclean of the packages
installed through apt.

The objective is leave the environment as clean as possible by purging
automatically all the packages installed in the test.

For that an env variable has to be defined as => APT_AUTOCLEAN: 1. The
variable has to be defined explicitely in order to avoid be applied in
tests for example when snapd is intalled.

zyga approved these changes Jun 8, 2017

Looks good to me

+ mkdir -p /etc/systemd/system/snapd.service.d
+ cat <<EOF > /etc/systemd/system/snapd.service.d/local.conf
+[Unit]
+StartLimitInterval=0
@zyga

zyga Jun 8, 2017

Contributor

@morphis this will conflict with one of your branches

@zyga zyga merged commit e4e95b5 into snapcore:master Jun 8, 2017

7 checks passed

artful-amd64 autopkgtest finished (success)
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
xenial-amd64 autopkgtest finished (success)
Details
xenial-i386 autopkgtest finished (success)
Details
xenial-ppc64el autopkgtest finished (success)
Details
yakkety-amd64 autopkgtest finished (success)
Details
zesty-amd64 autopkgtest finished (success)
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment