コード例 #1
0
class ITC020204_detachNetworkFromCluster(BaseTestCase):
    '''
    @summary: ITC-02集群管理-02集群网络操作-04将网络从集群分离
    '''
    def setUp(self):
        '''
        @summary: 测试用例执行前的环境初始化(前提)
        '''
        # 调用父类方法,获取该用例所对应的测试数据模块
        self.dm = super(self.__class__, self).setUp()
        # step1:创建一个集群
        LogPrint().info("Pre-Test-1: Create cluster '%s' for this TC." %
                        self.dm.cluster_name)
        self.assertTrue(
            smart_create_cluster(self.dm.cluster_info, self.dm.cluster_name))
        # step2:创建一个逻辑网络
        LogPrint().info("Pre-Test-2: Create network '%s' for this TC." %
                        self.dm.nw_name)
        self.assertTrue(smart_create_network(self.dm.nw_info, self.dm.nw_name))
        # step3:附加该网络到集群上
        LogPrint().info(
            "Pre-Test-3: Attach network '%s'to cluster '%s' for this TC." %
            (self.dm.nw_name, self.dm.cluster_name))
        self.clusterapi = ClusterAPIs()
        self.clusterapi.attachNetworkToCluster(self.dm.cluster_name,
                                               self.dm.nw_info)

    def test_detachNetworkFromCluster(self):
        '''
        @summary: 测试用例执行步骤
        @note: 测试将网络从集群中分离
        @note: 操作成功,验证返回状态码,验证集群中是否有该网络
        '''
        LogPrint().info("Test: Detach Network %s from Cluster %s. " %
                        (self.dm.nw_name, self.dm.cluster_name))
        r = self.clusterapi.detachNetworkFromCluster(self.dm.cluster_name,
                                                     self.dm.nw_name)
        if r['status_code'] == self.dm.status_code:
            #检查集群中网络是否存在
            if not self.clusterapi.getClusterNetworkInfo(
                    self.dm.cluster_name, self.dm.nw_name):
                LogPrint().info(
                    "PASS: Detach Network %s from Cluster %s SUCCESS. " %
                    (self.dm.nw_name, self.dm.cluster_name))
            else:
                LogPrint().info("FAIL: Cluster %s still has Network %s. " %
                                (self.dm.cluster_name, self.dm.nw_name))
        else:
            LogPrint().info("FAIL: Returned status code is WRONG.")

    def tearDown(self):
        '''
        @summary: 测试结束后的资源清理(恢复初始环境)
        '''
        LogPrint().info("Post-Test-1: Delete network '%s' for this TC." %
                        self.dm.nw_name)
        self.assertTrue(smart_delete_network(self.dm.nw_name, self.dm.dc_name))
        LogPrint().info("Post-Test-2: Delete cluster '%s' for this TC." %
                        self.dm.cluster_name)
        self.assertTrue(smart_delete_cluster(self.dm.cluster_name))
コード例 #2
0
class ITC020202_GetClusterNetworkInfo(BaseTestCase):
    '''
    @summary: ITC-02集群管理-01集群操作-02获取指定集群的网络信息
    '''
    def setUp(self):
        '''
        @summary: 测试用例执行前的环境初始化(前提)
        '''
        # 调用父类方法,获取该用例所对应的测试数据模块
        self.dm = super(self.__class__, self).setUp()
        # step1:创建一个集群
        LogPrint().info("Pre-Test-1: Create cluster '%s' for this TC." %
                        self.dm.cluster_name)
        self.assertTrue(
            smart_create_cluster(self.dm.cluster_info, self.dm.cluster_name))
        # step2:创建一个逻辑网络
        LogPrint().info("Pre-Test-2: Create network '%s' for this TC." %
                        self.dm.nw_name)
        self.assertTrue(smart_create_network(self.dm.nw_info, self.dm.nw_name))
        # step3:附加该网络到集群上
        LogPrint().info(
            "Pre-Test-3: Attach network '%s'to cluster '%s' for this TC." %
            (self.dm.nw_name, self.dm.cluster_name))
        self.clusterapi = ClusterAPIs()
        self.clusterapi.attachNetworkToCluster(self.dm.cluster_name,
                                               self.dm.nw_info)

    def test_GetClusterNetworkInfo(self):
        '''
        @summary: 测试用例执行步骤
        @note: 操作成功,验证网络信息
        '''
        LogPrint().info("Test: Get the cluster %s's network info. " %
                        self.dm.cluster_name)
        r = self.clusterapi.getClusterNetworkInfo(self.dm.cluster_name,
                                                  self.dm.nw_name)
        dict_actual = r
        dict_expected = xmltodict.parse(self.dm.nw_info)
        dictCompare = DictCompare()
        if dictCompare.isSubsetDict(dict_expected, dict_actual):
            LogPrint().info("PASS: Get ClusterNetwork '%s' info SUCCESS." %
                            self.dm.nw_name)


