Skip to content

Commit

Permalink
fix typo in Job condition check
Browse files Browse the repository at this point in the history
Signed-off-by: Zac Pitones <[email protected]>
  • Loading branch information
pit1sIBM committed May 24, 2024
1 parent d651383 commit dadd918
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
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

0 comments on commit dadd918

Please sign in to comment.