Updated message reliability test report
Signed-off-by: yevh-berdnyk <ie.berdnyk@gmail.com>
This commit is contained in:
parent
434324d5fc
commit
19ff402b4b
|
@ -0,0 +1,42 @@
|
|||
import net.sf.json.JSONArray;
|
||||
import net.sf.json.JSONObject;
|
||||
node ('linux1'){sauce('1be1b688-e0e7-4314-92a0-db11f52d3c00'){
|
||||
def testPassed = true
|
||||
try {
|
||||
|
||||
stage('Tests & Report'){
|
||||
try {
|
||||
withCredentials([string(credentialsId: 'GIT_HUB_TOKEN', variable: 'GIT_HUB_TOKEN'),
|
||||
string(credentialsId: 'SOB_SAUCE_ACCESS_KEY', variable: 'SOB_SAUCE_ACCESS_KEY'),
|
||||
string(credentialsId: 'SOB_SAUCE_USERNAME', variable: 'SOB_SAUCE_USERNAME')]){
|
||||
sh 'cd test/appium/tests && python3 -m pytest test_message_reliability.py::TestMessageReliability::$test_to_run --messages_number=$messages_number --message_wait_time=$message_wait_time $apk' }
|
||||
}
|
||||
finally {
|
||||
saucePublisher()
|
||||
junit testDataPublishers: [[$class: 'SauceOnDemandReportPublisher', jobVisibility: 'public']],
|
||||
testResults: 'test/appium/tests/*.xml'
|
||||
archiveArtifacts 'test/appium/tests/*.png'
|
||||
}
|
||||
}
|
||||
} catch(e) {
|
||||
testPassed = false
|
||||
}
|
||||
|
||||
stage('Slack notification'){
|
||||
def c = (testPassed ? 'good' : 'warning')
|
||||
def resultText = (testPassed ? '' : 'FAILED')
|
||||
def fileData = readFile('test/appium/tests/messages.txt')
|
||||
def map = evaluate(fileData)
|
||||
def text = 'Sent messages: ' + map.sent + '\nReceived messages: ' + map.received + '\n<' + env.BUILD_URL + '/artifact/test/appium/tests/chart.png' + '|Test run chart>'
|
||||
JSONArray attachments = new JSONArray();
|
||||
JSONObject attachment = new JSONObject();
|
||||
|
||||
attachment.put('title','Message reliability job run, ' + test_to_run + ' ' + resultText);
|
||||
attachment.put('title_link', env.BUILD_URL);
|
||||
attachment.put('text', text);
|
||||
|
||||
attachments.add(attachment);
|
||||
slackSend(color: c, channel: '#test-notifications', attachments: attachments.toString())
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,4 +1,9 @@
|
|||
def create_chart_one_to_one_chat(one_to_one_chat_data: dict):
|
||||
def write_data_to_file(sent: int, received: int):
|
||||
with open('messages.txt', 'a') as f:
|
||||
f.write("['sent': %s, 'received': %s]" % (sent, received))
|
||||
|
||||
|
||||
def create_one_to_one_chat_report(one_to_one_chat_data: dict):
|
||||
import matplotlib
|
||||
matplotlib.use('Agg')
|
||||
import matplotlib.pyplot as plt
|
||||
|
@ -13,7 +18,10 @@ def create_chart_one_to_one_chat(one_to_one_chat_data: dict):
|
|||
time_2 = sorted(user_b['message_time'])
|
||||
ax.plot([i / 60 for i in time_2], [user_b['message_time'][i] for i in time_2],
|
||||
'o-', color='#f61e06', label='user_b')
|
||||
|
||||
sent_messages = user_a['sent_messages'] + user_b['sent_messages']
|
||||
received_messages = len(user_a['message_time']) + len(user_b['message_time'])
|
||||
|
||||
title = "User A: sent messages: {}, received messages: {}" \
|
||||
"\nUser B: sent messages: {}, received messages: {}".format(user_a['sent_messages'],
|
||||
len(user_a['message_time']),
|
||||
|
@ -22,14 +30,17 @@ def create_chart_one_to_one_chat(one_to_one_chat_data: dict):
|
|||
if sent_messages:
|
||||
title += "\nReceived messages: {}%".format(
|
||||
round((len(user_a['message_time']) + len(user_b['message_time'])) / sent_messages * 100, ndigits=2))
|
||||
|
||||
plt.title(title)
|
||||
plt.xlabel('chat session duration, minutes')
|
||||
plt.ylabel('time to receive a message, seconds')
|
||||
plt.legend()
|
||||
fig.savefig('chart.png')
|
||||
|
||||
write_data_to_file(sent=sent_messages, received=received_messages)
|
||||
|
||||
def create_chart_public_chat(public_chat_data: dict):
|
||||
|
||||
def create_public_chat_report(public_chat_data: dict):
|
||||
import matplotlib
|
||||
matplotlib.use('Agg')
|
||||
import matplotlib.pyplot as plt
|
||||
|
@ -46,3 +57,5 @@ def create_chart_public_chat(public_chat_data: dict):
|
|||
plt.ylabel('time to receive a message, seconds')
|
||||
plt.legend()
|
||||
fig.savefig('chart.png')
|
||||
|
||||
write_data_to_file(sent=sent_messages, received=len(message_time))
|
|
@ -4,7 +4,7 @@ import re
|
|||
import subprocess
|
||||
import asyncio
|
||||
|
||||
from support.message_reliability_chart import create_chart_one_to_one_chat, create_chart_public_chat
|
||||
from support.message_reliability_report import create_one_to_one_chat_report, create_public_chat_report
|
||||
from support.network_api import NetworkApi
|
||||
from os import environ
|
||||
from appium import webdriver
|
||||
|
@ -227,6 +227,7 @@ class MessageReliabilityTestCase(MultipleDeviceTestCase):
|
|||
|
||||
def teardown_method(self, method):
|
||||
if self.one_to_one_chat_data:
|
||||
create_chart_one_to_one_chat(self.one_to_one_chat_data)
|
||||
create_one_to_one_chat_report(self.one_to_one_chat_data)
|
||||
if self.public_chat_data:
|
||||
create_chart_public_chat(self.public_chat_data)
|
||||
create_public_chat_report(self.public_chat_data)
|
||||
super(MultipleDeviceTestCase, self).teardown_method(method)
|
||||
|
|
Loading…
Reference in New Issue