Пример #1
0
 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()
Пример #2
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)
Пример #3
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)
Пример #4
0
 def test_GetProfileList(self):
     '''
     @summary: 获取系统配置集列表
     @note: 操作成功,验证返回状态码
     '''
     self.proapi = ProfilesAPIs()
     LogPrint().info("Test: Get profile list.")
     r = self.proapi.getProfilesList()
     if r['status_code'] == 200:
         LogPrint().info('PASS: Get profile list SUCCESS.')
         self.flag = True
     else:
         LogPrint().error('FAIL: Returned status code is WRONG.')
         self.flag = False
     self.assertTrue(self.flag)
Пример #5
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.")
Пример #6
0
 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)
Пример #7
0
    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)
#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
Пример #9
0
 def tearDown(self):
     LogPrint().info("Post-Test-1: Delete template %s." % self.dm.temp_name)
     self.assertTrue(smart_delete_template(self.dm.temp_name))
     LogPrint().info("Post-Test-2: Delete profile %s." %
                     self.dm.profile_name)
     ProfilesAPIs().delProfile(self.dm.profile_name, self.nw_id)