Exemple #1
0
 def setUp(self):
     self.dm = super(self.__class__, self).setUp()
     self.nwapi = NetworkAPIs()  
     #首先新建两个网络network001和network002 
     LogPrint().info("Pre-Test-1: Create network %s."%self.dm.nw_name1)
     self.assertTrue(smart_create_network(self.dm.nw_info1, self.dm.nw_name1)) 
     LogPrint().info("Pre-Test-2: Create network %s."%self.dm.nw_name2)
     self.assertTrue(smart_create_network(self.dm.nw_info2, self.dm.nw_name2))  
 def setUp(self):
     self.dm = super(self.__class__, self).setUp()
     self.nwapi = NetworkAPIs()  
     #首先新建一个网络并获取其id
     LogPrint().info("Pre-Test-1: Create a network %s for TC."%self.dm.nw_name)
     self.nw_id = self.nwapi.createNetwork(self.dm.nw_info)['result']['network']['@id']
     self.proapi = ProfilesAPIs()
     LogPrint().info("Pre-Test-2: Create a profile %s for this network."%self.dm.profile_name)
     self.proapi.createProfiles(self.dm.profile_info, self.nw_id)
 def setUp(self):
     '''
     @summary: 测试用例执行前的环境初始化(前提)
     '''
     self.dm = super(self.__class__, self).setUp()
     self.nwapi = NetworkAPIs()  
     #首先新建一个网络并获取其id
     LogPrint().info("Pre-Test: Create a network %s for TC."%self.dm.nw_name)
     self.nw_id = self.nwapi.createNetwork(self.dm.nw_info)['result']['network']['@id']
Exemple #4
0
 def setUp(self):
     self.dm = super(self.__class__, self).setUp()
     self.nwapi = NetworkAPIs()
     '''
     @note: 如果该数据中心内不存在网络,就创建一个网络
     '''
     LogPrint().info("Pre-Test: Create network %s."%self.dm.nw_name)
     if not self.nwapi.searchNetworkByName(self.dm.nw_name)['result']['networks']:
         self.nwapi.createNetwork(self.dm.nw_info) 
Exemple #5
0
 def setUp(self):
     '''
     @summary: 测试用例执行前的环境初始化(前提)
     '''
     # 初始化测试数据
     self.dm = super(self.__class__, self).setUp()
     self.nwapi = NetworkAPIs()
     # 准备1:创建一个网络
     LogPrint().info("Pre-Test: Create a network '%s' for this TC." % self.dm.nw_name)
     self.assertTrue(smart_create_network(self.dm.nw_info,self.dm.nw_name))
class ITC090304_CreateProfile_NoRequired(BaseTestCase):
    """
    @summary: ITC-06配置集管理-03创建一个配置集-04验证参数完整性
    """

    def setUp(self):
        """
        @summary: 测试用例执行前的环境初始化(前提)
        """
        self.dm = super(self.__class__, self).setUp()
        self.nwapi = NetworkAPIs()
        # 首先新建一个网络并获取其id
        LogPrint().info("Pre-Test: Create a network %s for TC." % self.dm.nw_name)
        self.nw_id = self.nwapi.createNetwork(self.dm.nw_info)["result"]["network"]["@id"]

    def test_CreateProfile_NoRequired(self):
        """
        @summary: 分为三种情况,1)缺少名称 2)缺少网络id 3)提供网络名称而非网络id
        @note: 操作失败,验证返回状态码和报错信息
        """
        self.expected_result_index = 0
        self.proapi = ProfilesAPIs()

        @BaseTestCase.drive_data(self, self.dm.profile_info)
        def do_test(xml_info):
            self.flag = True
            LogPrint().info("Test: Create a profile for network %s." % self.dm.nw_name)
            r = self.proapi.createProfiles(xml_info)
            if r["status_code"] == self.dm.expected_status_code:
                dictCompare = DictCompare()
                if dictCompare.isSubsetDict(
                    xmltodict.parse(self.dm.expected_info_list[self.expected_result_index]), r["result"]
                ):
                    LogPrint().info("PASS: The returned status code and messages are CORRECT.")
                else:
                    LogPrint().error("FAIL: The returned messages are INCORRECT.")
                    self.flag = False
            else:
                LogPrint().error(
                    "FAIL: The returned status code is '%s' while it should be '%s'."
                    % (r["status_code"], self.dm.expected_status_code)
                )
                self.flag = False
            self.assertTrue(self.flag)
            self.expected_result_index += 1

        do_test()

    def tearDown(self):
        LogPrint().info("Post-Test: Delete the network %s." % self.dm.nw_name)
        self.nwapi.delNetwork(self.dm.nw_name, self.dm.dc_name)
Exemple #7
0
 def setUp(self):
     '''
     @summary: 初始化测试数据、测试环境。
     '''
     # 初始化测试数据
     self.dm = super(self.__class__, self).setUp()
     self.nwapi = NetworkAPIs()  
     #首先新建一个网络并获取其id
     LogPrint().info("Pre-Test-1: Create a new network '%s'." % self.dm.nw_name)
     self.nw_id = self.nwapi.createNetwork(self.dm.nw_info)['result']['network']['@id']
     #为该网络创建多个配置集 
     LogPrint().info("Pre-Test-2: Create multi-profiles for network '%s'." % self.dm.nw_name)
     self.proapi = ProfilesAPIs()
     self.proapi.createProfiles(self.dm.profile_info,self.nw_id)
Exemple #8
0
 def test_GetNetworkList(self):
     '''
     @summary: 测试步骤
     @note: (1)获取所有逻辑网络列表;
     @note: (2)验证接口返回的状态码是否正确。
     '''
     self.nwapi = NetworkAPIs()
     LogPrint().info("Test: Get all networks list.")
     r = self.nwapi.getNetworksList()
     if r['status_code']==200:
         LogPrint().info('PASS: Get Network list SUCCESS.')
         self.flag = True
     else:
         LogPrint().error('FAIL: Get Network list FAIL. Returned status code "%s" is Wrong.' % r['status_code'])
         self.flag = False
     self.assertTrue(self.flag)
Exemple #9
0
class ITC06010302_CreateNetwork_VerifyName(BaseTestCase):
    '''
    @summary: ITC-06网络管理-01基本操作-03创建一个新的网络-02验证名称合法性
    '''
    def setUp(self):
        self.dm = super(self.__class__, self).setUp()
        self.nwapi = NetworkAPIs() 
          
    def test_CreateNetwork_VerifyName(self):
        '''
        @summary: 验证名称合法性,分为两种:1)包含非法字符 2)字符长度超出范围。
        @note: 检查返回状态码和报错信息
        ''' 
        self.expected_result_index = 0
        # 使用数据驱动,根据测试数据文件循环创建多个网络
        @BaseTestCase.drive_data(self, self.dm.nw_info)
        def do_test(xml_info):
            r = self.nwapi.createNetwork(xml_info)
            if r['status_code']==self.dm.expected_status_code:
                dictCompare = DictCompare()
                if dictCompare.isSubsetDict(xmltodict.parse(self.dm.expected_info_list[self.expected_result_index]), r['result']):
                    LogPrint().info("PASS: Returned status code and messages are CORRECT.")
                    self.flag = True
                else:
                    LogPrint().error("FAIL: Returned messages are INCORRECT.")
                    self.flag = False
            else:
                LogPrint().error("FAIL: Returned status code '%s' is WRONG while it should be '%s'." % (r['status_code'], self.dm.expected_status_code))
                self.flag = False
            self.assertTrue(self.flag)
            self.expected_result_index += 1
        do_test()
