Skip to content

Commit

Permalink
Default to time.time() on POSIX
Browse files Browse the repository at this point in the history
  • Loading branch information
mattjala committed Apr 16, 2024
1 parent 2a7f57a commit 102c25d
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 60 deletions.
6 changes: 0 additions & 6 deletions admin/docker/docker-compose-internal-lb.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ services:
- NODE_TYPE=dn
- AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}
- AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}
- MAX_SCAN_DURATION=${MAX_SCAN_DURATION}
- FLUSH_TIMEOUT=${FLUSH_TIMEOUT}
- FLUSH_SLEEP_INTERVAL=${FLUSH_SLEEP_INTERVAL}
ports:
- ${DN_PORT}
logging:
Expand All @@ -50,9 +47,6 @@ services:
- AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}
- AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}
- HSDS_ENDPOINT=${HSDS_ENDPOINT}
- MAX_SCAN_DURATION=${MAX_SCAN_DURATION}
- FLUSH_TIMEOUT=${FLUSH_TIMEOUT}
- FLUSH_SLEEP_INTERVAL=${FLUSH_SLEEP_INTERVAL}

ports:
- ${SN_PORT_RANGE}:${SN_PORT}
Expand Down
6 changes: 0 additions & 6 deletions admin/docker/docker-compose.aws.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@ services:
- AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}
- BUCKET_NAME=${BUCKET_NAME}
- LOG_LEVEL=${LOG_LEVEL}
- MAX_SCAN_DURATION=${MAX_SCAN_DURATION}
- FLUSH_TIMEOUT=${FLUSH_TIMEOUT}
- FLUSH_SLEEP_INTERVAL=${FLUSH_SLEEP_INTERVAL}
ports:
- ${DN_PORT}
depends_on:
Expand All @@ -57,9 +54,6 @@ services:
- BUCKET_NAME=${BUCKET_NAME}
- LOG_LEVEL=${LOG_LEVEL}
- HSDS_ENDPOINT=${HSDS_ENDPOINT}
- MAX_SCAN_DURATION=${MAX_SCAN_DURATION}
- FLUSH_TIMEOUT=${FLUSH_TIMEOUT}
- FLUSH_SLEEP_INTERVAL=${FLUSH_SLEEP_INTERVAL}
ports:
- ${SN_PORT_RANGE}:${SN_PORT}
depends_on:
Expand Down
6 changes: 0 additions & 6 deletions admin/docker/docker-compose.azure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ services:
- AZURE_CONNECTION_STRING=${AZURE_CONNECTION_STRING}
- BUCKET_NAME=${BUCKET_NAME}
- LOG_LEVEL=${LOG_LEVEL}
- MAX_SCAN_DURATION=${MAX_SCAN_DURATION}
- FLUSH_TIMEOUT=${FLUSH_TIMEOUT}
- FLUSH_SLEEP_INTERVAL=${FLUSH_SLEEP_INTERVAL}
ports:
- ${DN_PORT}
depends_on:
Expand All @@ -48,9 +45,6 @@ services:
- BUCKET_NAME=${BUCKET_NAME}
- LOG_LEVEL=${LOG_LEVEL}
- HSDS_ENDPOINT=${HSDS_ENDPOINT}
- MAX_SCAN_DURATION=${MAX_SCAN_DURATION}
- FLUSH_TIMEOUT=${FLUSH_TIMEOUT}
- FLUSH_SLEEP_INTERVAL=${FLUSH_SLEEP_INTERVAL}
ports:
- ${SN_PORT_RANGE}:${SN_PORT}
depends_on:
Expand Down
8 changes: 0 additions & 8 deletions admin/docker/docker-compose.posix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@ services:
- NODE_TYPE=dn
- ROOT_DIR=/data
- BUCKET_NAME=${BUCKET_NAME}
- LOG_LEVEL=${LOG_LEVEL}
- MAX_SCAN_DURATION=${MAX_SCAN_DURATION}
- FLUSH_TIMEOUT=${FLUSH_TIMEOUT}
- FLUSH_SLEEP_INTERVAL=${FLUSH_SLEEP_INTERVAL}
ports:
- ${DN_PORT}
depends_on:
Expand All @@ -47,10 +43,6 @@ services:
- ROOT_DIR=/data
- BUCKET_NAME=${BUCKET_NAME}
- HSDS_ENDPOINT=${HSDS_ENDPOINT}
- LOG_LEVEL=${LOG_LEVEL}
- MAX_SCAN_DURATION=${MAX_SCAN_DURATION}
- FLUSH_TIMEOUT=${FLUSH_TIMEOUT}
- FLUSH_SLEEP_INTERVAL=${FLUSH_SLEEP_INTERVAL}
ports:
- ${SN_PORT_RANGE}:${SN_PORT}
depends_on:
Expand Down
6 changes: 0 additions & 6 deletions admin/docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@ services:
- AZURE_CONNECTION_STRING=${AZURE_CONNECTION_STRING}
- BUCKET_NAME=${BUCKET_NAME}
- LOG_LEVEL=${LOG_LEVEL}
- MAX_SCAN_DURATION=${MAX_SCAN_DURATION}
- FLUSH_TIMEOUT=${FLUSH_TIMEOUT}
- FLUSH_SLEEP_INTERVAL=${FLUSH_SLEEP_INTERVAL}
ports:
- ${DN_PORT}
depends_on:
Expand All @@ -57,9 +54,6 @@ services:
- BUCKET_NAME=${BUCKET_NAME}
- LOG_LEVEL=${LOG_LEVEL}
- HSDS_ENDPOINT=${HSDS_ENDPOINT}
- MAX_SCAN_DURATION=${MAX_SCAN_DURATION}
- FLUSH_TIMEOUT=${FLUSH_TIMEOUT}
- FLUSH_SLEEP_INTERVAL=${FLUSH_SLEEP_INTERVAL}
ports:
- ${SN_PORT_RANGE}:${SN_PORT}
depends_on:
Expand Down
15 changes: 14 additions & 1 deletion hsds/util/timeUtil.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
##############################################################################
from datetime import datetime
import time
import os
import pytz


