From 1cc4a67c7c4afc7cc88cf8518612b57b20f66446 Mon Sep 17 00:00:00 2001 From: Fei Peng Date: Fri, 14 Aug 2020 13:37:15 +0800 Subject: [PATCH] Support endpoint with '/' at the end. 1. Support endpoint with '/' at the end. 2. Change the doc in config.py for tests and examples. --- examples/config.py | 6 ++++-- src/borneo/config.py | 4 +++- test/config.py | 6 ++++-- test/query.py | 3 +-- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/examples/config.py b/examples/config.py index 2865ed5..f302cea 100644 --- a/examples/config.py +++ b/examples/config.py @@ -12,12 +12,14 @@ # # The default settings below are sufficient if the Cloud Simulator has been # started on the endpoint, localhost:8080, which is its default. If not, the -# parameters in this file should be changed as needed. +# parameters in this file should be changed as needed. Please see sample config +# options in: config_cloudsim.py, config_onprem.py and config_cloud.py, change +# the parameters in those files, then copy the content to this file. # # The endpoint to use to connect to the service. This endpoint is for a Cloud # Simulator running on its default port (8080) on the local machine. endpoint = 'localhost:8080' -# The server type, please don't change it. +# The server type. server_type = 'cloudsim' diff --git a/src/borneo/config.py b/src/borneo/config.py index 54db665..8a05c23 100644 --- a/src/borneo/config.py +++ b/src/borneo/config.py @@ -1212,7 +1212,7 @@ def create_url(endpoint, path): # Strip out any slashes if the format was protocol://host[:port] if host.startswith('//'): - host = host[2:] + host = host.lstrip('/') if protocol != 'http' and protocol != 'https': raise IllegalArgumentException( @@ -1223,6 +1223,8 @@ def create_url(endpoint, path): def validate_port(endpoint, portstring): # Check that a port is a valid, non negative integer. try: + # Strip out any slashes after the port string. + portstring = portstring.rstrip('/') port = int(portstring) CheckValue.check_int_ge_zero(port, 'port') return port diff --git a/test/config.py b/test/config.py index 26e4f94..8a238d2 100644 --- a/test/config.py +++ b/test/config.py @@ -13,14 +13,16 @@ # # The default settings below are sufficient if the Cloud Simulator has been # started on the endpoint, localhost:8080, which is its default. If not, the -# parameters in this file should be changed as needed. +# parameters in this file should be changed as needed. Please see sample config +# options in: config_cloudsim.py and config_onprem.py, change the parameters +# in those files, then copy the content to this file. # # The endpoint to use to connect to the service. This endpoint is for a Cloud # Simulator running on its default port (8080) on the local machine. endpoint = 'localhost:8080' -# The server type, please don't change it. +# The server type. server_type = 'cloudsim' # Cloud Simulator version. Use None to test with the latest Cloud Simulator diff --git a/test/query.py b/test/query.py index 514402d..2880c0b 100644 --- a/test/query.py +++ b/test/query.py @@ -253,8 +253,7 @@ def testQueryStatementSelectWithMaxReadKb(self): self.query_request.set_statement(query_statement).set_max_read_kb( max_read_kb) result = self.handle.query(self.query_request) - if (is_onprem() and version is not None and - compare_version(version, '20.2.0') == -1): + if is_onprem(): records = self.check_query_result(result, num_records) else: records = self.check_query_result(result, max_read_kb + 1, True)