#                 return True
        else:
            LogPrint().error("FAIL: Returned message is WRONG. ")
            self.flag = False
        self.assertTrue(self.flag)

    def tearDown(self):
        '''
        @summary: 测试结束后的资源清理(恢复初始环境)
        '''
        LogPrint().info("Post-Test-1: Delete network '%s' for this TC." %
                        self.dm.nw_name)
        self.assertTrue(smart_delete_network(self.dm.nw_name, self.dm.dc_name))
        LogPrint().info("Post-Test-2: Delete cluster '%s' for this TC." %
                        self.dm.cluster_name)
        self.assertTrue(smart_delete_cluster(self.dm.cluster_name))
コード例 #3
0
ファイル: Cluster.py プロジェクト: FineFan/oVirt3.3WebAPITest
class ITC020205_UpdateNetworkofCluster(BaseTestCase):
    """
    @summary: ITC-02集群管理-02集群网络操作-05更新集群网络信息
    """

    def setUp(self):
        """
        @summary: 测试用例执行前的环境初始化(前提)
        """
        # 调用父类方法,获取该用例所对应的测试数据模块
        self.dm = super(self.__class__, self).setUp()
        # step1:创建一个集群
        LogPrint().info("Pre-Test-1: Create cluster '%s' for this TC." % self.dm.cluster_name)
        self.assertTrue(smart_create_cluster(self.dm.cluster_info, self.dm.cluster_name))
        # step2:创建一个逻辑网络
        LogPrint().info("Pre-Test-2: Create network '%s' for this TC." % self.dm.nw_name)
        self.assertTrue(smart_create_network(self.dm.nw_info, self.dm.nw_name))
        # step3:附加该网络到集群上
        LogPrint().info(
            "Pre-Test-3: Attach network '%s'to cluster '%s' for this TC." % (self.dm.nw_name, self.dm.cluster_name)
        )
        self.clusterapi = ClusterAPIs()
        self.clusterapi.attachNetworkToCluster(self.dm.cluster_name, self.dm.nw_info)

    def test_UpdateNetworkofCluster(self):
        """
        @summary: 测试用例执行步骤
        @note: 更新集群网络信息
        @note: 操作成功,验证返回状态码,验证更新信息是否正确
        """
        LogPrint().info("Test: Update Network %s of Cluster %s. " % (self.dm.nw_name, self.dm.cluster_name))
        r = self.clusterapi.updateNetworkOfCluster(self.dm.cluster_name, self.dm.nw_name, self.dm.nw_info_new)
        if r["status_code"] == self.dm.status_code:
            dict_actual = self.clusterapi.getClusterNetworkInfo(self.dm.cluster_name, self.dm.nw_name)
            # dict_expected = {'network':xmltodict.parse(self.dm.nw_info_new)['network']}
            dict_expected = xmltodict.parse(self.dm.nw_info_new)
            dictCompare = DictCompare()
            if dictCompare.isSubsetDict(dict_expected, dict_actual):
                LogPrint().info(
                    "PASS: Detach Network %s from Cluster %s SUCCESS. " % (self.dm.nw_name, self.dm.cluster_name)
                )
            else:
                LogPrint().info("FAIL: Returned message is WRONG. ")
        else:
            LogPrint().info("FAIL: Returned status code is WRONG.")

    def tearDown(self):
        """
        @summary: 测试结束后的资源清理(恢复初始环境)
        """
        LogPrint().info("Post-Test-1: Delete network '%s' for this TC." % self.dm.nw_name)
        self.assertTrue(smart_delete_network(self.dm.nw_name, self.dm.dc_name))
        LogPrint().info("Post-Test-2: Delete cluster '%s' for this TC." % self.dm.cluster_name)
        self.assertTrue(smart_delete_cluster(self.dm.cluster_name))
