This repository was archived by the owner on Jun 28, 2024. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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+
10+ setup () {
11+ export KUBECONFIG=/etc/kubernetes/admin.conf
12+ if sudo -E kubectl get runtimeclass | grep -q kata; then
13+ pod_config_dir=" ${BATS_TEST_DIRNAME} /runtimeclass_workloads"
14+ else
15+ pod_config_dir=" ${BATS_TEST_DIRNAME} /untrusted_workloads"
16+ fi
17+ }
18+
19+ @test " Parallel jobs" {
20+ job_name=" jobtest"
21+ declare -a names=( test1 test2 test3 )
22+ # Create yaml files
23+ for i in " ${names[@]} " ; do
24+ sed " s/\$ ITEM/$i /" ${pod_config_dir} /job-template.yaml > ${pod_config_dir} /job-$i .yaml
25+ done
26+
27+ # Create the jobs
28+ for i in " ${names[@]} " ; do
29+ sudo -E kubectl create -f " ${pod_config_dir} /job-$i .yaml"
30+ done
31+
32+ # Check the jobs
33+ sudo -E kubectl get jobs -l jobgroup=${job_name}
34+
35+ # Check the pods
36+ sudo -E kubectl wait --for=condition=Ready pod -l jobgroup=${job_name}
37+
38+ # Check output of the jobs
39+ for i in $( sudo -E kubectl get pods -l jobgroup=${job_name} -o name) ; do
40+ sudo -E kubectl logs ${i}
41+ done
42+ }
43+
44+ teardown () {
45+ # Delete jobs
46+ sudo -E kubectl delete jobs -l jobgroup=${job_name}
47+
48+ # Remove generated yaml files
49+ for i in " ${names[@]} " ; do
50+ rm -f ${pod_config_dir} /job-$i .yaml
51+ done
52+ }
Original file line number Diff line number Diff line change @@ -29,6 +29,7 @@ bats k8s-uts+ipc-ns.bats
2929bats k8s-env.bats
3030bats k8s-pid-ns.bats
3131bats k8s-cpu-ns.bats
32+ bats k8s-parallel.bats
3233bats k8s-memory.bats
3334bats k8s-liveness-probes.bats
3435bats k8s-attach-handlers.bats
Original file line number Diff line number Diff line change 1+ #
2+ # Copyright (c) 2018 Intel Corporation
3+ #
4+ # SPDX-License-Identifier: Apache-2.0
5+ #
6+ apiVersion : batch/v1
7+ kind : Job
8+ metadata :
9+ name : process-item-$ITEM
10+ labels :
11+ jobgroup : jobtest
12+ spec :
13+ template :
14+ metadata :
15+ name : jobtest
16+ labels :
17+ jobgroup : jobtest
18+ spec :
19+ runtimeClassName : kata
20+ containers :
21+ - name : test
22+ image : busybox
23+ command : ["tail", "-f", "/dev/null"]
24+ restartPolicy : Never
Original file line number Diff line number Diff line change 1+ #
2+ # Copyright (c) 2018 Intel Corporation
3+ #
4+ # SPDX-License-Identifier: Apache-2.0
5+ #
6+ apiVersion : batch/v1
7+ kind : Job
8+ metadata :
9+ name : process-item-$ITEM
10+ labels :
11+ jobgroup : jobtest
12+ spec :
13+ template :
14+ metadata :
15+ name : jobtest
16+ annotations :
17+ io.kubernetes.cri-o.TrustedSandbox : " false"
18+ io.kubernetes.cri.untrusted-workload : " true"
19+ labels :
20+ jobgroup : jobtest
21+ spec :
22+ containers :
23+ - name : test
24+ image : busybox
25+ command : ["tail", "-f", "/dev/null"]
26+ restartPolicy : Never
You can’t perform that action at this time.
0 commit comments