diff options
author | Mathew Robinson <chasinglogic@gmail.com> | 2019-02-19 10:50:57 -0500 |
---|---|---|
committer | Mathew Robinson <chasinglogic@gmail.com> | 2019-04-08 14:08:49 -0400 |
commit | 8dd6d4755734ed37c1b98dfdefce3ca6bc65f1f6 (patch) | |
tree | 69e936c4953cbead2e3bae2690157c5fe75e709d /jstests/free_mon | |
parent | c600aa9d7423eca8151daf626e2799d9a6c7b31c (diff) | |
download | mongo-8dd6d4755734ed37c1b98dfdefce3ca6bc65f1f6.tar.gz |
SERVER-32295 Support Python 3
Diffstat (limited to 'jstests/free_mon')
-rw-r--r-- | jstests/free_mon/libs/mock_http_common.py | 1 | ||||
-rw-r--r-- | jstests/free_mon/libs/mock_http_control.py | 1 | ||||
-rw-r--r-- | jstests/free_mon/libs/mock_http_server.py | 34 |
3 files changed, 20 insertions, 16 deletions
diff --git a/jstests/free_mon/libs/mock_http_common.py b/jstests/free_mon/libs/mock_http_common.py index fe4c428ef6f..14cc6ba5a21 100644 --- a/jstests/free_mon/libs/mock_http_common.py +++ b/jstests/free_mon/libs/mock_http_common.py @@ -7,6 +7,7 @@ URL_PATH_LAST_METRICS = "/last_metrics" URL_DISABLE_FAULTS = "/disable_faults" URL_ENABLE_FAULTS = "/enable_faults" + class Stats: """Stats class shared between client and server.""" diff --git a/jstests/free_mon/libs/mock_http_control.py b/jstests/free_mon/libs/mock_http_control.py index 8f2469155cb..778450dd374 100644 --- a/jstests/free_mon/libs/mock_http_control.py +++ b/jstests/free_mon/libs/mock_http_control.py @@ -11,6 +11,7 @@ import urllib.request import mock_http_common + def main(): """Main entry point.""" parser = argparse.ArgumentParser(description='MongoDB Mock Free Monitoring Endpoint.') diff --git a/jstests/free_mon/libs/mock_http_server.py b/jstests/free_mon/libs/mock_http_server.py index f6ce1a39299..c5609c8fe35 100644 --- a/jstests/free_mon/libs/mock_http_server.py +++ b/jstests/free_mon/libs/mock_http_server.py @@ -23,22 +23,16 @@ last_metrics = None last_register = None disable_faults = False fault_type = None - """Fault which causes the server to return an HTTP failure on register.""" FAULT_FAIL_REGISTER = "fail_register" - """Fault which causes the server to return a response with a document with a bad version.""" FAULT_INVALID_REGISTER = "invalid_register" - """Fault which causes metrics to return halt after 5 metric uploads have occurred.""" FAULT_HALT_METRICS_5 = "halt_metrics_5" - """Fault which causes metrics to return permanentlyDelete = true after 3 uploads.""" FAULT_PERMANENTLY_DELETE_AFTER_3 = "permanently_delete_after_3" - """Fault which causes metrics to trigger resentRegistration at 3 uploads.""" FAULT_RESEND_REGISTRATION_AT_3 = "resend_registration_at_3" - """Fault which causes metrics to trigger resentRegistration once.""" FAULT_RESEND_REGISTRATION_ONCE = "resend_registration_once" @@ -132,14 +126,20 @@ class FreeMonHandler(http.server.BaseHTTPRequestHandler): }) else: data = bson.BSON.encode({ - 'version': bson.int64.Int64(1), - 'haltMetricsUploading': False, - 'id': 'mock123', - 'informationalURL': 'http://www.example.com/123', - 'message': 'Welcome to the Mock Free Monitoring Endpoint', - 'reportingInterval': bson.int64.Int64(1), + 'version': + bson.int64.Int64(1), + 'haltMetricsUploading': + False, + 'id': + 'mock123', + 'informationalURL': + 'http://www.example.com/123', + 'message': + 'Welcome to the Mock Free Monitoring Endpoint', + 'reportingInterval': + bson.int64.Int64(1), 'userReminder': -"""To see your monitoring data, navigate to the unique URL below. + """To see your monitoring data, navigate to the unique URL below. Anyone you share the URL with will also be able to view this page. https://localhost:8080/someUUID6v5jLKTIZZklDvN5L8sZ @@ -196,7 +196,7 @@ You can disable monitoring at any time by running db.disableFreeMonitoring().""" 'id': 'mock123', 'reportingInterval': bson.int64.Int64(1), 'message': 'Thanks for all the metrics', - 'resendRegistration' : True, + 'resendRegistration': True, }) elif not disable_faults and \ stats.metrics_calls == 3 and fault_type == FAULT_RESEND_REGISTRATION_AT_3: @@ -208,7 +208,7 @@ You can disable monitoring at any time by running db.disableFreeMonitoring().""" 'id': 'mock123', 'reportingInterval': bson.int64.Int64(1), 'message': 'Thanks for all the metrics', - 'resendRegistration' : True, + 'resendRegistration': True, }) else: data = bson.BSON.encode({ @@ -250,6 +250,7 @@ You can disable monitoring at any time by running db.disableFreeMonitoring().""" disable_faults = False self._send_header() + def run(port, server_class=http.server.HTTPServer, handler_class=FreeMonHandler): """Run web server.""" server_address = ('', port) @@ -284,7 +285,8 @@ def main(): if args.fault: if args.fault not in SUPPORTED_FAULT_TYPES: - print("Unsupported fault type %s, supports types are %s" % (args.fault, SUPPORTED_FAULT_TYPES)) + print("Unsupported fault type %s, supports types are %s" % (args.fault, + SUPPORTED_FAULT_TYPES)) sys.exit(1) fault_type = args.fault |