diff --git a/locust_benchmark/create_feature_group.py b/locust_benchmark/create_feature_group.py index b61a69a41..2ac6cf568 100644 --- a/locust_benchmark/create_feature_group.py +++ b/locust_benchmark/create_feature_group.py @@ -1,7 +1,6 @@ from common.hopsworks_client import HopsworksClient if __name__ == "__main__": - hopsworks_client = HopsworksClient() fg = hopsworks_client.get_or_create_fg() hopsworks_client.insert_data(fg) diff --git a/python/tests/client/test_base_client.py b/python/tests/client/test_base_client.py index 1b16ce4b3..e7a6deec3 100644 --- a/python/tests/client/test_base_client.py +++ b/python/tests/client/test_base_client.py @@ -15,6 +15,7 @@ # import os +from functools import wraps import pytest import requests @@ -22,7 +23,21 @@ from hsfs.client.exceptions import RestAPIError +def changes_environ(f): + @wraps(f) + def g(*args, **kwds): + old_environ = os.environ.copy() + try: + return f(*args, **kwds) + finally: + os.environ.clear() + os.environ.update(old_environ) + + return g + + class TestBaseClient: + @changes_environ def test_valid_token_no_retires(self, mocker): # Arrange os.environ[Client.REST_ENDPOINT] = "True" @@ -48,6 +63,7 @@ def test_valid_token_no_retires(self, mocker): # Assert assert spy_retry_token_expired.call_count == 0 + @changes_environ def test_invalid_token_retires(self, mocker): # Arrange os.environ[Client.REST_ENDPOINT] = "True" @@ -77,6 +93,7 @@ def test_invalid_token_retires(self, mocker): # Assert assert spy_retry_token_expired.call_count == 10 + @changes_environ def test_invalid_token_retires_backoff_break(self, mocker): # Arrange os.environ[Client.REST_ENDPOINT] = "True"