Skip to content

Commit 69cc887

Browse files
committed
test air gapped update
Signed-off-by: Gaëtan Lehmann <[email protected]>
1 parent f9bb219 commit 69cc887

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

tests/misc/test_air_gapped_update.py

+44
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)