Example #1
0
# 获取vmware模板
get_vmware_templates_url = "/admin/v1/hypersivor/vmware/templates?resourcePoolId="
# 获取openstack模板
get_openstack_templates_url = "/admin/v1/hypersivor/openstack/images?resourcePoolId="
# 获取镜像
get_images_url = "/admin/v1/images/"

# 构造测试数据
testdata_path = Conf.get_testdata_path()
excelFile = testdata_path + os.sep + "镜像管理.xlsx"
# 创建镜像
param_create_images = read_excel_tuple(excelFile, '创建镜像')
# 编辑镜像
param_update_images = read_excel_tuple(excelFile, '编辑镜像')
# 删除镜像
param_delete_images = OperationExcleData(excelFile, "删除镜像").getcase_tuple()
# 添加资源池模板
param_create_template = read_excel_tuple(excelFile, '添加资源池模板')
# 删除资源池模板
param_delete_template = OperationExcleData(excelFile,
                                           "删除资源池模板").getcase_tuple()


# 根据传入的资源池获取镜像模板列表
def get_template_list(uri, headers, resourcepoolType, resourcepool):
    template_list = []
    resourcepool_id = get_resourcepoolid(uri, headers, resourcepool)
    if resourcepoolType == "vmware":
        get_vmware_template_response = requests.get(
            url=uri + get_vmware_templates_url + str(resourcepool_id),
            headers=headers).json()
Example #2
0
import allure
from utils.LogUtil import my_log

# 创建组织url
create_orgnization_url = "/admin/v1/organizations"
# 编辑组织/删除组织url
update_orgnization_url = "/admin/v1/organizations/"
# 创建用户url
create_user_url = "/admin/v1/users"
# 编辑/删除用户url
update_user_url = "/admin/v1/users/"

# 创建组织
testdata_path = Conf.get_testdata_path()
excelFile = testdata_path + os.sep + "组织用户.xlsx"
create_orgnization_param = OperationExcleData(excelFile,
                                              "创建组织").getcase_tuple()
# 编辑组织
update_orgnization_param = OperationExcleData(excelFile,
                                              '编辑组织').getcase_tuple()
# 删除组织
delete_orgnization_param = OperationExcleData(excelFile,
                                              '删除组织').getcase_tuple()
# 创建用户
create_user_param = OperationExcleData(excelFile, "创建用户").getcase_tuple()
# 编辑用户
update_user_param = OperationExcleData(excelFile, "编辑用户").getcase_tuple()
# 添加已有用户
create_exsiting_user_param = OperationExcleData(excelFile,
                                                "添加已有用户").getcase_tuple()