Exemple #10
0
class ITC06010305_CreateNetwork_DupVlan(BaseTestCase):
    '''
    @summary: ITC-06网络管理-01基本操作-03创建一个新的网络-05同一数据中心内网络vlan id重复
    '''
    def setUp(self):
        self.dm = super(self.__class__, self).setUp()
        self.nwapi = NetworkAPIs()
        #创建一个网络,vlan id=2
        LogPrint().info("Pre-Test: Create network %s.Set its vlan id 2."%self.dm.nw_name1)
        self.assertTrue(smart_create_network(self.dm.nw_info1, self.dm.nw_name1))
        
    def test_CreateNetwork_DupVlan(self):
        '''
        @summary: 创建网络,vlan id重复
        @note: 操作失败,检查返回状态码和报错信息
        '''
        LogPrint().info("Test: Create network %s.Set its vlan id 2."%self.dm.nw_name2)
        r = self.nwapi.createNetwork(self.dm.nw_info2)
        if r['status_code'] == self.dm.expected_status_code:
            dictCompare = DictCompare()
            if dictCompare.isSubsetDict(r['result'], xmltodict.parse(self.dm.expected_info)):
                LogPrint().info("PASS: Returned status code and messages are CORRECT when create dup_vlan network.")
                self.flag = True
            else:
                LogPrint().error("FAIL: Returned messages are INCORRECCT when create dup_vlan network.")
                self.flag = False
        else:
            LogPrint().error("FAIL: Returned status code is '%s', INCORRECT. " % r['status_code'])
            self.flag = False
        self.assertTrue(self.flag)

    def tearDown(self):
        LogPrint().info("Post-Test: Delete network %s."%self.dm.nw_name1)
        self.assertTrue(smart_delete_network(self.dm.nw_name1,self.dm.dc_name))
Exemple #11
0
class ITC06010304_CreateNetwork_NoRequired(BaseTestCase):
    '''
    @summary: ITC-06网络管理-01基本操作-03创建一个新的网络-04缺少必填项
    '''
    def setUp(self):
        self.dm = super(self.__class__, self).setUp()
        self.nwapi = NetworkAPIs() 
          
    def test_CreateNetwork_NoRequired(self):
        '''
        @summary: 缺少必填项:网络名称和所在数据中心id。
        @note: 操作失败,检查返回状态码和报错信息
        ''' 
        # 本用例有多种测试情况,所以期望结果也有多种,这个变量代表期望结果的索引值
        self.expected_result_index = 0
        
        # 使用数据驱动,根据测试数据文件循环创建多个网络
        @BaseTestCase.drive_data(self, self.dm.nw_info)
        def do_test(xml_info):
            r = self.nwapi.createNetwork(xml_info)
            if r['status_code']==self.dm.expected_status_code:
                dictCompare = DictCompare()
                if dictCompare.isSubsetDict(xmltodict.parse(self.dm.expected_info_list[self.expected_result_index]), r['result']):
                    LogPrint().info("PASS: Returned status code and messages are CORRECT.")
                    self.flag = True
                else:
                    LogPrint().error("FAIL: Returned messages are INCORRECT.")
                    self.flag = False
            else:
                LogPrint().error("FAIL: Returned status code is '%s' while it should be '%s'." % (r['status_code'], self.dm.expected_status_code))
                self.flag = False
            self.assertTrue(self.flag)
            self.expected_result_index += 1
        do_test()
Exemple #12
0
class ITC06010301_CreateNetwork(BaseTestCase):
    '''
    @summary: ITC-06网络管理-01基本操作-03创建一个新的网络-01成功创建
    '''
    def setUp(self):
        self.dm = super(self.__class__, self).setUp()
        self.nwapi = NetworkAPIs()   
        self.assertTrue(smart_delete_network(self.dm.nw_name, self.dm.dc_name))
        
    def test_CreateNetwork(self): 
        '''
        @summary: 测试用例执行步骤
        @note: (1)新建网络;
        @note: (2)验证接口返回的状态码、接口信息是否正确。
        '''
        LogPrint().info("Test: Create network %s."%self.dm.nw_name)
        r = self.nwapi.createNetwork(self.dm.nw_info)
        if r['status_code'] == self.dm.expected_status_code:
            dict_actual = r['result']
            dict_expected = xmltodict.parse(self.dm.nw_info)
            dictCompare = DictCompare()
            if dictCompare.isSubsetDict(dict_expected, dict_actual):
                LogPrint().info("PASS: Create Network SUCCESS." )
                self.flag = True
            else:
                LogPrint().error("FAIL: Network's info INCORRECT.")
                self.flag = False
        else:
            LogPrint().error("FAIL: Create Network FAILED. Returned status code '%s' is Wrong." % r['status_code'] )
            self.flag = False
        self.assertTrue(self.flag)
            
    def tearDown(self):
        LogPrint().info("Post-Test: Delete network %s."%self.dm.nw_name)
        self.assertTrue(smart_delete_network(self.dm.nw_name,self.dm.dc_name)) 
Exemple #13
0
class ITC090301_CreateProfile(BaseTestCase):
    """
    @summary: ITC-06配置集管理-03创建配置集-01成功创建
    """

    def setUp(self):
        """
        @summary: 测试用例执行前的环境初始化(前提)
        """
        self.dm = super(self.__class__, self).setUp()
        self.nwapi = NetworkAPIs()
        # 首先新建一个网络并获取其id
        LogPrint().info("Pre-Test: Create a network %s for TC." % self.dm.nw_name)
        self.nw_id = self.nwapi.createNetwork(self.dm.nw_info)["result"]["network"]["@id"]

    def test_CreateProfile(self):
        """
        @summary: 创建配置集
        @note: 操作成功,验证返回状态码,验证接口返回信息
        """
        self.flag = True
        self.proapi = ProfilesAPIs()
        LogPrint().info("Test: Create a profile %s for network %s." % (self.dm.profile_name, self.dm.nw_name))
        r = self.proapi.createProfiles(self.dm.profile_info, self.nw_id)
        if r["status_code"] == self.dm.expected_status_code:
            dict_actual = r["result"]
            dict_expected = xmltodict.parse((self.dm.profile_info % self.nw_id))
            dictCompare = DictCompare()
            if dictCompare.isSubsetDict(dict_expected, dict_actual):
                LogPrint().info(
                    "PASS: Create profile %s for network %s SUCCESS." % (self.dm.profile_name, self.dm.nw_name)
                )
            #                 return True
            else:
                LogPrint().error("FAIL:Returned Profile info INCORRECT.")
                self.flag = False
        else:
            LogPrint().error(
                "FAIL: Returned status code is %s not %s. " % (r["status_code"], self.dm.expected_status_code)
            )
            self.flag = False
        self.assertTrue(self.flag)

    def tearDown(self):
        LogPrint().info("Post-Test: Delete the network %s." % self.dm.nw_name)
        self.nwapi.delNetwork(self.dm.nw_name, self.dm.dc_name)
Exemple #14
0
 def setUp(self):
     """
     @summary: 测试用例执行前的环境初始化(前提)
     """
     self.dm = super(self.__class__, self).setUp()
     self.nwapi = NetworkAPIs()
     # 首先新建一个网络并获取其id
     LogPrint().info("Pre-Test: Create a network %s for TC." % self.dm.nw_name)
     self.nw_id = self.nwapi.createNetwork(self.dm.nw_info)["result"]["network"]["@id"]
Exemple #15
0
 def setUp(self):
     self.dm = super(self.__class__, self).setUp()
     self.nwapi = NetworkAPIs()
     # 首先新建一个网络并获取其id
     LogPrint().info("Pre-Test-1: Create a network %s for TC." % self.dm.nw_name)
     self.nw_id = self.nwapi.createNetwork(self.dm.nw_info)["result"]["network"]["@id"]
     self.proapi = ProfilesAPIs()
     LogPrint().info("Pre-Test-2: Create a profile %s for this network." % self.dm.profile_name)
     self.proapi.createProfiles(self.dm.profile_info, self.nw_id)
