Skip to content

Commit

Permalink
Support endpoint with '/' at the end.
Browse files Browse the repository at this point in the history
1. Support endpoint with '/' at the end.
2. Change the doc in config.py for tests and examples.
  • Loading branch information
pengfei0107 committed Aug 14, 2020
1 parent b3c0f28 commit 1cc4a67
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
6 changes: 4 additions & 2 deletions examples/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
4 changes: 3 additions & 1 deletion src/borneo/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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
Expand Down
6 changes: 4 additions & 2 deletions test/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions test/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 1cc4a67

Please sign in to comment.