-
Notifications
You must be signed in to change notification settings - Fork 574
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests/main/component-hooks: add test showing that component hooks can…
… run with connected plug
- Loading branch information
1 parent
a3dc648
commit 5e4f87d
Showing
4 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
tests/main/component-hooks/comp-with-install-hook/meta/component.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,5 @@ | ||
component: snap-with-comps+comp-with-install-hook | ||
type: test | ||
version: 1.0 | ||
summary: Component 1 | ||
description: First component for snap-with-comps |
7 changes: 7 additions & 0 deletions
7
tests/main/component-hooks/comp-with-install-hook/meta/hooks/install
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,7 @@ | ||
#!/bin/bash | ||
|
||
set -xe | ||
|
||
printf "GET /ip HTTP/1.0\r\n\r\n" | nc httpbin.org 80 2>&1 > "${SNAP_COMMON}/install-logs" | ||
|
||
touch "${SNAP_COMMON}/install-done" |
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,13 @@ | ||
name: snap-with-comps | ||
version: 1.0 | ||
summary: Snap with components | ||
description: A snap that defines components | ||
base: core22 | ||
components: | ||
comp-with-install-hook: | ||
type: test | ||
hooks: | ||
install: | ||
plugs: [network] | ||
plugs: | ||
network: |
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,27 @@ | ||
summary: Test component hooks get run | ||
|
||
details: | | ||
Verifies that component hooks run on install | ||
systems: [ubuntu-16.04-64, ubuntu-18.04-64, ubuntu-2*, ubuntu-core-*] | ||
|
||
debug: | | ||
cat /var/snap/snap-with-comps/common/install-logs | ||
execute: | | ||
snap pack snap-with-comps/ | ||
snap pack comp-with-install-hook/ | ||
snap install --dangerous snap-with-comps_1.0_all.snap | ||
change_id=$(snap install --no-wait --dangerous snap-with-comps+comp-with-install-hook_1.0.comp) | ||
snap watch "${change_id}" | ||
# check component install change was as expected | ||
snap change "${change_id}" | MATCH '^Done .*Prepare component' | ||
snap change "${change_id}" | MATCH '^Done .*Mount component' | ||
snap change "${change_id}" | MATCH '^Done .*Make component .* available to the system' | ||
snap change "${change_id}" | MATCH '^Done .*Run install hook of "snap-with-comps\+comp-with-install-hook" component if present' | ||
# the hook writes this file if it runs (and uses the network via the network | ||
# plug) successfully | ||
test -f /var/snap/snap-with-comps/common/install-done |