github.com/dmaizel/tests@v0.0.0-20210728163746-cae6a2d9cee8/integration/kubernetes/k8s-job.bats (about) 1 #!/usr/bin/env bats 2 # 3 # Copyright (c) 2019 Intel Corporation 4 # 5 # SPDX-License-Identifier: Apache-2.0 6 # 7 8 load "${BATS_TEST_DIRNAME}/../../.ci/lib.sh" 9 load "${BATS_TEST_DIRNAME}/tests_common.sh" 10 issue="https://github.com/kata-containers/tests/issues/1746" 11 12 setup() { 13 skip "test not working see: ${issue}" 14 export KUBECONFIG="${KUBECONFIG:-$HOME/.kube/config}" 15 get_pod_config_dir 16 } 17 18 @test "Run a job to completion" { 19 skip "test not working see: ${issue}" 20 job_name="job-pi-test" 21 22 # Create job 23 kubectl apply -f "${pod_config_dir}/job.yaml" 24 25 # Verify job 26 kubectl describe jobs/"$job_name" | grep "SuccessfulCreate" 27 28 # List pods that belong to the job 29 pod_name=$(kubectl get pods --selector=job-name=$job_name --output=jsonpath='{.items[*].metadata.name}') 30 31 # Verify that the job is completed 32 cmd="kubectl get pods -o jsonpath='{.items[*].status.phase}' | grep Succeeded" 33 waitForProcess "$wait_time" "$sleep_time" "$cmd" 34 35 # Verify the output of the pod 36 pi_number="3.14" 37 kubectl logs "$pod_name" | grep "$pi_number" 38 } 39 40 teardown() { 41 skip "test not working see: ${issue}" 42 kubectl delete pod "$pod_name" 43 # Verify that pod is not running 44 run kubectl get pods 45 echo "$output" 46 [[ "$output" =~ "No resources found" ]] 47 48 49 kubectl delete jobs/"$job_name" 50 # Verify that the job is not running 51 run kubectl get jobs 52 echo "$output" 53 [[ "$output" =~ "No resources found" ]] 54 }