# 移除用户
remove_exsiting_user_param = OperationExcleData(excelFile,
Example #3
0
from common.get_excel_data import OperationExcleData
from common.get_db_data import init_arangodb
import allure
from utils.LogUtil import my_log
from utils.AssertUtil import AssertUtil

#创建、编辑、删除字典url
create_dictionaries_url = "/admin/v1/dictionaries"
update_dictionaries_url = "/admin/v1/dictionaries/"
delete_dictionaries_url = "/admin/v1/dictionaries/"
get_parentDictionaryKey_url = "/admin/v1/dictionaries/tree"

#获取测试数据
testdata_path = Conf.get_testdata_path()
excelFile = testdata_path + os.sep + "配置管理.xlsx"
create_dictionaries_data = OperationExcleData(excelFile,
                                              "创建字典").getcase_tuple()
update_dictionaries_data = OperationExcleData(excelFile,
                                              "编辑字典").getcase_tuple()
delete_dictionarie_date = OperationExcleData(excelFile, "删除字典").getcase_tuple()


def get_dictionarys():
    """
    获取所有的字典
    :return:
    """
    conn = init_arangodb("cmdb_db")
    arangodb = conn.opendb("cmdb")
    aql = "FOR c IN dictionary RETURN c"
    dictionarys = arangodb.AQLQuery(aql)
    return dictionarys
Example #4
0
import os
from config import Conf
import pytest
from common.get_excel_data import OperationExcleData
import requests
from common.get_db_data import init_arangodb
from utils.LogUtil import my_log
from utils.AssertUtil import AssertUtil
import allure

# 配置项类型url
base_category_url = "/admin/v1/categories"
categorys_tree_url = "/admin/v1/categories/tree/?sortField=createTime&sortOrder=desc"
testdata_path = Conf.get_testdata_path()
excelFile = testdata_path + os.sep + "配置管理.xlsx"
category_data = OperationExcleData(excelFile, "创建配置项类型").getcase_tuple()
update_category_data = OperationExcleData(excelFile, "编辑配置项类型").getcase_tuple()
delete_category_data = OperationExcleData(excelFile, "删除配置项类型").getcase_tuple()


@pytest.mark.cmdb
@pytest.mark.run(order=1)
@allure.feature("CMDB")
@allure.story("创建配置项类型")
@pytest.mark.parametrize(
    "ID, testcases, name, code, sourceCategoryCode, parentCategoryKey, icon, status_code, expected_result",
    category_data)
def test_create_category(uri, headers, ID, testcases, name, code,
                         sourceCategoryCode, parentCategoryKey, icon,
                         status_code, expected_result):
    """
from common.get_excel_data import OperationExcleData
import requests
from test_case.cmdb.test_category import get_category_code
from test_case.cmdb.test_group import get_group
from test_case.cmdb.test_property import get_property
from common.get_db_data import init_arangodb
import allure
from utils.LogUtil import my_log
from utils.AssertUtil import AssertUtil

# 配置项url
base_configitems_url = "/admin/v1/config_items"
testdata_path = Conf.get_testdata_path()
excelFile = testdata_path + os.sep + "配置管理.xlsx"
importFile = testdata_path + os.sep + "云主机.xlsx"
configitem_data = OperationExcleData(excelFile, "创建配置项").getcase_tuple()
update_configitem_data = OperationExcleData(excelFile, "编辑配置项").getcase_tuple()
import_configitem_data = OperationExcleData(excelFile,
                                            "导入导出配置项").getcase_tuple()
delete_configitem_data = OperationExcleData(excelFile, "删除配置项").getcase_tuple()


@pytest.mark.cmdb
@pytest.mark.run(order=3)
@allure.feature("CMDB")
@allure.story("创建配置项")
@pytest.mark.parametrize(
    "ID, testcases,category,groupname,propertyname,propertycode,propertvalue,status_code,expected_result",
    configitem_data)
def test_create_configitems(uri, headers, ID, testcases, category, groupname,
                            propertyname, propertycode, propertvalue,
Example #6
0
import time
import allure
from utils.LogUtil import my_log


# 创建监控组url
create_monitorgroup_url = "/admin/v1/groups"
# 编辑/删除监控组url
update_monitorgroup_url = "/admin/v1/groups/"
# 获取资源url
get_resource_url = "/admin/v1/config_items/ip_props/page?pageSize=1000000000"

testdata_path = Conf.get_testdata_path()
excelFile = testdata_path + os.sep + "监控告警.xlsx"
# 创建监控组
create_monitorgroup_param = OperationExcleData(excelFile, "创建监控组").getcase_tuple()
# 编辑监控组
update_monitorgroup_param = OperationExcleData(excelFile, '编辑监控组').getcase_tuple()
# 删除监控组
delete_monitorgroup_param = OperationExcleData(excelFile, '删除监控组').getcase_tuple()


# 获取监控组列表
def get_monitorgroup_list(uri, headers):
    monitorgroup_list_response = requests.get(
        url=uri + create_monitorgroup_url,
        headers=headers
    ).json()
    monitorgroup_list = monitorgroup_list_response['data']["list"]
    return monitorgroup_list
import requests
import json
import os
from config import Conf
from common.get_excel_data import OperationExcleData
from utils.AssertUtil import AssertUtil
import allure
from utils.LogUtil import my_log

# 创建数据中心请求url
createDataCenter_url = "/admin/v1/regions"

# 获取创建数据中心请求参数数据
testdata_path = Conf.get_testdata_path()
excelFile = testdata_path + os.sep + "物理资源.xlsx"
datacenter_data = OperationExcleData(excelFile, "添加数据中心").getCaseList()
update_datacenter_data = OperationExcleData(excelFile,
                                            "编辑数据中心").getcase_tuple()
delete_datacenter_data = OperationExcleData(excelFile,
                                            "删除数据中心").getcase_tuple()


@pytest.mark.smoke
@pytest.mark.run(order=1)
@allure.feature("计算资源")
@allure.story("创建数据中心")
@pytest.mark.parametrize("datacenter_data", datacenter_data)
def test_create_datacenter(uri, headers, datacenter_data):
    """
    创建数据中心接口
    :param ip:
Example #8
0
from test_case.network_resource.test_network import get_network_id, get_subnet_id, get_subnetip_id,get_object_id
import time
import allure
from utils.LogUtil import my_log
from utils.AssertUtil import AssertUtil

# 创建虚拟机请求url
create_instance_url = "/admin/v1/instances"
# 获取资源池集群url
get_cluster_url = "/admin/v1/hypersivor/vmware/clusters/?resourcePoolId="

# 获取创建实例请求参数数据
testdata_path = Conf.get_testdata_path()
excelFile = testdata_path + os.sep + "物理资源.xlsx"
sheetName = "创建虚拟机"
instance_data = OperationExcleData(excelFile, sheetName).getcase_tuple()

@pytest.mark.smoke
@pytest.mark.run(order=12)
@pytest.mark.parametrize("resourcepooltype,region,resourcepool,tenant,project,vmname,account,image, ostype,cluster,host,cpu,memory,osdisk,disktype,net,subnet,nettype,ipaddress,status_code,expected_result,expected_db", instance_data)
@allure.feature("虚拟机")
@allure.story("创建虚拟机")
def test_create_vm(uri, headers, resourcepooltype,region,resourcepool, tenant, project, vmname,
            account,image, ostype,cluster,host,cpu,memory,osdisk,disktype,net,subnet,nettype,ipaddress,status_code,expected_result,expected_db):
            resourcePoolId = get_resourcepoolid(uri, headers, resourcepool)
            tenantId = get_tenant_id(uri, headers, tenant)
            projectId = get_project_id(uri, headers, project)
            netId = get_network_id(uri, headers, net)
            subnetId = get_subnet_id(uri, headers, net, subnet)
            imageId = get_image_id(uri, headers,image)
            subnetipId = get_subnetip_id(uri, headers, net, subnet, ipaddress)
Example #9
0
# @Author  : zhuxuefei
import os
from config import Conf
import pytest
from common.get_excel_data import OperationExcleData
import requests
from test_case.cmdb.test_category import get_categorykey
from common.get_db_data import init_arangodb
import allure
from utils.LogUtil import my_log
from utils.AssertUtil import AssertUtil

base_category_url = "/admin/v1/categories"
testdata_path = Conf.get_testdata_path()
excelFile = testdata_path + os.sep + "配置管理.xlsx"
add_property_data = OperationExcleData(excelFile, "修改类型属性").getcase_tuple()


def get_property(propertyCode, propertyName):
    """
    根据属性名称和code获取属性记录
    :param propertyCode:
    :param propertyName:
    :return:
    """
    conn = init_arangodb("cmdb_db")
    arangodb = conn.opendb("cmdb")
    aql = "FOR c IN property RETURN c"
    queryresult = arangodb.AQLQuery(aql)
    for property in queryresult:
        if property.name == propertyName and property.code == propertyCode:
Example #10
0
from utils.LogUtil import my_log


get_user_url = "/admin/v1/users"
create_tenant_url="/admin/v1/vdcs/"
update_tenant_url="/admin/v1/vdcs/"
delete_tenant_url="/admin/v1/vdcs/"
manage_tenant_url="/admin/v1/vdcs/"
create_project_url="/admin/v1/projects"
update_project_url="/admin/v1/projects/"
delete_project_url="/admin/v1/projects/"

testdata_path = Conf.get_testdata_path()
excelFile = testdata_path + os.sep + "业务管理.xlsx"

create_tenant_data=OperationExcleData(excelFile,"创建租户").getCaseList()
update_tenant_data=OperationExcleData(excelFile,"编辑租户").getcase_tuple()
manage_user_data=OperationExcleData(excelFile,"成员管理").getcase_tuple()
create_project_data = read_excel_tuple(excelFile, '创建项目')
update_project_data=OperationExcleData(excelFile, '编辑项目').getcase_tuple()
delete_project_data=OperationExcleData(excelFile, '删除项目').getcase_tuple()
delete_tenant_data=OperationExcleData(excelFile, '删除租户').getcase_tuple()

# 创建租户
@pytest.mark.smoke
@pytest.mark.run(order=9)
@pytest.mark.parametrize("create_tenant_data",create_tenant_data)
@allure.feature("业务管理")
@allure.story("创建租户")
def test_create_tenant(uri, headers, create_tenant_data):
    createTenant_response = requests.post(url=uri + create_tenant_url,
from utils.LogUtil import my_log

#从Excel获取虚拟机信息
testdata_path = Conf.get_testdata_path()
excelFile =testdata_path + os.sep + "物理资源.xlsx"
sheetName = "操作虚拟机"
disk_sheetName = "编辑虚拟机磁盘"
network_sheetName = "添加虚拟机网卡"
deleteNic_sheetName = "删除虚拟机网卡"
configCpuAndMemory_sheetName = "编辑虚拟机配置"
clone_sheetName = "克隆虚拟机"
rebuildOs_sheetName = "重装虚拟机操作系统"
migrate_sheetName = "迁移虚拟机"
snapshot_sheetName = "创建快照"

instance_data = OperationExcleData(excelFile, sheetName).getcase_tuple()
instance_disk_data = OperationExcleData(excelFile, disk_sheetName).getcase_tuple()
instance_network_data = OperationExcleData(excelFile, network_sheetName).getcase_tuple()
instance_deleteNic_data = OperationExcleData(excelFile,deleteNic_sheetName).getcase_tuple()
instance_configCpuAndMemory_data = OperationExcleData(excelFile, configCpuAndMemory_sheetName).getcase_tuple()
instance_clone_data = OperationExcleData(excelFile, clone_sheetName).getcase_tuple()
instance_rebuildOs_data = OperationExcleData(excelFile, rebuildOs_sheetName).getcase_tuple()
instance_migrate_data = OperationExcleData(excelFile, migrate_sheetName).getcase_tuple()
instance_snapshot_data = OperationExcleData(excelFile, snapshot_sheetName).getcase_tuple()

# 创建虚拟机请求url
create_instance_url = "/admin/v1/instances"

#虚拟机关机
@pytest.mark.smoke
@pytest.mark.run(order=13)
Example #12
0
import pytest
from common.get_excel_data import OperationExcleData
import requests
from test_case.cmdb.test_category import get_categorykey
from test_case.cmdb.test_dictionary import get_dictionary
from test_case.cmdb.test_configitems import get_configitem_key
import allure
from utils.LogUtil import my_log
from utils.AssertUtil import AssertUtil


category_relationship_url = "/admin/v1/relationships/category_to_category"
configitem_relationship_url = "admin/v1/relationships/config_item_to_config_item"
testdata_path = Conf.get_testdata_path()
excelFile = testdata_path + os.sep + "配置管理.xlsx"
category_relationship_data = OperationExcleData(excelFile, "配置类型关系").getcase_tuple()
configitem_relationship_data = OperationExcleData(excelFile, "配置项关系").getcase_tuple()

@pytest.mark.cmdb
@pytest.mark.run(order=4)
@allure.feature("CMDB")
@allure.story("创建配置类型间关系")
@pytest.mark.parametrize("ID, testcases, categoryfrom, relationship, categoryto, status_code, expected_result", category_relationship_data)
def test_category_relationship(uri, headers, ID, testcases, categoryfrom, relationship, categoryto,status_code, expected_result):
    """
    创建配置类型间关系
    :param uri:
    :param headers:
    :param ID:
    :param testcases:
    :param categoryfrom:源配置项类型
from config import Conf
from common.get_excel_data import OperationExcleData
from common.get_db_data import assert_mysqldb
from common.get_db_data import init_mysqldb
from test_case.cmp_compute.test_datacenter import get_datacenterid
import allure
from utils.LogUtil import my_log
from utils.AssertUtil import AssertUtil

# 添加资源池请求url
createResourcePool_url = "/admin/v1/resourcepools"

testdata_path = Conf.get_testdata_path()
excelFile = testdata_path + os.sep + "物理资源.xlsx"
sheetName = "添加资源池"
resourcepool_data = OperationExcleData(excelFile, sheetName).getcase_tuple()


@pytest.mark.smoke
@pytest.mark.run(order=2)
@pytest.mark.parametrize(
    "ID,testcases,regionname,name,type,descrption,rpip,rpport,proxyIp,proxyPort,username,password,datacenter,domain,projectId,protocol,region,version,status_code,expected_result,expected_db",
    resourcepool_data)
@allure.feature("计算资源")
@allure.story("添加资源池")
def test_createResourcePool(uri, headers, ID, testcases, regionname, name,
                            type, descrption, rpip, rpport, proxyIp, proxyPort,
                            username, password, datacenter, domain, projectId,
                            protocol, region, version, status_code,
                            expected_result, expected_db):
    """