Exemple #16
0
class ITC090401_UpdateProfile(BaseTestCase):
    """
    @summary: ITC-06配置集管理-04编辑配置集-01成功编辑
    """

    def setUp(self):
        self.dm = super(self.__class__, self).setUp()
        self.nwapi = NetworkAPIs()
        # 首先新建一个网络并获取其id
        LogPrint().info("Pre-Test-1: Create a network %s for TC." % self.dm.nw_name)
        self.nw_id = self.nwapi.createNetwork(self.dm.nw_info)["result"]["network"]["@id"]
        self.proapi = ProfilesAPIs()
        LogPrint().info("Pre-Test-2: Create a profile %s for this network." % self.dm.profile_name)
        self.proapi.createProfiles(self.dm.profile_info, self.nw_id)

    def test_UpdateProfile(self):
        """
        @summary: 编辑配置集
        @note: 操作成功,验证返回状态码,验证接口返回信息
        """
        self.flag = True
        LogPrint().info("Test: Update profile %s of network %s." % (self.dm.profile_name, self.dm.nw_name))
        r = self.proapi.updateProfile(self.dm.profile_name, self.nw_id, self.dm.update_info)
        if r["status_code"] == self.dm.expected_status_code:
            dict_actual = r["result"]
            dict_expected = xmltodict.parse(self.dm.update_info)
            dictCompare = DictCompare()
            if dictCompare.isSubsetDict(dict_expected, dict_actual):
                LogPrint().info("PASS: Update Profile info SUCCESS.")
            else:
                LogPrint().error("FAIL: Update Profile info INCORRECT.")
                self.flag = False
        else:
            LogPrint().error(
                "FAIL: The returned status code is '%s' while it should be '%s'."
                % (r["status_code"], self.dm.expected_status_code)
            )
            self.flag = False
        self.assertTrue(self.flag)

    def tearDown(self):
        # 删除该网络,清空环境
        LogPrint().info("Post-Test: Delete the network %s." % self.dm.nw_name)
        self.nwapi.delNetwork(self.dm.nw_name, self.dm.dc_name)
Exemple #17
0
class ITC090402_UpdateProfile_DupName(BaseTestCase):
    """
    @summary: ITC-06配置集管理-04编辑配置集-01重名
    """

    def setUp(self):
        self.dm = super(self.__class__, self).setUp()
        self.nwapi = NetworkAPIs()
        # 首先新建一个网络并获取其id
        LogPrint().info("Pre-Test-1: Create a network %s for TC." % self.dm.nw_name)
        self.nw_id = self.nwapi.createNetwork(self.dm.nw_info)["result"]["network"]["@id"]
        # 创建两个配置集
        self.proapi = ProfilesAPIs()
        LogPrint().info("Pre-Test-2: Create a profile %s for this network." % self.dm.profile_name1)
        self.proapi.createProfiles(self.dm.profile_info1, self.nw_id)
        LogPrint().info("Pre-Test-3: Create a profile %s for this network." % self.dm.profile_name2)
        self.proapi.createProfiles(self.dm.profile_info2, self.nw_id)

    def test_UpdateProfile(self):
        """
        @summary: 编辑配置集,重名
        @note: 操作失败,验证返回状态码,验证报错信息
        """
        # 编辑配置集1,使其名字和配置集2重名
        self.flag = True
        LogPrint().info("Test: Update profile %s.Set its name be %s." % (self.dm.profile_name1, self.dm.profile_name2))
        r = self.proapi.updateProfile(self.dm.profile_name1, self.nw_id, self.dm.update_info)
        if r["status_code"] == self.dm.expected_status_code:
            dictCompare = DictCompare()
            if dictCompare.isSubsetDict(r["result"], xmltodict.parse(self.dm.expected_info)):
                LogPrint().info("PASS: The returned status code and messages are CORRECT when update dup profile.")
            else:
                LogPrint().error("FAIL: The returned messages are INCORRECCT when update dup profile.")
                self.flag = False
        else:
            LogPrint().error("FAIL: The returned status code is '%s', INCORRECT. " % r["status_code"])
            self.flag = False
        self.assertTrue(self.flag)

    def tearDown(self):
        # 删除该网络,清空环境
        LogPrint().info("Post-Test: Delete the network %s." % self.dm.nw_name)
        self.nwapi.delNetwork(self.dm.nw_name, self.dm.dc_name)
Exemple #18
0
class ITC090304_CreateProfile_NoRequired(BaseTestCase):
    '''
    @summary: ITC-06配置集管理-03创建一个配置集-04验证参数完整性
    '''
    def setUp(self):
        '''
        @summary: 测试用例执行前的环境初始化(前提)
        '''
        self.dm = super(self.__class__, self).setUp()
        self.nwapi = NetworkAPIs()  
        #首先新建一个网络并获取其id
        LogPrint().info("Pre-Test: Create a network %s for TC."%self.dm.nw_name)
        self.nw_id = self.nwapi.createNetwork(self.dm.nw_info)['result']['network']['@id']
          
    def test_CreateProfile_NoRequired(self):
        '''
        @summary: 分为三种情况,1)缺少名称 2)缺少网络id 3)提供网络名称而非网络id
        @note: 操作失败,验证返回状态码和报错信息
        ''' 
        self.expected_result_index = 0
        self.proapi = ProfilesAPIs()
        @BaseTestCase.drive_data(self, self.dm.profile_info)
        def do_test(xml_info):
            self.flag = True
            LogPrint().info("Test: Create a profile for network %s."%self.dm.nw_name)
            r = self.proapi.createProfiles(xml_info)
            if r['status_code']==self.dm.expected_status_code:
                dictCompare = DictCompare()
                if dictCompare.isSubsetDict(xmltodict.parse(self.dm.expected_info_list[self.expected_result_index]), r['result']):
                    LogPrint().info("PASS: The returned status code and messages are CORRECT.")
                else:
                    LogPrint().error("FAIL: The returned messages are INCORRECT.")
                    self.flag = False
            else:
                LogPrint().error("FAIL: The returned status code is '%s' while it should be '%s'." % (r['status_code'], self.dm.expected_status_code))
                self.flag = False
            self.assertTrue(self.flag)
            self.expected_result_index += 1
        do_test()
        
    def tearDown(self):
        LogPrint().info("Post-Test: Delete the network %s."%self.dm.nw_name)
        self.nwapi.delNetwork(self.dm.nw_name, self.dm.dc_name)
Exemple #19
0
class ITC090302_CreateProfile_VerifyName(BaseTestCase):
    """
    @summary: ITC-06配置集管理-03创建配置集-02验证名称合法性
    """

    def setUp(self):
        """
        @summary: 测试用例执行前的环境初始化(前提)
        """
        self.dm = super(self.__class__, self).setUp()
        self.nwapi = NetworkAPIs()
        # 首先新建一个网络并获取其id
        LogPrint().info("Pre-Test: Create a network %s for TC." % self.dm.nw_name)
        self.nw_id = self.nwapi.createNetwork(self.dm.nw_info)["result"]["network"]["@id"]

    def test_CreateProfile_VerifyName(self):
        """
        @summary: 验证名称合法性:包含非法字符
        @note: 操作失败,验证返回状态码和报错信息
        """
        self.proapi = ProfilesAPIs()
        self.flag = True
        LogPrint().info("Test: Create a profile for network %s." % self.dm.nw_name)
        r = self.proapi.createProfiles(self.dm.profile_info, self.nw_id)
        if r["status_code"] == self.dm.expected_status_code:
            dictCompare = DictCompare()
            if dictCompare.isSubsetDict(xmltodict.parse(self.dm.expected_info), r["result"]):
                LogPrint().info("PASS: The returned status code and messages are CORRECT.")
            else:
                LogPrint().error("FAIL: The returned messages are INCORRECT.")
                self.flag = False
        else:
            LogPrint().error(
                "FAIL: The returned status code is '%s' while it should be '%s'."
                % (r["status_code"], self.dm.expected_status_code)
            )
            self.flag = False
        self.assertTrue(self.flag)

    def tearDown(self):
        LogPrint().info("Post-Test: Delete the network %s." % self.dm.nw_name)
        self.nwapi.delNetwork(self.dm.nw_name, self.dm.dc_name)
