Skip to content

Commit 6adcc80

Browse files
committed
test air gapped update
Signed-off-by: Gaëtan Lehmann <[email protected]>
1 parent 2fe8fd3 commit 6adcc80

File tree

3 files changed

+53
-0
lines changed

3 files changed

+53
-0
lines changed

jobs.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,15 @@
431431
"params": {},
432432
"paths": ["tests/fs_diff"],
433433
},
434+
"air-gapped": {
435+
"description": "air gapped — without network — tests",
436+
"requirements": [
437+
"A host with no access to the internet",
438+
],
439+
"nb_pools": 1,
440+
"params": {},
441+
"paths": ["tests/air_gapped"],
442+
}
434443
}
435444

436445
# List used by the 'check' action: tests listed here will not raise a check error

tests/air_gapped/__init__.py

Whitespace-only changes.
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import logging
2+
import os
3+
from urllib.request import urlretrieve
4+
5+
from lib.host import Host
6+
7+
# These tests are basic tests meant to check the update process in air-gapped environment.
8+
#
9+
# Requirements:
10+
# - a host running XCP-ng 8.3.
11+
# - with no access to internet
12+
# - TODO: a snapshot to restore the host to a state without the offline repositories, to integrate when #226
13+
# will be merged
14+
15+
REPOS = ['base', 'linstor', 'updates']
16+
17+
18+
def air_gapped_download(url: str, host: Host):
19+
logging.debug(f"downloading {url}")
20+
tmppath = f'/tmp/{os.path.basename(url)}'
21+
urlretrieve(url, tmppath)
22+
host.scp(tmppath, tmppath)
23+
os.remove(tmppath)
24+
25+
26+
def test_air_gapped_update(host: Host):
27+
# get the required files and install the offline repositories
28+
air_gapped_download(
29+
'https://raw.githubusercontent.com/xcp-ng/xcp/refs/heads/master/scripts/setup_offline_xcpng_repos', host
30+
)
31+
host.ssh(['chmod', 'a+x', '/tmp/setup_offline_xcpng_repos'])
32+
for repo in REPOS:
33+
archive = f'xcpng-8_3-offline-{repo}-latest.tar'
34+
air_gapped_download(f'https://repo.vates.tech/xcp-ng/offline/8/8.3/{archive}', host)
35+
host.ssh(['/tmp/setup_offline_xcpng_repos', f'/tmp/{archive}'])
36+
host.ssh(['rm', '-f', f'/tmp/{archive}'])
37+
repolist = host.ssh(['yum', 'repolist', '-q'])
38+
# ensure the repos are installed
39+
for repo in REPOS:
40+
assert f'xcp-ng-{repo}' in repolist
41+
# run the actual update
42+
host.ssh(['yum', '-y', 'update'])
43+
# restart the XAPI toolstack
44+
host.ssh(['xe-toolstack-restart'])

0 commit comments

Comments
 (0)