Skip to content

Commit e7945bc

Browse files
committed
test(test-guest): add Snap installation provisioning
Signed-off-by: Evan Lezar <elezar@nvidia.com>
1 parent eb73c6c commit e7945bc

11 files changed

Lines changed: 289 additions & 140 deletions

File tree

‎nix/test-guest/README.md‎

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -63,18 +63,18 @@ The root [`flake.nix`](../../flake.nix) exposes this directory as the `test-gues
6363

6464
## Supported configurations
6565

66-
| Distro | Docker | Rootless Podman | SELinux | Package format |
67-
| --- | --- | --- | --- | --- |
68-
| Ubuntu 24.04 | Yes | No | No | `.deb` |
69-
| Ubuntu 26.04 | Yes | Yes | No | `.deb` |
70-
| CentOS Stream 10 | No | No | Yes | `.rpm` |
71-
| Fedora 44 | No | Yes | Yes | `.rpm` |
72-
| Rocky Linux 9 | Yes | No | Yes | `.rpm` |
66+
| Distro | Docker package | Docker Snap | Rootless Podman | SELinux | Package format |
67+
| --- | --- | --- | --- | --- | --- |
68+
| Ubuntu 24.04 | Yes | Yes | No | No | `.deb` |
69+
| Ubuntu 26.04 | Yes | Yes | Yes | No | `.deb` |
70+
| CentOS Stream 10 | No | No | No | Yes | `.rpm` |
71+
| Fedora 44 | No | No | Yes | Yes | `.rpm` |
72+
| Rocky Linux 9 | Yes | No | No | Yes | `.rpm` |
7373

7474
The `snapd` configuration is available for Ubuntu and prepares snapd for
75-
local Snap lifecycle experiments. It does not install Docker, because the Snap
76-
gateway reproduction uses the Docker **Snap** and its `docker:docker-daemon`
77-
interface rather than the host-package Docker configuration.
75+
local Snap lifecycle experiments. Add `docker-snap` after `snapd` to install
76+
the Docker **Snap** and model the `docker:docker-daemon` interface used by the
77+
OpenShell Snap. This is separate from the host-package Docker configuration.
7878

7979
`podman-rootless` configures the explicit rootless Podman guest setup used by
8080
OpenShell tests. It supports Fedora and Ubuntu 26.04 or later. Ubuntu adds the
@@ -242,27 +242,26 @@ nix run .#test-guest -- \
242242
-- openshell --version
243243
```
244244

245-
## Reproduce Snap gateway startup
245+
## Verify Snap gateway status
246246

247-
The gateway Snap must be native to the guest architecture. Copy an existing
248-
Snap artifact and the reproduction script into a prepared Ubuntu guest, then
249-
run the script as root. It follows the Release Canary ordering exactly: install
250-
the Snap, connect Docker/log/system interfaces, and immediately query the
251-
gateway. On each failure it prints snapd and gateway journals.
247+
The candidate Snap must be native to the guest architecture. The `openshell-snap`
248+
provisioner installs it, connects the Docker/log/system interfaces, registers the
249+
local gateway, and waits for `openshell status`, matching the Release Canary
250+
validation flow.
252251

253252
```shell
254253
nix run .#test-guest -- \
255254
--distro ubuntu-24-04 \
256255
--with snapd \
256+
--with docker-snap \
257257
--keep \
258-
--copy ./openshell_*.snap:/tmp/openshell.snap \
259-
--copy ./nix/test-guest/scripts/snap-gateway-repro.sh:/usr/local/bin/snap-gateway-repro \
260-
-- sudo /usr/local/bin/snap-gateway-repro /tmp/openshell.snap 10 30
258+
--copy ./openshell_*.snap:/var/lib/openshell-conformance/candidate/openshell.snap \
259+
--provision openshell-snap \
260+
-- true
261261
```
262262

263263
`--keep` retains the overlay and serial log when diagnosing a failure. The
264-
runner prints their location after shutdown. The final `30` accepts automatic
265-
recovery for up to 30 seconds; omit it to require the canary's immediate check.
264+
runner prints their location after shutdown.
266265

267266

268267
The destination must be an absolute guest path. Copied files are installed with mode `0755`.
@@ -271,7 +270,8 @@ The destination must be an absolute guest path. Copied files are installed with
271270

