mirror of
https://github.com/Telecominfraproject/wlan-lanforge-scripts.git
synced 2025-10-31 18:58:01 +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,12 +443,14 @@ class GhostRequest:
|
||||
if self.debug:
|
||||
print('Target files: %s' % target_files)
|
||||
|
||||
text = 'Testbed: %s<br />' % testbeds[0]
|
||||
if self.influx_token is not None:
|
||||
influxdb = RecordInflux(_influx_host=self.influx_host,
|
||||
_influx_port=self.influx_port,
|
||||
_influx_org=self.influx_org,
|
||||
_influx_token=self.influx_token,
|
||||
_influx_bucket=self.influx_bucket)
|
||||
try:
|
||||
short_description = 'Tests passed' # variable name
|
||||
numeric_score = test_pass_fail_results['PASS'] # value
|
||||
tags = dict()
|
||||
@@ -488,8 +490,10 @@ class GhostRequest:
|
||||
tags['Graph-Group'] = 'Subtest FAIL'
|
||||
date = datetime.utcfromtimestamp(max(times)).isoformat()
|
||||
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()
|
||||
test_tag_table = ''
|
||||
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>' \
|
||||
'<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>' \
|
||||
'<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'],
|
||||
test_pass_fail_results['FAIL'], subtest_pass_total, subtest_fail_total)
|
||||
|
||||
dut_table = dut_table + '</tbody></table>'
|
||||
text = text + dut_table
|
||||
|
||||
for dictionary in web_pages_and_pdfs:
|
||||
@@ -555,6 +558,7 @@ class GhostRequest:
|
||||
)
|
||||
if self.debug:
|
||||
print('Test Tag: %s' % test_tag)
|
||||
try:
|
||||
grafana.create_custom_dashboard(target_csvs=target_files,
|
||||
title=title,
|
||||
datasource=grafana_datasource,
|
||||
@@ -572,6 +576,9 @@ class GhostRequest:
|
||||
snapshot = grafana.list_snapshots()[-1]
|
||||
text = text + '<iframe src="http://%s:3000/dashboard/snapshot/%s" width="100%s" height=1500></iframe><br />' % (
|
||||
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)
|
||||
|
||||
|
||||
@@ -220,7 +220,7 @@ class lf_check():
|
||||
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.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')
|
||||
lanforge_node_version = stdout.readlines()
|
||||
# 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.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(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')
|
||||
lanforge_kernel_version = stdout.readlines()
|
||||
# print('\n'.join(output))
|
||||
@@ -246,7 +246,7 @@ class lf_check():
|
||||
output = ""
|
||||
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.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')
|
||||
lanforge_gui_version = stdout.readlines()
|
||||
# print('\n'.join(output))
|
||||
@@ -999,9 +999,15 @@ blog: http://{blog}:2368
|
||||
# Ghost will put data in stderr
|
||||
if('ghost' in command):
|
||||
if(self.test_result != "TIMEOUT"):
|
||||
text = open(stderr_log_txt).read()
|
||||
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 = str(stdout_log_txt).replace('/home/lanforge','')
|
||||
stderr_log_link = str(stderr_log_txt).replace('/home/lanforge','')
|
||||
@@ -1172,12 +1178,11 @@ Example :
|
||||
print("lanforge_gui_version exception")
|
||||
|
||||
# LANforge and scripts config
|
||||
lf_test_setup = pd.DataFrame({
|
||||
'LANforge': lanforge_node_version,
|
||||
'kernel version': lanforge_kernel_version,
|
||||
'GUI version': lanforge_gui_version,
|
||||
'scripts git sha': scripts_git_sha
|
||||
})
|
||||
lf_test_setup = pd.DataFrame()
|
||||
lf_test_setup['LANforge'] = lanforge_node_version
|
||||
lf_test_setup['kernel version'] = lanforge_kernel_version
|
||||
lf_test_setup['GUI version'] = lanforge_gui_version
|
||||
lf_test_setup['scripts git sha'] = scripts_git_sha
|
||||
|
||||
# generate output reports
|
||||
report.set_title("LF Check: lf_check.py")
|
||||
|
||||
Reference in New Issue
Block a user