예제 #1
0
 def test_TearDown(self):
     dcapi = DataCenterAPIs()
     capi = ClusterAPIs()
     time.sleep(30)
     # Step1:将data1存储域设置为Maintenance状态
     LogPrint().info("Post-Module-Test-1: Deactivate data storage domains '%s'." % self.dm.data1_nfs_name)
     self.assertTrue(smart_deactive_storage_domain(self.dm.dc_nfs_name, self.dm.data1_nfs_name))
     
     # Step2:删除数据中心dc1(非强制,之后存储域变为Unattached状态)
     if dcapi.searchDataCenterByName(self.dm.dc_nfs_name)['result']['data_centers']:
         LogPrint().info("Post-Module-Test-2: Delete DataCenter '%s'." % self.dm.dc_nfs_name)
         self.assertTrue(dcapi.delDataCenter(self.dm.dc_nfs_name)['status_code']==self.dm.expected_status_code_del_dc)
             
     # Step3:删除4个Unattached状态存储域(data1/data2/iso1/export1)
     LogPrint().info("Post-Module-Test-3: Delete all unattached storage domains.")
     dict_sd_to_host = [self.dm.data1_nfs_name, self.dm.data2_nfs_name]
     for sd in dict_sd_to_host:
         smart_del_storage_domain(sd, self.dm.xml_del_sd_option, host_name=self.dm.host1_name)
     
     # Step4:删除主机(host1)
     LogPrint().info("Post-Module-Test-6: Delete host '%s'." % self.dm.host1_name)
     self.assertTrue(smart_del_host(self.dm.host1_name, self.dm.xml_del_host_option))
     
     # Step5:删除集群cluster1
     if capi.searchClusterByName(self.dm.cluster_nfs_name)['result']['clusters']:
         LogPrint().info("Post-Module-Test-5: Delete Cluster '%s'." % self.dm.cluster_nfs_name)
         self.assertTrue(capi.delCluster(self.dm.cluster_nfs_name)['status_code']==self.dm.expected_status_code_del_dc)
예제 #2
0
 def test_DeleteCluster(self):
     '''
     @summary: 测试用例执行步骤
     @note: (1)删除一个干净的集群;
     @note: (2)操作成功,验证接口返回的状态码是否正确,验证被删除的集群不再存在。
     '''
     clusterapi = ClusterAPIs()
     # 测试1:获取集群的信息,并与期望结果进行对比
     LogPrint().info("Test: Delete the clean cluster '%s'." %
                     self.dm.cluster_name)
     r = clusterapi.delCluster(self.dm.cluster_name)
     if r['status_code'] == self.dm.status_code:
         #             print self.clusterapi.searchClusterByName(self.dm.cluster_name)['result']['clusters']
         if not clusterapi.searchClusterByName(
                 self.dm.cluster_name)['result']['clusters']:
             LogPrint().info("PASS: Delete Cluster '%s' info SUCCESS." %
                             self.dm.cluster_name)
             self.flag = True
         else:
             LogPrint().error("FAIL: The Cluster '%s' is still exist ." %
                              self.dm.cluster_name)
             self.flag = False
     else:
         LogPrint().error("FAIL: Returned status code '%s' is WRONG." %
                          r['status_code'])
         self.flag = False
     self.assertTrue(self.flag)
예제 #3
0
    def test_TearDown(self):
        '''
        @summary: 模块级测试资源清理
        '''
        dcapi = DataCenterAPIs()
        capi = ClusterAPIs()
         
        # Step2:将export和iso存储域设置为Maintenance状态,然后从数据中心分离
        LogPrint().info("Post-Module-Test-2-1: Deactivate storage domains '%s'." % self.dm.export1_name)
        self.assertTrue(smart_deactive_storage_domain(self.dm.dc_nfs_name, self.dm.export1_name))
        LogPrint().info("Post-Module-Test-2-2: Detach storage domains '%s'." % self.dm.export1_name)
        self.assertTrue(smart_detach_storage_domain(self.dm.dc_nfs_name, self.dm.export1_name))
        LogPrint().info("Post-Module-Test-2-3: Deactivate storage domains '%s'." % self.dm.iso1_name)
        self.assertTrue(smart_deactive_storage_domain(self.dm.dc_nfs_name, self.dm.iso1_name))
        LogPrint().info("Post-Module-Test-2-4: Detach storage domains '%s'." % self.dm.iso1_name)
        self.assertTrue(smart_detach_storage_domain(self.dm.dc_nfs_name, self.dm.iso1_name))
        
        # Step3:将data2存储域设置为Maintenance状态,然后从数据中心分离
        LogPrint().info("Post-Module-Test-3-1: Deactivate data storage domains '%s'." % self.dm.data2_nfs_name)
        self.assertTrue(smart_deactive_storage_domain(self.dm.dc_nfs_name, self.dm.data2_nfs_name))
        LogPrint().info("Post-Module-Test-3-2: Detach data storage domains '%s'." % self.dm.data2_nfs_name)
        self.assertTrue(smart_detach_storage_domain(self.dm.dc_nfs_name, self.dm.data2_nfs_name))
        
        # Step4:将data1存储域设置为Maintenance状态
        LogPrint().info("Post-Module-Test-4: Deactivate data storage domains '%s'." % self.dm.data1_nfs_name)
        self.assertTrue(smart_deactive_storage_domain(self.dm.dc_nfs_name, self.dm.data1_nfs_name))
