Fixed flakiness in test_request_time_tracker
-import pytest
from plenum.server.monitor import RequestTimeTracker
-import time
INSTANCE_COUNT = 4
@@ -9,7 +7,7 @@ INSTANCE_COUNT = 4
def test_request_tracker_start_adds_request():
req_tracker = RequestTimeTracker(INSTANCE_COUNT)
req = ("id", 42)
- now = time.perf_counter()
+ now = 1.0
req_tracker.start(req[0], req[1], now)
@@ -20,7 +18,7 @@ def test_request_tracker_start_adds_request():
def test_request_tracker_order_by_master_makes_request_ordered_and_returns_time_to_order():
req_tracker = RequestTimeTracker(INSTANCE_COUNT)
req = ("id", 42)
- now = time.perf_counter()
+ now = 1.0
req_tracker.start(req[0], req[1], now)
tto = req_tracker.order(0, req[0], req[1], now + 5)
@@ -32,7 +30,7 @@ def test_request_tracker_order_by_master_makes_request_ordered_and_returns_time_
def test_request_tracker_order_by_backup_returns_time_to_order():
req_tracker = RequestTimeTracker(INSTANCE_COUNT)
req = ("id", 42)
- now = time.perf_counter()
+ now = 1.0
req_tracker.start(req[0], req[1], now)
tto = req_tracker.order(1, req[0], req[1], now + 5)
@@ -44,7 +42,7 @@ def test_request_tracker_order_by_backup_returns_time_to_order():
def test_request_tracker_deletes_request_only_when_it_is_ordered_by_all_instances():
req_tracker = RequestTimeTracker(INSTANCE_COUNT)
req = ("id", 42)
- now = time.perf_counter()
+ now = 1.0
req_tracker.start(req[0], req[1], now)
for instId in range(INSTANCE_COUNT - 1):
@@ -58,7 +56,7 @@ def test_request_tracker_deletes_request_only_when_it_is_ordered_by_all_instance
def test_request_tracker_doesnt_wait_for_new_instances_on_old_requests():
req_tracker = RequestTimeTracker(INSTANCE_COUNT)
req = ("id", 42)
- now = time.perf_counter()
+ now = 1.0
req_tracker.start(req[0], req[1], now)
req_tracker.add_instance()
@@ -72,7 +70,7 @@ def test_request_tracker_doesnt_wait_for_new_instances_on_old_requests():
def test_request_tracker_waits_for_new_instances_on_new_requests():
req_tracker = RequestTimeTracker(INSTANCE_COUNT)
req = ("id", 42)
- now = time.perf_counter()
+ now = 1.0
req_tracker.add_instance()
req_tracker.start(req[0], req[1], now)
@@ -88,7 +86,7 @@ def test_request_tracker_waits_for_new_instances_on_new_requests():
def test_request_tracker_performs_garbage_collection_on_remove_instance():
req_tracker = RequestTimeTracker(INSTANCE_COUNT)
req = ("id", 42)
- now = time.perf_counter()
+ now = 1.0
req_tracker.start(req[0], req[1], now)
req_tracker.order(1, req[0], req[1], now)