コード例 #4
0
ファイル: Cluster.py プロジェクト: FineFan/oVirt3.3WebAPITest
class ITC020204_detachNetworkFromCluster(BaseTestCase):
    """
    @summary: ITC-02集群管理-02集群网络操作-04将网络从集群分离
    """

    def setUp(self):
        """
        @summary: 测试用例执行前的环境初始化(前提)
        """
        # 调用父类方法,获取该用例所对应的测试数据模块
        self.dm = super(self.__class__, self).setUp()
        # step1:创建一个集群
        LogPrint().info("Pre-Test-1: Create cluster '%s' for this TC." % self.dm.cluster_name)
        self.assertTrue(smart_create_cluster(self.dm.cluster_info, self.dm.cluster_name))
        # step2:创建一个逻辑网络
        LogPrint().info("Pre-Test-2: Create network '%s' for this TC." % self.dm.nw_name)
        self.assertTrue(smart_create_network(self.dm.nw_info, self.dm.nw_name))
        # step3:附加该网络到集群上
        LogPrint().info(
            "Pre-Test-3: Attach network '%s'to cluster '%s' for this TC." % (self.dm.nw_name, self.dm.cluster_name)
        )
        self.clusterapi = ClusterAPIs()
        self.clusterapi.attachNetworkToCluster(self.dm.cluster_name, self.dm.nw_info)

    def test_detachNetworkFromCluster(self):
        """
        @summary: 测试用例执行步骤
        @note: 测试将网络从集群中分离
        @note: 操作成功,验证返回状态码,验证集群中是否有该网络
        """
        LogPrint().info("Test: Detach Network %s from Cluster %s. " % (self.dm.nw_name, self.dm.cluster_name))
        r = self.clusterapi.detachNetworkFromCluster(self.dm.cluster_name, self.dm.nw_name)
        if r["status_code"] == self.dm.status_code:
            # 检查集群中网络是否存在
            if not self.clusterapi.getClusterNetworkInfo(self.dm.cluster_name, self.dm.nw_name):
                LogPrint().info(
                    "PASS: Detach Network %s from Cluster %s SUCCESS. " % (self.dm.nw_name, self.dm.cluster_name)
                )
            else:
                LogPrint().info("FAIL: Cluster %s still has Network %s. " % (self.dm.cluster_name, self.dm.nw_name))
        else:
            LogPrint().info("FAIL: Returned status code is WRONG.")

    def tearDown(self):
        """
        @summary: 测试结束后的资源清理(恢复初始环境)
        """
        LogPrint().info("Post-Test-1: Delete network '%s' for this TC." % self.dm.nw_name)
        self.assertTrue(smart_delete_network(self.dm.nw_name, self.dm.dc_name))
        LogPrint().info("Post-Test-2: Delete cluster '%s' for this TC." % self.dm.cluster_name)
        self.assertTrue(smart_delete_cluster(self.dm.cluster_name))
コード例 #5
0
ファイル: Cluster.py プロジェクト: FineFan/oVirt3.3WebAPITest
class ITC020202_GetClusterNetworkInfo(BaseTestCase):
    """
    @summary: ITC-02集群管理-01集群操作-02获取指定集群的网络信息
    """

    def setUp(self):
        """
        @summary: 测试用例执行前的环境初始化(前提)
        """
        # 调用父类方法,获取该用例所对应的测试数据模块
        self.dm = super(self.__class__, self).setUp()
        # step1:创建一个集群
        LogPrint().info("Pre-Test-1: Create cluster '%s' for this TC." % self.dm.cluster_name)
        self.assertTrue(smart_create_cluster(self.dm.cluster_info, self.dm.cluster_name))
        # step2:创建一个逻辑网络
        LogPrint().info("Pre-Test-2: Create network '%s' for this TC." % self.dm.nw_name)
        self.assertTrue(smart_create_network(self.dm.nw_info, self.dm.nw_name))
        # step3:附加该网络到集群上
        LogPrint().info(
            "Pre-Test-3: Attach network '%s'to cluster '%s' for this TC." % (self.dm.nw_name, self.dm.cluster_name)
        )
        self.clusterapi = ClusterAPIs()
        self.clusterapi.attachNetworkToCluster(self.dm.cluster_name, self.dm.nw_info)

    def test_GetClusterNetworkInfo(self):
        """
        @summary: 测试用例执行步骤
        @note: 操作成功,验证网络信息
        """
        LogPrint().info("Test: Get the cluster %s's network info. " % self.dm.cluster_name)
        r = self.clusterapi.getClusterNetworkInfo(self.dm.cluster_name, self.dm.nw_name)
        dict_actual = r
        dict_expected = xmltodict.parse(self.dm.nw_info)
        dictCompare = DictCompare()
        if dictCompare.isSubsetDict(dict_expected, dict_actual):
            LogPrint().info("PASS: Get ClusterNetwork '%s' info SUCCESS." % self.dm.nw_name)
        #                 return True
        else:
            LogPrint().error("FAIL: Returned message is WRONG. ")
            self.flag = False
        self.assertTrue(self.flag)

    def tearDown(self):
        """
        @summary: 测试结束后的资源清理(恢复初始环境)
        """
        LogPrint().info("Post-Test-1: Delete network '%s' for this TC." % self.dm.nw_name)
        self.assertTrue(smart_delete_network(self.dm.nw_name, self.dm.dc_name))
        LogPrint().info("Post-Test-2: Delete cluster '%s' for this TC." % self.dm.cluster_name)
        self.assertTrue(smart_delete_cluster(self.dm.cluster_name))
