Skip to content

Commit abc52cf

Browse files
authored
Merge pull request #56 from kannon92/setup-e2e-test-github-action
E2E Test
2 parents 4269e61 + bb84fd6 commit abc52cf

File tree

5 files changed

+151
-0
lines changed

5 files changed

+151
-0
lines changed

.github/workflows/e2e.yaml

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Run tests
2+
3+
on: [ push, pull_request ]
4+
5+
permissions:
6+
contents: read
7+
8+
jobs:
9+
e2e:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Install Go
13+
uses: actions/setup-go@v4
14+
with:
15+
go-version: 1.22.6
16+
- name: Checkout code
17+
uses: actions/checkout@v3
18+
- name: Build
19+
run: make PREFIX=artifacts cmds
20+
- name: install helm and kubectl
21+
run: |
22+
sudo snap install helm --classic
23+
sudo snap install kubectl --classic
24+
- name: Setup e2e
25+
run: make setup-e2e
26+
- name: run e2e test
27+
run: make test-e2e
28+
- name: teardown e2e test
29+
run: make teardown-e2e

Makefile

+9
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,15 @@ generate-deepcopy: vendor
113113
output:object:dir=$(CURDIR)/api/$(VENDOR)/resource/$${api}; \
114114
done
115115

116+
setup-e2e:
117+
test/e2e/setup-e2e.sh
118+
119+
test-e2e:
120+
test/e2e/e2e.sh
121+
122+
teardown-e2e:
123+
test/e2e/teardown-e2e.sh
124+
116125
# Generate an image for containerized builds
117126
# Note: This image is local only
118127
.PHONY: .build-image

test/e2e/e2e.sh

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#!/usr/bin/env bash
2+
3+
# Copyright 2024 The Kubernetes Authors.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
# Very Simple Script for testing the demo
18+
19+
kubectl create -f demo/gpu-test1.yaml
20+
kubectl create -f demo/gpu-test2.yaml
21+
kubectl create -f demo/gpu-test3.yaml
22+
kubectl create -f demo/gpu-test4.yaml
23+
kubectl create -f demo/gpu-test5.yaml
24+
25+
kubectl wait --for=condition=Ready -n gpu-test1 pod/pod0 --timeout=120s
26+
kubectl wait --for=condition=Ready -n gpu-test1 pod/pod1 --timeout=120s
27+
gpu_test_1=$(kubectl get pods -n gpu-test1 | grep -c 'Running')
28+
if [ $gpu_test_1 != 2 ]; then
29+
echo "gpu_test_1 $gpu_test_1 failed to match against 2 expected pods"
30+
exit 1
31+
fi
32+
33+
34+
kubectl wait --for=condition=Ready -n gpu-test2 pod/pod0 --timeout=120s
35+
gpu_test_2=$(kubectl get pods -n gpu-test2 | grep -c 'Running')
36+
if [ $gpu_test_2 != 1 ]; then
37+
echo "gpu_test_2 $gpu_test_2 failed to match against 1 expected pod"
38+
exit 1
39+
fi
40+
41+
kubectl wait --for=condition=Ready -n gpu-test3 pod/pod0 --timeout=120s
42+
gpu_test_3=$(kubectl get pods -n gpu-test3 | grep -c 'Running')
43+
if [ $gpu_test_3 != 1 ]; then
44+
echo "gpu_test_3 $gpu_test_3 failed to match against 1 expected pod"
45+
exit 1
46+
fi
47+
48+
kubectl wait --for=condition=Ready -n gpu-test4 pod/pod0 --timeout=120s
49+
kubectl wait --for=condition=Ready -n gpu-test4 pod/pod1 --timeout=120s
50+
gpu_test_4=$(kubectl get pods -n gpu-test4 | grep -c 'Running')
51+
if [ $gpu_test_4 != 2 ]; then
52+
echo "gpu_test_4 $gpu_test_4 failed to match against 1 expected pods"
53+
exit 1
54+
fi
55+
56+
kubectl wait --for=condition=Ready -n gpu-test5 pod/pod0 --timeout=120s
57+
gpu_test_5=$(kubectl get pods -n gpu-test5 | grep -c 'Running')
58+
if [ $gpu_test_5 != 1 ]; then
59+
echo "gpu_test_5 $gpu_test_5 failed to match against 1 expected pod"
60+
exit 1
61+
fi
62+
63+
echo "test ran successfully"

test/e2e/setup-e2e.sh

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/usr/bin/env bash
2+
3+
# Copyright 2024 The Kubernetes Authors.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
# stop at first failure to save time
18+
set -e
19+
20+
bash demo/build-driver.sh
21+
bash demo/create-cluster.sh
22+
helm upgrade -i \
23+
--create-namespace \
24+
--namespace dra-example-driver \
25+
dra-example-driver \
26+
deployments/helm/dra-example-driver

test/e2e/teardown-e2e.sh

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/usr/bin/env bash
2+
3+
# Copyright 2023 The Kubernetes Authors.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
# This scripts invokes `kind build image` so that the resulting
18+
# image has a containerd with CDI support.
19+
#
20+
# Usage: kind-build-image.sh <tag of generated image>
21+
22+
set -e
23+
24+
bash demo/delete-cluster.sh

0 commit comments

Comments
 (0)