adapt remaining tests to kubetest

This commit is contained in:
David Arnold 2021-05-13 22:58:11 -04:00
parent 8a20c93b21
commit 7b057d8c0f
No known key found for this signature in database
GPG key ID: 6D6A936E69C59D08
5 changed files with 53 additions and 112 deletions

View file

@ -8,13 +8,23 @@ with lib;
test = {
name = "nginx-deployment";
description = "Test testing nginx deployment";
testScript = ''
kube.wait_until_succeeds("docker load --input='${config.docker.images.nginx.image}'")
kube.wait_until_succeeds("kubectl apply -f ${config.kubernetes.result}")
script = ''
@pytest.mark.applymanifest('${config.kubernetes.resultYAML}')
def test_nginx_deployment(kube):
"""Tests whether nginx deployment gets successfully created"""
kube.succeed("kubectl get deployment | grep -i nginx")
kube.wait_until_succeeds("kubectl get deployment -o go-template nginx --template={{.status.readyReplicas}} | grep 10")
kube.wait_until_succeeds({pkgs.curl}/bin/curl http://nginx.default.svc.cluster.local | grep -i hello")
kube.wait_for_registered(timeout=30)
deployments = kube.get_deployments()
nginx_deploy = deployments.get('nginx')
assert nginx_deploy is not None
status = nginx_deploy.status()
assert status.readyReplicas == 10
# TODO: implement those kind of checks from the host machine into the cluster
# via port forwarding, prepare all runtimes accordingly
# ${pkgs.curl}/bin/curl http://nginx.default.svc.cluster.local | grep -i hello
'';
};
}