def test_06_stop_cpvm(self): """Test stop CPVM """ # Validate the following # 1. The CPVM should go to stop state # 2. After a brief delay of say one minute, the SSVM should be # restarted once again and return to Running state with previous # two test cases still passing # 3. If either of the two above steps fail the test is a failure list_cpvm_response = list_ssvms(self.apiclient, systemvmtype='consoleproxy', state='Running', zoneid=self.zone.id) self.assertEqual(isinstance(list_cpvm_response, list), True, "Check list response returns a valid list") cpvm = list_cpvm_response[0] hosts = list_hosts(self.apiclient, id=cpvm.hostid) self.assertEqual(isinstance(hosts, list), True, "Check list response returns a valid list") self.debug("Stopping CPVM: %s" % cpvm.id) cmd = stopSystemVm.stopSystemVmCmd() cmd.id = cpvm.id self.apiclient.stopSystemVm(cmd) timeout = self.services["timeout"] while True: list_cpvm_response = list_ssvms(self.apiclient, id=cpvm.id) if isinstance(list_cpvm_response, list): if list_cpvm_response[0].state == 'Running': break if timeout == 0: raise Exception("List CPVM call failed!") time.sleep(self.services["sleep"]) timeout = timeout - 1 cpvm_response = list_cpvm_response[0] self.debug("CPVM state after debug: %s" % cpvm_response.state) self.assertEqual(cpvm_response.state, 'Running', "Check whether CPVM is running or not") # Wait for the agent to be up self.waitForSystemVMAgent(cpvm_response.name) # Call above tests to ensure CPVM is properly running self.test_02_list_cpvm_vm() # Wait for some time before running diagnostic scripts on SSVM # as it may take some time to start all service properly time.sleep(int(self.services["configurableData"]["systemVmDelay"])) self.test_04_cpvm_internals() return
def test_06_stop_cpvm(self): """Test stop CPVM """ # Validate the following # 1. The CPVM should go to stop state # 2. After a brief delay of say one minute, the SSVM should be # restarted once again and return to Running state with previous # two test cases still passing # 3. If either of the two above steps fail the test is a failure list_cpvm_response = list_ssvms( self.apiclient, systemvmtype='consoleproxy', state='Running', zoneid=self.zone.id ) self.assertEqual( isinstance(list_cpvm_response, list), True, "Check list response returns a valid list" ) cpvm = list_cpvm_response[0] hosts = list_hosts( self.apiclient, id=cpvm.hostid ) self.assertEqual( isinstance(hosts, list), True, "Check list response returns a valid list" ) self.debug("Stopping CPVM: %s" % cpvm.id) cmd = stopSystemVm.stopSystemVmCmd() cmd.id = cpvm.id self.apiclient.stopSystemVm(cmd) cpvm_response = self.checkForRunningSystemVM(cpvm) self.debug("CPVM state after debug: %s" % cpvm_response.state) self.assertEqual( cpvm_response.state, 'Running', "Check whether CPVM is running or not" ) # Wait for the agent to be up self.waitForSystemVMAgent(cpvm_response.name) # Call above tests to ensure CPVM is properly running self.test_02_list_cpvm_vm() self.test_04_cpvm_internals()
def test_stop_svm(self, svm_type): # Validate the following # 1. The SVM should go to stop state # 2. The SVM should be restarted and return to Running state with the checks of the previous two test cases still passing # 3. If either of the two above steps fail the test is a failure list_svm_response = list_ssvms( self.apiclient, systemvmtype=svm_type, state='Running', zoneid=self.zone.id ) self.assertEqual( isinstance(list_svm_response, list), True, "Check list response returns a valid list" ) svm = list_svm_response[0] hosts = list_hosts( self.apiclient, id=svm.hostid ) self.assertEqual( isinstance(hosts, list), True, "Check list response returns a valid list" ) self.logger.debug("Stopping System VM: %s" % svm.id) cmd = stopSystemVm.stopSystemVmCmd() cmd.id = svm.id cmd.forced = "true" self.apiclient.stopSystemVm(cmd) self.wait_for_svm_state(svm.id, 'Stopped', self.services["timeout"], self.services["sleep"]) self.logger.debug("Starting System VM: %s" % svm.id) cmd = startSystemVm.startSystemVmCmd() cmd.id = svm.id self.apiclient.startSystemVm(cmd) self.wait_for_svm_state(svm.id, 'Running', self.services["timeout"], self.services["sleep"]) self.wait_for_system_vm_agent(svm.name) return
def test_06_stop_cpvm(self): """Test stop CPVM """ # Validate the following # 1. The CPVM should go to stop state # 2. After a brief delay of say one minute, the SSVM should be # restarted once again and return to Running state with previous # two test cases still passing # 3. If either of the two above steps fail the test is a failure list_cpvm_response = list_ssvms( self.apiclient, systemvmtype='consoleproxy', state='Running', zoneid=self.zone.id ) self.assertEqual( isinstance(list_cpvm_response, list), True, "Check list response returns a valid list" ) cpvm = list_cpvm_response[0] hosts = list_hosts( self.apiclient, id=cpvm.hostid ) self.assertEqual( isinstance(hosts, list), True, "Check list response returns a valid list" ) self.debug("Stopping CPVM: %s" % cpvm.id) cmd = stopSystemVm.stopSystemVmCmd() cmd.id = cpvm.id self.apiclient.stopSystemVm(cmd) timeout = self.services["timeout"] while True: list_cpvm_response = list_ssvms( self.apiclient, id=cpvm.id ) if isinstance(list_cpvm_response, list): if list_cpvm_response[0].state == 'Running': break if timeout == 0: raise Exception("List CPVM call failed!") time.sleep(self.services["sleep"]) timeout = timeout - 1 cpvm_response = list_cpvm_response[0] self.debug("CPVM state after debug: %s" % cpvm_response.state) self.assertEqual( cpvm_response.state, 'Running', "Check whether CPVM is running or not" ) # Wait for the agent to be up self.waitForSystemVMAgent(cpvm_response.name) # Call above tests to ensure CPVM is properly running self.test_02_list_cpvm_vm() # Wait for some time before running diagnostic scripts on SSVM # as it may take some time to start all service properly time.sleep(int(self.services["configurableData"]["systemVmDelay"])) self.test_04_cpvm_internals() return
def test_11_ss_nfs_version_on_ssvm(self): """Test NFS Version on Secondary Storage mounted properly on SSVM """ # 1) List SSVM in zone # 2) Get id and url from mounted nfs store # 3) Update NFS version for previous image store # 4) Stop SSVM # 5) Check NFS version of mounted nfs store after SSVM starts nfs_version = self.config.nfsVersion if nfs_version == None: self.skipTest('No NFS version provided in test data') #List SSVM for zone id list_ssvm_response = list_ssvms(self.apiclient, systemvmtype='secondarystoragevm', state='Running', zoneid=self.zone.id) self.assertNotEqual(list_ssvm_response, None) self.assertEqual(isinstance(list_ssvm_response, list), True, "Check list response returns a valid list") self.assertEqual(len(list_ssvm_response), 1, "Check list System VMs response") ssvm = list_ssvm_response[0] image_stores_response = ImageStore.list(self.apiclient, zoneid=self.zone.id) if self.hypervisor.lower() in ('vmware', 'hyperv'): # SSH into SSVMs is done via management server for Vmware and Hyper-V result = get_process_status(self.apiclient.connection.mgtSvr, 22, self.apiclient.connection.user, self.apiclient.connection.passwd, ssvm.privateip, "mount | grep 'type nfs'", hypervisor=self.hypervisor) for res in result: split_res = res.split("on") mounted_img_store_url = split_res[0].strip() for img_store in image_stores_response: img_store_url = str(img_store.url) if img_store_url.startswith("nfs://"): img_store_url = img_store_url[6:] #Add colon after ip address to match output from mount command first_slash = img_store_url.find('/') img_store_url = img_store_url[ 0:first_slash] + ':' + img_store_url[first_slash:] if img_store_url == mounted_img_store_url: img_store_id = img_store.id break self.assertNotEqual(img_store_id, None, "Check image store id mounted on SSVM") #Update NFS version for image store mounted on SSVM updateConfigurationCmd = updateConfiguration.updateConfigurationCmd() updateConfigurationCmd.name = "secstorage.nfs.version" updateConfigurationCmd.value = nfs_version updateConfigurationCmd.imagestoreuuid = img_store_id updateConfigurationResponse = self.apiclient.updateConfiguration( updateConfigurationCmd) self.logger.debug("updated the parameter %s with value %s" % (updateConfigurationResponse.name, updateConfigurationResponse.value)) #Stop SSVM self.debug("Stopping SSVM: %s" % ssvm.id) cmd = stopSystemVm.stopSystemVmCmd() cmd.id = ssvm.id self.apiclient.stopSystemVm(cmd) def checkForRunningSSVM(): new_list_ssvm_response = list_ssvms(self.apiclient, id=ssvm.id) if isinstance(new_list_ssvm_response, list): return new_list_ssvm_response[0].state == 'Running', None res, _ = wait_until(self.services["sleep"], self.services["timeout"], checkForRunningSSVM) if not res: self.fail("List SSVM call failed!") new_list_ssvm_response = list_ssvms(self.apiclient, id=ssvm.id) self.assertNotEqual(new_list_ssvm_response, None) self.assertEqual(isinstance(new_list_ssvm_response, list), True, "Check list response returns a valid list") ssvm = new_list_ssvm_response[0] self.debug("SSVM state after debug: %s" % ssvm.state) self.assertEqual(ssvm.state, 'Running', "Check whether SSVM is running or not") # Wait for the agent to be up self.waitForSystemVMAgent(ssvm.name) #Check NFS version on mounted image store result = get_process_status(self.apiclient.connection.mgtSvr, 22, self.apiclient.connection.user, self.apiclient.connection.passwd, ssvm.privateip, "mount | grep '%s'" % mounted_img_store_url, hypervisor=self.hypervisor) self.assertNotEqual(result, None) self.assertEqual(len(result), 1, "Check result length") res = result[0] mounted_nfs_version = res.split("vers=")[1][0:1] self.assertEqual( int(mounted_nfs_version), int(nfs_version), "Check mounted NFS version to be the same as provided") return
def test_11_ss_nfs_version_on_ssvm(self): """Test NFS Version on Secondary Storage mounted properly on SSVM """ # 1) List SSVM in zone # 2) Get id and url from mounted nfs store # 3) Update NFS version for previous image store # 4) Stop SSVM # 5) Check NFS version of mounted nfs store after SSVM starts nfs_version = self.config.nfsVersion if nfs_version == None: self.skipTest('No NFS version provided in test data') #List SSVM for zone id list_ssvm_response = list_ssvms( self.apiclient, systemvmtype='secondarystoragevm', state='Running', zoneid=self.zone.id ) self.assertNotEqual( list_ssvm_response, None ) self.assertEqual( isinstance(list_ssvm_response, list), True, "Check list response returns a valid list" ) self.assertEqual( len(list_ssvm_response), 1, "Check list System VMs response" ) ssvm = list_ssvm_response[0] image_stores_response = ImageStore.list(self.apiclient,zoneid=self.zone.id) if self.hypervisor.lower() in ('vmware', 'hyperv'): # SSH into SSVMs is done via management server for Vmware and Hyper-V result = get_process_status( self.apiclient.connection.mgtSvr, 22, self.apiclient.connection.user, self.apiclient.connection.passwd, ssvm.privateip, "mount | grep 'type nfs'", hypervisor=self.hypervisor) for res in result: split_res = res.split("on") mounted_img_store_url = split_res[0].strip() for img_store in image_stores_response: img_store_url = str(img_store.url) if img_store_url.startswith("nfs://"): img_store_url = img_store_url[6:] #Add colon after ip address to match output from mount command first_slash = img_store_url.find('/') img_store_url = img_store_url[0:first_slash] + ':' + img_store_url[first_slash:] if img_store_url == mounted_img_store_url: img_store_id = img_store.id break self.assertNotEqual( img_store_id, None, "Check image store id mounted on SSVM" ) #Update NFS version for image store mounted on SSVM updateConfigurationCmd = updateConfiguration.updateConfigurationCmd() updateConfigurationCmd.name = "secstorage.nfs.version" updateConfigurationCmd.value = nfs_version updateConfigurationCmd.imagestoreuuid = img_store_id updateConfigurationResponse = self.apiclient.updateConfiguration(updateConfigurationCmd) self.logger.debug("updated the parameter %s with value %s"%(updateConfigurationResponse.name, updateConfigurationResponse.value)) #Stop SSVM self.debug("Stopping SSVM: %s" % ssvm.id) cmd = stopSystemVm.stopSystemVmCmd() cmd.id = ssvm.id self.apiclient.stopSystemVm(cmd) def checkForRunningSSVM(): new_list_ssvm_response = list_ssvms( self.apiclient, id=ssvm.id ) if isinstance(new_list_ssvm_response, list): return new_list_ssvm_response[0].state == 'Running', None res, _ = wait_until(self.services["sleep"], self.services["timeout"], checkForRunningSSVM) if not res: self.fail("List SSVM call failed!") new_list_ssvm_response = list_ssvms( self.apiclient, id=ssvm.id ) self.assertNotEqual( new_list_ssvm_response, None ) self.assertEqual( isinstance(new_list_ssvm_response, list), True, "Check list response returns a valid list" ) ssvm = new_list_ssvm_response[0] self.debug("SSVM state after debug: %s" % ssvm.state) self.assertEqual( ssvm.state, 'Running', "Check whether SSVM is running or not" ) # Wait for the agent to be up self.waitForSystemVMAgent(ssvm.name) #Check NFS version on mounted image store result = get_process_status( self.apiclient.connection.mgtSvr, 22, self.apiclient.connection.user, self.apiclient.connection.passwd, ssvm.privateip, "mount | grep '%s'"%mounted_img_store_url, hypervisor=self.hypervisor) self.assertNotEqual( result, None ) self.assertEqual( len(result), 1, "Check result length" ) res = result[0] mounted_nfs_version = res.split("vers=")[1][0:1] self.assertEqual( int(mounted_nfs_version), int(nfs_version), "Check mounted NFS version to be the same as provided" ) return