#         LogPrint().info("Post-Module-Test-3-2: Detach data storage domains '%s'." % self.dm.data1_nfs_name)
#         self.assertTrue(smart_detach_storage_domain(self.dm.dc_nfs_name, self.dm.data1_nfs_name))
                 
        # Step5:删除数据中心dc1(非强制,之后存储域变为Unattached状态)
        if dcapi.searchDataCenterByName(self.dm.dc_nfs_name)['result']['data_centers']:
            LogPrint().info("Post-Module-Test-5: Delete DataCenter '%s'." % self.dm.dc_nfs_name)
            self.assertTrue(dcapi.delDataCenter(self.dm.dc_nfs_name)['status_code']==self.dm.expected_status_code_del_dc)
                 
        # Step6:删除4个Unattached状态存储域(data1/data2/export1/iso)
        LogPrint().info("Post-Module-Test-6: Delete all unattached storage domains.")
        dict_sd_to_host = [self.dm.data1_nfs_name, self.dm.data2_nfs_name, self.dm.iso1_name, self.dm.export1_name]
        for sd in dict_sd_to_host:
            smart_del_storage_domain(sd, self.dm.xml_del_sd_option, host_name=self.dm.host1_name)
         
        # Step7:删除主机(host1)
        LogPrint().info("Post-Module-Test-7: Delete host '%s'." % self.dm.host1_name)
        self.assertTrue(smart_del_host(self.dm.host1_name, self.dm.xml_del_host_option))
        LogPrint().info("Post-Module-Test-7: Delete host '%s'." % self.dm.host2_name)
        self.assertTrue(smart_del_host(self.dm.host2_name, self.dm.xml_del_host_option)) 
        # Step8:删除集群cluster1
        if capi.searchClusterByName(self.dm.cluster_nfs_name)['result']['clusters']:
            LogPrint().info("Post-Module-Test-8: Delete Cluster '%s'." % self.dm.cluster_nfs_name)
            self.assertTrue(capi.delCluster(self.dm.cluster_nfs_name)['status_code']==self.dm.expected_status_code_del_dc)
예제 #4
0
    def test_TearDown(self):
        dcapi = DataCenterAPIs()
        capi = ClusterAPIs()

        # Step1:将ISO域和Export域设置为Maintenance状态
        LogPrint().info("Post-Module-Test-1: Deactivate ISO and Export storage domains.")
        self.assertTrue(smart_deactive_storage_domain(self.dm.dc_name, self.dm.iso1_name))
        self.assertTrue(smart_deactive_storage_domain(self.dm.dc_name, self.dm.export1_name))

        # Step2:将ISO域和Export域从对应的数据中心分离(detach)
        LogPrint().info("Post-Module-Test-2: Deattch ISO and Export storage domains.")
        self.assertTrue(smart_detach_storage_domain(self.dm.dc_name, self.dm.iso1_name))
        self.assertTrue(smart_detach_storage_domain(self.dm.dc_name, self.dm.export1_name))

        # Step3:将Data存储域设置为Maintenance状态
        LogPrint().info("Post-Module-Test-3: Deactivate all data storage domains.")
        self.assertTrue(smart_deactive_storage_domain(self.dm.dc_name, self.dm.data1_nfs_name))
        # self.assertTrue(smart_deactive_storage_domain(self.dm.dc_name, self.dm.data1_iscsi_name))

        # 删除3个数据中心(非强制,之后存储域变为Unattached状态)
        if dcapi.searchDataCenterByName(self.dm.dc_name):
            LogPrint().info("Post-Module-Test-4: Delete DataCenter '%s'." % self.dm.dc_name)
            self.assertTrue(dcapi.delDataCenter(self.dm.dc_name)["status_code"] == self.dm.expected_status_code_del_dc)

        # 删除3个Unattached状态的Data存储域和ISO/Export域(如果没有配置FC,则删除2个)
        LogPrint().info("Post-Module-Test-5: Delete all storage domains.")
        dict_sd_to_host = {
            self.dm.data1_nfs_name: self.dm.host1_name,
            self.dm.iso1_name: self.dm.host1_name,
            self.dm.export1_name: self.dm.host1_name,
        }
        for sd in dict_sd_to_host:
            smart_del_storage_domain(sd, self.dm.xml_del_sd_option, host_name=dict_sd_to_host[sd])

        # 删除主机(host1和host4)
        LogPrint().info("Post-Module-Test-6: Delete all hosts.")
        for host_name in [self.dm.host1_name, self.dm.host4_name]:
            self.assertTrue(smart_del_host(host_name, self.dm.xml_del_host_option))

        # 删除集群

        if capi.searchClusterByName(self.dm.cluster_name):
            LogPrint().info("Post-Module-Test-7: Delete Cluster '%s'." % self.dm.cluster_name)
            self.assertTrue(capi.delCluster(self.dm.cluster_name)["status_code"] == self.dm.expected_status_code_del_dc)