Exemple #20
0
class ITC090402_UpdateProfile_DupName(BaseTestCase):
    '''
    @summary: ITC-06配置集管理-04编辑配置集-01重名
    '''
    def setUp(self):
        self.dm = super(self.__class__, self).setUp()
        self.nwapi = NetworkAPIs()  
        #首先新建一个网络并获取其id
        LogPrint().info("Pre-Test-1: Create a network %s for TC."%self.dm.nw_name)
        self.nw_id = self.nwapi.createNetwork(self.dm.nw_info)['result']['network']['@id']
        #创建两个配置集
        self.proapi = ProfilesAPIs()
        LogPrint().info("Pre-Test-2: Create a profile %s for this network."%self.dm.profile_name1)
        self.proapi.createProfiles(self.dm.profile_info1, self.nw_id)
        LogPrint().info("Pre-Test-3: Create a profile %s for this network."%self.dm.profile_name2)
        self.proapi.createProfiles(self.dm.profile_info2, self.nw_id)
        
    def test_UpdateProfile(self):
        '''
        @summary: 编辑配置集,重名
        @note: 操作失败,验证返回状态码,验证报错信息
        ''' 
        #编辑配置集1,使其名字和配置集2重名 
        self.flag = True
        LogPrint().info("Test: Update profile %s.Set its name be %s."%(self.dm.profile_name1, self.dm.profile_name2))
        r = self.proapi.updateProfile(self.dm.profile_name1, self.nw_id, self.dm.update_info)
        if r['status_code'] == self.dm.expected_status_code:
            dictCompare = DictCompare()
            if dictCompare.isSubsetDict(r['result'], xmltodict.parse(self.dm.expected_info)):
                LogPrint().info("PASS: The returned status code and messages are CORRECT when update dup profile.")
            else:
                LogPrint().error("FAIL: The returned messages are INCORRECCT when update dup profile.")
                self.flag = False
        else:
            LogPrint().error("FAIL: The returned status code is '%s', INCORRECT. " % r['status_code'])
            self.flag = False
        self.assertTrue(self.flag)
            
    def tearDown(self):
        #删除该网络,清空环境
        LogPrint().info("Post-Test: Delete the network %s."%self.dm.nw_name)
        self.nwapi.delNetwork(self.dm.nw_name, self.dm.dc_name)    
Exemple #21
0
class ITC090301_CreateProfile(BaseTestCase):
    '''
    @summary: ITC-06配置集管理-03创建配置集-01成功创建
    '''
    def setUp(self):
        '''
        @summary: 测试用例执行前的环境初始化(前提)
        '''
        self.dm = super(self.__class__, self).setUp()
        self.nwapi = NetworkAPIs()  
        #首先新建一个网络并获取其id
        LogPrint().info("Pre-Test: Create a network %s for TC."%self.dm.nw_name)
        self.nw_id = self.nwapi.createNetwork(self.dm.nw_info)['result']['network']['@id']
         
    def test_CreateProfile(self):
        '''
        @summary: 创建配置集
        @note: 操作成功,验证返回状态码,验证接口返回信息
        ''' 
        self.flag = True
        self.proapi = ProfilesAPIs()
        LogPrint().info("Test: Create a profile %s for network %s."%(self.dm.profile_name, self.dm.nw_name))
        r = self.proapi.createProfiles(self.dm.profile_info, self.nw_id)
        if r['status_code'] == self.dm.expected_status_code:
            dict_actual = r['result']
            dict_expected = xmltodict.parse((self.dm.profile_info %self.nw_id))
            dictCompare = DictCompare()
            if dictCompare.isSubsetDict(dict_expected, dict_actual):
                LogPrint().info("PASS: Create profile %s for network %s SUCCESS."%(self.dm.profile_name, self.dm.nw_name))
#                 return True
            else:
                LogPrint().error("FAIL:Returned Profile info INCORRECT.")
                self.flag = False
        else:
            LogPrint().error("FAIL: Returned status code is %s not %s. "% (r['status_code'], self.dm.expected_status_code) )
            self.flag = False
        self.assertTrue(self.flag)
            
    def tearDown(self):
        LogPrint().info("Post-Test: Delete the network %s."%self.dm.nw_name)
        self.nwapi.delNetwork(self.dm.nw_name, self.dm.dc_name)
Exemple #22
0
class ITC090303_CreateProfile_DupName(BaseTestCase):
    """
    @summary: ITC-06配置集管理-03新建一个配置集-03名称重复
    """

    def setUp(self):
        """
        @summary: 测试用例执行前的环境初始化(前提)
        """
        self.dm = super(self.__class__, self).setUp()
        self.nwapi = NetworkAPIs()
        # 首先新建一个网络并获取其id
        LogPrint().info("Pre-Test-1: Create a network %s for TC." % self.dm.nw_name)
        self.nw_id = self.nwapi.createNetwork(self.dm.nw_info)["result"]["network"]["@id"]
        # 创建一个配置集
        LogPrint().info("Pre-Test-2: Create a profile %s for this network." % self.dm.profile_name)
        self.proapi = ProfilesAPIs()
        self.proapi.createProfiles(self.dm.profile_info, self.nw_id)

    def test_CreateProfile_DupName(self):
        """
        @note: 操作失败,检查返回状态码和提示信息
        """
        self.flag = True
        LogPrint().info("Test: Create a dupname profile for network %s." % self.dm.nw_name)
        r = self.proapi.createProfiles(self.dm.profile_info, self.nw_id)
        if r["status_code"] == self.dm.expected_status_code:
            dictCompare = DictCompare()
            if dictCompare.isSubsetDict(r["result"], xmltodict.parse(self.dm.expected_info)):
                LogPrint().info("PASS: The returned status code and messages are CORRECT when create dup profile.")
            else:
                LogPrint().error("FAIL: The returned messages are INCORRECCT when create dup profile.")
                self.flag = False
        else:
            LogPrint().error("FAIL: The returned status code is '%s', INCORRECT. " % r["status_code"])
            self.flag = False
        self.assertTrue(self.flag)

    def tearDown(self):
        LogPrint().info("Post-Test: Delete the network %s." % self.dm.nw_name)
        self.nwapi.delNetwork(self.dm.nw_name, self.dm.dc_name)
