canonical / edgex-checkbox-provider

Checkbox tests for EdgeX snaps
Apache License 2.0
0 stars 3 forks source link

Snap command not found when running core20 snap on uc16 #59

Closed farshidtz closed 1 year ago

farshidtz commented 1 year ago

After the upgrade to core20 base snap (https://github.com/canonical/edgex-checkbox-provider/pull/49), the snap command is no longer works when running the tests on a host with Ubuntu Core 16:

2023/01/30 19:00:09 [exec] sudo snap install edgexfoundry --channel=latest/edge
2023/01/30 19:00:09 [stderr] sudo: snap: command not found

Steps to reproduce:

$ multipass launch core --name=uc16
Launched: uc16
$ multipass shell uc16
$ sudo snap install checkbox-edgexfoundry --edge --devmode
checkbox-edgexfoundry (edge) 2.0 from Canonical Certification Team (ce-certification-qa) installed
$ sudo DEFAULT_TEST_CHANNEL="latest/beta" checkbox-edgexfoundry.latest
...
-------------[ Running job 22 / 22. Estimated time left: unknown ]--------------
---------------------------[ Test edgexfoundry snap ]---------------------------
ID: com.canonical.certification::edgex/latest/edgexfoundry
Category: com.canonical.certification::edgex
... 8< -------------------------------------------------------------------------
Cloning into 'tmp/edgex-snap-testing'...
Running Go snap tests for edgexfoundry:
go: downloading github.com/stretchr/testify v1.8.1
go: downloading github.com/davecgh/go-spew v1.1.1
go: downloading github.com/pmezard/go-difflib v1.0.0
go: downloading gopkg.in/yaml.v3 v3.0.1
2023/02/10 11:37:50 [CLEAN]
2023/02/10 11:37:50 [exec] sudo snap remove --purge edgexfoundry
2023/02/10 11:37:50 [stderr] sudo: snap: command not found
2023/02/10 11:37:50 [SETUP]
2023/02/10 11:37:50 [exec] sudo snap install edgexfoundry --channel=latest/beta
2023/02/10 11:37:50 [stderr] sudo: snap: command not found
2023/02/10 11:37:50 [TEARDOWN]
2023/02/10 11:37:50 [exec] (sudo journalctl --since "2023-02-10 11:37:50" --no-pager | grep "edgexfoundry"|| true) > edgexfoundry.log
Wrote snap logs to /home/ubuntu/tmp/edgex-snap-testing/test/suites/edgexfoundry/edgexfoundry.log
2023/02/10 11:37:50 [exec] sudo snap remove --purge edgexfoundry
2023/02/10 11:37:50 [stderr] sudo: snap: command not found
2023/02/10 11:37:50 Failed to setup tests: exit status 1: sudo: snap: command not found
FAIL    edgex-snap-testing/test/suites/edgexfoundry 0.028s
FAIL
========== edgexfoundry snap error logs ==========
------------------------------------------------------------------------- >8 ---
Outcome: job failed
farshidtz commented 1 year ago

Installing the snapd snap before running the tests solves this issue:

sudo snap install snapd
$ sudo DEFAULT_TEST_CHANNEL="latest/beta" checkbox-edgexfoundry.latest
Cloning into 'tmp/edgex-snap-testing'...
Running Go snap tests for edgexfoundry:
2023/02/10 11:39:34 [CLEAN]
2023/02/10 11:39:34 [exec] sudo snap remove --purge edgexfoundry
2023/02/10 11:39:34 [stderr] snap "edgexfoundry" is not installed
2023/02/10 11:39:34 [SETUP]
2023/02/10 11:39:34 [exec] sudo snap install edgexfoundry --channel=latest/beta
2023/02/10 11:40:15 [stdout] edgexfoundry (beta) 3.0.0-dev.29 from Canonical** installed
...
farshidtz commented 1 year ago

Snapd is actually installed already, perhaps coming from the core snap. The problem is that the core20 checkbox-edgexfoundry snap replaces the snap binary with a symbolic link to where the snapped snapd would have been installed:

ubuntu@uc16:~$ snap version
snap    2.58
snapd   2.58
series  16
kernel  4.4.0-187-generic

ubuntu@uc16:~$ ls -l /usr/bin/snap
-rwxr-xr-x 1 root root 25033504 Dec  1 20:41 /usr/bin/snap

ubuntu@uc16:~$ sudo snap run --shell checkbox-edgexfoundry.latest

root@uc16:/home/ubuntu# snap version
bash: snap: command not found

root@uc16:/home/ubuntu# ls -l /usr/bin/snap
lrwxrwxrwx 1 root root 32 Jan 26 06:46 /usr/bin/snap -> /snap/snapd/current/usr/bin/snap