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

fix typo in Job condition check #74

Merged
merged 1 commit into from
May 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
3 changes: 2 additions & 1 deletion oper8/verify_resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

DEFAULT_TIMESTAMP_KEY = "lastTransitionTime"
AVAILABLE_CONDITION_KEY = "Available"
COMPLETE_CONDITION_KEY = "Complete"
PROGRESSING_CONDITION_KEY = "Progressing"
NEW_RS_AVAILABLE_REASON = "NewReplicaSetAvailable"

Expand Down Expand Up @@ -144,7 +145,7 @@ def verify_pod(object_state: dict) -> bool:
def verify_job(object_state: dict) -> bool:
"""Verify that a job has completed successfully"""
# https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/job-v1/#JobStatus
return _verify_condition(object_state, "Completed", True)
return _verify_condition(object_state, COMPLETE_CONDITION_KEY, True)


def verify_deployment(object_state: dict) -> bool:
Expand Down
9 changes: 6 additions & 3 deletions tests/test_verify_resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from oper8.utils import nested_set
from oper8.verify_resources import (
AVAILABLE_CONDITION_KEY,
COMPLETE_CONDITION_KEY,
DEFAULT_TIMESTAMP_KEY,
NEW_RS_AVAILABLE_REASON,
PROGRESSING_CONDITION_KEY,
Expand Down Expand Up @@ -182,7 +183,9 @@ def test_verify_pod_custom_verification():

def test_verify_job_completed():
"""Make sure a completed job verifies cleanly"""
assert run_test_verify(kind="Job", conditions=[make_condition("Completed", True)])
assert run_test_verify(
kind="Job", conditions=[make_condition(COMPLETE_CONDITION_KEY, True)]
)


def test_verify_job_failed():
Expand Down Expand Up @@ -216,7 +219,7 @@ def test_verify_job_separate_namespace():
"""Make sure a completed job from a different namespace verifies cleanly"""
assert run_test_verify(
kind="Job",
conditions=[make_condition("Completed", True)],
conditions=[make_condition(COMPLETE_CONDITION_KEY, True)],
obj_namespace="adifferent",
search_namespace="adifferent",
)
Expand All @@ -226,7 +229,7 @@ def test_verify_job_null_namespace():
"""Make sure a completed job in the same namespace verifies cleanly"""
assert run_test_verify(
kind="Job",
conditions=[make_condition("Completed", True)],
conditions=[make_condition(COMPLETE_CONDITION_KEY, True)],
obj_namespace=TEST_NAMESPACE,
search_namespace=_SESSION_NAMESPACE,
)
Expand Down
Loading