Skip to content

Commit

Permalink
Fix types when checking wait conditions (#300)
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobtomlinson authored Feb 2, 2024
1 parent 7cef424 commit de17205
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
2 changes: 1 addition & 1 deletion kr8s/_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ async def _test_conditions(
expression = matches.group("expression")
condition = matches.group("condition")
[value] = jsonpath.findall(expression, self._raw)
results.append(value == condition)
results.append(str(value) == str(condition))
else:
raise ValueError(f"Unknown condition type {condition}")
if mode == "any":
Expand Down
41 changes: 41 additions & 0 deletions kr8s/tests/test_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,47 @@ def test_pod_wait_ready_sync(example_pod_spec):
pod.wait("delete")


def test_wait_replicas(ns):
from kr8s.objects import StatefulSet

ss = StatefulSet(
{
"metadata": {
"name": "test-wait-replicas",
"namespace": ns,
},
"spec": {
"replicas": 3,
"selector": {
"matchLabels": {
"app": "test-wait-replicas",
}
},
"template": {
"metadata": {
"labels": {
"app": "test-wait-replicas",
}
},
"spec": {
"containers": [
{
"name": "test-wait-replicas",
"image": "nginx:latest",
}
]
},
},
},
}
)
ss.create()
try:
ss.wait("jsonpath='{.status.availableReplicas}'=3", timeout=30)
finally:
ss.delete()


def test_pod_refresh_sync(example_pod_spec):
pod = SyncPod(example_pod_spec)
pod.create()
Expand Down

0 comments on commit de17205

Please sign in to comment.