Skip to content

Commit

Permalink
Remove PERSISTENCE from python: Unit testing
Browse files Browse the repository at this point in the history
  • Loading branch information
nadinet authored and axsaucedo committed Apr 7, 2021
1 parent a758d81 commit 0c65d92
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 13 deletions.
5 changes: 2 additions & 3 deletions python/seldon_core/microservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,9 +352,8 @@ def main():
user_class = getattr(interface_file, parts[1])

if args.persistence:
logger.error(f"persistence is not supported")
else:
user_object = user_class(**parameters)
logger.error(f"persistence: ignored, persistence is deprecated")
user_object = user_class(**parameters)

http_port = args.http_port
grpc_port = args.grpc_port
Expand Down
20 changes: 10 additions & 10 deletions python/tests/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,16 @@ def __init__(self, app_location, envs={}, tracing=False):

def _env_vars(self, envs):
env_vars = dict(os.environ)
s2i_env_file = os.path.join(self.app_location, ".s2i", "environment")
with open(s2i_env_file) as fh:
for line in fh.readlines():
line = line.strip()
if line:
key, value = line.split("=", 1)
key, value = key.strip(), value.strip()
if key and value:
env_vars[key] = value

env_vars.update(envs)
env_vars.update(
{
Expand All @@ -36,16 +46,6 @@ def _env_vars(self, envs):
}
)

s2i_env_file = os.path.join(self.app_location, ".s2i", "environment")
with open(s2i_env_file) as fh:
for line in fh.readlines():
line = line.strip()
if line:
key, value = line.split("=", 1)
key, value = key.strip(), value.strip()
if key and value:
env_vars[key] = value

return env_vars

def _get_cmd(self, tracing):
Expand Down
9 changes: 9 additions & 0 deletions python/tests/test_microservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,3 +249,12 @@ def test_load_annotations(mock_isfile):
def test_health_status(microservice):
response = requests.get("http://127.0.0.1:9000/health/status")
response.raise_for_status()


@pytest.mark.parametrize(
"microservice", [{"envs": {"PERSISTENCE": "1"}}], indirect=True
)
def test_persistence_flag_exist(microservice):
response = requests.get("http://127.0.0.1:9000/health/status")
# This just tests that persistence flag was not removed ("soft" deprecation)
response.raise_for_status()

0 comments on commit 0c65d92

Please sign in to comment.