Skip to content

Commit

Permalink
mock skydriver.k8s.scanner_instance.SkymapScannerStopperJob.do_job
Browse files Browse the repository at this point in the history
  • Loading branch information
ric-evans committed Jun 13, 2023
1 parent f0b8620 commit 89b6536
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion skydriver/k8s/scanner_instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ def __init__(
ENV.K8S_NAMESPACE,
)

def start_job(self) -> Any:
def do_job(self) -> Any:
"""Start the k8s job."""

# TODO: stop first k8s job (server & clientmanager-starter)
Expand Down
2 changes: 1 addition & 1 deletion skydriver/rest_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ async def stop_scanner_instance(
)

try:
k8s_job.start_job()
k8s_job.do_job()
except kubernetes.client.exceptions.ApiException as e:
LOGGER.exception(e)
raise web.HTTPError(
Expand Down
3 changes: 3 additions & 0 deletions tests/integration/test_backlog_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ def client() -> RestClient:
N_JOBS = 5


@mock.patch("skydriver.k8s.scanner_instance.SkymapScannerStopperJob.do_job", new=Mock())
@mock.patch("skydriver.k8s.utils.KubeAPITools.start_job")
async def test_00(kapitsj_mock: Mock, server: Callable[[], RestClient]) -> None:
"""Test backlog job starting."""
Expand All @@ -102,6 +103,7 @@ async def test_00(kapitsj_mock: Mock, server: Callable[[], RestClient]) -> None:
print_it(await rc.request("GET", "/scans/backlog"))


@mock.patch("skydriver.k8s.scanner_instance.SkymapScannerStopperJob.do_job", new=Mock())
@mock.patch("skydriver.k8s.utils.KubeAPITools.start_job")
async def test_01(kapitsj_mock: Mock, server: Callable[[], RestClient]) -> None:
"""Test backlog job starting with multiple."""
Expand All @@ -125,6 +127,7 @@ async def test_01(kapitsj_mock: Mock, server: Callable[[], RestClient]) -> None:
print_it(await rc.request("GET", "/scans/backlog"))


@mock.patch("skydriver.k8s.scanner_instance.SkymapScannerStopperJob.do_job", new=Mock())
@mock.patch("skydriver.k8s.utils.KubeAPITools.start_job")
async def test_10(
kapitsj_mock: Mock,
Expand Down

0 comments on commit 89b6536

Please sign in to comment.