Exemple #23
0
class ITC090401_UpdateProfile(BaseTestCase):
    '''
    @summary: ITC-06配置集管理-04编辑配置集-01成功编辑
    '''
    def setUp(self):
        self.dm = super(self.__class__, self).setUp()
        self.nwapi = NetworkAPIs()  
        #首先新建一个网络并获取其id
        LogPrint().info("Pre-Test-1: Create a network %s for TC."%self.dm.nw_name)
        self.nw_id = self.nwapi.createNetwork(self.dm.nw_info)['result']['network']['@id']
        self.proapi = ProfilesAPIs()
        LogPrint().info("Pre-Test-2: Create a profile %s for this network."%self.dm.profile_name)
        self.proapi.createProfiles(self.dm.profile_info, self.nw_id)
        
    def test_UpdateProfile(self): 
        '''
        @summary: 编辑配置集
        @note: 操作成功,验证返回状态码,验证接口返回信息
        ''' 
        self.flag = True
        LogPrint().info("Test: Update profile %s of network %s."%(self.dm.profile_name, self.dm.nw_name))
        r = self.proapi.updateProfile(self.dm.profile_name, self.nw_id, self.dm.update_info)
        if r['status_code'] == self.dm.expected_status_code:
            dict_actual = r['result']
            dict_expected = xmltodict.parse(self.dm.update_info)
            dictCompare = DictCompare()
            if dictCompare.isSubsetDict(dict_expected, dict_actual):
                LogPrint().info("PASS: Update Profile info SUCCESS." )
            else:
                LogPrint().error("FAIL: Update Profile info INCORRECT.")
                self.flag = False
        else:
            LogPrint().error("FAIL: The returned status code is '%s' while it should be '%s'." % (r['status_code'], self.dm.expected_status_code)  )            
            self.flag = False
        self.assertTrue(self.flag)
            
    def tearDown(self):
        #删除该网络,清空环境
        LogPrint().info("Post-Test: Delete the network %s."%self.dm.nw_name)
        self.nwapi.delNetwork(self.dm.nw_name, self.dm.dc_name)
Exemple #24
0
class ITC090303_CreateProfile_DupName(BaseTestCase):
    '''
    @summary: ITC-06配置集管理-03新建一个配置集-03名称重复
    '''
    def setUp(self):
        '''
        @summary: 测试用例执行前的环境初始化(前提)
        '''
        self.dm = super(self.__class__, self).setUp()
        self.nwapi = NetworkAPIs()  
        #首先新建一个网络并获取其id
        LogPrint().info("Pre-Test-1: Create a network %s for TC."%self.dm.nw_name)
        self.nw_id = self.nwapi.createNetwork(self.dm.nw_info)['result']['network']['@id']
        #创建一个配置集
        LogPrint().info("Pre-Test-2: Create a profile %s for this network."%self.dm.profile_name)
        self.proapi = ProfilesAPIs()
        self.proapi.createProfiles(self.dm.profile_info, self.nw_id)
          
    def test_CreateProfile_DupName(self):
        '''
        @note: 操作失败,检查返回状态码和提示信息
        '''
        self.flag = True
        LogPrint().info("Test: Create a dupname profile for network %s."% self.dm.nw_name)
        r = self.proapi.createProfiles(self.dm.profile_info, self.nw_id)
        if r['status_code'] == self.dm.expected_status_code:
            dictCompare = DictCompare()
            if dictCompare.isSubsetDict(r['result'], xmltodict.parse(self.dm.expected_info)):
                LogPrint().info("PASS: The returned status code and messages are CORRECT when create dup profile.")
            else:
                LogPrint().error("FAIL: The returned messages are INCORRECCT when create dup profile.")
                self.flag = False
        else:
            LogPrint().error("FAIL: The returned status code is '%s', INCORRECT. " % r['status_code'])
            self.flag = False
        self.assertTrue(self.flag)
        
    def tearDown(self):
        LogPrint().info("Post-Test: Delete the network %s."%self.dm.nw_name)
        self.nwapi.delNetwork(self.dm.nw_name, self.dm.dc_name)
Exemple #25
0
class ITC0905_DeleteProfile(BaseTestCase):
    """
    @summary: ITC-06配置集管理-05删除配置集
    """

    def setUp(self):
        self.dm = super(self.__class__, self).setUp()
        self.nwapi = NetworkAPIs()
        # 首先网络并获取其id
        LogPrint().info("Pre-Test-1: Create a network %s for TC." % self.dm.nw_name)
        self.nw_id = self.nwapi.createNetwork(self.dm.nw_info)["result"]["network"]["@id"]
        # 为网络创建一个配置集
        LogPrint().info("Pre-Test-2: Create a profile %s for this network." % self.dm.profile_name)
        self.proapi = ProfilesAPIs()
        self.proapi.createProfiles(self.dm.profile_info, self.nw_id)

    def test_DeleteProfile(self):
        """
        @summary: 删除配置集
        @note: 操作成功,验证返回状态码,验证配置集是否存在
        """
        self.flag = True
        LogPrint().info("Test: Delete profile %s." % self.dm.profile_name)
        r = self.proapi.delProfile(self.dm.profile_name, self.nw_id)
        if r["status_code"] == self.dm.expected_status_code:
            if not self.proapi.isExist(self.dm.profile_name, self.nw_id):
                LogPrint().info("PASS: Delete profile %s SUCCESS." % self.dm.profile_name)
            else:
                LogPrint().error("FAIL: Profile %s is still exist." % self.dm.profile_name)
                self.flag = False
        else:
            LogPrint().error("FAIL: The returned status code is '%s', INCORRECT. " % r["status_code"])
            self.flag = False
        self.assertTrue(self.flag)

    def tearDown(self):
        # 删除该网络,清空环境
        LogPrint().info("Post-Test: Delete the network %s." % self.dm.nw_name)
        self.nwapi.delNetwork(self.dm.nw_name, self.dm.dc_name)
Exemple #26
0
class ITC0905_DeleteProfile(BaseTestCase):
    '''
    @summary: ITC-06配置集管理-05删除配置集
    '''
    def setUp(self):
        self.dm = super(self.__class__, self).setUp()
        self.nwapi = NetworkAPIs()  
        #首先网络并获取其id
        LogPrint().info("Pre-Test-1: Create a network %s for TC."%self.dm.nw_name)
        self.nw_id = self.nwapi.createNetwork(self.dm.nw_info)['result']['network']['@id']
        #为网络创建一个配置集
        LogPrint().info("Pre-Test-2: Create a profile %s for this network."%self.dm.profile_name)
        self.proapi = ProfilesAPIs()
        self.proapi.createProfiles(self.dm.profile_info, self.nw_id)
        
    def test_DeleteProfile(self):
        '''
        @summary: 删除配置集
        @note: 操作成功,验证返回状态码,验证配置集是否存在
        '''  
        self.flag = True
        LogPrint().info("Test: Delete profile %s."%self.dm.profile_name)
        r = self.proapi.delProfile(self.dm.profile_name, self.nw_id)
        if r['status_code'] == self.dm.expected_status_code:
            if not self.proapi.isExist(self.dm.profile_name, self.nw_id):
                LogPrint().info("PASS: Delete profile %s SUCCESS."%self.dm.profile_name)
            else:
                LogPrint().error("FAIL: Profile %s is still exist."%self.dm.profile_name)
                self.flag = False
        else:
            LogPrint().error("FAIL: The returned status code is '%s', INCORRECT. " % r['status_code'])
            self.flag = False
        self.assertTrue(self.flag) 
        
    def tearDown(self):
        #删除该网络,清空环境
        LogPrint().info("Post-Test: Delete the network %s."%self.dm.nw_name)
        self.nwapi.delNetwork(self.dm.nw_name, self.dm.dc_name)
