@@ -382,139 +382,3 @@ def test_migrate_cert_store(cephadm_module: CephadmOrchestrator):
382382 assert cephadm_module .cert_key_store .get_cert ('grafana_cert' , host = 'host2' )
383383 assert cephadm_module .cert_key_store .get_key ('grafana_key' , host = 'host1' )
384384 assert cephadm_module .cert_key_store .get_key ('grafana_key' , host = 'host2' )
385-
386-
387- @pytest .mark .parametrize (
388- "nvmeof_spec_store_entries, should_migrate_specs, expected_groups" ,
389- [
390- (
391- [
392- {'spec' : {
393- 'service_type' : 'nvmeof' ,
394- 'service_name' : 'nvmeof.foo' ,
395- 'service_id' : 'foo' ,
396- 'placement' : {
397- 'hosts' : ['host1' ]
398- },
399- 'spec' : {
400- 'pool' : 'foo' ,
401- },
402- },
403- 'created' : datetime_to_str (datetime_now ())},
404- {'spec' : {
405- 'service_type' : 'nvmeof' ,
406- 'service_name' : 'nvmeof.bar' ,
407- 'service_id' : 'bar' ,
408- 'placement' : {
409- 'hosts' : ['host2' ]
410- },
411- 'spec' : {
412- 'pool' : 'bar' ,
413- },
414- },
415- 'created' : datetime_to_str (datetime_now ())}
416- ],
417- [True , True ], ['default1' , 'default2' ]),
418- (
419- [
420- {'spec' :
421- {
422- 'service_type' : 'nvmeof' ,
423- 'service_name' : 'nvmeof.foo' ,
424- 'service_id' : 'foo' ,
425- 'placement' : {
426- 'hosts' : ['host1' ]
427- },
428- 'spec' : {
429- 'pool' : 'foo' ,
430- },
431- },
432- 'created' : datetime_to_str (datetime_now ())},
433- {'spec' :
434- {
435- 'service_type' : 'nvmeof' ,
436- 'service_name' : 'nvmeof.bar' ,
437- 'service_id' : 'bar' ,
438- 'placement' : {
439- 'hosts' : ['host2' ]
440- },
441- 'spec' : {
442- 'pool' : 'bar' ,
443- 'group' : 'bar'
444- },
445- },
446- 'created' : datetime_to_str (datetime_now ())},
447- {'spec' :
448- {
449- 'service_type' : 'nvmeof' ,
450- 'service_name' : 'nvmeof.testing_testing' ,
451- 'service_id' : 'testing_testing' ,
452- 'placement' : {
453- 'label' : 'baz'
454- },
455- 'spec' : {
456- 'pool' : 'baz' ,
457- },
458- },
459- 'created' : datetime_to_str (datetime_now ())}
460- ], [True , False , True ], ['default1' , 'bar' , 'default2' ]
461- ),
462- ]
463- )
464- @mock .patch ("cephadm.serve.CephadmServe._run_cephadm" , _run_cephadm ('[]' ))
465- def test_migrate_nvmeof_spec (
466- cephadm_module : CephadmOrchestrator ,
467- nvmeof_spec_store_entries ,
468- should_migrate_specs ,
469- expected_groups
470- ):
471- with with_host (cephadm_module , 'host1' ):
472- for spec in nvmeof_spec_store_entries :
473- cephadm_module .set_store (
474- SPEC_STORE_PREFIX + spec ['spec' ]['service_name' ],
475- json .dumps (spec , sort_keys = True ),
476- )
477-
478- # make sure nvmeof_migration_queue is populated accordingly
479- cephadm_module .migration_current = 1
480- cephadm_module .spec_store .load ()
481- ls = json .loads (cephadm_module .get_store ('nvmeof_migration_queue' ))
482- assert all ([s ['spec' ]['service_type' ] == 'nvmeof' for s in ls ])
483- # shortcut nvmeof_migration_queue loading by directly assigning
484- # ls output to nvmeof_migration_queue list
485- cephadm_module .migration .nvmeof_migration_queue = ls
486-
487- # skip other migrations and go directly to 7_8 migration (nvmeof spec)
488- cephadm_module .migration_current = 7
489- cephadm_module .migration .migrate ()
490- assert cephadm_module .migration_current == LAST_MIGRATION
491-
492- print (cephadm_module .spec_store .all_specs )
493-
494- for i in range (len (nvmeof_spec_store_entries )):
495- nvmeof_spec_store_entry = nvmeof_spec_store_entries [i ]
496- should_migrate = should_migrate_specs [i ]
497- expected_group = expected_groups [i ]
498-
499- service_name = nvmeof_spec_store_entry ['spec' ]['service_name' ]
500- service_id = nvmeof_spec_store_entry ['spec' ]['service_id' ]
501- placement = nvmeof_spec_store_entry ['spec' ]['placement' ]
502- pool = nvmeof_spec_store_entry ['spec' ]['spec' ]['pool' ]
503-
504- if should_migrate :
505- assert service_name in cephadm_module .spec_store .all_specs
506- nvmeof_spec = cephadm_module .spec_store .all_specs [service_name ]
507- nvmeof_spec_json = nvmeof_spec .to_json ()
508- assert nvmeof_spec_json ['service_type' ] == 'nvmeof'
509- assert nvmeof_spec_json ['service_id' ] == service_id
510- assert nvmeof_spec_json ['service_name' ] == service_name
511- assert nvmeof_spec_json ['placement' ] == placement
512- assert nvmeof_spec_json ['spec' ]['pool' ] == pool
513- # make sure spec has the "group" parameter set to "default<counter>"
514- assert nvmeof_spec_json ['spec' ]['group' ] == expected_group
515- else :
516- nvmeof_spec = cephadm_module .spec_store .all_specs [service_name ]
517- nvmeof_spec_json = nvmeof_spec .to_json ()
518- assert nvmeof_spec_json ['spec' ]['pool' ] == pool
519- # make sure spec has the "group" parameter still set to its old value
520- assert nvmeof_spec_json ['spec' ]['group' ] == expected_group
0 commit comments