27 lines
714 B
Python
27 lines
714 B
Python
|
import os
|
||
|
|
||
|
import testinfra.utils.ansible_runner
|
||
|
|
||
|
testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
|
||
|
os.environ["MOLECULE_INVENTORY_FILE"]
|
||
|
).get_hosts("all")
|
||
|
|
||
|
|
||
|
def test_k3s_running_and_enabled(host):
|
||
|
k3s = host.service("k3s")
|
||
|
assert k3s.is_running
|
||
|
assert k3s.is_enabled
|
||
|
|
||
|
|
||
|
def test_k3s_node_ready(host):
|
||
|
jsonpth = '{range .items[*]}{@.metadata.name}:{range @.status.conditions[?(@.type=="Ready")]}{@.type}={@.status};{end}{end}' # noqa
|
||
|
nodes = host.run(f"kubectl get nodes -o jsonpath='{jsonpth}'").stdout
|
||
|
|
||
|
assert "rocky9-k3s:Ready=True;" in nodes
|
||
|
|
||
|
|
||
|
def test_k3s_cluster_ready(host):
|
||
|
cluster = host.run("kubectl get --raw='/readyz'").stdout
|
||
|
|
||
|
assert cluster == "ok"
|