Exemple #27
0
class ITC090302_CreateProfile_VerifyName(BaseTestCase):
    '''
    @summary: ITC-06配置集管理-03创建配置集-02验证名称合法性
    '''
    def setUp(self):
        '''
        @summary: 测试用例执行前的环境初始化(前提)
        '''
        self.dm = super(self.__class__, self).setUp()
        self.nwapi = NetworkAPIs()  
        #首先新建一个网络并获取其id
        LogPrint().info("Pre-Test: Create a network %s for TC."%self.dm.nw_name)
        self.nw_id = self.nwapi.createNetwork(self.dm.nw_info)['result']['network']['@id']
          
    def test_CreateProfile_VerifyName(self):
        '''
        @summary: 验证名称合法性:包含非法字符
        @note: 操作失败,验证返回状态码和报错信息
        ''' 
        self.proapi = ProfilesAPIs()
        self.flag = True
        LogPrint().info("Test: Create a profile for network %s."%self.dm.nw_name)
        r = self.proapi.createProfiles(self.dm.profile_info, self.nw_id)
        if r['status_code']==self.dm.expected_status_code:
            dictCompare = DictCompare()
            if dictCompare.isSubsetDict(xmltodict.parse(self.dm.expected_info), r['result']):
                LogPrint().info("PASS: The returned status code and messages are CORRECT.")
            else:
                LogPrint().error("FAIL: The returned messages are INCORRECT.")
                self.flag = False
        else:
            LogPrint().error("FAIL: The returned status code is '%s' while it should be '%s'." % (r['status_code'], self.dm.expected_status_code))
            self.flag = False
        self.assertTrue(self.flag)
              
    def tearDown(self):
        LogPrint().info("Post-Test: Delete the network %s."%self.dm.nw_name)
        self.nwapi.delNetwork(self.dm.nw_name, self.dm.dc_name)
Exemple #28
0
class ITC06010303_CreateNetwork_DupName(BaseTestCase):
    '''
    @summary: ITC-06网络管理-01基本操作-03创建一个新的网络-03同一数据中心内网络重名
    '''
    def setUp(self):
        self.dm = super(self.__class__, self).setUp()
        self.nwapi = NetworkAPIs()
        '''
        @note: 如果该数据中心内不存在网络,就创建一个网络
        '''
        LogPrint().info("Pre-Test: Create network %s."%self.dm.nw_name)
        if not self.nwapi.searchNetworkByName(self.dm.nw_name)['result']['networks']:
            self.nwapi.createNetwork(self.dm.nw_info) 
          
    def test_CreateNetwork_DupName(self):
        '''
        @summary: 创建重名网络
        @note: 操作失败,检查返回状态码和报错信息
        '''
        LogPrint().info("Test: Create dup network %s."%self.dm.nw_name)
        r = self.nwapi.createNetwork(self.dm.nw_info)
        if r['status_code'] == self.dm.expected_status_code:
            dictCompare = DictCompare()
            print xmltodict.parse(self.dm.expected_info)
            if dictCompare.isSubsetDict(r['result'], xmltodict.parse(self.dm.expected_info)):
                LogPrint().info("PASS: Returned status code and messages are CORRECT when create dup network.")
                self.flag = True
            else:
                LogPrint().error("FAIL: Returned messages are INCORRECCT when create dup network.")
                self.flag = False
        else:
            LogPrint().error("FAIL: Returned status code is '%s', INCORRECT. " % r['status_code'])
            self.flag = False
        self.assertTrue(self.flag)
        
    def tearDown(self):
        LogPrint().info("Post-Test: Delete network %s."%self.dm.nw_name)
        self.assertTrue(smart_delete_network(self.dm.nw_name,self.dm.dc_name))
Exemple #29
0
class ITC060105_DeleteNetwork(BaseTestCase):
    '''
    @summary: ITC-06网络管理-01基本操作-05删除网络
    '''
    def setUp(self):
        self.dm = super(self.__class__, self).setUp()
        self.nwapi = NetworkAPIs()  
        #首先新建一个网络 
        LogPrint().info("Pre-Test-1: Create network %s."%self.dm.nw_name)
        self.assertTrue(smart_create_network(self.dm.nw_info, self.dm.nw_name))
        
    def test_DeleteNetwork(self): 
        '''
        @summary: 删除网络
        @note: 操作成功,检查返回状态码,检查网络是否存在
        ''' 
        LogPrint().info("Test: Delete network %s."%self.dm.nw_name)
        r = self.nwapi.delNetwork(self.dm.nw_name, self.dm.dc_name)
        if r['status_code'] == self.dm.expected_status_code:
            if not self.nwapi.isNetworkExist(self.dm.nw_name, self.dm.dc_name):
                LogPrint().info("PASS: Delete network %s success."%self.dm.nw_name)
                self.flag = True
            else:
                LogPrint().error("FAIL: Delete network fail.The network %s is still exist."%self.dm.nw_name)
                self.flag = False
        else:
            LogPrint().error("FAIL: The returned status code is '%s', INCORRECT. " % r['status_code'])
            self.flag = False
        self.assertTrue(self.flag) 
        
    def tearDown(self):
        '''
        @summary: 删除该网络,清空环境
        '''
        LogPrint().info("Post-Test-1: Delete network %s."%self.dm.nw_name)
        self.assertTrue(smart_delete_network(self.dm.nw_name,self.dm.dc_name))
Exemple #30
0
class ITC060202_GetNetworkProfileInfo(BaseTestCase):
    '''
    @summary: ITC-06网络管理-02配置集管理-02获取配置集详情
    '''
    def setUp(self):
        '''
        @summary: 初始化测试数据、测试环境。
        '''
        # 初始化测试数据
        self.dm = super(self.__class__, self).setUp()
        self.nwapi = NetworkAPIs()  
        #首先新建一个网络并获取其id
        LogPrint().info("Pre-Test-1: Create a new network '%s'." % self.dm.nw_name)
        self.nw_id = self.nwapi.createNetwork(self.dm.nw_info)['result']['network']['@id']
        #为该网络创建多个配置集 
        LogPrint().info("Pre-Test-2: Create multi-profiles for network '%s'." % self.dm.nw_name)
        self.proapi = ProfilesAPIs()
        self.proapi.createProfiles(self.dm.profile_info,self.nw_id)
  
    def test_GetNetworkProfileInfo(self):
        '''
        @summary: 获取网络的配置集信息
        @note: 操作成功,验证返回码和接口信息
        '''
        self.nwproapi = NetworkProfilesAPIs()
        LogPrint().info("Test: Get network %s's profile %s info." % (self.dm.nw_name, self.dm.profile_name))
        r = self.nwproapi.getNetworkProfileInfo(self.nw_id, self.dm.profile_name)
        if r['status_code']==self.dm.expected_status_code:
            dict_actual = r['result']
            dict_expected = xmltodict.parse((self.dm.profile_info %self.nw_id))
            dictCompare = DictCompare()
            if dictCompare.isSubsetDict(dict_expected, dict_actual):
                LogPrint().info("PASS: Get network %s's profile %s info SUCCESS." % (self.dm.nw_name, self.dm.profile_name) )
                self.flag = True
            else:
                LogPrint().error("FAIL: Returned messages are INCORRECT.")
                self.flag = False
        else:
            LogPrint().error("FAIL: Get NetworkProfile Info FAILED. Returned status code '%s' is WRONG." % r['status_code'] )
            self.flag = False
        self.assertTrue(self.flag)
        
    def tearDown(self):
        '''
        @summary: 清除该网络及配置集
        '''
        LogPrint().info("Post-Test: Delete network '%s' and it's profiles." % self.dm.nw_name)
        self.assertTrue(smart_delete_network(self.dm.nw_name,self.dm.dc_name))        
Exemple #31
0
 def setUp(self):
     self.dm = super(self.__class__, self).setUp()
     LogPrint().info("Pre-Test-1: Create a template %s for TC." %
                     self.dm.temp_name)
     self.assertTrue(
         smart_create_template(self.dm.temp_name, self.dm.temp_info))
     #为所在数据中心的ovirtmgmt网络创建一个配置集
     LogPrint().info("Pre-Test-2: Create a profile %s for ovirtmgmt." %
                     self.dm.profile_name)
     self.nw_id = NetworkAPIs().getNetworkIdByName('ovirtmgmt',
                                                   self.dm.dc_name)
     print self.nw_id
     r = ProfilesAPIs().createProfiles(self.dm.profile_info, self.nw_id)
     if r['status_code'] == 201:
         self.proid = r['result']['vnic_profile']['@id']
         LogPrint().info("Create Profile SUCCESS.")
     else:
         LogPrint().error("Create Profile fail.The status_code is WRONG.")
