Skip to content
Snippets Groups Projects
Commit 01d1df5f authored by Nikolay Stanchev's avatar Nikolay Stanchev
Browse files

Merge branch 'aggregation' into clmcservice

parents b4e33a8d e85fba96
No related branches found
No related tags found
No related merge requests found
......@@ -70,11 +70,23 @@ class Aggregator(Thread):
self._stop_flag.set()
def set_event_lock(self, event):
"""
Auxiliary method to set a thread-safe event lock object to the aggregator (used for testing).
:param event: the event lock object
"""
setattr(self, 'event', event)
def run(self):
"""
Performs the functionality of the aggregator - query data from both measurements merge that data and post it back in influx every 5 seconds.
"""
if hasattr(self, 'event'):
self.event.set()
current_time = int(time())
while True:
if self._stop_flag.is_set():
......
......@@ -25,6 +25,7 @@
import pytest
import random
import time
import threading
class TestE2ESimulation(object):
......@@ -44,9 +45,11 @@ class TestE2ESimulation(object):
random.seed(0) # Seed random function so we can reliably test for average queries
print("Starting aggregator...")
event = threading.Event()
e2e_aggregator.set_event_lock(event)
e2e_aggregator.start()
time.sleep(1)
event.wait() # wait until the aggregator thread has set the event lock (it has reached its run method and is ready to start)
print("Running simulation, please wait...")
e2e_simulator.run()
......@@ -68,7 +71,7 @@ class TestE2ESimulation(object):
"count_avg_request_size": 38, "count_avg_response_size": 38, "count_avg_bandwidth": 38}),
('SELECT mean(*) FROM "E2EMetrics"."autogen"."e2e_delays"',
{"time": "1970-01-01T00:00:00Z", "mean_delay_forward": 8.048245614035087, "mean_delay_reverse": 13.043859649122808, "mean_delay_service": 23.42105263157895,
{"time": "1970-01-01T00:00:00Z", "mean_delay_forward": 8.010964912280702, "mean_delay_reverse": 12.881578947368423, "mean_delay_service": 23.42105263157895,
'mean_avg_request_size': 10485760, 'mean_avg_response_size': 1024, 'mean_avg_bandwidth': 104857600}),
])
def test_simulation(self, influx_db, query, expected_result):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment