44import stackinator .mirror as mirror
55import yaml
66
7+ from stackinator .spack_util import Version
8+
79
810@pytest .fixture
911def test_path ():
@@ -36,7 +38,7 @@ def mirror_ok(systems_path):
3638
3739def test_mirror_init (clean_root , mount_path , systems_path , mirror_ok ):
3840 """Check that the three kinds of mirror are resolved into separate members."""
39- mirrors_obj = mirror .Mirrors (clean_root , mount_path , "1.1" , mirror_file = mirror_ok )
41+ mirrors_obj = mirror .Mirrors (clean_root , mount_path , Version ( 1 , 1 ) , mirror_file = mirror_ok )
4042
4143 with (systems_path / "../test-gpg-pub.asc" ).open ("rb" ) as pub_key_file :
4244 pub_key_b64 = base64 .b64encode (pub_key_file .read ()).decode ()
@@ -79,20 +81,20 @@ def test_system_mirrors_yaml_rejected(systems_path, mount_path):
7981
8082 # mirror-ok contains a mirrors.yaml; passing it as the system config root must raise.
8183 with pytest .raises (mirror .MirrorError ):
82- mirror .Mirrors (systems_path / "mirror-ok" , mount_path , "1.1" )
84+ mirror .Mirrors (systems_path / "mirror-ok" , mount_path , Version ( 1 , 1 ) )
8385
8486
8587def test_missing_mirror_file (clean_root , mount_path ):
8688 """A --mirror file that does not exist raises MirrorError."""
8789
8890 with pytest .raises (mirror .MirrorError ):
89- mirror .Mirrors (clean_root , mount_path , "1.1" , mirror_file = clean_root / "does-not-exist.yaml" )
91+ mirror .Mirrors (clean_root , mount_path , Version ( 1 , 1 ) , mirror_file = clean_root / "does-not-exist.yaml" )
9092
9193
9294def test_no_mirror_file (clean_root , mount_path ):
9395 """With no --mirror file there are no mirrors configured."""
9496
95- mirrors_obj = mirror .Mirrors (clean_root , mount_path , "1.1" )
97+ mirrors_obj = mirror .Mirrors (clean_root , mount_path , Version ( 1 , 1 ) )
9698
9799 assert mirrors_obj .buildcache is None
98100 assert mirrors_obj .bootstrap is None
@@ -105,7 +107,11 @@ def test_command_line_cache(clean_root, mount_path, systems_path, mirror_ok):
105107 """Check that adding a cache from the command line works."""
106108
107109 mirrors = mirror .Mirrors (
108- clean_root , mount_path , "1.1" , mirror_file = mirror_ok , cmdline_cache = systems_path / "mirror-ok/cache.yaml"
110+ clean_root ,
111+ mount_path ,
112+ Version (1 , 1 ),
113+ mirror_file = mirror_ok ,
114+ cmdline_cache = systems_path / "mirror-ok/cache.yaml" ,
109115 )
110116
111117 # the command line cache overrides any build cache defined in the mirror file,
@@ -127,7 +133,11 @@ def test_keyless_command_line_cache(tmp_path, clean_root, mount_path, systems_pa
127133 """A cache.yaml without a key configures a read-only (fetch-only) build cache."""
128134
129135 mirrors = mirror .Mirrors (
130- clean_root , mount_path , "1.1" , mirror_file = mirror_ok , cmdline_cache = systems_path / "mirror-ok/cache-nokey.yaml"
136+ clean_root ,
137+ mount_path ,
138+ Version (1 , 1 ),
139+ mirror_file = mirror_ok ,
140+ cmdline_cache = systems_path / "mirror-ok/cache-nokey.yaml" ,
131141 )
132142
133143 # the cache exists (so it is fetched from), but has no signing key ...
@@ -158,7 +168,7 @@ def test_readonly_buildcache(tmp_path, clean_root, mount_path, systems_path):
158168 """A buildcache in the mirror file without a private_key is read-only (fetch-only)."""
159169
160170 mirrors = mirror .Mirrors (
161- clean_root , mount_path , "1.1" , mirror_file = systems_path / "mirror-readonly-cache/mirrors.yaml"
171+ clean_root , mount_path , Version ( 1 , 1 ) , mirror_file = systems_path / "mirror-readonly-cache/mirrors.yaml"
162172 )
163173
164174 # the cache exists (so it is fetched from), but has no signing key ...
@@ -192,7 +202,7 @@ def test_config_files(tmp_path, clean_root, mount_path, mirror_ok):
192202 so this also exercises relative key paths resolving against the mirror file's dir.
193203 """
194204
195- mirrors_obj = mirror .Mirrors (clean_root , mount_path , "1.1" , mirror_file = mirror_ok )
205+ mirrors_obj = mirror .Mirrors (clean_root , mount_path , Version ( 1 , 1 ) , mirror_file = mirror_ok )
196206 files = mirrors_obj .config_files (tmp_path )
197207
198208 expected = {
@@ -236,7 +246,7 @@ def test_spack_mirrors_yaml(tmp_path, clean_root, mount_path, mirror_ok):
236246 }
237247 }
238248
239- mirrors_obj = mirror .Mirrors (clean_root , mount_path , "1.1" , mirror_file = mirror_ok )
249+ mirrors_obj = mirror .Mirrors (clean_root , mount_path , Version ( 1 , 1 ) , mirror_file = mirror_ok )
240250 files = mirrors_obj .config_files (tmp_path )
241251 data = yaml .safe_load (files [tmp_path / "mirrors.yaml" ])
242252
@@ -250,7 +260,7 @@ def test_mount_specific_buildcache(tmp_path, clean_root, mount_path, mirror_ok):
250260 cache is namespaced per-mount-point to avoid relocation issues / collisions.
251261 """
252262
253- mirrors_obj = mirror .Mirrors (clean_root , mount_path , "1.1" , mirror_file = mirror_ok )
263+ mirrors_obj = mirror .Mirrors (clean_root , mount_path , Version ( 1 , 1 ) , mirror_file = mirror_ok )
254264
255265 # mirror-ok's buildcache is mount_specific: false by default; enable it.
256266 mirrors_obj .buildcache ["mount_specific" ] = True
@@ -269,7 +279,7 @@ def test_mount_specific_buildcache(tmp_path, clean_root, mount_path, mirror_ok):
269279def test_mount_specific_disabled (tmp_path , clean_root , mount_path , mirror_ok ):
270280 """A buildcache with mount_specific false is unchanged, even when a mount point is set."""
271281
272- mirrors_obj = mirror .Mirrors (clean_root , mount_path , "1.1" , mirror_file = mirror_ok )
282+ mirrors_obj = mirror .Mirrors (clean_root , mount_path , Version ( 1 , 1 ) , mirror_file = mirror_ok )
273283
274284 # confirm the fixture leaves the flag off
275285 assert mirrors_obj .buildcache ["mount_specific" ] is False
@@ -301,7 +311,7 @@ def test_remote_bootstrap_configs(tmp_path, clean_root, mount_path, mirror_ok):
301311 },
302312 }
303313
304- mirrors_obj = mirror .Mirrors (clean_root , mount_path , "1.1" , mirror_file = mirror_ok )
314+ mirrors_obj = mirror .Mirrors (clean_root , mount_path , Version ( 1 , 1 ) , mirror_file = mirror_ok )
305315 files = mirrors_obj .config_files (tmp_path )
306316
307317 bs_data = yaml .safe_load (files [tmp_path / "bootstrap.yaml" ])
@@ -327,7 +337,7 @@ def test_local_bootstrap_configs(tmp_path, clean_root, mount_path):
327337 mirror_file .write_text (f"bootstrap:\n url: { boot } \n " )
328338
329339 config_root = tmp_path / "config"
330- mirrors_obj = mirror .Mirrors (clean_root , mount_path , "1.1" , mirror_file = mirror_file )
340+ mirrors_obj = mirror .Mirrors (clean_root , mount_path , Version ( 1 , 1 ) , mirror_file = mirror_file )
331341 files = mirrors_obj .config_files (config_root )
332342
333343 bs_data = yaml .safe_load (files [config_root / "bootstrap.yaml" ])
@@ -357,13 +367,13 @@ def test_local_bootstrap_missing_metadata(tmp_path, clean_root, mount_path):
357367 mirror_file .write_text (f"bootstrap:\n url: { boot } \n " )
358368
359369 with pytest .raises (mirror .MirrorError ):
360- mirror .Mirrors (clean_root , mount_path , "1.1" , mirror_file = mirror_file )
370+ mirror .Mirrors (clean_root , mount_path , Version ( 1 , 1 ) , mirror_file = mirror_file )
361371
362372
363373def test_keys (tmp_path , clean_root , mount_path , systems_path , mirror_ok ):
364374 """Check that gpg keys are decoded, relocated and reported consistently."""
365375
366- mirrors_obj = mirror .Mirrors (clean_root , mount_path , "1.1" , mirror_file = mirror_ok )
376+ mirrors_obj = mirror .Mirrors (clean_root , mount_path , Version ( 1 , 1 ) , mirror_file = mirror_ok )
367377 files = mirrors_obj .config_files (tmp_path )
368378
369379 # the buildcache is the only mirror with keys (sources are checksum-verified)
@@ -383,7 +393,7 @@ def test_keys(tmp_path, clean_root, mount_path, systems_path, mirror_ok):
383393def test_local_caches_config (tmp_path , clean_root , mount_path , mirror_ok ):
384394 """The source cache is emitted to config.yaml; the concretizer cache to concretizer.yaml."""
385395
386- mirrors_obj = mirror .Mirrors (clean_root , mount_path , "1.1" , mirror_file = mirror_ok )
396+ mirrors_obj = mirror .Mirrors (clean_root , mount_path , Version ( 1 , 1 ) , mirror_file = mirror_ok )
387397 files = mirrors_obj .config_files (tmp_path )
388398
389399 config_data = yaml .safe_load (files [tmp_path / "config.yaml" ])
@@ -401,7 +411,7 @@ def test_concretizer_cache_only(tmp_path, clean_root, mount_path):
401411 mirror_file = tmp_path / "mirrors.yaml"
402412 mirror_file .write_text ("concretizer:\n path: /scratch/only-concretizer\n " )
403413
404- mirrors_obj = mirror .Mirrors (clean_root , mount_path , "1.1" , mirror_file = mirror_file )
414+ mirrors_obj = mirror .Mirrors (clean_root , mount_path , Version ( 1 , 1 ) , mirror_file = mirror_file )
405415 files = mirrors_obj .config_files (tmp_path )
406416
407417 assert mirrors_obj .source_cache is None
@@ -418,7 +428,7 @@ def test_concretizer_cache_skipped_on_spack_1_0(tmp_path, clean_root, mount_path
418428 mirror_file = tmp_path / "mirrors.yaml"
419429 mirror_file .write_text ("concretizer:\n path: /scratch/only-concretizer\n " )
420430
421- mirrors_obj = mirror .Mirrors (clean_root , mount_path , "1.0" , mirror_file = mirror_file )
431+ mirrors_obj = mirror .Mirrors (clean_root , mount_path , Version ( 1 , 0 ) , mirror_file = mirror_file )
422432 files = mirrors_obj .config_files (tmp_path )
423433
424434 # the cache is still recorded as requested, but no concretizer.yaml is written
@@ -431,7 +441,7 @@ def test_local_caches_absent(tmp_path, clean_root, mount_path, systems_path):
431441
432442 # mirror-no-sourcecache has neither a sourcecache nor a concretizer entry
433443 mirrors_obj = mirror .Mirrors (
434- clean_root , mount_path , "1.1" , mirror_file = systems_path / "mirror-no-sourcecache/mirrors.yaml"
444+ clean_root , mount_path , Version ( 1 , 1 ) , mirror_file = systems_path / "mirror-no-sourcecache/mirrors.yaml"
435445 )
436446 files = mirrors_obj .config_files (tmp_path )
437447
@@ -449,7 +459,9 @@ def test_s3_fetch_and_push_connections(tmp_path, clean_root, mount_path, systems
449459 buildcache and sourcemirror entries accept the same spack connection config.
450460 """
451461
452- mirrors_obj = mirror .Mirrors (clean_root , mount_path , "1.1" , mirror_file = systems_path / "mirror-s3/mirrors.yaml" )
462+ mirrors_obj = mirror .Mirrors (
463+ clean_root , mount_path , Version (1 , 1 ), mirror_file = systems_path / "mirror-s3/mirrors.yaml"
464+ )
453465 files = mirrors_obj .config_files (tmp_path )
454466 data = yaml .safe_load (files [tmp_path / "mirrors.yaml" ])
455467
@@ -492,4 +504,4 @@ def test_bad_config(clean_root, mount_path, systems_path, system_name):
492504 """Check that MirrorError is raised at construction for bad keys or a bad cache path."""
493505
494506 with pytest .raises (mirror .MirrorError ):
495- mirror .Mirrors (clean_root , mount_path , "1.1" , mirror_file = systems_path / system_name / "mirrors.yaml" )
507+ mirror .Mirrors (clean_root , mount_path , Version ( 1 , 1 ) , mirror_file = systems_path / system_name / "mirrors.yaml" )
0 commit comments