Exemple #32
0
class ITC060201_GetNetworkProfileList(BaseTestCase):
    '''
    @summary: ITC-06网络管理-02配置集管理-01获取配置集列表
    '''
    def setUp(self):
        '''
        @summary: 初始化测试数据、测试环境。
        '''
        self.dm = super(self.__class__, self).setUp()
        self.nwapi = NetworkAPIs()  
        
        #首先新建一个网络并获取其id
        LogPrint().info("Pre-Test-1: Create a new network '%s'." % self.dm.nw_name)
        self.nw_id = self.nwapi.createNetwork(self.dm.nw_info)['result']['network']['@id']
        
        #为该网络创建多个配置集
        LogPrint().info("Pre-Test-2: Create multi-profiles for network '%s'." % self.dm.nw_name) 
        self.proapi = ProfilesAPIs()
        @BaseTestCase.drive_data(self, self.dm.profile_info)
        def do_test(xml_info):
            self.proapi.createProfiles(xml_info,self.nw_id)
        do_test()
  
    def test_GetNetworkProfileList(self):
        '''
        @summary: 获取网络的配置集列表
        '''
        self.nwproapi = NetworkProfilesAPIs()
        LogPrint().info("Test: To get all NetworkProfiles list.")
        r = self.nwproapi.getNetworkProfileList(self.nw_id)
        if r['status_code']==self.dm.expected_status_code:
            LogPrint().info('PASS: Get NetworkProfile list SUCCESS.')
            self.flag = True
        else:
            LogPrint().error('FAIL: Get Network Profile list FAIL. Returned status code "%s" is WRONG.' % r['status_code'])
            self.flag = False
        self.assertTrue(self.flag)
        
    def tearDown(self):
        '''
        @summary: 清除该网络及配置集
        '''
        LogPrint().info("Post-Test: Delete network '%s' and it's profiles." % self.dm.nw_name)
        self.assertTrue(smart_delete_network(self.dm.nw_name,self.dm.dc_name))
Exemple #33
0
class ITC06010402_UpdateNetwork_DupName(BaseTestCase):
    '''
    @summary: ITC-06网络管理-01基本操作-04编辑网络-02网络名称重复
    '''
    def setUp(self):
        self.dm = super(self.__class__, self).setUp()
        self.nwapi = NetworkAPIs()  
        #首先新建两个网络network001和network002 
        LogPrint().info("Pre-Test-1: Create network %s."%self.dm.nw_name1)
        self.assertTrue(smart_create_network(self.dm.nw_info1, self.dm.nw_name1)) 
        LogPrint().info("Pre-Test-2: Create network %s."%self.dm.nw_name2)
        self.assertTrue(smart_create_network(self.dm.nw_info2, self.dm.nw_name2))  
        
    def test_UpdateNetwork(self):
        #对network001进行编辑:名称修改为network002 
        '''
        @summary: 编辑网络重名
        @note: 操作失败,检查返回状态码和报错信息
        ''' 
        LogPrint().info("Test: Update network %s.Set its name be %s."%(self.dm.nw_name1, self.dm.nw_name2))
        r = self.nwapi.updateNetwork(self.dm.nw_name1, self.dm.dc_name, self.dm.update_info)
        if r['status_code'] == self.dm.expected_status_code:
            dictCompare = DictCompare()
            if dictCompare.isSubsetDict(r['result'], xmltodict.parse(self.dm.expected_info)):
                LogPrint().info("PASS: The returned status code and messages are CORRECT when update dup network.")
                self.flag = True
            else:
                LogPrint().error("FAIL: The returned messages are INCORRECCT when update dup network.")
                self.flag = False
        else:
            LogPrint().error("FAIL: The returned status code is '%s', INCORRECT. " % r['status_code'])
            self.flag = False
        self.assertTrue(self.flag)
            
    def tearDown(self):
        #删除该网络,清空环境
        LogPrint().info("Post-Test-1: Delete network %s."%self.dm.nw_name1)
        self.assertTrue(smart_delete_network(self.dm.nw_name1,self.dm.dc_name))
        LogPrint().info("Post-Test-2: Delete network %s."%self.dm.nw_name2)
        self.assertTrue(smart_delete_network(self.dm.nw_name2,self.dm.dc_name))
Exemple #34
0
class ITC06010401_UpdateNetwork(BaseTestCase):
    '''
    @summary: ITC-06网络管理-01基本操作-04编辑网络-01成功编辑
    '''
    def setUp(self):
        self.dm = super(self.__class__, self).setUp()
        self.nwapi = NetworkAPIs()  
        #首先新建一个网络 
        LogPrint().info("Pre-Test: Create network %s."%self.dm.nw_name)
        self.assertTrue(smart_create_network(self.dm.nw_info, self.dm.nw_name)) 
        
    def test_UpdateNetwork(self):
        '''
        @summary: 编辑网络
        @note: 操作成功,检查返回状态码和网络信息
        ''' 
        LogPrint().info("Test: Update network %s."%self.dm.nw_name)
        r = self.nwapi.updateNetwork(self.dm.nw_name, self.dm.dc_name, self.dm.update_info)
        if r['status_code'] == self.dm.expected_status_code:
            dict_actual = r['result']
            dict_expected = xmltodict.parse(self.dm.update_info)
            dictCompare = DictCompare()
            if dictCompare.isSubsetDict(dict_expected, dict_actual):
                LogPrint().info("PASS: Update Network info SUCCESS." )
                self.flag = True
            else:
                LogPrint().error("FAIL: Update Network info INCORRECT.")
                self.flag = False
        else:
            LogPrint().error("FAIL: Update Network info FAILED. Returned status code '%s' is WRONG." % r['status_code'] )
            self.flag = False
        self.assertTrue(self.flag)
            
    def tearDown(self):
        #删除该网络,清空环境
        LogPrint().info("Post-Test: Delete network %s."%self.dm.new_nw_name)
        self.assertTrue(smart_delete_network(self.dm.new_nw_name,self.dm.dc_name))
