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
+40
-10
No files matched your search
@@ -78,6 +78,7 @@ urlpatterns = [
|
||||
django.urls.path(r'clientSubmitNPS/', OpenBench.views.client_submit_nps),
|
||||
django.urls.path(r'clientSubmitError/', OpenBench.views.client_submit_error),
|
||||
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
|
||||
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.core.files.storage import FileSystemStorage
|
||||
from django.core.files.base import ContentFile
|
||||
from django.utils import timezone
|
||||
|
||||
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
||||
# GENERAL UTILITIES #
|
||||
@@ -745,6 +746,19 @@ def client_submit_results(request):
|
||||
# Returns {}, or { 'stop' : True }
|
||||
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])
|
||||
|
||||
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
||||
# #
|
||||
|
||||
Reference in new issue
Block a user