diff options
| -rwxr-xr-x | bin/snap_tests.py | 32 | ||||
| -rw-r--r-- | units/snappy/snappy.pxu | 19 |
2 files changed, 31 insertions, 20 deletions
diff --git a/bin/snap_tests.py b/bin/snap_tests.py index bcfb48c..e6ea23b 100755 --- a/bin/snap_tests.py +++ b/bin/snap_tests.py @@ -12,7 +12,6 @@ import sys from checkbox_support.snap_utils.snapd import Snapd # Requirements for the test snap: -# - the snap must not be installed at the start of the nested test plan # - the snap must be strictly confined (no classic or devmode flags) # - there must be different revisions on the stable & edge channels try: @@ -70,6 +69,9 @@ class SnapInstall(): args = parser.parse_args(sys.argv[2:]) print('Install {}...'.format(TEST_SNAP)) s = Snapd(SNAPD_TASK_TIMEOUT, SNAPD_POLL_INTERVAL, verbose=True) + if s.list(TEST_SNAP): + print('{} already installed. Removing'.format(TEST_SNAP)) + s.remove(TEST_SNAP) s.install(TEST_SNAP, args.channel) print('Confirm in snap list...') data = s.list() @@ -87,11 +89,12 @@ class SnapRefresh(): def invoked(self): """Test refresh of test-snapd-tools snap.""" def get_rev(): - data = Snapd().list() - for snap in data: - if snap['name'] == TEST_SNAP: - return snap['revision'] - print('Get starting revision...') + return Snapd().list(TEST_SNAP)['revision'] + if Snapd().list(TEST_SNAP): + print('Remove previously installed revision') + Snapd().remove(TEST_SNAP) + print('Install starting revision...') + Snapd().install(TEST_SNAP, 'stable') start_rev = get_rev() print(' revision:', start_rev) print('Refresh to edge...') @@ -112,10 +115,15 @@ class SnapRevert(): def invoked(self): """Test revert of test-snapd-tools snap.""" s = Snapd(SNAPD_TASK_TIMEOUT, SNAPD_POLL_INTERVAL) + if s.list(TEST_SNAP): + s.remove(TEST_SNAP) + print('Install stable revision') + s.install(TEST_SNAP) + print('Refresh to edge') + s.refresh(TEST_SNAP, 'edge') print('Get stable channel revision from store...') r = s.info(TEST_SNAP) stable_rev = r['channels']['latest/stable']['revision'] - print('Get current installed revision...') r = s.list(TEST_SNAP) installed_rev = r['revision'] # should be edge revision print('Reverting snap {}...'.format(TEST_SNAP)) @@ -140,6 +148,11 @@ class SnapReupdate(): """Test re-update of test-snapd-tools snap.""" s = Snapd(SNAPD_TASK_TIMEOUT, SNAPD_POLL_INTERVAL) print('Get edge channel revision from store...') + if s.list(TEST_SNAP): + s.remove(TEST_SNAP) + s.install(TEST_SNAP) + s.refresh(TEST_SNAP, 'edge') + s.revert(TEST_SNAP) r = s.info(TEST_SNAP) edge_rev = r['channels']['latest/edge']['revision'] print('Remove edge revision...') @@ -160,8 +173,11 @@ class SnapRemove(): def invoked(self): """Test remove of test-snapd-tools snap.""" - print('Install {}...'.format(TEST_SNAP)) + print('Remove {}...'.format(TEST_SNAP)) s = Snapd(SNAPD_TASK_TIMEOUT, SNAPD_POLL_INTERVAL) + if not s.list(TEST_SNAP): + print('{} not found. Installing'.format(TEST_SNAP)) + s.install(TEST_SNAP) s.remove(TEST_SNAP) print('Check not in snap list') data = s.list() diff --git a/units/snappy/snappy.pxu b/units/snappy/snappy.pxu index fed3f76..45ffc1b 100644 --- a/units/snappy/snappy.pxu +++ b/units/snappy/snappy.pxu @@ -46,7 +46,6 @@ plugin: shell command: snap_tests.py remove category_id: snappy estimated_duration: 10s -depends: snappy/snap-install flags: preserve-locale user: root environ: TEST_SNAP SNAPD_TASK_TIMEOUT SNAPD_POLL_INTERVAL @@ -83,7 +82,6 @@ _steps: _verification: Check hello version is back to its stable version plugin: manual -depends: snappy/snap-refresh category_id: snappy estimated_duration: 60 @@ -101,7 +99,6 @@ _steps: _verification: Check hello version is again the one from the beta channel plugin: manual -depends: snappy/snap-revert category_id: snappy estimated_duration: 60 @@ -109,12 +106,12 @@ id: snappy/snap-refresh-automated template-engine: jinja2 _summary: Test the snap refresh command is working. _description: - The snap {{ __checkbox_env__.get("TEST_SNAP", "test-snapd-tools") }} should - be installed from the stable channel prior to starting the test. The job - refreshes to edge and compares the revision before and after. + The test will install the + {{ __checkbox_env__.get("TEST_SNAP", "test-snapd-tools") }} snap from the + stable channel and then refreshes it to edge and compares the revision before + and after the refresh. plugin: shell command: snap_tests.py refresh -depends: snappy/snap-install category_id: snappy estimated_duration: 10s user: root @@ -124,12 +121,11 @@ id: snappy/snap-revert-automated template-engine: jinja2 _summary: Test the snap revert command is working. _description: - Runs after snap-refresh-automated and should revert the installed edge channel - snap {{ __checkbox_env__.get("TEST_SNAP", "test-snapd-tools") }} leftover - from that test to the one from stable. + Checks if the edge channel + {{ __checkbox_env__.get("TEST_SNAP", "test-snapd-tools") }} snap is reverted + back to the one from stable. plugin: shell command: snap_tests.py revert -depends: snappy/snap-refresh-automated category_id: snappy estimated_duration: 10s user: root @@ -143,7 +139,6 @@ _description: snap can be refreshed after removal of the blacklisted revision. plugin: shell command: snap_tests.py reupdate -depends: snappy/snap-revert-automated category_id: snappy estimated_duration: 10s user: root |
