Add a heartbeat to the Client
Hits /clientHeartbeat/ when no data exists to report May return a stop header to abort the workload
This commit is contained in:
1 parent
26936a0610
commit
b3f8cc67af
4 files changed
+38
-8
No files matched your search
+22
-8
@@ -385,6 +385,15 @@ class ServerReporter:
|
|||||||
|
|
||||||
return ServerReporter.report(config, 'clientSubmitResults', payload)
|
return ServerReporter.report(config, 'clientSubmitResults', payload)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def report_heartbeat(config):
|
||||||
|
|
||||||
|
payload = {
|
||||||
|
'test_id' : config.workload['test']['id']
|
||||||
|
}
|
||||||
|
|
||||||
|
return ServerReporter.report(config, 'clientHeartbeat', payload)
|
||||||
|
|
||||||
class Cutechess:
|
class Cutechess:
|
||||||
|
|
||||||
## Handles building the very long string of arguments that need to be passed
|
## Handles building the very long string of arguments that need to be passed
|
||||||
@@ -629,8 +638,8 @@ class ResultsReporter(object):
|
|||||||
if result:
|
if result:
|
||||||
self.pending.append(result)
|
self.pending.append(result)
|
||||||
|
|
||||||
# Send results every 30 seconds, until all Tasks are done
|
# Send results, or a heartbeat, every REPORT_INTERVAL seconds until done
|
||||||
if not self.bulk and self.send_results(report_interval=REPORT_INTERVAL):
|
if self.send_results(report_interval=REPORT_INTERVAL):
|
||||||
return
|
return
|
||||||
|
|
||||||
# Kill everything if openbench.exit is created
|
# Kill everything if openbench.exit is created
|
||||||
@@ -646,19 +655,24 @@ class ResultsReporter(object):
|
|||||||
break
|
break
|
||||||
|
|
||||||
# Send any remaining results immediately
|
# Send any remaining results immediately
|
||||||
self.send_results(report_interval=0)
|
self.send_results(report_interval=0, final_report=True)
|
||||||
|
|
||||||
def send_results(self, report_interval):
|
def send_results(self, report_interval, final_report=False):
|
||||||
|
|
||||||
# Nothing to send, or we are sending too frequently
|
# Do not send more often than report_interval dictates
|
||||||
if not self.pending or self.last_report + report_interval > time.time():
|
if self.last_report + report_interval > time.time():
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# Most recent time we sent a report is now
|
# Most recent time we attempted to sent a report is now
|
||||||
self.last_report = time.time()
|
self.last_report = time.time()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Send all of the queued Results at once
|
|
||||||
|
# Heartbeat when no results, or still awaiting bulk results
|
||||||
|
if not self.pending or (self.bulk and not final_report):
|
||||||
|
response = ServerReporter.report_heartbeat(self.config).json()
|
||||||
|
|
||||||
|
else: # Send all of the queued Results at once
|
||||||
response = ServerReporter.report_results(self.config, self.pending).json()
|
response = ServerReporter.report_results(self.config, self.pending).json()
|
||||||
self.pending = []
|
self.pending = []
|
||||||
|
|
||||||
|
|||||||
@@ -78,6 +78,7 @@ urlpatterns = [
|
|||||||
django.urls.path(r'clientSubmitNPS/', OpenBench.views.client_submit_nps),
|
django.urls.path(r'clientSubmitNPS/', OpenBench.views.client_submit_nps),
|
||||||
django.urls.path(r'clientSubmitError/', OpenBench.views.client_submit_error),
|
django.urls.path(r'clientSubmitError/', OpenBench.views.client_submit_error),
|
||||||
django.urls.path(r'clientSubmitResults/', OpenBench.views.client_submit_results),
|
django.urls.path(r'clientSubmitResults/', OpenBench.views.client_submit_results),
|
||||||
|
django.urls.path(r'clientHeartbeat/', OpenBench.views.client_heartbeat),
|
||||||
|
|
||||||
# Nice endpoints, which can be hit from the website or with credentials cleanly
|
# Nice endpoints, which can be hit from the website or with credentials cleanly
|
||||||
django.urls.path(r'api/config/', OpenBench.views.api_configs),
|
django.urls.path(r'api/config/', OpenBench.views.api_configs),
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ from django.http import HttpResponse, JsonResponse
|
|||||||
from django.views.decorators.csrf import csrf_exempt
|
from django.views.decorators.csrf import csrf_exempt
|
||||||
from django.core.files.storage import FileSystemStorage
|
from django.core.files.storage import FileSystemStorage
|
||||||
from django.core.files.base import ContentFile
|
from django.core.files.base import ContentFile
|
||||||
|
from django.utils import timezone
|
||||||
|
|
||||||
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
||||||
# GENERAL UTILITIES #
|
# GENERAL UTILITIES #
|
||||||
@@ -745,6 +746,19 @@ def client_submit_results(request):
|
|||||||
# Returns {}, or { 'stop' : True }
|
# Returns {}, or { 'stop' : True }
|
||||||
return JsonResponse(OpenBench.utils.update_test(request, machine))
|
return JsonResponse(OpenBench.utils.update_test(request, machine))
|
||||||
|
|
||||||
|
@csrf_exempt
|
||||||
|
def client_heartbeat(request):
|
||||||
|
|
||||||
|
# Pass along any error messages if they appear
|
||||||
|
machine, response = client_verify_worker(request)
|
||||||
|
if response != None: return response
|
||||||
|
|
||||||
|
# Force a refresh of the updated timestamp
|
||||||
|
machine.save()
|
||||||
|
|
||||||
|
# Include a 'stop' header iff the test was finished
|
||||||
|
test = Test.objects.get(id=int(request.POST['test_id']))
|
||||||
|
return JsonResponse([{}, { 'stop' : True }][test.finished])
|
||||||
|
|
||||||
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
||||||
# #
|
# #
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
<tr><td class="td-label">Client Version</td><td>{{machine.info.client_ver}}</td></tr>
|
<tr><td class="td-label">Client Version</td><td>{{machine.info.client_ver}}</td></tr>
|
||||||
<tr><td class="td-label">Python Version</td><td>{{machine.info.python_ver}}</td></tr>
|
<tr><td class="td-label">Python Version</td><td>{{machine.info.python_ver}}</td></tr>
|
||||||
<tr><td class="td-label">System Version</td><td>{{machine.info.os_name}} {{machine.info.os_ver}}</td></tr>
|
<tr><td class="td-label">System Version</td><td>{{machine.info.os_name}} {{machine.info.os_ver}}</td></tr>
|
||||||
|
<tr><td class="td-label">Last Seen</td><td class="timestamp">{{machine.updated|date:'U'}}</td>
|
||||||
|
|
||||||
<tr><td class="td-label"></td><td><br></td></tr>
|
<tr><td class="td-label"></td><td><br></td></tr>
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user