Skip to content

Commit f3759c7

Browse files
committed
added more mirror tests
1 parent e386498 commit f3759c7

File tree

2 files changed

+60
-5
lines changed

2 files changed

+60
-5
lines changed

stackinator/mirror.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,14 +206,14 @@ def _create_bootstrap_configs(self, config_root: pathlib.Path):
206206
bootstrap_yaml['sources'].append(
207207
{
208208
'name': name,
209-
'metadata': bs_mirror_path,
209+
'metadata': str(bs_mirror_path),
210210
}
211211
)
212212
# And trust each one
213213
bootstrap_yaml['trusted'][name] = True
214214

215215
# Create the metadata dir and metadata.yaml
216-
bs_mirror_path.mkdir(parents=True)
216+
bs_mirror_path.mkdir(parents=True, exist_ok=True)
217217
bs_mirror_yaml = {
218218
'type': 'install',
219219
'info': mirror['url'],

unittests/test_mirrors.py

Lines changed: 58 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,65 @@ def test_command_line_cache(systems_path):
4848
assert cache_mirror['mount_specific']
4949

5050
def test_create_spack_mirrors_yaml(systems_path):
51-
pass
51+
"""Check that the mirrors.yaml passed to spack is correct"""
52+
53+
valid_spack_yaml = {
54+
"mirrors": {
55+
"fake-mirror": {
56+
"fetch": {"url": "https://github.com"},
57+
"push": {"url": "https://github.com"},
58+
},
59+
"buildcache-mirror": {
60+
"fetch": {"url": "https://mirror.spack.io"},
61+
"push": {"url": "https://mirror.spack.io"},
62+
},
63+
"bootstrap-mirror": {
64+
"fetch": {"url": "https://mirror.spack.io"},
65+
"push": {"url": "https://mirror.spack.io"},
66+
}
67+
}
68+
}
69+
70+
dest = systems_path / "mirror-ok" / "test_output.yaml"
71+
mirrors_obj = mirror.Mirrors(systems_path / "mirror-ok")
72+
mirrors_obj._create_spack_mirrors_yaml(dest)
73+
74+
with dest.open() as f:
75+
data = yaml.safe_load(f)
76+
77+
assert data == valid_spack_yaml
78+
79+
def test_create_bootstrap_configs(systems_path):
80+
"""Check that spack bootstrap configs are generated correctly"""
81+
82+
valid_yaml = {
83+
"sources": [
84+
{
85+
"name": "bootstrap-mirror",
86+
"metadata": str(systems_path / "mirror-ok" / "bootstrap" / "bootstrap-mirror"),
87+
}
88+
],
89+
"trusted": {
90+
"bootstrap-mirror": True
91+
},
92+
}
93+
valid_metadata = {
94+
"type": "install",
95+
"info": "https://mirror.spack.io",
96+
}
97+
98+
path = systems_path / "mirror-ok"
99+
bs_mirror_path = path / "bootstrap/bootstrap-mirror"
100+
mirrors_obj = mirror.Mirrors(path)
101+
mirrors_obj._create_bootstrap_configs(path)
102+
103+
with (path/'bootstrap.yaml').open() as f:
104+
bs_data = yaml.safe_load(f)
105+
assert bs_data == valid_yaml
52106

53-
def test_create_bootstrap_configs():
54-
pass
107+
with (bs_mirror_path/'metadata.yaml').open() as f:
108+
metadata = yaml.safe_load(f)
109+
assert metadata == valid_metadata
55110

56111
def test_key_setup(systems_path, tmp_path):
57112
"""Check that public keys are set up properly."""

0 commit comments

Comments
 (0)