-
Notifications
You must be signed in to change notification settings - Fork 587
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: add a test for snapctl is-connected --pid
- Loading branch information
1 parent
223a672
commit ee670df
Showing
5 changed files
with
84 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
summary: Ensure that "snapctl is-connected --pid" works. | ||
|
||
prepare: | | ||
#shellcheck source=tests/lib/snaps.sh | ||
. "$TESTSLIB"/snaps.sh | ||
install_local test-snap1 | ||
install_local test-snap2 | ||
execute: | | ||
echo "The test-snap1 service is running" | ||
systemctl is-active snap.test-snap1.svc.service | ||
svc_pid=$(systemctl show --property=MainPID snap.test-snap1.svc.service | cut -d = -f 2) | ||
echo "Plugs and slots are initially disconnected" | ||
not test-snap2.snapctl is-connected bar-plug | ||
not test-snap2.snapctl is-connected foo-slot | ||
echo "Disconnected interfaces are not connected to a snap process" | ||
not test-snap2.snapctl is-connected --pid "$svc_pid" bar-plug | ||
not test-snap2.snapctl is-connected --pid "$svc_pid" foo-slot | ||
echo "Disconnected interfaces are not connected to non-snap process" | ||
not test-snap2.snapctl is-connected --pid 1 bar-plug | ||
not test-snap2.snapctl is-connected --pid 1 foo-slot | ||
echo "Connect interfaces" | ||
snap connect test-snap1:foo-plug test-snap2:foo-slot | ||
snap connect test-snap2:bar-plug test-snap1:bar-slot | ||
echo "Connected interfaces report as connected to snap process" | ||
test-snap2.snapctl is-connected --pid "$svc_pid" bar-plug | ||
test-snap2.snapctl is-connected --pid "$svc_pid" foo-slot | ||
echo "Interfaces still not connected to non-snap process" | ||
not test-snap2.snapctl is-connected --pid 1 bar-plug | ||
not test-snap2.snapctl is-connected --pid 1 foo-slot |
4 changes: 4 additions & 0 deletions
4
tests/main/snapctl-is-connected-pid/test-snap1/bin/service.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/sh | ||
|
||
echo "service running" | ||
exec sleep infinity |
21 changes: 21 additions & 0 deletions
21
tests/main/snapctl-is-connected-pid/test-snap1/meta/snap.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
name: test-snap1 | ||
version: 1 | ||
summary: First test snap | ||
|
||
plugs: | ||
foo-plug: | ||
interface: content | ||
content: foo | ||
target: $SNAP_COMMON/foo | ||
|
||
slots: | ||
bar-slot: | ||
interface: content | ||
content: bar | ||
read: | ||
- $SNAP | ||
|
||
apps: | ||
svc: | ||
command: bin/service.sh | ||
daemon: simple |
2 changes: 2 additions & 0 deletions
2
tests/main/snapctl-is-connected-pid/test-snap2/bin/run-snapctl.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#!/bin/sh | ||
exec snapctl "$@" |
20 changes: 20 additions & 0 deletions
20
tests/main/snapctl-is-connected-pid/test-snap2/meta/snap.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
name: test-snap2 | ||
version: 1 | ||
summary: Second test snap | ||
|
||
plugs: | ||
bar-plug: | ||
interface: content | ||
content: bar | ||
target: $SNAP_COMMON/bar | ||
|
||
slots: | ||
foo-slot: | ||
interface: content | ||
content: foo | ||
read: | ||
- $SNAP | ||
|
||
apps: | ||
snapctl: | ||
command: bin/run-snapctl.sh |