aboutsummaryrefslogtreecommitdiffstats
path: root/hdv/redfish
diff options
context:
space:
mode:
Diffstat (limited to 'hdv/redfish')
-rw-r--r--hdv/redfish/conf/cases.xlsxbin17263 -> 0 bytes
-rw-r--r--hdv/redfish/conf/cases.yaml329
-rw-r--r--hdv/redfish/conf/config.yaml11
-rw-r--r--hdv/redfish/conf/depends.yaml33
-rw-r--r--hdv/redfish/excel_2_yaml.py62
-rw-r--r--hdv/redfish/hdv.py14
-rw-r--r--hdv/redfish/hdv_redfish.py141
7 files changed, 248 insertions, 342 deletions
diff --git a/hdv/redfish/conf/cases.xlsx b/hdv/redfish/conf/cases.xlsx
deleted file mode 100644
index e7fc61d..0000000
--- a/hdv/redfish/conf/cases.xlsx
+++ /dev/null
Binary files differ
diff --git a/hdv/redfish/conf/cases.yaml b/hdv/redfish/conf/cases.yaml
index 5d92689..3a64ebc 100644
--- a/hdv/redfish/conf/cases.yaml
+++ b/hdv/redfish/conf/cases.yaml
@@ -1,186 +1,281 @@
---
- case_name: get asset code
case_sn: 1
+ enabled: false
expected_code: 200
- expected_result: '{"AssetTag": "CM_cc@1234"}'
+ expected_result:
+ AssetTag: CM_cc@1234
group: asset managment
header: null
method: GET
request_body: null
url: /redfish/v1/Systems/{system_id}
- key_flag_dict: {"system_id": "Members"}
+ key_flag_dict:
+ system_id: Members
+
- case_name: check main board name
case_sn: 8
+ enabled: true
expected_code: 200
- expected_result: '{"Oem":{"Mainboard": {"BoardName": "RS33M2C9S"}}}'
+ expected_result:
+ Oem:
+ Mainboard:
+ BoardName: RS33M2C9S
group: asset managment
header: null
method: GET
request_body: null
url: /redfish/v1/Chassis/{chassis_id}
- key_flag_dict: {"chassis_id": "Members"}
+ key_flag_dict:
+ chassis_id: Members
+
- case_name: check CPU amount
case_sn: 11
+ enabled: true
expected_code: 200
- expected_result: '{"Members@odata.count": 2}'
+ expected_result:
+ Members@odata.count: 2
group: compoment management
header: null
method: GET
request_body: null
url: /redfish/v1/Systems/{system_id}/Processors
- key_flag_dict: {"system_id": "Members"}
+ key_flag_dict:
+ system_id: Members
+
- case_name: check CPU info
case_sn: 2
+ enabled: true
expected_code: 200
- expected_result: '{ "count": 2, "Manufacturer": "Intel(R) Corporation", "MaxSpeedMHz":
- 2300, "Model": "Intel(R) Xeon(R) Gold 5218N CPU @ 2.30GHz", "ProcessorArchitecture":
- ["x86", "IA-64", "ARM", "MIPS", "OEM"], "Socket": [1, 2], "Status": { "Health":
- "OK", "State": "Enabled" }, "TotalCores": 16, "TotalThreads":
- 32}'
+ expected_result:
+ count: 2
+ Manufacturer: "Intel(R) Corporation"
+ MaxSpeedMHz: 2300
+ Model: "Intel(R) Xeon(R) Gold 5218N CPU @ 2.30GHz"
+ ProcessorArchitecture: ["x86", "IA-64", "ARM", "MIPS", "OEM"]
+ Socket: [1, 2]
+ Status:
+ Health: OK
+ State: Enabled
+ TotalCores: 16
+ TotalThreads: 32
group: compoment management
header: null
method: GET
request_body: null
url: /redfish/v1/Systems/{system_id}/Processors/{cpu_id}
- key_flag_dict: {"system_id": "Members", "cpu_id": "Members"}
+ key_flag_dict:
+ system_id: Members
+ cpu_id: Members
+
- case_name: set asset code
case_sn: 1
+ enabled: true
expected_code: 200
- expected_result: '{"AssetTag": "CM_cc@1234"}'
+ expected_result:
+ AssetTag: CM_cc@1234
group: asset managment
header: null
method: PATCH
request_body: '{"AssetTag": "CM_cc@1234"}'
url: /redfish/v1/Systems/{system_id}
- key_flag_dict: {"system_id": "Members"}
+ key_flag_dict:
+ system_id: Members
+
- case_name: set host name
case_sn: 3
+ enabled: true
expected_code: 200
- expected_result: '{"HostName": "NFV-RPZJHZ-01B"}'
+ expected_result:
+ HostName: NFV-RPZJHZ-01B
group: asset managment
header: null
method: PATCH
request_body: '{"HostName": "NFV-RPZJHZ-01B"}'
url: /redfish/v1/Systems/{system_id}
- key_flag_dict: {"system_id": "Members"}
+ key_flag_dict:
+ system_id: Members
+
- case_name: check host name
case_sn: 4
+ enabled: true
expected_code: 200
- expected_result: '{"HostName": "NFV-RPZJHZ-01B"}'
+ expected_result:
+ HostName: NFV-RPZJHZ-01B
group: asset managment
header: null
method: GET
request_body: null
url: /redfish/v1/Systems/{system_id}
- key_flag_dict: {"system_id": "Members"}
+ key_flag_dict:
+ system_id: Members
+
- case_name: check manufacturer
case_sn: 5
+ enabled: true
expected_code: 200
- expected_result: '{"Manufacturer": "New H3C Technologies Co., Ltd."}'
+ expected_result:
+ Manufacturer: "New H3C Technologies Co., Ltd."
group: asset managment
header: null
method: GET
request_body: null
url: /redfish/v1/Systems/{system_id}
- key_flag_dict: {"system_id": "Members"}
+ key_flag_dict:
+ system_id: Members
+
- case_name: check model
case_sn: 6
+ enabled: true
expected_code: 200
- expected_result: '{"Model": "UniServer R4900 G3"}'
+ expected_result:
+ Model: "UniServer R4900 G3"
group: asset managment
header: null
method: GET
request_body: null
url: /redfish/v1/Systems/{system_id}
- key_flag_dict: {"system_id": "Members"}
+ key_flag_dict:
+ system_id: Members
+
- case_name: check serial number
case_sn: 7
+ enabled: true
expected_code: 200
- expected_result: '{"SerialNumber": "N/A"}'
+ expected_result:
+ SerialNumber: N/A
group: asset managment
header: null
method: GET
request_body: null
url: /redfish/v1/Systems/{system_id}
- key_flag_dict: {"system_id": "Members"}
+ key_flag_dict:
+ system_id: Members
+
- case_name: check main board name
case_sn: 8
+ enabled: true
expected_code: 200
- expected_result: '{"Oem":{"Mainboard": {"BoardName": "RS33M2C9S"}}}'
+ expected_result:
+ Oem:
+ Mainboard:
+ BoardName: RS33M2C9S
group: asset managment
header: null
method: GET
request_body: null
url: /redfish/v1/Chassis/{chassis_id}
- key_flag_dict: {"chassis_id": "Members"}
+ key_flag_dict:
+ chassis_id: Members
+
- case_name: check main board serial number
case_sn: 9
+ enabled: true
expected_code: 200
- expected_result: '{"Oem": {"Mainboard": {"SerialNumber": "N/A"}}}'
+ expected_result:
+ Oem:
+ Mainboard:
+ SerialNumber: N/A
group: asset managment
header: null
method: GET
request_body: null
url: /redfish/v1/Chassis/{chassis_id}
- key_flag_dict: {"chassis_id": "Members"}
+ key_flag_dict:
+ chassis_id: Members
+
- case_name: check BIOS version
case_sn: 10
+ enabled: true
expected_code: 200
- expected_result: '{"BiosVersion": "2.00.35P01 V100R001B02D035SP01"}'
+ expected_result:
+ BiosVersion: "2.00.35P01 V100R001B02D035SP01"
group: asset managment
header: null
method: GET
request_body: null
url: /redfish/v1/Systems/{system_id}
- key_flag_dict: {"system_id": "Members"}
+ key_flag_dict:
+ system_id: Members
+
- case_name: check CPU amount
case_sn: 11
+ enabled: true
expected_code: 200
- expected_result: '{"Members@odata.count": 2}'
+ expected_result:
+ Members@odata.count: 2
group: compoment management
header: null
method: GET
request_body: null
url: /redfish/v1/Systems/{system_id}/Processors
- key_flag_dict: {"system_id": "Members"}
+ key_flag_dict:
+ system_id: Member
+
- case_name: check CPU info
case_sn: 12
+ enabled: true
expected_code: 200
- expected_result: '{ "count": 2, "Manufacturer": "Intel(R) Corporation", "MaxSpeedMHz":
- 2300, "Model": "Intel(R) Xeon(R) Gold 5218N CPU @ 2.30GHz", "ProcessorArchitecture":
- ["x86", "IA-64", "ARM", "MIPS", "OEM"], "Socket": [1, 2], "Status": { "Health":
- "OK", "State": "Enabled" }, "TotalCores": 16, "TotalThreads":
- 32}'
+ expected_result:
+ count: 2
+ Manufacturer: Intel(R) Corporation
+ MaxSpeedMHz: 2300
+ Model: "Intel(R) Xeon(R) Gold 5218N CPU @ 2.30GHz"
+ ProcessorArchitecture: ["x86", "IA-64", "ARM", "MIPS", "OEM"]
+ Socket: [1, 2]
+ Status:
+ Health: OK
+ State: Enabled
+ TotalCores: 16
+ TotalThreads: 32
group: compoment management
header: null
method: GET
request_body: null
url: /redfish/v1/Systems/{system_id}/Processors/{cpu_id}
- key_flag_dict: {"system_id": "Members","cpu_id": "Members"}
+ key_flag_dict:
+ system_id: Members
+ cpu_id: Members
+
- case_name: check memory mount
case_sn: 13
+ enabled: true
expected_code: 200
- expected_result: '{"Members@odata.count": 12}'
+ expected_result:
+ Members@odata.count: 12
group: compoment management
header: null
method: GET
request_body: null
url: /redfish/v1/Systems/{system_id}/Memory
- key_flag_dict: {"system_id": "Members"}
+ key_flag_dict:
+ system_id: Members
+
- case_name: check memory information
case_sn: 14
+ enabled: true
expected_code: 200
- expected_result: '{ "count": 12, "BaseModuleType": "RDIMM", "CapacityMiB":
- 32768, "DeviceLocator": "N/A", "Manufacturer": ["Hynix Semiconductor", "Micron"], "MemoryDeviceType":
- "DDR4", "OperatingSpeedMhz": 2666, "PartNumber": ["HMA84GR7AFR4N-VK","36ASF4G72PZ-2G6D1"], "Status":
- { "Health": "OK", "State": "Enabled" }}'
+ expected_result:
+ count: 12
+ BaseModuleType: RDIMM
+ CapacityMiB: 32768
+ DeviceLocator: N/A
+ Manufacturer: ["Hynix Semiconductor", "Micron"]
+ MemoryDeviceType: DDR4
+ OperatingSpeedMhz: 2666
+ PartNumber: ["HMA84GR7AFR4N-VK", "36ASF4G72PZ-2G6D1"]
+ Status:
+ Health: OK
+ State: Enabled
group: compoment management
header: null
method: GET
request_body: null
url: /redfish/v1/Systems/{system_id}/Memory/{memory_id}
- key_flag_dict: {"system_id" : "Members", "memory_id" : "Members"}
-
+ key_flag_dict:
+ System_id: Members
+ memory_id: Members
+
# - case_name: check raid card amount
# case_sn: 15
# expected_code: 200
@@ -236,42 +331,78 @@
# method: GET
# request_body: null
# url: https://{bmc_ip}{networkports_id}
-# - case_name: check fans information
-# case_sn: 20
-# expected_code: 200
-# expected_result: '{ "FanSummary": { "Count": 6 }, "Fans": [ { "MemberId":
-# "N/A", "Oem": { "Public": { "SpeedRatio":
-# "N/A" } }, "Status": { "Health":
-# "OK", "State": "Enabled" } }, { "MemberId":
-# "N/A", "Oem": { "Public": { "SpeedRatio":
-# "N/A" } }, "Status": { "Health":
-# "OK", "State": "Enabled" } },{ "MemberId":
-# "N/A", "Oem": { "Public": { "SpeedRatio":
-# "N/A" } }, "Status": { "Health":
-# "OK", "State": "Enabled" } },{ "MemberId":
-# "N/A", "Oem": { "Public": { "SpeedRatio":
-# "N/A" } }, "Status": { "Health":
-# "OK", "State": "Enabled" } },{ "MemberId":
-# "N/A", "Oem": { "Public": { "SpeedRatio":
-# "N/A" } }, "Status": { "Health":
-# "OK", "State": "Enabled" } },{ "MemberId":
-# "N/A", "Oem": { "Public": { "SpeedRatio":
-# "N/A" } }, "Status": { "Health":
-# "OK", "State": "Enabled" } } ],}'
-# group: compoment management
-# header: null
-# method: GET
-# request_body: null
-# url: https://{bmc_ip}/redfish/v1/Chassis/{chassis_id}/Thermal
-# - case_name: check power amount
-# case_sn: 21
-# expected_code: 200
-# expected_result: '{ "DeviceMaxNum": { "PowerSupplyNum": 2},}'
-# group: compoment management
-# header: null
-# method: GET
-# request_body: null
-# url: https://{bmc_ip}/redfish/v1/Chassis/{chassis_id}
+- case_name: check fans information
+ case_sn: 20
+ enabled: true
+ expected_code: 200
+ expected_result:
+ FanSummary:
+ Count: 6
+ Fans:
+ - MemberId: N/A
+ Oem:
+ Public:
+ SpeedRatio: N/A
+ Status:
+ Health: OK
+ State: Enabled
+ - MemberId: N/A
+ Oem:
+ Public:
+ SpeedRatio: N/A
+ Status:
+ Health: OK
+ State: Enabled
+ - MemberId: N/A
+ Oem:
+ Public:
+ SpeedRatio: N/A
+ Status:
+ Health: OK
+ State: Enabled
+ - MemberId: N/A
+ Oem:
+ Public:
+ SpeedRatio: N/A
+ Status:
+ Health: OK
+ State: Enabled
+ - MemberId: N/A
+ Oem:
+ Public:
+ SpeedRatio: N/A
+ Status:
+ Health: OK
+ State: Enabled
+ - MemberId: N/A
+ Oem:
+ Public:
+ SpeedRatio: N/A
+ Status:
+ Health: OK
+ State: Enabled
+ group: compoment management
+ header: null
+ method: GET
+ request_body: null
+ url: /redfish/v1/Chassis/{chassis_id}/Thermal
+ key_flag_dict:
+ chassis_id: Members
+
+- case_name: check power amount
+ case_sn: 21
+ enabled: true
+ expected_code: 200
+ expected_result:
+ DeviceMaxNum:
+ PowerSupplyNum: 2
+ group: compoment management
+ header: null
+ method: GET
+ request_body: null
+ url: /redfish/v1/Chassis/{chassis_id}
+ key_flag_dict:
+ chassis_id: MemberId
# - case_name: check power detail info
# case_sn: 22
# expected_code: 200
@@ -306,19 +437,27 @@
# method: GET
# request_body: null
# url: https://{bmc_ip}/redfish/v1/Chassis/{chassis_id}/Thermal
-# - case_name: check cpu temperature
-# case_sn: 25
-# expected_code: 200
-# expected_result: '{ "Temperatures": [ { "Name": "INPUT_TEMP", "ReadingCelsius":
-# "N/A", }, { "Name": "CPU1_TEMP", "ReadingCelsius":
-# "N/A", }, { "Name": "CPU2_TEMP", "ReadingCelsius":
-# "N/A", }, ]}'
-# group: sensor management
-# header: null
-# method: GET
-# request_body: null
-# url: https://{bmc_ip}/redfish/v1/Chassis/{chassis_id}/Thermal
-# - case_name: check server power state
+- case_name: check cpu temperature
+ case_sn: 25
+ enabled: true
+ expected_code: 200
+ expected_result:
+ Temperatures:
+ - Name: INPUT_TEMP
+ ReadingCelsius: N/A
+ - Name: CPU1_TEMP
+ ReadingCelsius: N/A
+ - Name: CPU2_TEMP
+ ReadingCelsius: N/A
+ group: sensor management
+ header: null
+ method: GET
+ request_body: null
+ url: /redfish/v1/Chassis/{chassis_id}/Thermal
+ key_flag_dict:
+ chassis_id: Member
+
+#- case_name: check server power state
# case_sn: 26
# expected_code: 200
# expected_result: '{"PowerState": "On"}'
diff --git a/hdv/redfish/conf/config.yaml b/hdv/redfish/conf/config.yaml
index 4f71234..4ed6876 100644
--- a/hdv/redfish/conf/config.yaml
+++ b/hdv/redfish/conf/config.yaml
@@ -2,14 +2,3 @@
bmc_ip: https://172.29.160.22
bmc_user: root
bmc_pwd: Huawei12#$
-attr_name: 3
-pro_seq: 4
-url_seq: 5
-req_header_seq: 6
-req_body_seq: 7
-expect_return_code_seq: 8
-expect_return_value_seq: 9
-return_code_seq: 10
-return_value_seq: 11
-detail_result: 12
-final_result: 13
diff --git a/hdv/redfish/conf/depends.yaml b/hdv/redfish/conf/depends.yaml
deleted file mode 100644
index eecdcd4..0000000
--- a/hdv/redfish/conf/depends.yaml
+++ /dev/null
@@ -1,33 +0,0 @@
----
-- component_id: cpu_id
- key_flags: Members
- pro_value: GET
- url_value: https://{bmc_ip}/redfish/v1/Systems/{system_id}/Processors
-- component_id: memory_id
- key_flags: Members
- pro_value: GET
- url_value: https://{bmc_ip}/redfish/v1/Systems/{system_id}/Memory
-- component_id: storage_id
- key_flags: Members
- pro_value: GET
- url_value: https://{bmc_ip}/redfish/v1/Systems/{system_id}/Storages
-- component_id: drives_id
- key_flags: Drives
- pro_value: GET
- url_value: https://{bmc_ip}{storage_id}
-- component_id: networkadapters_id
- key_flags: Members
- pro_value: GET
- url_value: https://{bmc_ip}/redfish/v1/Chassis/{chassis_id}/NetworkAdapters
-- component_id: networkports_id
- key_flags: Controllers:Link:NetworkPorts
- pro_value: GET
- url_value: https://{bmc_ip}{networkadapters_id}
-- component_id: volume_id
- key_flags: Members
- pro_value: GET
- url_value: https://{bmc_ip}{storage_id}/Volumes
-- component_id: manager_id
- key_flags: Members
- pro_value: GET
- url_value: https://{bmc_ip}/redfish/v1/Managers
diff --git a/hdv/redfish/excel_2_yaml.py b/hdv/redfish/excel_2_yaml.py
deleted file mode 100644
index 948ead3..0000000
--- a/hdv/redfish/excel_2_yaml.py
+++ /dev/null
@@ -1,62 +0,0 @@
-##############################################################################
-# Copyright (c) 2020 China Mobile Co.,Ltd and others.
-#
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# which accompanies this distribution, and is available at
-# http://www.apache.org/licenses/LICENSE-2.0
-##############################################################################
-'''
-excel 2 yaml tools
-convert excel config to yaml format config: depends.yaml and cases.yaml.
-'''
-import os
-import yaml
-from openpyxl.reader.excel import load_workbook
-# pylint: disable=E0611
-from log_utils import LOGGER
-
-
-def load_sheet(excel_file, sheet_index, start_col, end_col):
- '''
- load sheet
- '''
- if not os.path.exists(excel_file):
- LOGGER.error("excel file not existing")
- return None
- input_file = load_workbook(excel_file)
- input_ws = input_file[input_file.sheetnames[sheet_index]]
- cell_key = []
- rows_list = []
- for i in range(start_col, end_col):
- cell_key.append(input_ws.cell(row=1, column=i).value)
- row = 2
- while input_ws.cell(row=row, column=1).value:
- cell_value = []
- for i in range(start_col, end_col):
- value = input_ws.cell(row=row, column=i).value
- if isinstance(value, str):
- value = value.strip().replace('\n', '')
- cell_value.append(value)
- cell_dict = dict(zip(cell_key, cell_value))
- row += 1
- rows_list.append(cell_dict)
-
- LOGGER.info(rows_list)
- return rows_list
-
-
-def create_yaml(id_dict, yaml_file):
- '''
- create yaml
- '''
- with open(yaml_file, 'w') as y_file:
- yaml.dump(id_dict, y_file, explicit_start=True)
-
-
-DEPEND_FILE_NAME = "./conf/depends.yaml"
-LOGGER.info("create %s ", DEPEND_FILE_NAME)
-create_yaml(load_sheet("./conf/cases.xlsx", 1, 1, 5), DEPEND_FILE_NAME)
-
-CASE_FILE_NAME = "./conf/cases.yaml"
-create_yaml(load_sheet("./conf/cases.xlsx", 0, 1, 10), CASE_FILE_NAME)
diff --git a/hdv/redfish/hdv.py b/hdv/redfish/hdv.py
index e06286e..ac5b035 100644
--- a/hdv/redfish/hdv.py
+++ b/hdv/redfish/hdv.py
@@ -34,15 +34,8 @@ def parse_args():
version='%(prog)s 0.1', help="show tool version")
parser.add_argument('--config', type=str, default="./conf/config.yaml",
help="given global config.yaml file")
- parser.add_argument('--file_type', type=str, default="excel",
- help="config file type, [yaml|excel],default is excel")
- parser.add_argument('--case_yaml', type=str, default="./conf/cases.yaml",
- help="case yaml file, uesd if file_type = yaml")
- parser.add_argument('--depends_yaml', type=str,
- default="./conf/depends.yaml",
- help="depends yaml file,uesd if file_type = yaml")
- parser.add_argument('--case_excel', type=str, default="./conf/cases.xlsx",
- help="excel case file used if file_type = excel")
+ parser.add_argument('--case', type=str, default="./conf/cases.yaml",
+ help="case yaml file")
args = parser.parse_args()
return args
@@ -52,8 +45,7 @@ def main():
main function
'''
args = parse_args()
- run_case(args.config, args.case_excel, args.depends_yaml, args.case_yaml,
- args.file_type)
+ run_case(args.config, args.case)
if __name__ == "__main__":
diff --git a/hdv/redfish/hdv_redfish.py b/hdv/redfish/hdv_redfish.py
index db819da..b965f9f 100644
--- a/hdv/redfish/hdv_redfish.py
+++ b/hdv/redfish/hdv_redfish.py
@@ -167,31 +167,6 @@ def get_component_ids_yaml(file):
return None
return yaml.load(open(file, "r"))
-
-def get_component_ids_excel(excel_file):
- '''
- get the component_id settings from the excel sheet2
- the componnet_id is the parent id of the hardware resource of sheet1
- '''
- input_file = load_workbook(excel_file)
- input_ws = input_file[input_file.sheetnames[1]]
- cell_key = []
- id_info_list = []
- for i in range(1, 5):
- cell_key.append(input_ws.cell(row=1, column=i).value)
- row = 2
- while input_ws.cell(row=row, column=1).value:
- cell_value = []
- for i in range(1, 5):
-
- cell_value.append(input_ws.cell(row=row, column=i).value.
- encode("utf8").decode("utf8").replace('\n', ''))
- cell_dict = dict(zip(cell_key, cell_value))
- row += 1
- id_info_list.append(cell_dict)
- return id_info_list
-
-
def create_real_url(url_value, id_dict, config_file, key_flag_dict, http_handler, bmc_ip):
'''
create the real url
@@ -223,6 +198,7 @@ def create_real_url(url_value, id_dict, config_file, key_flag_dict, http_handler
url_list[index] = url_list[index] + parent_url
response_list = handle_depend_url("GET", url_list, http_handler, bmc_ip)
+
url_list = create_obj_id_list(key_flag_dict[value['var']], response_list)
if url_list is None or url_list.__len__() == 0:
@@ -322,32 +298,6 @@ def create_obj_id_list(key_flags, response_list):
LOGGER.error("%s %s", ERROR_CODE['E400003'], key_flags)
return end_id_list
-def read_row(input_ws, row, config_file):
- '''
- read a row value
- '''
- pro_value = input_ws.cell(row=row, column=config_file["pro_seq"]).value
- url_value = input_ws.cell(row=row, column=config_file["url_seq"]).value
- req_body_value = input_ws.cell(
- row=row, column=config_file["req_body_seq"]).value
- expect_return_code = \
- input_ws.cell(
- row=row, column=config_file["expect_return_code_seq"]).value
- expect_return_value = \
- input_ws.cell(
- row=row, column=config_file["expect_return_value_seq"]).value
- attr_name = input_ws.cell(row=row, column=config_file["attr_name"]).value
-
- if req_body_value is not None:
- req_body_value = literal_eval(req_body_value)
- if expect_return_code is not None:
- expect_return_code = int(expect_return_code)
- if expect_return_value is not None:
- expect_return_value = literal_eval(expect_return_value)
- return pro_value, url_value, req_body_value, expect_return_code,\
- expect_return_value, attr_name
-
-
def execute_post_url(body, handler, url):
'''
execute post url
@@ -484,25 +434,6 @@ def parse_test_result(expect_return_value, expect_return_code,
return return_value_list, return_code_list, final_result, flag
-def write_result_2_excel(config_file, input_ws, row, flag, result):
- '''
- write the result back to excel
- '''
- if not result:
- input_ws.cell(row=row, column=config_file["detail_result"],
- value=str('N/A'))
- else:
- input_ws.cell(row=row, column=config_file["detail_result"],
- value=str(result))
- if flag == 0:
- input_ws.cell(row=row, column=config_file["final_result"],
- value=str("Success"))
- else:
- input_ws.cell(row=row, column=config_file["final_result"],
- value=str("Failure"))
- return row
-
-
def execute_final_url(config_file, depends_id, http_handler,
method, url, req_body, key_flag_dict, bmc_ip):
'''
@@ -520,11 +451,14 @@ def run_test_case_yaml(config_file, case_file, depends_id, http_handler, bmc_ip)
cases_result = []
cases = read_yaml(case_file)
for case in cases:
+ if(case['enabled'] is False):
+ LOGGER.debug("skipping case: %s", case["case_name"])
+ continue
+
+ LOGGER.debug("running case: %s", case["case_name"])
method, url, req_body, expected_code, expected_value, tc_name, key_flag_dict \
= case['method'], case['url'], case['request_body'], \
case['expected_code'], case['expected_result'], case['case_name'], case['key_flag_dict']
-
- expected_value = literal_eval(expected_value)
flag = 0
final_rst = {}
@@ -545,7 +479,6 @@ def run_test_case_yaml(config_file, case_file, depends_id, http_handler, bmc_ip)
str(final_rst) if len(final_rst) > 0 else "N/A"
cases_result.append(case)
LOGGER.info("writing test final_rst for case %s", tc_name)
-
write_result_2_yaml(cases_result)
LOGGER.info("############### end perform test case ###################")
@@ -569,56 +502,10 @@ def write_result_2_yaml(result):
explicit_start=True)
-def run_test_case_excel(config_file, case_file, depends_id, http_handler):
- '''
- perform the test case one by one,
- and write test final_result back to the excel.
- '''
- LOGGER.info("############### start perform test case #################")
- input_file = load_workbook(case_file)
- input_ws = input_file[input_file.sheetnames[0]]
-
- row = 2
- while input_ws.cell(row=row, column=1).value:
- method, url, req_body, expected_code, expected_value, tc_name \
- = read_row(input_ws, row, config_file)
-
- LOGGER.info("run test case ##%s##", tc_name)
- if tc_name == "configure BMC ip in static, ipv4":
- LOGGER.debug("debug")
- flag = 0
- final_result = {}
- rsp_list = []
- rsp_list = execute_final_url(config_file, depends_id, http_handler,
- method, url, req_body)
- if rsp_list is not None and len(rsp_list) > 0:
- return_value_list, return_code_list, final_result, flag = \
- parse_test_result(expected_value, expected_code,
- rsp_list, final_result)
- final_result.update({'info': return_value_list})
- LOGGER.debug("return_code_list:%s", return_code_list)
- input_ws.cell(row=row, column=config_file["return_code_seq"],
- value=str(return_code_list))
- else:
- LOGGER.error("%s", ERROR_CODE['E600001'])
- flag += 1
-
- LOGGER.info("writing test final_result for row %s", row)
- row = write_result_2_excel(
- config_file, input_ws, row, flag, final_result)
- row += 1
- input_file.save(case_file)
- LOGGER.info("############### end perform test case ###################")
-
-
-def run(conf_file, case_excel_file=None, depend_yaml_file=None,
- case_yaml_file=None, file_mode=None):
+def run(conf_file, case_file=None):
'''
@param conf_file: config.yaml
- @param case_excel_file: excel case file
- @param depend_yaml_file: depends yaml file used if file_mode=yaml
- @param case_yaml_file: case yaml file, used if file_mode=yaml
- @param file_mode: "excel" or "yaml"
+ @param case_file: case yaml file
access function
'''
# parse config.yaml
@@ -646,15 +533,9 @@ def run(conf_file, case_excel_file=None, depend_yaml_file=None,
depends_id = {}
# read the test case sheet and perform test
- if file_mode == "excel":
- run_test_case_excel(config_file,
- case_excel_file, depends_id, http_handler)
- elif file_mode == "yaml":
- run_test_case_yaml(config_file,
- case_yaml_file, depends_id, http_handler, bmc_ip)
- else:
- LOGGER.error("%s,%s", ERROR_CODE['E200001'], file_mode)
- return None
+ run_test_case_yaml(config_file,
+ case_file, depends_id, http_handler, bmc_ip)
+
LOGGER.info("done,checking the log %s", LOG_FILE)