예제 #5
0
 def test_DeleteCluster(self):
     """
     @summary: 测试用例执行步骤
     @note: (1)删除一个干净的集群;
     @note: (2)操作成功,验证接口返回的状态码是否正确,验证被删除的集群不再存在。
     """
     clusterapi = ClusterAPIs()
     # 测试1:获取集群的信息,并与期望结果进行对比
     LogPrint().info("Test: Delete the clean cluster '%s'." % self.dm.cluster_name)
     r = clusterapi.delCluster(self.dm.cluster_name)
     if r["status_code"] == self.dm.status_code:
         #             print self.clusterapi.searchClusterByName(self.dm.cluster_name)['result']['clusters']
         if not clusterapi.searchClusterByName(self.dm.cluster_name)["result"]["clusters"]:
             LogPrint().info("PASS: Delete Cluster '%s' info SUCCESS." % self.dm.cluster_name)
             self.flag = True
         else:
             LogPrint().error("FAIL: The Cluster '%s' is still exist ." % self.dm.cluster_name)
             self.flag = False
     else:
         LogPrint().error("FAIL: Returned status code '%s' is WRONG." % r["status_code"])
         self.flag = False
     self.assertTrue(self.flag)
예제 #6
0
    def test_TearDown(self):
        vmapi = VirtualMachineAPIs()
        #Step1:删除虚拟机
        vmapi.delVm(self.dm.vm_name)
        dcapi = DataCenterAPIs()
        capi = ClusterAPIs()
        # Step2:将export存储域和data2存储域设置为Maintenance状态,然后从数据中心分离
        #         LogPrint().info("Post-Module-Test-1: Deactivate storage domains '%s'." % self.dm.export1_name)
        #         self.assertTrue(smart_deactive_storage_domain(self.dm.dc_nfs_name, self.dm.export1_name))
        #         LogPrint().info("Post-Module-Test-2: Detach storage domains '%s'." % self.dm.export1_name)
        #         self.assertTrue(smart_detach_storage_domain(self.dm.dc_nfs_name, self.dm.export1_name))

        LogPrint().info(
            "Post-Module-Test-3: Deactivate data storage domains '%s'." %
            self.dm.data2_nfs_name)
        self.assertTrue(
            smart_deactive_storage_domain(self.dm.dc_nfs_name,
                                          self.dm.data2_nfs_name))
        LogPrint().info(
            "Post-Module-Test-4: Detach data storage domains '%s'." %
            self.dm.data2_nfs_name)
        self.assertTrue(
            smart_detach_storage_domain(self.dm.dc_nfs_name,
                                        self.dm.data2_nfs_name))
        # Step3:将data1存储域设置为Maintenance状态
        LogPrint().info(
            "Post-Module-Test-5: Deactivate data storage domains '%s'." %
            self.dm.data1_nfs_name)
        self.assertTrue(
            smart_deactive_storage_domain(self.dm.dc_nfs_name,
                                          self.dm.data1_nfs_name))

        # Step4:删除数据中心dc1(非强制,之后存储域变为Unattached状态)
        if dcapi.searchDataCenterByName(
                self.dm.dc_nfs_name)['result']['data_centers']:
            LogPrint().info("Post-Module-Test-6: Delete DataCenter '%s'." %
                            self.dm.dc_nfs_name)
            self.assertTrue(
                dcapi.delDataCenter(self.dm.dc_nfs_name)['status_code'] ==
                self.dm.expected_status_code_del_dc)

        # Step5:删除3个Unattached状态存储域(data1/data2/export1)
        LogPrint().info(
            "Post-Module-Test-7: Delete all unattached storage domains.")
        dict_sd_to_host = [self.dm.data1_nfs_name, self.dm.data2_nfs_name]
        for sd in dict_sd_to_host:
            smart_del_storage_domain(sd,
                                     self.dm.xml_del_sd_option,
                                     host_name=self.dm.host1_name)

        # Step6:删除主机(host1)
        LogPrint().info("Post-Module-Test-8: Delete host '%s'." %
                        self.dm.host1_name)
        self.assertTrue(
            smart_del_host(self.dm.host1_name, self.dm.xml_del_host_option))

        # Step7:删除集群cluster1
        if capi.searchClusterByName(
                self.dm.cluster_nfs_name)['result']['clusters']:
            LogPrint().info("Post-Module-Test-9: Delete Cluster '%s'." %
                            self.dm.cluster_nfs_name)
            self.assertTrue(
                capi.delCluster(self.dm.cluster_nfs_name)['status_code'] ==
                self.dm.expected_status_code_del_dc)