#encoding:utf-8
from TestAPIs.StorageDomainAPIs import StorageDomainAPIs
from TestAPIs.ProfilesAPIs import ProfilesAPIs
from TestAPIs.NetworkAPIs import NetworkAPIs
import TestData.VirtualMachine.ITC05_SetUp as ModuleData
'''
@note: PreData
'''
'''
@note: 这里使用数据中心自带的ovirtmgmt/ovirtmgmt配置集
'''
nic_name = 'nic-ITC05'
sd_id = StorageDomainAPIs().getStorageDomainIdByName(ModuleData.data1_nfs_name)
nw_id = NetworkAPIs().getNetworkIdByName('ovirtmgmt', ModuleData.dc_nfs_name)
pro_id = ProfilesAPIs().getProfileIdByName('ovirtmgmt', nw_id)
nic_info = '''
<nic>
    <name>%s</name>
    <interface>virtio</interface>
    <linked>false</linked>
    <plugged>false</plugged>
</nic>
''' % (nic_name)
'''
@note: ExpectedData
'''
expected_status_code = 200
Exemple #36
0
class ITC0902_GetProfileInfo(BaseTestCase):
    """
    @summary: ITC-06配置集管理-02获取指定配置集信息
    """

    def setUp(self):
        """
        @summary: 测试用例执行前的环境初始化(前提)
        """
        self.dm = super(self.__class__, self).setUp()
        self.nwapi = NetworkAPIs()
        # 首先新建一个网络并获取其id
        LogPrint().info("Pre-Test-1: Create a network %s for TC." % self.dm.nw_name)
        self.nw_id = self.nwapi.createNetwork(self.dm.nw_info)["result"]["network"]["@id"]
        self.proapi = ProfilesAPIs()
        LogPrint().info("Pre-Test-2: Create a profile %s for this network." % self.dm.profile_name)
        self.proapi.createProfiles(self.dm.profile_info, self.nw_id)

    def test_GetProfileInfo_byname(self):
        """
        @summary: 根据配置集名称获取其信息
        @note: 操作成功,验证返回状态码,验证接口返回信息
        """
        self.flag = True
        r = self.proapi.getProfileInfo(profile_name=self.dm.profile_name, nw_id=self.nw_id)
        LogPrint().info("Test-1: Get profile %s by NAME." % self.dm.profile_name)
        if r["status_code"] == self.dm.expected_status_code:
            dict_actual = r["result"]
            dict_expected = xmltodict.parse((self.dm.profile_info % self.nw_id))
            dictCompare = DictCompare()
            if dictCompare.isSubsetDict(dict_expected, dict_actual):
                LogPrint().info("PASS: Get Profile info SUCCESS.")
            else:
                LogPrint().error("FAIL:Returned Profile info INCORRECT.")
                self.flag = False
        else:
            LogPrint().error(
                "FAIL: Returned status code is %s not %s. " % (r["status_code"], self.dm.expected_status_code)
            )
            self.flag = False
        self.assertTrue(self.flag)

    def test_GetProfileInfo_id(self):
        """
        @summary: 根据配置集id获取信息
        @note: 操作成功,验证返回状态码,验证接口返回信息
        """
        # 测试1:根据网络id获取网络信息
        self.flag = True
        LogPrint().info("Test-2: Get profile %s by ID." % self.dm.profile_name)
        profile_id = self.proapi.getProfileIdByName(self.dm.profile_name, self.nw_id)
        r = self.proapi.getProfileInfo(profile_id=profile_id)
        if r["status_code"] == self.dm.expected_status_code:
            dict_actual = r["result"]
            dict_expected = xmltodict.parse((self.dm.profile_info % self.nw_id))
            dictCompare = DictCompare()
            if dictCompare.isSubsetDict(dict_expected, dict_actual):
                LogPrint().info("PASS: Get Profile info SUCCESS.")
            else:
                LogPrint().error("FAIL:Returned Profile info INCORRECT.")
                self.flag = False
        else:
            LogPrint().error(
                "FAIL: Returned status code is %s not %s. " % (r["status_code"], self.dm.expected_status_code)
            )
            self.flag = False
        self.assertTrue(self.flag)

    def tearDown(self):
        """
        @summary: 测试结束后的资源清理(恢复初始环境)
        """
        LogPrint().info("Post-Test: Delete the network %s." % self.dm.nw_name)
        self.nwapi.delNetwork(self.dm.nw_name, self.dm.dc_name)
Exemple #37
0
class ITC060102_GetNetworkInfo(BaseTestCase):
    '''
    @summary: ITC-06网络管理-01基本操作-02获取指定网络信息
    '''
    def setUp(self):
        '''
        @summary: 测试用例执行前的环境初始化(前提)
        '''
        # 初始化测试数据
        self.dm = super(self.__class__, self).setUp()
        self.nwapi = NetworkAPIs()
        # 准备1:创建一个网络
        LogPrint().info("Pre-Test: Create a network '%s' for this TC." % self.dm.nw_name)
        self.assertTrue(smart_create_network(self.dm.nw_info,self.dm.nw_name))
        
    def test_GetNetworkInfo_name(self):
        '''
        @summary: 测试用例执行步骤
        @note: (1)根据名称获取指定逻辑网络的信息;
        @note: (2)验证接口返回的状态码、接口信息是否正确。
        '''
        # 测试1:根据网络名称和数据中心名称获取网络信息(在同一数据中心内网络名称是唯一的)
        LogPrint().info("Test: Get the network's ('%s') info by name." % self.dm.nw_name)
        r = self.nwapi.getNetworkInfo(nw_name=self.dm.nw_name,dc_name=ModuleData.dc_name)
        if r['status_code']==self.dm.expected_status_code:
            dict_actual = r['result']
            dict_expected = xmltodict.parse(self.dm.nw_info)
            dictCompare = DictCompare()
            if dictCompare.isSubsetDict(dict_expected, dict_actual):
                LogPrint().info("PASS: Get Network's ('%s') info SUCCESS." % self.dm.nw_name )
                self.flag = True
            else:
                LogPrint().error("FAIL: Get Network's ('%s') info INCORRECT." % self.dm.nw_name)
                self.flag = False
        else:
            LogPrint().error("FAIL: Get Network info FAILED. Returned status code '%s' is WRONG." % r['status_code'])
            self.flag = False
        self.assertTrue(self.flag)
    
    def test_GetNetworkInfo_id(self):
        '''
        @summary: 测试用例执行步骤
        @note: (1)根据ID获取指定逻辑网络的信息;
        @note: (2)验证接口返回的状态码、接口信息是否正确。
        '''
        # 测试1:根据网络id获取网络信息
        nw_id = self.nwapi.getNetworkIdByName(self.dm.nw_name, self.dm.dc_name)
        LogPrint().info("Test: Get the network's ('%s') info by id ('%s')." % (self.dm.nw_name, nw_id))
        r = self.nwapi.getNetworkInfo(nw_id=nw_id)
        if r['status_code']==self.dm.expected_status_code:
            dict_actual = r['result']
            dict_expected = xmltodict.parse(self.dm.nw_info)
            dictCompare = DictCompare()
            if dictCompare.isSubsetDict(dict_expected, dict_actual):
                LogPrint().info("PASS: Get Network info SUCCESS by ID." )
                self.flag = True
            else:
                LogPrint().error("FAIL: Get Network info INCORRECT by ID.")
                self.flag = False
        else:
            LogPrint().error("FAIL: Get Network info FAILED. Returned status code '%s' is Wrong." % r['status_code'])
            self.flag = False
        self.assertTrue(self.flag)

    def tearDown(self):
        '''
        @summary: 测试结束后的资源清理(恢复初始环境)
        '''
        LogPrint().info("Post-Test: Delete network '%s'." % self.dm.nw_name)
        self.assertTrue(smart_delete_network(self.dm.nw_name,self.dm.dc_name))    
Exemple #38
0
 def setUp(self):
     self.dm = super(self.__class__, self).setUp()
     self.nwapi = NetworkAPIs()   
     self.assertTrue(smart_delete_network(self.dm.nw_name, self.dm.dc_name))
Exemple #39
0
 def setUp(self):
     self.dm = super(self.__class__, self).setUp()
     self.nwapi = NetworkAPIs()  
     #首先新建一个网络 
     LogPrint().info("Pre-Test-1: Create network %s."%self.dm.nw_name)
     self.assertTrue(smart_create_network(self.dm.nw_info, self.dm.nw_name))
Exemple #40
0
 def setUp(self):
     self.dm = super(self.__class__, self).setUp()
     self.nwapi = NetworkAPIs() 
Exemple #41
0
 def setUp(self):
     self.dm = super(self.__class__, self).setUp()
     self.nwapi = NetworkAPIs()
     #创建一个网络,vlan id=2
     LogPrint().info("Pre-Test: Create network %s.Set its vlan id 2."%self.dm.nw_name1)
     self.assertTrue(smart_create_network(self.dm.nw_info1, self.dm.nw_name1))