Skip to content
This repository was archived by the owner on Jun 28, 2024. It is now read-only.

Commit bdd397e

Browse files
author
James O. D. Hunt
authored
Merge pull request #992 from GabyCT/topic/addparallel
test: Add K8S test for parallel processing using expansions
2 parents 124fbb0 + 1553133 commit bdd397e

4 files changed

Lines changed: 103 additions & 0 deletions

File tree

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
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+
}

integration/kubernetes/run_kubernetes_tests.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ bats k8s-uts+ipc-ns.bats
2929
bats k8s-env.bats
3030
bats k8s-pid-ns.bats
3131
bats k8s-cpu-ns.bats
32+
bats k8s-parallel.bats
3233
bats k8s-memory.bats
3334
bats k8s-liveness-probes.bats
3435
bats k8s-attach-handlers.bats
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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

0 commit comments

Comments
 (0)