github.com/dmaizel/tests@v0.0.0-20210728163746-cae6a2d9cee8/integration/kubernetes/k8s-parallel.bats (about) 1 #!/usr/bin/env bats 2 # 3 # Copyright (c) 2018 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 11 setup() { 12 export KUBECONFIG="${KUBECONFIG:-$HOME/.kube/config}" 13 get_pod_config_dir 14 job_name="jobtest" 15 names=( "test1" "test2" "test3" ) 16 } 17 18 @test "Parallel jobs" { 19 # Create yaml files 20 for i in "${names[@]}"; do 21 sed "s/\$ITEM/$i/" ${pod_config_dir}/job-template.yaml > ${pod_config_dir}/job-$i.yaml 22 done 23 24 # Create the jobs 25 for i in "${names[@]}"; do 26 kubectl create -f "${pod_config_dir}/job-$i.yaml" 27 done 28 29 # Check the jobs 30 kubectl get jobs -l jobgroup=${job_name} 31 32 # Check the pods 33 kubectl wait --for=condition=Ready --timeout=$timeout pod -l jobgroup=${job_name} 34 35 # Check output of the jobs 36 for i in $(kubectl get pods -l jobgroup=${job_name} -o name); do 37 kubectl logs ${i} 38 done 39 } 40 41 teardown() { 42 # Delete jobs 43 kubectl delete jobs -l jobgroup=${job_name} 44 45 # Remove generated yaml files 46 for i in "${names[@]}"; do 47 rm -f ${pod_config_dir}/job-$i.yaml 48 done 49 }