Skip to content

Commit

Permalink
tests/lib/tools/store-state: exit on errors, update relevant tests (#…
Browse files Browse the repository at this point in the history
…14725)

* tests/lib/tools//store-state: exit on errors

Signed-off-by: Maciej Borzecki <[email protected]>

tests/lib/tools/store-state: use gojq

Signed-off-by: Maciej Borzecki <[email protected]>

* tests/main/interfaces-custom-device-app-slot: fix missing ack of developer1 assertions

Signed-off-by: Maciej Borzecki <[email protected]>

* tests/main/store-state: use core22 for test snap

Signed-off-by: Maciej Borzecki <[email protected]>

* tests/main/system-usernames-snap-scoped: use core22 base, install before using fake store

Signed-off-by: Maciej Borzecki <[email protected]>

* tests/lib/tools/store-state: mask failure in a ping to the main store

The ping is best effort, and is only helpful when later requests will
exercise parts of the API related to lookup of snaps that aren't already
installed. However, in the tests, all relevant dependencies should be
installed beforehand anyway.

Signed-off-by: Maciej Borzecki <[email protected]>

---------

Signed-off-by: Maciej Borzecki <[email protected]>
  • Loading branch information
bboozzoo authored Nov 15, 2024
1 parent 09fcec0 commit ff9d91a
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 2 deletions.
7 changes: 5 additions & 2 deletions tests/lib/tools/store-state
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash

set -e

STORE_CONFIG=/etc/systemd/system/snapd.service.d/store.conf

show_help() {
Expand Down Expand Up @@ -141,8 +143,9 @@ setup_fake_store(){
return 1
fi

# before switching make sure we have a session macaroon
snap find test-snapd-tools
# before switching make sure we have a session macaroon, but keep it best
# effort
snap find test-snapd-tools || true
mkdir -p "$top_dir/asserts"

# debugging
Expand Down
13 changes: 13 additions & 0 deletions tests/main/interfaces-custom-device-app-slot/task.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,22 @@ prepare: |
snap install core
fi
# Install store-state dependencies
echo "Ensure jq is installed"
if ! command -v jq; then
snap install --devmode jq
fi
echo "Ensure yaml2json is installed"
if ! command -v yaml2json; then
snap install --devmode remarshal
fi
snap debug can-manage-refreshes | MATCH false
snap ack "$TESTSLIB/assertions/testrootorg-store.account-key"
snap ack "$TESTSLIB/assertions/developer1.account"
snap ack "$TESTSLIB/assertions/developer1.account-key"
"$TESTSTOOLS"/store-state setup-fake-store "$BLOB_DIR"
Expand Down
1 change: 1 addition & 0 deletions tests/main/store-state/snap/meta/snap.yaml.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: SNAPNAME
summary: generic snap
version: '1.0'
base: core22

apps:
test-app:
Expand Down
4 changes: 4 additions & 0 deletions tests/main/store-state/task.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ execute: |
snap info core | MATCH "store-url:.*https://snapcraft.io"
fi
# install test snap dependency before switching to fake store
# TODO: extract base name when switching to gojq
snap install core22
# Setup fakestore
STORE_DIR="$(pwd)/fake-store-blobdir"
snap ack "$TESTSLIB/assertions/testrootorg-store.account-key"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: SNAPNAME
summary: Snap requesting snap-scoped system users
version: '1.0'
base: core22

apps:
test-app:
Expand Down
4 changes: 4 additions & 0 deletions tests/main/system-usernames-snap-scoped/task.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ prepare: |
snap debug can-manage-refreshes | MATCH false
# install dependencies before switching to fake store
# TODO extract base from snap metadata when swithing to gojq
snap install core22
snap ack "$TESTSLIB/assertions/testrootorg-store.account-key"
"$TESTSTOOLS"/store-state setup-fake-store "$STORE_DIR"
Expand Down

0 comments on commit ff9d91a

Please sign in to comment.