mirror of
https://github.com/Telecominfraproject/wlan-lanforge-scripts.git
synced 2025-11-01 11:18:03 +00:00
Error reporting for Influx and Grafana in Ghost posts
Signed-off-by: Matthew Stidham <stidmatt@gmail.com>
This commit is contained in:
@@ -443,53 +443,57 @@ class GhostRequest:
|
|||||||
if self.debug:
|
if self.debug:
|
||||||
print('Target files: %s' % target_files)
|
print('Target files: %s' % target_files)
|
||||||
|
|
||||||
|
text = 'Testbed: %s<br />' % testbeds[0]
|
||||||
if self.influx_token is not None:
|
if self.influx_token is not None:
|
||||||
influxdb = RecordInflux(_influx_host=self.influx_host,
|
influxdb = RecordInflux(_influx_host=self.influx_host,
|
||||||
_influx_port=self.influx_port,
|
_influx_port=self.influx_port,
|
||||||
_influx_org=self.influx_org,
|
_influx_org=self.influx_org,
|
||||||
_influx_token=self.influx_token,
|
_influx_token=self.influx_token,
|
||||||
_influx_bucket=self.influx_bucket)
|
_influx_bucket=self.influx_bucket)
|
||||||
short_description = 'Tests passed' # variable name
|
try:
|
||||||
numeric_score = test_pass_fail_results['PASS'] # value
|
short_description = 'Tests passed' # variable name
|
||||||
tags = dict()
|
numeric_score = test_pass_fail_results['PASS'] # value
|
||||||
if self.debug:
|
tags = dict()
|
||||||
print(datetime.utcfromtimestamp(max(times)))
|
if self.debug:
|
||||||
tags['testbed'] = testbeds[0]
|
print(datetime.utcfromtimestamp(max(times)))
|
||||||
tags['script'] = 'GhostRequest'
|
tags['testbed'] = testbeds[0]
|
||||||
tags['Graph-Group'] = 'PASS'
|
tags['script'] = 'GhostRequest'
|
||||||
date = datetime.utcfromtimestamp(max(times)).isoformat()
|
tags['Graph-Group'] = 'PASS'
|
||||||
influxdb.post_to_influx(short_description, numeric_score, tags, date)
|
date = datetime.utcfromtimestamp(max(times)).isoformat()
|
||||||
|
influxdb.post_to_influx(short_description, numeric_score, tags, date)
|
||||||
|
|
||||||
short_description = 'Tests failed' # variable name
|
short_description = 'Tests failed' # variable name
|
||||||
numeric_score = test_pass_fail_results['FAIL'] # value
|
numeric_score = test_pass_fail_results['FAIL'] # value
|
||||||
tags = dict()
|
tags = dict()
|
||||||
tags['testbed'] = testbeds[0]
|
tags['testbed'] = testbeds[0]
|
||||||
tags['script'] = 'GhostRequest'
|
tags['script'] = 'GhostRequest'
|
||||||
tags['Graph-Group'] = 'FAIL'
|
tags['Graph-Group'] = 'FAIL'
|
||||||
date = datetime.utcfromtimestamp(max(times)).isoformat()
|
date = datetime.utcfromtimestamp(max(times)).isoformat()
|
||||||
influxdb.post_to_influx(short_description, numeric_score, tags, date)
|
influxdb.post_to_influx(short_description, numeric_score, tags, date)
|
||||||
|
|
||||||
short_description = 'Subtests passed' # variable name
|
short_description = 'Subtests passed' # variable name
|
||||||
numeric_score = subtest_pass_fail_results['PASS'] # value
|
numeric_score = subtest_pass_fail_results['PASS'] # value
|
||||||
tags = dict()
|
tags = dict()
|
||||||
if self.debug:
|
if self.debug:
|
||||||
print(datetime.utcfromtimestamp(max(times)))
|
print(datetime.utcfromtimestamp(max(times)))
|
||||||
tags['testbed'] = testbeds[0]
|
tags['testbed'] = testbeds[0]
|
||||||
tags['script'] = 'GhostRequest'
|
tags['script'] = 'GhostRequest'
|
||||||
tags['Graph-Group'] = 'Subtest PASS'
|
tags['Graph-Group'] = 'Subtest PASS'
|
||||||
date = datetime.utcfromtimestamp(max(times)).isoformat()
|
date = datetime.utcfromtimestamp(max(times)).isoformat()
|
||||||
influxdb.post_to_influx(short_description, numeric_score, tags, date)
|
influxdb.post_to_influx(short_description, numeric_score, tags, date)
|
||||||
|
|
||||||
short_description = 'Subtests failed' # variable name
|
short_description = 'Subtests failed' # variable name
|
||||||
numeric_score = subtest_pass_fail_results['FAIL'] # value
|
numeric_score = subtest_pass_fail_results['FAIL'] # value
|
||||||
tags = dict()
|
tags = dict()
|
||||||
tags['testbed'] = testbeds[0]
|
tags['testbed'] = testbeds[0]
|
||||||
tags['script'] = 'GhostRequest'
|
tags['script'] = 'GhostRequest'
|
||||||
tags['Graph-Group'] = 'Subtest FAIL'
|
tags['Graph-Group'] = 'Subtest FAIL'
|
||||||
date = datetime.utcfromtimestamp(max(times)).isoformat()
|
date = datetime.utcfromtimestamp(max(times)).isoformat()
|
||||||
influxdb.post_to_influx(short_description, numeric_score, tags, date)
|
influxdb.post_to_influx(short_description, numeric_score, tags, date)
|
||||||
|
except Exception as err:
|
||||||
|
influx_error = err
|
||||||
|
text += ('<p style="color:red;">InfluxDB Error: %s</p><br />' % influx_error)
|
||||||
|
|
||||||
text = 'Testbed: %s<br />' % testbeds[0]
|
|
||||||
raw_test_tags = list()
|
raw_test_tags = list()
|
||||||
test_tag_table = ''
|
test_tag_table = ''
|
||||||
for tag in test_tag.values():
|
for tag in test_tag.values():
|
||||||
@@ -526,11 +530,10 @@ class GhostRequest:
|
|||||||
'<tr><td style="border-color: gray; border-style: solid; border-width: 1px; ">Subtests passed</td>' \
|
'<tr><td style="border-color: gray; border-style: solid; border-width: 1px; ">Subtests passed</td>' \
|
||||||
'<td colspan="3" style="border-color: gray; border-style: solid; border-width: 1px; ">%s</td></tr>' \
|
'<td colspan="3" style="border-color: gray; border-style: solid; border-width: 1px; ">%s</td></tr>' \
|
||||||
'<tr><td style="border-color: gray; border-style: solid; border-width: 1px; ">Subtests failed</td>' \
|
'<tr><td style="border-color: gray; border-style: solid; border-width: 1px; ">Subtests failed</td>' \
|
||||||
'<td colspan="3" style="border-color: gray; border-style: solid; border-width: 1px; ">%s</td></tr>' % (
|
'<td colspan="3" style="border-color: gray; border-style: solid; border-width: 1px; ">%s</td></tr>' \
|
||||||
|
'</tbody></table>' % (
|
||||||
dut_table_columns, test_tag_table, test_pass_fail_results['PASS'],
|
dut_table_columns, test_tag_table, test_pass_fail_results['PASS'],
|
||||||
test_pass_fail_results['FAIL'], subtest_pass_total, subtest_fail_total)
|
test_pass_fail_results['FAIL'], subtest_pass_total, subtest_fail_total)
|
||||||
|
|
||||||
dut_table = dut_table + '</tbody></table>'
|
|
||||||
text = text + dut_table
|
text = text + dut_table
|
||||||
|
|
||||||
for dictionary in web_pages_and_pdfs:
|
for dictionary in web_pages_and_pdfs:
|
||||||
@@ -555,23 +558,27 @@ class GhostRequest:
|
|||||||
)
|
)
|
||||||
if self.debug:
|
if self.debug:
|
||||||
print('Test Tag: %s' % test_tag)
|
print('Test Tag: %s' % test_tag)
|
||||||
grafana.create_custom_dashboard(target_csvs=target_files,
|
try:
|
||||||
title=title,
|
grafana.create_custom_dashboard(target_csvs=target_files,
|
||||||
datasource=grafana_datasource,
|
title=title,
|
||||||
bucket=grafana_bucket,
|
datasource=grafana_datasource,
|
||||||
from_date=start_time,
|
bucket=grafana_bucket,
|
||||||
to_date=end_time.strftime('%Y-%m-%d %H:%M:%S'),
|
from_date=start_time,
|
||||||
pass_fail='GhostRequest',
|
to_date=end_time.strftime('%Y-%m-%d %H:%M:%S'),
|
||||||
testbed=testbeds[0],
|
pass_fail='GhostRequest',
|
||||||
test_tag=test_tag)
|
testbed=testbeds[0],
|
||||||
# get the details of the dashboard through the API, and set the end date to the youngest KPI
|
test_tag=test_tag)
|
||||||
grafana.list_dashboards()
|
# get the details of the dashboard through the API, and set the end date to the youngest KPI
|
||||||
|
grafana.list_dashboards()
|
||||||
|
|
||||||
grafana.create_snapshot(title='Testbed: ' + title)
|
grafana.create_snapshot(title='Testbed: ' + title)
|
||||||
time.sleep(3)
|
time.sleep(3)
|
||||||
snapshot = grafana.list_snapshots()[-1]
|
snapshot = grafana.list_snapshots()[-1]
|
||||||
text = text + '<iframe src="http://%s:3000/dashboard/snapshot/%s" width="100%s" height=1500></iframe><br />' % (
|
text = text + '<iframe src="http://%s:3000/dashboard/snapshot/%s" width="100%s" height=1500></iframe><br />' % (
|
||||||
grafana_host, snapshot['key'], '%')
|
grafana_host, snapshot['key'], '%')
|
||||||
|
except Exception as err:
|
||||||
|
grafana_error = err
|
||||||
|
text = text + '<p style="color:red;">Grafana Error: %s</p><br />' % grafana_error
|
||||||
|
|
||||||
text = text + 'Low priority results: %s' % csvreader.to_html(low_priority)
|
text = text + 'Low priority results: %s' % csvreader.to_html(low_priority)
|
||||||
|
|
||||||
|
|||||||
@@ -220,7 +220,7 @@ class lf_check():
|
|||||||
ssh = paramiko.SSHClient() # creating shh client object we use this object to connect to router
|
ssh = paramiko.SSHClient() # creating shh client object we use this object to connect to router
|
||||||
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) # automatically adds the missing host key
|
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) # automatically adds the missing host key
|
||||||
#ssh.connect(self.lf_mgr_ip, port=22, username=self.lf_mgr_user, password=self.lf_mgr_pass, banner_timeout=600)
|
#ssh.connect(self.lf_mgr_ip, port=22, username=self.lf_mgr_user, password=self.lf_mgr_pass, banner_timeout=600)
|
||||||
ssh.connect(hostname=self.lf_mgr_ip, port=22, username=self.lf_mgr_user, password=self.lf_mgr_pass, banner_timeout=600)
|
ssh.connect(hostname=self.lf_mgr_ip, port=22, username=self.lf_mgr_user, password=self.lf_mgr_pass, allow_agent=False, look_for_keys=False, banner_timeout=600)
|
||||||
stdin, stdout, stderr = ssh.exec_command('uname -n')
|
stdin, stdout, stderr = ssh.exec_command('uname -n')
|
||||||
lanforge_node_version = stdout.readlines()
|
lanforge_node_version = stdout.readlines()
|
||||||
# print('\n'.join(output))
|
# print('\n'.join(output))
|
||||||
@@ -233,7 +233,7 @@ class lf_check():
|
|||||||
ssh = paramiko.SSHClient() # creating shh client object we use this object to connect to router
|
ssh = paramiko.SSHClient() # creating shh client object we use this object to connect to router
|
||||||
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) # automatically adds the missing host key
|
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) # automatically adds the missing host key
|
||||||
#ssh.connect(self.lf_mgr_ip, port=22, username=self.lf_mgr_user, password=self.lf_mgr_pass, banner_timeout=600)
|
#ssh.connect(self.lf_mgr_ip, port=22, username=self.lf_mgr_user, password=self.lf_mgr_pass, banner_timeout=600)
|
||||||
ssh.connect(hostname=self.lf_mgr_ip, port=22, username=self.lf_mgr_user, password=self.lf_mgr_pass, banner_timeout=600)
|
ssh.connect(hostname=self.lf_mgr_ip, port=22, username=self.lf_mgr_user, password=self.lf_mgr_pass, allow_agent=False, look_for_keys=False, banner_timeout=600)
|
||||||
stdin, stdout, stderr = ssh.exec_command('uname -r')
|
stdin, stdout, stderr = ssh.exec_command('uname -r')
|
||||||
lanforge_kernel_version = stdout.readlines()
|
lanforge_kernel_version = stdout.readlines()
|
||||||
# print('\n'.join(output))
|
# print('\n'.join(output))
|
||||||
@@ -246,7 +246,7 @@ class lf_check():
|
|||||||
output = ""
|
output = ""
|
||||||
ssh = paramiko.SSHClient() # creating shh client object we use this object to connect to router
|
ssh = paramiko.SSHClient() # creating shh client object we use this object to connect to router
|
||||||
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) # automatically adds the missing host key
|
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) # automatically adds the missing host key
|
||||||
ssh.connect(hostname=self.lf_mgr_ip, port=22, username=self.lf_mgr_user, password=self.lf_mgr_pass, banner_timeout=600)
|
ssh.connect(hostname=self.lf_mgr_ip, port=22, username=self.lf_mgr_user, password=self.lf_mgr_pass, allow_agent=False, look_for_keys=False, banner_timeout=600)
|
||||||
stdin, stdout, stderr = ssh.exec_command('./btserver --version | grep Version')
|
stdin, stdout, stderr = ssh.exec_command('./btserver --version | grep Version')
|
||||||
lanforge_gui_version = stdout.readlines()
|
lanforge_gui_version = stdout.readlines()
|
||||||
# print('\n'.join(output))
|
# print('\n'.join(output))
|
||||||
@@ -999,8 +999,14 @@ blog: http://{blog}:2368
|
|||||||
# Ghost will put data in stderr
|
# Ghost will put data in stderr
|
||||||
if('ghost' in command):
|
if('ghost' in command):
|
||||||
if(self.test_result != "TIMEOUT"):
|
if(self.test_result != "TIMEOUT"):
|
||||||
self.test_result = "Success"
|
text = open(stderr_log_txt).read()
|
||||||
background = self.background_blue
|
if 'Error' in text:
|
||||||
|
self.test_result = "Failure"
|
||||||
|
background = self.background_red
|
||||||
|
else:
|
||||||
|
self.test_result = "Success"
|
||||||
|
background = self.background_blue
|
||||||
|
|
||||||
|
|
||||||
# stdout_log_link is used for the email reporting to have the corrected path
|
# stdout_log_link is used for the email reporting to have the corrected path
|
||||||
stdout_log_link = str(stdout_log_txt).replace('/home/lanforge','')
|
stdout_log_link = str(stdout_log_txt).replace('/home/lanforge','')
|
||||||
@@ -1172,12 +1178,11 @@ Example :
|
|||||||
print("lanforge_gui_version exception")
|
print("lanforge_gui_version exception")
|
||||||
|
|
||||||
# LANforge and scripts config
|
# LANforge and scripts config
|
||||||
lf_test_setup = pd.DataFrame({
|
lf_test_setup = pd.DataFrame()
|
||||||
'LANforge': lanforge_node_version,
|
lf_test_setup['LANforge'] = lanforge_node_version
|
||||||
'kernel version': lanforge_kernel_version,
|
lf_test_setup['kernel version'] = lanforge_kernel_version
|
||||||
'GUI version': lanforge_gui_version,
|
lf_test_setup['GUI version'] = lanforge_gui_version
|
||||||
'scripts git sha': scripts_git_sha
|
lf_test_setup['scripts git sha'] = scripts_git_sha
|
||||||
})
|
|
||||||
|
|
||||||
# generate output reports
|
# generate output reports
|
||||||
report.set_title("LF Check: lf_check.py")
|
report.set_title("LF Check: lf_check.py")
|
||||||
|
|||||||
Reference in New Issue
Block a user