272271
```text
273272
--distro NAME Base distro: ubuntu-24-04, ubuntu-26-04, centos, fedora, or rocky
274-
--with NAME Apply docker, podman-rootless, selinux, or snapd; repeatable
273+
--with NAME Apply docker, docker-snap, podman-rootless, selinux, or snapd; repeatable
274+
--provision NAME Apply a post-artifact system provisioner; repeatable
275275
--install PATH Install a .deb or .rpm package; repeatable
276276
--copy SRC:DEST Copy a regular file into the guest, preserving its host mode;
277277
repeatable

‎nix/test-guest/cache.sh‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Usage:
1313
1414
Options:
1515
--distro NAME Base distro: ubuntu-24-04, ubuntu-26-04, centos, fedora, or rocky
16-
--with NAME Apply a configuration; repeatable (docker, podman-rootless, selinux, snapd)
16+
--with NAME Apply a configuration; repeatable (docker, docker-snap, podman-rootless, selinux, snapd)
1717
--repository REF OCI repository without a tag
1818
--digest DIGEST Trusted OCI manifest digest required for pulls
1919
--cache-dir PATH Override the local prepared-disk cache directory
@@ -380,6 +380,7 @@ build_local() {
380380
for configuration in "${configurations[@]}"; do
381381
case "${configuration}" in
382382
docker) validation+='; docker info >/dev/null' ;;
383+
docker-snap) validation+='; /snap/bin/docker info >/dev/null' ;;
383384
podman-rootless) validation+='; podman info >/dev/null' ;;
384385
selinux) validation+='; test "$(getenforce)" = Enforcing' ;;
385386
esac
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
---
5+
# Docker delivered by Snap is deliberately separate from the host-package
6+
# Docker configuration. It models the interface expected by the OpenShell Snap.
7+
- name: Configure Docker Snap
8+
hosts: test_vm
9+
become: true
10+
gather_facts: true
11+
12+
tasks:
13+
- name: Validate Docker Snap support
14+
ansible.builtin.assert:
15+
that:
16+
- ansible_facts.distribution == "Ubuntu"
17+
fail_msg: >-
18+
Docker Snap is currently configured only for Ubuntu test guests,
19+
not {{ ansible_facts.distribution }}.
20+
21+
- name: Verify snapd is available
22+
ansible.builtin.command:
23+
cmd: snap wait system seed.loaded
24+
changed_when: false
25+
26+
- name: Check whether Docker Snap is installed
27+
ansible.builtin.command:
28+
cmd: snap list docker
29+
register: docker_snap
30+
changed_when: false
31+
failed_when: false
32+
33+
- name: Install Docker Snap
34+
ansible.builtin.command:
35+
cmd: snap install docker
36+
when: docker_snap.rc != 0
37+
38+
- name: Wait for Docker Snap API
39+
ansible.builtin.command:
40+
cmd: /snap/bin/docker info
41+
register: docker_snap_info
42+
changed_when: false
43+
retries: 30
44+
delay: 1
45+
until: docker_snap_info.rc == 0

‎nix/test-guest/configuration/snapd.yml‎

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,19 @@
2323
- name: Install snapd
2424
ansible.builtin.apt:
2525
name: snapd
26-
state: present
26+
state: latest
2727
install_recommends: false
2828

29+
- name: Report installed and candidate snapd packages
30+
ansible.builtin.command:
31+
cmd: apt-cache policy snapd
32+
register: snapd_package_policy
33+
changed_when: false
34+
35+
- name: Display installed and candidate snapd packages
36+
ansible.builtin.debug:
37+
var: snapd_package_policy.stdout_lines
38+
2939
- name: Start snapd socket activation
3040
ansible.builtin.systemd_service:
3141
name: snapd.socket
@@ -36,3 +46,13 @@
3646
ansible.builtin.command:
3747
cmd: snap wait system seed.loaded
3848
changed_when: false
49+
50+
- name: Query running snapd version
51+
ansible.builtin.command:
52+
cmd: snap version
53+
register: snapd_version
54+
changed_when: false
55+
56+
- name: Display running snapd version
57+
ansible.builtin.debug:
58+
var: snapd_version.stdout_lines

‎nix/test-guest/default.nix‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ let
3030
podman-rootless = ./configuration/podman-rootless.yml;
3131
selinux = ./configuration/selinux.yml;
3232
snapd = ./configuration/snapd.yml;
33+
docker-snap = ./configuration/docker-snap.yml;
3334
};
3435

3536
configurationTasks = [
@@ -39,6 +40,10 @@ let
3940
"podman-rootless/ubuntu.yml"
4041
];
4142

43+
provisionerRoles = [
44+
"openshell-snap"
45+
];
46+
4247
mkDistroProfile =
4348
name: distro:
4449
pkgs.writeText "openshell-test-guest-${name}" ''
@@ -67,6 +72,13 @@ let
6772
}) configurationTasks)
6873
);
6974

75+
provisionerCatalog = pkgs.linkFarm "openshell-test-guest-provisioners" (
76+
map (name: {
77+
inherit name;
78+
path = ./provisioners/roles/${name};
79+
}) provisionerRoles
80+
);
81+
7082
runtimeInputs = [
7183
qemu
7284
pkgs.python3Packages.ansible-core
@@ -86,6 +98,7 @@ let
8698
export OPENSHELL_TEST_GUEST_RUNTIME=1
8799
export OPENSHELL_TEST_GUEST_DISTROS=${distroCatalog}
88100
export OPENSHELL_TEST_GUEST_CONFIGURATIONS=${configurationCatalog}
101+
export OPENSHELL_TEST_GUEST_PROVISIONERS=${provisionerCatalog}
89102
export OPENSHELL_TEST_GUEST_CACHE_LIB=${./cache-lib.sh}
90103
export OPENSHELL_TEST_GUEST_CACHE_RUNNER=${./cache.sh}
91104
export OPENSHELL_TEST_GUEST_CACHE_SEAL=${./cache-seal.sh}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
openshell_snap_package: /var/lib/openshell-conformance/candidate/openshell.snap
6+
openshell_snap_gateway_service: snap.openshell.gateway.service
7+
openshell_snap_ready_retries: 30
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
---
2+
# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
- name: Stop OpenShell Snap gateway service before Docker connection
6+
become: true
7+
ansible.builtin.systemd_service:
8+
name: "{{ openshell_snap_gateway_service }}"
9+
state: stopped
10+
11+
- name: Reset failed OpenShell Snap gateway service
12+
become: true
13+
ansible.builtin.command:
14+
cmd: systemctl reset-failed {{ openshell_snap_gateway_service }}
15+
changed_when: false
16+
17+
- name: Connect Docker Snap interface
18+
become: true
19+
ansible.builtin.command:
20+
cmd: snap connect openshell:docker docker:docker-daemon
21+
22+
- name: Connect log-observe interface
23+
become: true
24+
ansible.builtin.command:
25+
cmd: snap connect openshell:log-observe
26+
27+
- name: Connect system-observe interface
28+
become: true
29+
ansible.builtin.command:
30+
cmd: snap connect openshell:system-observe
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
---
2+
# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
- name: Gather facts for OpenShell Snap installation
6+
become: true
7+
ansible.builtin.setup:
8+
9+
- name: Validate OpenShell Snap installation support
10+
become: true
11+
ansible.builtin.assert:
12+
that:
13+
- ansible_facts.distribution == "Ubuntu"
14+
fail_msg: >-
15+
OpenShell Snap installation is currently supported only on Ubuntu test guests,
16+
not {{ ansible_facts.distribution }}.
17+
18+
- name: Verify the candidate OpenShell Snap is present
19+
become: true
20+
ansible.builtin.stat:
21+
path: "{{ openshell_snap_package }}"
22+
register: openshell_snap_package_stat
23+
24+
- name: Assert the candidate OpenShell Snap is present
25+
become: true
26+
ansible.builtin.assert:
27+
that: openshell_snap_package_stat.stat.exists
28+
fail_msg: "Candidate OpenShell Snap is missing: {{ openshell_snap_package }}"
29+
30+
- name: Remove any previously installed OpenShell Snap
31+
become: true
32+
ansible.builtin.command:
33+
cmd: snap remove --purge openshell
34+
changed_when: true
35+
failed_when: false
36+
37+
- name: Install candidate OpenShell Snap
38+
become: true
39+
ansible.builtin.command:
40+
cmd: "snap install {{ openshell_snap_package }} --dangerous"
41+
42+
- name: Connect OpenShell Snap interfaces
43+
block:
44+
- ansible.builtin.include_tasks: interfaces.yml
45+
rescue:
46+
- name: Gather OpenShell Snap gateway service status
47+
become: true
48+
ansible.builtin.command:
49+
cmd: >-
50+
systemctl status {{ openshell_snap_gateway_service }} --no-pager
51+
register: openshell_snap_gateway_service_status
52+
changed_when: false
53+
failed_when: false
54+
55+
- name: Gather OpenShell Snap gateway journal
56+
become: true
57+
ansible.builtin.command:
58+
cmd: >-
59+
journalctl --no-pager -u {{ openshell_snap_gateway_service }} -n 200
60+
register: openshell_snap_gateway_journal
61+
changed_when: false
62+
failed_when: false
63+
64+
- name: Report failed OpenShell Snap interface connection
65+
ansible.builtin.debug:
66+
msg:
67+
interface_connection_error: "{{ ansible_failed_result }}"
68+
gateway_service_status: "{{ openshell_snap_gateway_service_status.stdout }}"
69+
gateway_journal: "{{ openshell_snap_gateway_journal.stdout }}"
70+
71+
- name: Fail after collecting OpenShell Snap diagnostics
72+
ansible.builtin.fail:
73+
msg: "OpenShell Snap interface connection failed; see diagnostics above."
74+
75+
- name: Register OpenShell Snap gateway
76+
ansible.builtin.import_tasks: register.yml
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
---
2+
# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
- name: Check OpenShell Snap CLI version
6+
ansible.builtin.command:
7+
cmd: openshell --version
8+
changed_when: false
9+
10+
- name: Check OpenShell Snap services
11+
become: true
12+
ansible.builtin.command:
13+
cmd: snap services openshell
14+
changed_when: false
15+
16+
- name: Register local OpenShell Snap gateway
17+
ansible.builtin.command:
18+
cmd: openshell gateway add http://127.0.0.1:17670 --local --name snap-docker
19+
20+
- name: Select local OpenShell Snap gateway
21+
ansible.builtin.command:
22+
cmd: openshell gateway select snap-docker
23+
24+
- name: Wait for local OpenShell Snap gateway status
25+
ansible.builtin.command:
26+
cmd: openshell status
27+
register: openshell_snap_gateway_status
28+
changed_when: false
29+
retries: "{{ openshell_snap_ready_retries }}"
30+
delay: 1
31+
until: openshell_snap_gateway_status.rc == 0

0 commit comments

Comments
 (0)