Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue#120 #166

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
9 changes: 5 additions & 4 deletions AutomationFramework/capabilities.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
HOSTS = [
{
'host': '10.95.86.216',
'port': '12022',
'username': 'admin',
'password': 'admin',
'host': '10.95.86.114',
'port': '830',
'username': 'telefonica',
'password': 'Huawei@123',
'vendor': 'huawei',
},
]
16 changes: 12 additions & 4 deletions AutomationFramework/execute_sub_set.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import argparse
import os

from capabilities import HOSTS
if __name__ == '__main__':
vendor = HOSTS[0]['vendor']
parser = argparse.ArgumentParser()
parser.add_argument("tests_sub_set", help="The sub set of tests to execute. It can be a block or a sub-block. i.e. "
"tests/hardware, tests/hardware/test_hw_component.py or "
Expand All @@ -11,8 +12,14 @@
sub_set = args.tests_sub_set
print(sub_set)


if not os.path.exists('excel_logs/'+vendor):
os.makedirs('excel_logs/'+vendor)
if not os.path.exists('reports/'+vendor):
os.makedirs('reports/'+vendor)

# Delete cumulative logs file
excel_logs_path = os.path.dirname(os.path.realpath(__file__)) + '/excel_logs/'
excel_logs_path = os.path.dirname(os.path.realpath(__file__)) + '/excel_logs/'+vendor+'/'
cumulative_logs_path = excel_logs_path + 'cumulative_log.xlsx'
print('Removing file: ' + cumulative_logs_path)

Expand Down Expand Up @@ -41,11 +48,12 @@
raise Exception('Not allowed sub set. Expected notation: tests/hardware, tests/hardware/test_hw_component.py '
'or tests/hardware/test_hw_component.py::TestHardwareComponent::test_hw_component_description')

pytest_command = 'py.test ' + sub_set + ' --excelreport=reports/' + output_file_name + '_report.xls'
pytest_command = 'py.test ' + sub_set + ' --excelreport=reports/'+vendor+'/'+ output_file_name + '_report.xls'

print('- Running ' + pytest_command)
os.system(pytest_command)

# Change the cumulative log file name to sub_set file log
print('- Rename cummulative_logs.xlxs')
os.rename(cumulative_logs_path, excel_logs_path + output_file_name + '_logs.xlsx')
if os.path.exists(cumulative_logs_path):
os.rename(cumulative_logs_path, excel_logs_path + output_file_name + '_logs.xlsx')
30 changes: 13 additions & 17 deletions AutomationFramework/generate_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,18 @@

import os
import sys
from datetime import date

from datetime import date, datetime
import pandas as pd
from capabilities import HOSTS

today = date.today()

directory = sys.argv[1]
logs_directory = 'excel_logs'
vendor = HOSTS[0]['vendor']
directory = sys.argv[1]+'/'+vendor
logs_directory = 'excel_logs/'+vendor
out_log = pd.DataFrame()
out = pd.DataFrame()

if len(sys.argv) == 2:
vendor = ""
print("--------")
print("No VENDOR specified.")
print("--------")
else:
vendor = sys.argv[2]

print("\nStep #0: Concatenating logs:" + logs_directory)
print("--------")

Expand All @@ -35,6 +28,8 @@

out_log["TEST-ID (XML_FILE_NAME)"] = out_log["Test case name"] + '.xml'



with pd.ExcelWriter(directory + '/total_logs.xlsx') as writer:
out_log.to_excel(writer, sheet_name='Logs')

Expand Down Expand Up @@ -87,14 +82,15 @@
table = pd.pivot_table(out, index=['RESULT'],
columns=['TEST BLOCK'], aggfunc='count')
#
with pd.ExcelWriter(directory + '/final_output.xlsx') as writer:
timestamp = str(datetime.now().strftime("%d_%b_%Y_%H_%M_%S"))
with pd.ExcelWriter(directory + '/'+vendor+'_final_output_'+timestamp+'.xlsx') as writer:
template.to_excel(writer, sheet_name='Details')
out.to_excel(writer, sheet_name='Results')
table.to_excel(writer, sheet_name='Report')

print("\nStep #3: Removing aux files")
print("--------")
print('reports/total_logs.xlsx')
os.remove('reports/total_logs.xlsx')
print('reports/total_output.xlsx')
os.remove('reports/total_output.xlsx')
print('reports/'+vendor+'/total_logs.xlsx')
os.remove('reports/'+vendor+'/total_logs.xlsx')
print('reports/'+vendor+'/total_output.xlsx')
os.remove('reports/'+vendor+'/total_output.xlsx')
7 changes: 6 additions & 1 deletion AutomationFramework/page_objects/base/base_page_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,16 @@ def __init__(self, test_case_file=None, test_case_name=None, rpc_idx=0):
self.set_variables_to_commit(rpc_idx)
self.init_generic_variables_to_commit()
self.values_after_get = {}
self.excel_logger = ExcelLogger(workbook_name=Path('excel_logs/cumulative_log.xlsx'),
self.excel_logger = ExcelLogger(workbook_name=Path('excel_logs/'+HOSTS[0]['vendor']+'/cumulative_log.xlsx'),
columns=['Test case description', 'RPC ID', 'POM instance', 'Test case name',
'Filter', 'First get config', 'RPC', 'Edit config and commit',
'Second get config', 'Get'])


def close_session(self):
print("cerrando sesion")
self.rpc_automator.set_close_connection()

def init_generic_variables_to_commit(self):
self.generic_variables_to_commit = []
for variable, value in self.rpcs_list[self.rpc_idx_in_test_case]['params'].items():
Expand Down
108 changes: 108 additions & 0 deletions AutomationFramework/test_cases/adva_test_cases/hw_component.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@

- testcase:
name: hw_component_description
id: 1
description: >
This test is to get description components.
rpcs:
- template: hw_component_description.xml
operation: get
params:
name: "chassis"
description: ""

- testcase:
name: hw_component_hardware_version
id: 2
description: >
This test is to get the hardware version components.
rpcs:
- template: hw_component_hardware_version.xml
operation: get
params:
name: "chassis"
hardware_version: ""

- testcase:
name: hw_component_id
id: 3
description: >
This test is to get the component id.
rpcs:
- template: hw_component_id.xml
operation: get
params:
name: "chassis"
id: ""

- testcase:
name: hw_component_location
id: 4
description: >
This test is to get location components.
rpcs:
- template: hw_component_location.xml
operation: get
params:
name: "Fan#1"
location: ""

- testcase:
name: hw_component_mfg_date
id: 5
description: >
This test is to get manufacturing date.
rpcs:
- template: hw_component_mfg_date.xml
operation: get
params:
name: "chassis"
mfg_date: ""

- testcase:
name: hw_component_oper_status
id: 6
description: >
This test is to get operation status component.
rpcs:
- template: hw_component_oper_status.xml
operation: get
params:
name: "chassis"
oper_status: ""

- testcase:
name: hw_component_parent
id: 7
description: >
This test is to get name of the parent component.
rpcs:
- template: hw_component_parent.xml
operation: get
params:
name: "chassis"
parent: ""

- testcase:
name: hw_component_serial_no
id: 8
description: >
This test is to get serial number of the component.
rpcs:
- template: hw_component_serial_no.xml
operation: get
params:
name: "chassis"
serial_no: ""

- testcase:
name: hw_component_type
id: 9
description: >
This test is to get type of component by the system.
rpcs:
- template: hw_component_type.xml
operation: get
params:
name: "chassis"
type: ""
84 changes: 84 additions & 0 deletions AutomationFramework/test_cases/adva_test_cases/hw_cpu.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@

- testcase:
name: hw_cpu_avg
id: 1
description: >
This test is to get the cpu avg of components.
rpcs:
- template: hw_cpu_avg.xml
operation: get
params:
name: "cpu"
avg: ""

- testcase:
name: hw_cpu_instant
id: 2
description: >
This test is to get the cpu instant of components.
rpcs:
- template: hw_cpu_instant.xml
operation: get
params:
name: "cpu"
instant: ""

- testcase:
name: hw_cpu_interval
id: 3
description: >
This test is to get the cpu interval of components.
rpcs:
- template: hw_cpu_interval.xml
operation: get
params:
name: "cpu"
interval: ""

- testcase:
name: hw_cpu_max
id: 4
description: >
This test is to get the cpu max of components.
rpcs:
- template: hw_cpu_max.xml
operation: get
params:
name: "cpu"
max: ""

- testcase:
name: hw_cpu_max_time
id: 5
description: >
This test is to get the cpu max on time of components.
rpcs:
- template: hw_cpu_max_time.xml
operation: get
params:
name: "cpu"
max_time: ""

- testcase:
name: hw_cpu_min
id: 6
description: >
This test is to get the cpu min of components.
rpcs:
- template: hw_cpu_min.xml
operation: get
params:
name: "cpu"
min: ""

- testcase:
name: hw_cpu_min_time
id: 7
description: >
This test is to get the cpu min on time of components.
rpcs:
- template: hw_cpu_min_time.xml
operation: get
params:
name: "cpu"
min_time: ""
12 changes: 12 additions & 0 deletions AutomationFramework/test_cases/adva_test_cases/hw_fan.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

- testcase:
name: hw_fan_speed
id: 1
description: >
This test is to get the fan speed.
rpcs:
- template: hw_fan_speed.xml
operation: get
params:
name: "Fan#1"
speed: ""
26 changes: 26 additions & 0 deletions AutomationFramework/test_cases/adva_test_cases/hw_linecard.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

- testcase:
name: hw_linecard_power_admin
id: 1
description: >
This test is to set power admin state of a linecard.
rpcs:
- template: hw_linecard_power_admin.xml
target: candidate
operation: edit-config
commit: true
params:
name: "chassis"
power_admin_state: "POWER_DISABLED"

- testcase:
name: hw_linecard_power_admin_state
id: 2
description: >
This test is to get power admin state of a linecard.
rpcs:
- template: hw_linecard_power_admin_state.xml
operation: get
params:
name: "chassis"
power_admin_state: ""
Loading