@@ -617,172 +617,6 @@ def test_unmigrated_request_spec_instances(self):
617
617
self .cell_mappings ['cell2' ].uuid , result .details )
618
618
619
619
620
- class TestUpgradeCheckConsoles (test .NoDBTestCase ):
621
- """Tests for the nova-status upgrade check for consoles."""
622
-
623
- # We'll setup the database ourselves because we need to use cells fixtures
624
- # for multiple cell mappings.
625
- USES_DB_SELF = True
626
-
627
- # This will create three cell mappings: cell0, cell1 (default) and cell2
628
- NUMBER_OF_CELLS = 2
629
-
630
- def setUp (self ):
631
- super (TestUpgradeCheckConsoles , self ).setUp ()
632
- self .output = StringIO ()
633
- self .useFixture (fixtures .MonkeyPatch ('sys.stdout' , self .output ))
634
- # We always need the API DB to be setup.
635
- self .useFixture (nova_fixtures .Database (database = 'api' ))
636
- self .cmd = status .UpgradeCommands ()
637
-
638
- @staticmethod
639
- def _create_service_in_cell (ctxt , cell , binary , is_deleted = False ,
640
- disabled = False , version = None ,
641
- create_token_auth = False ):
642
- with context .target_cell (ctxt , cell ) as cctxt :
643
- service = objects .Service (context = cctxt , binary = binary ,
644
- disabled = disabled , host = 'dontcare' )
645
- if version :
646
- service .version = version
647
- service .create ()
648
-
649
- if is_deleted :
650
- service .destroy ()
651
-
652
- if create_token_auth :
653
- # We have to create an instance in order to create a token
654
- # auth.
655
- inst = objects .Instance (context = cctxt ,
656
- uuid = uuidutils .generate_uuid ())
657
- inst .create ()
658
- auth = objects .ConsoleAuthToken (context = cctxt ,
659
- console_type = 'novnc' ,
660
- host = 'hostname' , port = 6080 ,
661
- instance_uuid = inst .uuid )
662
- auth .authorize (CONF .consoleauth .token_ttl )
663
-
664
- return service
665
-
666
- def test_check_workaround_enabled (self ):
667
- """This is a 'success' case since the console auths check is
668
- ignored when the workaround is already enabled.
669
- """
670
- self .flags (enable_consoleauth = True , group = 'workarounds' )
671
- result = self .cmd ._check_console_auths ()
672
- self .assertEqual (upgradecheck .Code .SUCCESS , result .code )
673
-
674
- def test_deleted_disabled_consoleauth (self ):
675
- """Tests that services other than nova-consoleauth and deleted/disabled
676
- nova-consoleauth services are filtered out.
677
- """
678
- self ._setup_cells ()
679
- ctxt = context .get_admin_context ()
680
-
681
- # Create a compute service in cell1.
682
- self ._create_service_in_cell (ctxt , self .cell_mappings ['cell1' ],
683
- 'nova-compute' )
684
- # Create a deleted consoleauth service in cell1.
685
- self ._create_service_in_cell (ctxt , self .cell_mappings ['cell1' ],
686
- 'nova-consoleauth' , is_deleted = True )
687
- # Create a compute service in cell2.
688
- self ._create_service_in_cell (ctxt , self .cell_mappings ['cell2' ],
689
- 'nova-compute' )
690
- # Create a disabled consoleauth service in cell2.
691
- self ._create_service_in_cell (ctxt , self .cell_mappings ['cell2' ],
692
- 'nova-consoleauth' , disabled = True )
693
-
694
- result = self .cmd ._check_console_auths ()
695
- self .assertEqual (upgradecheck .Code .SUCCESS , result .code )
696
-
697
- def test_consoleauth_with_upgrade_not_started (self ):
698
- """Tests the scenario where the deployment is using consoles but has no
699
- compute services >= Rocky, i.e. a not started upgrade.
700
- """
701
- self ._setup_cells ()
702
- ctxt = context .get_admin_context ()
703
-
704
- # Create a deleted consoleauth service in cell1.
705
- self ._create_service_in_cell (ctxt , self .cell_mappings ['cell1' ],
706
- 'nova-consoleauth' , is_deleted = True )
707
- # Create a live consoleauth service in cell0. (Asserts we check cell0).
708
- self ._create_service_in_cell (ctxt , self .cell_mappings ['cell0' ],
709
- 'nova-consoleauth' )
710
- # Create Queens compute services in the cells.
711
- for cell in ['cell1' , 'cell2' ]:
712
- self ._create_service_in_cell (ctxt , self .cell_mappings [cell ],
713
- 'nova-compute' , version = 30 )
714
-
715
- result = self .cmd ._check_console_auths ()
716
- self .assertEqual (upgradecheck .Code .WARNING , result .code )
717
-
718
- def test_consoleauth_with_upgrade_complete (self ):
719
- """Tests the scenario where the deployment is using consoles and has
720
- all compute services >= Rocky in every cell database, i.e. a completed
721
- upgrade.
722
- """
723
- self ._setup_cells ()
724
- ctxt = context .get_admin_context ()
725
-
726
- # Create a live consoleauth service in cell1 with token auth.
727
- self ._create_service_in_cell (ctxt , self .cell_mappings ['cell1' ],
728
- 'nova-consoleauth' ,
729
- create_token_auth = True )
730
-
731
- # Create a live consoleauth service in cell2 with token auth.
732
- self ._create_service_in_cell (ctxt , self .cell_mappings ['cell2' ],
733
- 'nova-consoleauth' ,
734
- create_token_auth = True )
735
-
736
- # Create Rocky compute services in the cells.
737
- for cell in ['cell1' , 'cell2' ]:
738
- self ._create_service_in_cell (ctxt , self .cell_mappings [cell ],
739
- 'nova-compute' , version = 35 )
740
-
741
- # Create a Queens compute service in cell0. This not actually valid,
742
- # we do it to assert that we skip cell0 when checking service versions.
743
- self ._create_service_in_cell (ctxt , self .cell_mappings ['cell0' ],
744
- 'nova-compute' , version = 30 )
745
-
746
- result = self .cmd ._check_console_auths ()
747
- self .assertEqual (upgradecheck .Code .SUCCESS , result .code )
748
-
749
- def test_consoleauth_with_upgrade_partial (self ):
750
- """Tests the scenario where the deployment is using consoles and has
751
- compute services >= Rocky in at least one, but not all, cell databases,
752
- i.e. a partial upgrade.
753
- """
754
- self ._setup_cells ()
755
- ctxt = context .get_admin_context ()
756
-
757
- # Create a live consoleauth service in cell1.
758
- self ._create_service_in_cell (ctxt , self .cell_mappings ['cell1' ],
759
- 'nova-consoleauth' )
760
-
761
- # Create a live consoleauth service in cell2 with token auth.
762
- self ._create_service_in_cell (ctxt , self .cell_mappings ['cell2' ],
763
- 'nova-consoleauth' ,
764
- create_token_auth = True )
765
-
766
- # Create a Queens compute service in cell1.
767
- self ._create_service_in_cell (ctxt , self .cell_mappings ['cell1' ],
768
- 'nova-compute' , version = 30 )
769
-
770
- # Create a Rocky compute service in cell2.
771
- self ._create_service_in_cell (ctxt , self .cell_mappings ['cell2' ],
772
- 'nova-compute' , version = 35 )
773
-
774
- result = self .cmd ._check_console_auths ()
775
-
776
- self .assertEqual (upgradecheck .Code .WARNING , result .code )
777
- self .assertIn ("One or more cells were found which have nova-compute "
778
- "services older than Rocky. "
779
- "Please set the '[workarounds]enable_consoleauth' "
780
- "configuration option to 'True' on your console proxy "
781
- "host if you are performing a rolling upgrade to enable "
782
- "consoles to function during a partial upgrade." ,
783
- result .details )
784
-
785
-
786
620
class TestUpgradeCheckCinderAPI (test .NoDBTestCase ):
787
621
788
622
def setUp (self ):
0 commit comments