@@ -29,6 +29,7 @@ class TestMSMaintenanceAndSafeShutdown(cloudstackTestCase):
29
29
30
30
def setUp (self ):
31
31
self .apiclient = self .testClient .getApiClient ()
32
+ self .hypervisor = self .testClient .getHypervisorInfo ()
32
33
self .mgtSvrDetails = self .config .__dict__ ["mgtSvr" ][0 ].__dict__
33
34
self .cleanup = []
34
35
@@ -86,8 +87,38 @@ def run_async_cmd(self) :
86
87
{"name" : "test" , "displaytext" : "test" }
87
88
)
88
89
90
+ def getActiveManagementServers (self ):
91
+ cmd = listManagementServers .listManagementServersCmd ()
92
+ servers = self .apiclient .listManagementServers (cmd )
93
+ active_servers = []
94
+ for idx , server in enumerate (servers ):
95
+ if server .state == 'Up' :
96
+ active_servers .append (server .serviceip )
97
+ return active_servers
98
+
89
99
@attr (tags = ["advanced" , "smoke" ])
90
100
def test_01_prepare_and_cancel_maintenance (self ):
101
+ active_management_servers = self .getActiveManagementServers ()
102
+ if len (active_management_servers ) <= 1 :
103
+ self .skipTest ("Skipping test case, this test is intended for only multiple management servers" )
104
+
105
+ hypervisor = self .hypervisor .lower ()
106
+ if hypervisor == 'kvm' :
107
+ list_configurations_cmd = listConfigurations .listConfigurationsCmd ()
108
+ list_configurations_cmd .name = "host"
109
+ list_configurations_response = self .apiclient .listConfigurations (list_configurations_cmd )
110
+ self .assertNotEqual (len (list_configurations_response ), 0 ,
111
+ "Check if the list configurations API returns a non-empty response" )
112
+
113
+ for item in list_configurations_response :
114
+ if item .name == list_configurations_cmd .name :
115
+ host_config = item
116
+
117
+ hosts = host_config .value .split ("," )
118
+ if len (hosts ) <= 1 :
119
+ self .skipTest (
120
+ "Skipping test case, this test is intended for only multiple management server hosts configured on host setting for kvm" )
121
+
91
122
try :
92
123
prepare_for_maintenance_cmd = prepareForMaintenance .prepareForMaintenanceCmd ()
93
124
prepare_for_maintenance_cmd .managementserverid = 1
@@ -105,11 +136,6 @@ def test_01_prepare_and_cancel_maintenance(self):
105
136
cancel_maintenance_cmd = cancelMaintenance .cancelMaintenanceCmd ()
106
137
cancel_maintenance_cmd .managementserverid = 1
107
138
self .apiclient .cancelMaintenance (cancel_maintenance_cmd )
108
- # self.assertEqual(
109
- # response.maintenanceinitiated,
110
- # False,
111
- # "Failed to cancel maintenance"
112
- # )
113
139
## Just to be sure, run another async command
114
140
project = self .run_async_cmd ()
115
141
self .cleanup .append (project )
@@ -120,11 +146,6 @@ def test_02_prepare_and_cancel_shutdown(self):
120
146
prepare_for_shutdown_cmd = prepareForShutdown .prepareForShutdownCmd ()
121
147
prepare_for_shutdown_cmd .managementserverid = 1
122
148
self .apiclient .prepareForShutdown (prepare_for_shutdown_cmd )
123
- # self.assertEqual(
124
- # response.maintenanceinitiated,
125
- # True,
126
- # "Failed to prepare for maintenance"
127
- # )
128
149
try :
129
150
self .run_async_cmd ()
130
151
except Exception as e :
0 commit comments