예제 #7
0
    def test_TearDown(self):
        dcapi = DataCenterAPIs()
        capi = ClusterAPIs()

        # Step1:将ISO域和Export域设置为Maintenance状态
        LogPrint().info(
            "Post-Module-Test-1: Deactivate ISO and Export storage domains.")
        self.assertTrue(
            smart_deactive_storage_domain(self.dm.dc_name, self.dm.iso1_name))
        self.assertTrue(
            smart_deactive_storage_domain(self.dm.dc_name,
                                          self.dm.export1_name))

        # Step2:将ISO域和Export域从对应的数据中心分离(detach)
        LogPrint().info(
            "Post-Module-Test-2: Deattch ISO and Export storage domains.")
        self.assertTrue(
            smart_detach_storage_domain(self.dm.dc_name, self.dm.iso1_name))
        self.assertTrue(
            smart_detach_storage_domain(self.dm.dc_name, self.dm.export1_name))

        # Step3:将Data存储域设置为Maintenance状态
        LogPrint().info(
            "Post-Module-Test-3: Deactivate all data storage domains.")
        self.assertTrue(
            smart_deactive_storage_domain(self.dm.dc_name,
                                          self.dm.data1_nfs_name))
        #self.assertTrue(smart_deactive_storage_domain(self.dm.dc_name, self.dm.data1_iscsi_name))

        # 删除3个数据中心(非强制,之后存储域变为Unattached状态)
        if dcapi.searchDataCenterByName(self.dm.dc_name):
            LogPrint().info("Post-Module-Test-4: Delete DataCenter '%s'." %
                            self.dm.dc_name)
            self.assertTrue(
                dcapi.delDataCenter(self.dm.dc_name)['status_code'] ==
                self.dm.expected_status_code_del_dc)

        # 删除3个Unattached状态的Data存储域和ISO/Export域(如果没有配置FC,则删除2个)
        LogPrint().info("Post-Module-Test-5: Delete all storage domains.")
        dict_sd_to_host = {
            self.dm.data1_nfs_name: self.dm.host1_name,
            self.dm.iso1_name: self.dm.host1_name,
            self.dm.export1_name: self.dm.host1_name
        }
        for sd in dict_sd_to_host:
            smart_del_storage_domain(sd,
                                     self.dm.xml_del_sd_option,
                                     host_name=dict_sd_to_host[sd])

        # 删除主机(host1和host4)
        LogPrint().info("Post-Module-Test-6: Delete all hosts.")
        for host_name in [self.dm.host1_name, self.dm.host4_name]:
            self.assertTrue(
                smart_del_host(host_name, self.dm.xml_del_host_option))

        # 删除集群

        if capi.searchClusterByName(self.dm.cluster_name):
            LogPrint().info("Post-Module-Test-7: Delete Cluster '%s'." %
                            self.dm.cluster_name)
            self.assertTrue(
                capi.delCluster(self.dm.cluster_name)['status_code'] ==
                self.dm.expected_status_code_del_dc)