Skip to content

Commit 01a2015

Browse files
committed
Make submit_results_url optional, make log_dir mandatory
1 parent 48de836 commit 01a2015

File tree

2 files changed

+18
-14
lines changed

2 files changed

+18
-14
lines changed

dashboard/collect_performance.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
sys.exit(0)
1616

1717
n = 1
18+
url = None
1819
parser = configparser.RawConfigParser()
1920
try:
2021
parser.read(config)
@@ -25,13 +26,15 @@
2526
else:
2627
print('No test directory specified in your config file. Please do so.')
2728
sys.exit(0)
29+
if not parser.has_option('dashboard', 'LOG_DIR'):
30+
print('No log directory specified in your config file. Please do so.')
31+
sys.exit(0)
2832
if parser.has_option('dashboard', 'SUBMIT_RESULTS_URL'):
2933
url = parser.get('dashboard', 'SUBMIT_RESULTS_URL')
3034
else:
3135
print('No url specified in your config file for submitting test results. Please do so.')
32-
sys.exit(0)
33-
except configparser.Error:
34-
raise
36+
except configparser.Error as e:
37+
print("Something went wrong while parsing the configuration file:\n{}".format(e))
3538

3639
data = {'test_runs': [], 'grouped_tests': []}
3740
log = open("test_runs.log", "w")
@@ -81,10 +84,10 @@
8184
data['grouped_tests'].append({'endpoint': h[1], 'test_name': r[2]})
8285
break
8386

84-
# Try to send test results and endpoint and unit tests to the dashboard
85-
try:
86-
requests.post(url, json=data)
87-
print('Sent unit test results to the dashboard.')
88-
except:
89-
print('Sending unit test results to the dashboard failed.')
90-
raise
87+
# Try to send test results and endpoint-grouped unit tests to the dashboard
88+
if url:
89+
try:
90+
requests.post(url, json=data)
91+
print('Sent unit test results to the dashboard.')
92+
except Exception as e:
93+
print('Sending unit test results to the dashboard failed:\n{}'.format(e))

dashboard/tests/test_simple.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,19 @@
33

44

55
class MyTestCase(unittest.TestCase):
6+
67
def test_something(self):
7-
r = requests.get('http://0.0.0.0:5000/')
8+
r = requests.get('http://127.0.0.1:5000/')
89
self.assertEqual(200, r.status_code)
910

1011
def test_somethingElse(self):
11-
r = requests.get('http://0.0.0.0:5000/')
12+
r = requests.get('http://127.0.0.1:5000/')
1213
self.assertEqual(200, r.status_code)
1314

1415
def test_indexHit(self):
15-
r = requests.get('http://0.0.0.0:5000/')
16+
r = requests.get('http://127.0.0.1:5000/')
1617
self.assertEqual(200, r.status_code)
17-
r = requests.get('http://0.0.0.0:5000/static/assets/js/custom.js')
18+
r = requests.get('http://127.0.0.1:5000/static/assets/js/custom.js')
1819
self.assertEqual(200, r.status_code)
1920

2021

0 commit comments

Comments
 (0)