Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix data transmission to ReBenchDB on timeout #160

Merged
merged 2 commits into from
Sep 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
40 changes: 27 additions & 13 deletions rebench/rebenchdb.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import json
from datetime import datetime
from time import sleep

from .ui import UIError

Expand Down Expand Up @@ -92,19 +93,32 @@ def _send_to_rebench_db(self, payload_data, operation):
with open("payload.json", "w") as text_file: # pylint: disable=unspecified-encoding
text_file.write(payload)

try:
data = payload.encode('utf-8')
response = self._send_payload(data, url)
return True, response
except TypeError as te:
self._ui.error("{ind}Error: Reporting to ReBenchDB failed.\n"
+ "{ind}{ind}" + str(te) + "\n")
except (IOError, HTTPException):
# network or server may have issues, let's try one more time
return self._send_with_retries(payload.encode('utf-8'), url)

def _send_with_retries(self, payload_bytes, url):
attempts = 4
wait_sec = 10
while True:
try:
response = self._send_payload(payload, url)
response = self._send_payload(payload_bytes, url)
return True, response
except (IOError, HTTPException) as error:
except TypeError as te:
# can't handle this, just abort
self._ui.error("{ind}Error: Reporting to ReBenchDB failed.\n"
+ "{ind}{ind}" + str(error) + "\n")
return False, None
+ "{ind}{ind}" + str(te) + "\n")
return False, None
except (IOError, HTTPException) as error:
if attempts > 0:
# let's retry, the benchmark server might just time out, as usual
# but let it breath a little
self._ui.verbose_output_info(
"ReBenchDB: had issue reporting data. Trying again after "
+ str(wait_sec) + "seconds.\n"
+ "{ind}{ind}" + str(error) + "\n")
attempts -= 1
sleep(wait_sec)
wait_sec *= 2
else:
self._ui.error("{ind}Error: Reporting to ReBenchDB failed.\n"
+ "{ind}{ind}" + str(error) + "\n")
return False, None
19 changes: 19 additions & 0 deletions rebench/tests/denoise_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from .rebench_test_case import ReBenchTestCase
from ..denoise import minimize_noise, restore_noise


class DenoiseTest(ReBenchTestCase):

def setUp(self):
super(DenoiseTest, self).setUp()
self._set_path(__file__)

def test_minimize(self):
result = minimize_noise(False, self._ui)
self.assertIsInstance(result.succeeded, bool)
self.assertIsInstance(result.use_nice, bool)
self.assertIsInstance(result.use_shielding, bool)

# if it was successful, try to restore normal settings
if result.succeeded:
restore_noise(result, False, self._ui)