Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor test fixes #71

Merged
merged 3 commits into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ test/runtester.ready:
mock:
docker build -t mock_app ./test/mock_app

testimage:
docker pull kbase/runtester
docker tag kbase/runtester test/runtester


test:
nosetests -A "not online" -s -x -v --with-coverage --cover-package=JobRunner --cover-erase --cover-html --cover-html-dir=./test_coverage --nocapture --nologcapture .

Expand Down
9 changes: 7 additions & 2 deletions test/mock_data.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import os


_IMAGE = "dockerhub-prod.kbase.us/kbase:rast_sdk."
_IMAGE += "50b012d9b41b71ba31b30355627cf85f2611bc3e"
_BASE = u"https://ci.kbase.us/services/"

ref_data = os.environ.get("KB_REF_DATA", "/kb/data")

CATALOG_GET_MODULE_VERSION = {
"registration_id": "1553870236585_bab74ed6-4699-47b5-b865-d7130b90f542",
"release_timestamp": 1554153143124,
Expand Down Expand Up @@ -58,8 +63,8 @@
u"ee.server.version": u"0.2.11",
u"handle-url": _BASE + u"handle_service",
u"kbase-endpoint": u"https://ci.kbase.us/services",
u"ref.data.base": u"/kb/data",
u"ref_data_base": u"/kb/data",
u"ref.data.base": ref_data,
u"ref_data_base": ref_data,
u"external-url": _BASE + u"ee2",
u"shock-url": _BASE + u"shock-api",
u"srv.wiz.url": _BASE + u"service_wizard",
Expand Down
29 changes: 7 additions & 22 deletions test/test_methodrunner.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def setUpClass(cls):
"auth-service-url-v2": base,
"external-url": base,
"srv-wiz-url" : base,
"ref_data_base": "/kb/data",
"ref_data_base": os.environ.get("KB_REF_DATA", "/kb/data"),
"auth-service-url-allow-insecure": True,
"scratch": "/kb/module/work/tmp",
"user": "mrbogus",
Expand All @@ -80,10 +80,7 @@ def test_run(self):
mr = MethodRunner(self.cfg, "1234", logger=MockLogger())
module_info = deepcopy(CATALOG_GET_MODULE_VERSION)
module_info["docker_img_name"] = "mock_app:latest"
try:
os.makedirs("/tmp/mr/")
except:
pass
os.makedirs("/tmp/mr/", exist_ok=True)
q = Queue()
action = mr.run(self.conf, module_info, EE2_JOB_PARAMS, "1234", fin_q=q)
self.assertIn("name", action)
Expand All @@ -95,10 +92,7 @@ def test_no_output(self):
mr = MethodRunner(self.cfg, "1234", logger=MockLogger())
module_info = deepcopy(CATALOG_GET_MODULE_VERSION)
module_info["docker_img_name"] = "mock_app:latest"
try:
os.makedirs("/tmp/mr/")
except:
pass
os.makedirs("/tmp/mr/", exist_ok=True)
if os.path.exists("/tmp/mr/workdir/output.json"):
os.remove("/tmp/mr/workdir/output.json")
q = Queue()
Expand All @@ -117,10 +111,7 @@ def test_too_much_output(self):
mr = MethodRunner(self.cfg, "1234", logger=MockLogger())
module_info = deepcopy(CATALOG_GET_MODULE_VERSION)
module_info["docker_img_name"] = "mock_app:latest"
try:
os.makedirs("/tmp/mr/")
except:
pass
os.makedirs("/tmp/mr/", exist_ok=True)
if os.path.exists("/tmp/mr/workdir/output.json"):
os.remove("/tmp/mr/workdir/output.json")
q = Queue()
Expand All @@ -141,28 +132,22 @@ def test_secure_params(self):
module_info = deepcopy(CATALOG_GET_MODULE_VERSION)
module_info["docker_img_name"] = "mock_app:latest"
module_info["secure_config_params"] = CATALOG_GET_SECURE_CONFIG_PARAMS
try:
os.makedirs("/tmp/mr/")
except:
pass
os.makedirs("/tmp/mr/", exist_ok=True)
if os.path.exists("/tmp/mr/workdir/output.json"):
os.remove("/tmp/mr/workdir/output.json")
q = Queue()
params = deepcopy(EE2_JOB_PARAMS)
params["method"] = "echo_test.bogus"
mockrunner = MockRunner()
mr.runner = mockrunner
action = mr.run(self.conf, module_info, params, "1234", fin_q=q)
mr.run(self.conf, module_info, params, "1234", fin_q=q)
self.assertIn("KBASE_SECURE_CONFIG_PARAM_param1", mockrunner.env)

def test_bad_method(self):
mr = MethodRunner(self.cfg, "1234", logger=MockLogger())
module_info = deepcopy(CATALOG_GET_MODULE_VERSION)
module_info["docker_img_name"] = "mock_app:latest"
try:
os.makedirs("/tmp/mr/")
except:
pass
os.makedirs("/tmp/mr/", exist_ok=True)
if os.path.exists("/tmp/mr/workdir/output.json"):
os.remove("/tmp/mr/workdir/output.json")
q = Queue()
Expand Down