Skip to content

Commit 827d442

Browse files
committed
test air gapped update
1 parent 5f45470 commit 827d442

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

tests/misc/test_air_gapped_update.py

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

0 commit comments

Comments
 (0)