-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: sklearnserver integration (#11)
* feat: sklearnserver rock integration Summary of changes: - Added ROCK integrity tests. - Updated ROCK image definition. - Added tox with unit and integration tests. - Addressed review comments. - Modified to run tests. - Added handling of jinja2 templating - Updated tox.ini to properly update configmap template. - Updated rockcraft.yaml with new run-user option to run as non-root. canonical/seldon-core-operator#133 - Updated import procedure. - Tested with integration tests on the branch. - Reverted to use of shell commands and `yq` instead of CheckRock test class from chisme package. - Remove chisme package NOTE: Use of bash shell commands significantly reduces maintability of tox.ini ACK: @kimwnasptd
- Loading branch information
Showing
3 changed files
with
69 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Copyright 2022 Canonical Ltd. | ||
# See LICENSE file for licensing details. | ||
# | ||
# Tests for required artifacts to be present in the ROCK image. | ||
# | ||
|
||
from charmed_kubeflow_chisme.rock import CheckRock | ||
from pathlib import Path | ||
|
||
import os | ||
import logging | ||
import random | ||
import pytest | ||
import string | ||
import subprocess | ||
import yaml | ||
from pytest_operator.plugin import OpsTest | ||
|
||
@pytest.fixture() | ||
def rock_test_env(): | ||
"""Yields a temporary directory and random docker container name, then cleans them up after.""" | ||
container_name = "".join([str(i) for i in random.choices(string.ascii_lowercase, k=8)]) | ||
yield container_name | ||
|
||
try: | ||
subprocess.run(["docker", "rm", container_name]) | ||
except Exception: | ||
pass | ||
|
||
@pytest.mark.abort_on_fail | ||
def test_rock(ops_test: OpsTest, rock_test_env): | ||
"""Test rock.""" | ||
check_rock = CheckRock("rockcraft.yaml") | ||
container_name = rock_test_env | ||
LOCAL_ROCK_IMAGE = f"{check_rock.get_image_name()}:{check_rock.get_version()}" | ||
|
||
# verify that all artifacts are in correct locations | ||
subprocess.run(["docker", "run", LOCAL_ROCK_IMAGE, "exec", "ls", "-la", "/microservice/SKLearnServer.py"], check=True) | ||
|
||
# verify that rockcraft.yaml contains correct image name for PREDICTIVE_UNIT_IMAGE environment variable | ||
#assert CheckRock.get_environment()["PREDICTIVE_UNIT_IMAGE"].contains(LOCAL_ROCK_IMAGE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters