Skip to content

Commit

Permalink
tests: ensure snapd can be downloaded as a module (#11052)
Browse files Browse the repository at this point in the history
LP#1948838: moved files that cause an issue during git module download to tar files in the corresponding folders

Add spread test for validating snaps can be packed and installed (as well as `snap try`'d) with various circular symlinks.
  • Loading branch information
atesburak committed Dec 3, 2021
1 parent fa70d02 commit 46cd020
Show file tree
Hide file tree
Showing 23 changed files with 45 additions and 15 deletions.
2 changes: 1 addition & 1 deletion spread.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -785,7 +785,7 @@ suites:
_/hosts: _
_/hosts_n_dirs: _
# twisted fails in travis (but not regular spread).
# _/twisted: _
#_/twisted: _
_/func: _
_/funkyfunc: _
_/funcarg: _
Expand Down
Empty file.
Empty file.
Binary file added tests/completion/data/twisted/twisted.tar
Binary file not shown.
1 change: 1 addition & 0 deletions tests/completion/twisted.sh
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
cd "$SPREAD_PATH/$SPREAD_SUITE/data/twisted"
tar -xvf $SPREAD_PATH/$SPREAD_SUITE/data/twisted/twisted.tar

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

38 changes: 38 additions & 0 deletions tests/main/validate-container-happy/task.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
summary: check the symlinks following the right track

environment:
SNAP: test-snapd-validate-container-happy

prepare: |
execute: |
SNAP_MOUNT_DIR="$(os.paths snap-mount-dir)"
# We shouldn't use relative symlinks in Github as they cannot be packed correctly.
# So here let's test whether we can still pack such symlinks within a snap and use if needed.
# First we "try" to unpack the snap structure and untar the symlinks
# Then we pack the snap with these symlinks and then install
# Finally we check to see if the symlinks actually support the intervined symlinks
# Untar the symlinks
tar -xvf "$SNAP"/hell/hell.tar -C "$SNAP"/hell
snap try "$SNAP"
# Check to see if the symlinks point to the right paths
readlink "$SNAP_MOUNT_DIR"/"$SNAP"/current/hell/bar | MATCH "foo -> baz -> qux"
readlink "$SNAP_MOUNT_DIR"/"$SNAP"/current/hell/baz | MATCH "foo -> bar -> qux"
readlink "$SNAP_MOUNT_DIR"/"$SNAP"/current/hell/foo | MATCH "bar -> baz -> qux"
readlink "$SNAP_MOUNT_DIR"/"$SNAP"/current/hell/qux | MATCH "foo -> bar -> baz"
snap remove "$SNAP"
# Create a new snap structure that includes the unpacked symlinks
snap pack "$SNAP"
snap install --dangerous test-snapd-validate-container-happy_1.0_all.snap
tests.cleanup defer snap remove --purge test-snapd-validate-container-happy
# Check to see if the symlinks retain their existing paths
readlink "$SNAP_MOUNT_DIR"/"$SNAP"/current/hell/bar | MATCH "foo -> baz -> qux"
readlink "$SNAP_MOUNT_DIR"/"$SNAP"/current/hell/baz | MATCH "foo -> bar -> qux"
readlink "$SNAP_MOUNT_DIR"/"$SNAP"/current/hell/foo | MATCH "bar -> baz -> qux"
readlink "$SNAP_MOUNT_DIR"/"$SNAP"/current/hell/qux | MATCH "foo -> bar -> baz"
File renamed without changes.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
name: test-snapd-validate-container-happy
version: 1.0
apps:
validate-container:
command: bin/validate-container

0 comments on commit 46cd020

Please sign in to comment.