コード例 #6
0
class ITC020205_UpdateNetworkofCluster(BaseTestCase):
    '''
    @summary: ITC-02集群管理-02集群网络操作-05更新集群网络信息
    '''
    def setUp(self):
        '''
        @summary: 测试用例执行前的环境初始化(前提)
        '''
        # 调用父类方法,获取该用例所对应的测试数据模块
        self.dm = super(self.__class__, self).setUp()
        # step1:创建一个集群
        LogPrint().info("Pre-Test-1: Create cluster '%s' for this TC." %
                        self.dm.cluster_name)
        self.assertTrue(
            smart_create_cluster(self.dm.cluster_info, self.dm.cluster_name))
        # step2:创建一个逻辑网络
        LogPrint().info("Pre-Test-2: Create network '%s' for this TC." %
                        self.dm.nw_name)
        self.assertTrue(smart_create_network(self.dm.nw_info, self.dm.nw_name))
        # step3:附加该网络到集群上
        LogPrint().info(
            "Pre-Test-3: Attach network '%s'to cluster '%s' for this TC." %
            (self.dm.nw_name, self.dm.cluster_name))
        self.clusterapi = ClusterAPIs()
        self.clusterapi.attachNetworkToCluster(self.dm.cluster_name,
                                               self.dm.nw_info)

    def test_UpdateNetworkofCluster(self):
        '''
        @summary: 测试用例执行步骤
        @note: 更新集群网络信息
        @note: 操作成功,验证返回状态码,验证更新信息是否正确
        '''
        LogPrint().info("Test: Update Network %s of Cluster %s. " %
                        (self.dm.nw_name, self.dm.cluster_name))
        r = self.clusterapi.updateNetworkOfCluster(self.dm.cluster_name,
                                                   self.dm.nw_name,
                                                   self.dm.nw_info_new)
        if r['status_code'] == self.dm.status_code:
            dict_actual = self.clusterapi.getClusterNetworkInfo(
                self.dm.cluster_name, self.dm.nw_name)
            #dict_expected = {'network':xmltodict.parse(self.dm.nw_info_new)['network']}
            dict_expected = xmltodict.parse(self.dm.nw_info_new)
            dictCompare = DictCompare()
            if dictCompare.isSubsetDict(dict_expected, dict_actual):
                LogPrint().info(
                    "PASS: Detach Network %s from Cluster %s SUCCESS. " %
                    (self.dm.nw_name, self.dm.cluster_name))
            else:
                LogPrint().info("FAIL: Returned message is WRONG. ")
        else:
            LogPrint().info("FAIL: Returned status code is WRONG.")

    def tearDown(self):
        '''
        @summary: 测试结束后的资源清理(恢复初始环境)
        '''
        LogPrint().info("Post-Test-1: Delete network '%s' for this TC." %
                        self.dm.nw_name)
        self.assertTrue(smart_delete_network(self.dm.nw_name, self.dm.dc_name))
        LogPrint().info("Post-Test-2: Delete cluster '%s' for this TC." %
                        self.dm.cluster_name)
        self.assertTrue(smart_delete_cluster(self.dm.cluster_name))