Expand Down Expand Up @@ -67,4 +68,16 @@ def getNow(app):
Returns a precise timestamp even on platforms where
time.time() has low resolution (e.g. Windows)
"""
return (time.perf_counter() - app["start_time_relative"]) + app["start_time"]
system = os.name
current_time = 0

if system == "nt":
# Windows
current_time = (time.perf_counter() - app["start_time_relative"]) + app["start_time"]
elif system == "posix":
# Unix
current_time = time.time()
else:
raise ValueError(f"Unsupported OS: {system}")

return current_time
22 changes: 0 additions & 22 deletions tests/integ/broadcast_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,28 +36,6 @@ def getRootUUID(self, domain, username=None, password=None):
domain, username=username, password=password, session=self.session
)

def checkVerbose(self, dset_id, headers=None, expected=None):
# do a flush with rescan, then check the expected return values are correct
req = f"{self.endpoint}/"
params = {"flush": 1, "rescan": 1}
rsp = self.session.put(req, params=params, headers=headers)
# should get a NO_CONTENT code,
self.assertEqual(rsp.status_code, 204)

# do a get and verify the additional keys are
req = f"{self.endpoint}/datasets/{dset_id}"
params = {"verbose": 1}

rsp = self.session.get(req, params=params, headers=headers)
self.assertEqual(rsp.status_code, 200)
rspJson = json.loads(rsp.text)

for k in expected:
self.assertTrue(k in rspJson)
self.assertEqual(rspJson[k], expected[k])

# main

def testPut1DDataset(self):
# Test PUT value with broadcast for 1d dataset
print("testPut1DDataset", self.base_domain)
Expand Down
13 changes: 8 additions & 5 deletions tests/integ/value_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,16 @@ def getRootUUID(self, domain, username=None, password=None):

def checkVerbose(self, dset_id, headers=None, expected=None):
# do a flush with rescan, then check the expected return values are correct
num_retries = 5
req = f"{self.endpoint}/"
params = {"flush": 1, "rescan": 1}
rsp = self.session.put(req, params=params, headers=headers)
# should get a NO_CONTENT code,
self.assertEqual(rsp.status_code, 204)
for i in range(num_retries):
rsp = self.session.put(req, params=params, headers=headers)
if (rsp.status_code == 503):
# Retry
continue
# should get a NO_CONTENT code
self.assertEqual(rsp.status_code, 204)

# do a get and verify the additional keys are
req = f"{self.endpoint}/datasets/{dset_id}"
Expand All @@ -58,8 +63,6 @@ def checkVerbose(self, dset_id, headers=None, expected=None):
self.assertTrue(k in rspJson)
self.assertEqual(rspJson[k], expected[k])

# main

def testPut1DDataset(self):
# Test PUT value for 1d dataset
print("testPut1DDataset", self.base_domain)
Expand Down

0 comments on commit 102c25d

Please sign in to comment.