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
|
summary: Ensure that the ros-snapd-support interface works.
details: |
The ros-snapd-support interface allows the ros-snapd snap to
control snap applications.
The ros-snapd and ros2-snapd snaps define the ros-snapd-support plug.
The snaps declaring a plug on this interface must be able to control
snap applications through the snapd-snap.socket.
The test snap used has a command to get the list of snap applications
(exercising the read capability on the socket) and a command stop a snap application
(which checks the write capability).
environment:
# Python determines the "encoding" of standard output and it historically chose
# to use 7-bit ascii, breaking everything.
# In this test we pipe the outputs to gojq.
PYTHONIOENCODING: utf-8
debug: |
api-apps-client | gojq . || true
execute: |
"$TESTSTOOLS"/snaps-state install-local api-apps-client
echo "The ros-snapd-support plugs on the api-app-sclient snap is initially disconnected"
snap connections api-apps-client | MATCH "ros-snapd-support +api-apps-client:ros-snapd-support +- +-"
echo "Check for error 403 before connecting the plug"
api-apps-client > response.txt
gojq . < response.txt
gojq -r '."status-code"' < response.txt | MATCH '^403$'
echo "Connect the ros-snapd-support plug"
snap connect api-apps-client:ros-snapd-support
# Install a test snap running a service
"$TESTSTOOLS"/snaps-state install-local test-snapd-simple-service
echo "Check for presence of a the example snap service"
api-apps-client --url="/v2/apps" > response.txt
gojq . < response.txt
gojq -r '.result[] | select(.snap == "test-snapd-simple-service").enabled' < response.txt | MATCH '^true'
echo "We can disable a snap service"
api-apps-client --method=POST --url="/v2/apps" '{"action": "stop", "disable": true, "names": ["test-snapd-simple-service"]}' > response.txt
gojq . < response.txt
CHANGE=$(gojq -r '.change' < response.txt)
echo "Check if the service is now disabled"
retry -n 30 --wait 1 sh -c "api-apps-client --url=\"/v2/changes/${CHANGE}\" | gojq -r '.result.status' | MATCH '^Done'"
|