1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
|
summary: Check that snap configuration is maintained on per-revision basis.
details: |
This test ensures that snap configuration is mainted per snap revision
and is restored on revert.
systems: [-ubuntu-core-*]
execute: |
verify_config_value() {
expected="$1"
output=$(snap get config-versions value)
if [ "$output" != "$expected" ]; then
echo "Expected config value to be $expected but got $output"
exit 1
fi
}
echo "Install test snap"
"$TESTSTOOLS"/snaps-state install-local config-versions
# precondition
snap get config-versions configure-marker | MATCH "executed-for-v1"
echo "Setting config value affecting rev 1"
snap set config-versions value=100
echo "Install a new version of the test snap"
"$TESTSTOOLS"/snaps-state install-local config-versions-v2
# precondition
snap get config-versions configure-marker | MATCH "executed-for-v2"
snap get config-versions post-refresh-hook-marker | MATCH "executed-for-v2"
echo "Expecting config value to be carried over to the new version 2"
verify_config_value 100
echo "Changing the config value affecting rev 2"
snap set config-versions value=200
verify_config_value 200
echo "Refreshing to rev 1 should not restore config"
snap refresh --revision=x1 config-versions
verify_config_value 200
echo "Changing the config value affecting rev 1"
snap set config-versions value=300
echo "Refreshing back to the rev 2 should not restore config"
snap refresh --revision=x2 config-versions
verify_config_value 300
echo "Changing the config value affecting rev 2"
snap set config-versions value=400
verify_config_value 400
echo "Reverting to the rev 1"
snap revert config-versions
verify_config_value 300
echo "Revert back to the rev 2"
snap revert --revision=x2 config-versions
verify_config_value 400
echo "Failing refresh of rev 2"
snap refresh --revision=x1 config-versions
snap get config-versions post-refresh-hook-marker | MATCH "executed-for-v1"
snap get config-versions configure-marker | MATCH "executed-for-v1"
# force failure of v2 configure hook
snap set config-versions fail-configure=yes
snap refresh --revision=x2 config-versions || true
snap changes | MATCH "Error .* Refresh \"config-versions\" snap"
snap get config-versions post-refresh-hook-marker | MATCH "executed-for-v1"
|