Skip to content

Commit 74f4de6

Browse files
committed
test: add e2e test cases for hypernode
Signed-off-by: xuwentao <cutenear1993@yahoo.com>
1 parent 1d69621 commit 74f4de6

File tree

11 files changed

+498
-2
lines changed

11 files changed

+498
-2
lines changed

.github/workflows/e2e_hypernode.yaml

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: E2E Hypernode
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
tags:
8+
pull_request:
9+
10+
jobs:
11+
e2e_hypernode:
12+
runs-on: ubuntu-24.04
13+
name: E2E about Hypernode
14+
timeout-minutes: 40
15+
steps:
16+
- name: Install Go
17+
uses: actions/setup-go@v4
18+
with:
19+
go-version: 1.22.x
20+
21+
- name: Install musl
22+
run: |
23+
wget http://musl.libc.org/releases/musl-1.2.1.tar.gz
24+
tar -xf musl-1.2.1.tar.gz && cd musl-1.2.1
25+
./configure
26+
make && sudo make install
27+
28+
- uses: actions/cache@v2
29+
with:
30+
path: ~/go/pkg/mod
31+
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
32+
33+
- name: Install dependences
34+
run: |
35+
GO111MODULE="on" go install sigs.k8s.io/kind@v0.24.0
36+
curl -LO https://storage.googleapis.com/kubernetes-release/release/v1.31.0/bin/linux/amd64/kubectl && sudo install kubectl /usr/local/bin/kubectl
37+
38+
- name: Install kwok
39+
run: |
40+
helm repo add kwok https://kwok.sigs.k8s.io/charts/
41+
helm repo update
42+
helm install --namespace kube-system kwok kwok/kwok
43+
helm install kwok kwok/stage-fast
44+
# delete pod-complete stage to avoid volcano-job-pod change status to complete.
45+
kubectl delete stage pod-complete
46+
47+
- name: Checkout code
48+
uses: actions/checkout@v3
49+
50+
- name: Run E2E Tests
51+
run: |
52+
export ARTIFACTS_PATH=${{ github.workspace }}/e2e-hypernode-logs
53+
make e2e-test-hypernode CC=/usr/local/musl/bin/musl-gcc
54+
55+
- name: Upload e2e hypernode logs
56+
if: failure()
57+
uses: actions/upload-artifact@v4
58+
with:
59+
name: volcano_e2e_hypernode_logs
60+
path: ${{ github.workspace }}/e2e-hypernode-logs

Makefile

+3
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,9 @@ e2e-test-vcctl: vcctl images
142142
e2e-test-stress: images
143143
E2E_TYPE=STRESS ./hack/run-e2e-kind.sh
144144

145+
e2e-test-hypernode: images
146+
E2E_TYPE=HYPERNODE ./hack/run-e2e-kind.sh
147+
145148
generate-yaml: init manifests
146149
./hack/generate-yaml.sh TAG=${RELEASE_VER} CRD_VERSION=${CRD_VERSION}
147150

hack/lib/install.sh

+9-1
Original file line numberDiff line numberDiff line change
@@ -98,4 +98,12 @@ function install-ginkgo-if-not-exist {
9898
else
9999
echo -n "Found ginkgo, version: " && ginkgo version
100100
fi
101-
}
101+
}
102+
103+
function install-kwok-with-helm {
104+
helm repo add kwok https://kwok.sigs.k8s.io/charts/
105+
helm upgrade --namespace kube-system --install kwok kwok/kwok
106+
helm upgrade --install kwok kwok/stage-fast
107+
# delete pod-complete stage to avoid volcano-job-pod change status to complete.
108+
kubectl delete stage pod-complete
109+
}

hack/run-e2e-kind.sh

+58
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,57 @@ export CLUSTER_CONTEXT=("--name" "${CLUSTER_NAME}")
3131

3232
export KIND_OPT=${KIND_OPT:="--config ${VK_ROOT}/hack/e2e-kind-config.yaml"}
3333

34+
# kwok node config
35+
export KWOK_NODE_CPU=${KWOK_NODE_CPU:-4} # 4 cores
36+
export KWOK_NODE_MEMORY=${KWOK_NODE_MEMORY:-4Gi} # 4GB
37+
38+
# generate kwok node config
39+
function generate-kwok-node-config() {
40+
local node_index=$1
41+
local cpu=$2
42+
local memory=$3
43+
44+
cat <<EOF > "${VK_ROOT}/hack/kwok-node-${node_index}.yaml"
45+
apiVersion: v1
46+
kind: Node
47+
metadata:
48+
annotations:
49+
node.alpha.kubernetes.io/ttl: "0"
50+
kwok.x-k8s.io/node: fake
51+
labels:
52+
beta.kubernetes.io/arch: amd64
53+
beta.kubernetes.io/os: linux
54+
kubernetes.io/arch: amd64
55+
kubernetes.io/hostname: kwok-node-${node_index}
56+
kubernetes.io/os: linux
57+
kubernetes.io/role: agent
58+
node-role.kubernetes.io/agent: ""
59+
type: kwok
60+
name: kwok-node-${node_index}
61+
spec:
62+
taints:
63+
- effect: NoSchedule
64+
key: kwok.x-k8s.io/node
65+
value: fake
66+
status:
67+
capacity:
68+
cpu: "${cpu}"
69+
memory: "${memory}"
70+
pods: "110"
71+
allocatable:
72+
cpu: "${cpu}"
73+
memory: "${memory}"
74+
pods: "110"
75+
EOF
76+
}
77+
78+
# install kwok nodes
79+
function install-kwok-nodes(node_count) {
80+
for i in $(seq 0 $((node_count-1))); do
81+
generate-kwok-node-config $i "${KWOK_NODE_CPU}" "${KWOK_NODE_MEMORY}"
82+
kubectl apply -f "${VK_ROOT}/hack/kwok-node-${i}.yaml"
83+
done
84+
}
3485

3586
function install-volcano {
3687
install-helm
@@ -121,6 +172,7 @@ source "${VK_ROOT}/hack/lib/install.sh"
121172

122173
check-prerequisites
123174
kind-up-cluster
175+
install-kwok-with-helm
124176

125177
if [[ -z ${KUBECONFIG+x} ]]; then
126178
export KUBECONFIG="${HOME}/.kube/config"
@@ -166,6 +218,12 @@ case ${E2E_TYPE} in
166218
echo "Running stress e2e suite..."
167219
KUBECONFIG=${KUBECONFIG} GOOS=${OS} ginkgo -r --slow-spec-threshold='30s' --progress ./test/e2e/stress/
168220
;;
221+
"HYPERNODE")
222+
echo "Creating 8 kwok nodes for 3-tier topology"
223+
install-kwok-nodes(8)
224+
echo "Running hypernode e2e suite..."
225+
KUBECONFIG=${KUBECONFIG} GOOS=${OS} ginkgo -r --slow-spec-threshold='30s' --progress ./test/e2e/hypernode/
226+
;;
169227
esac
170228

171229
if [[ $? -ne 0 ]]; then

test/e2e/hypernode/e2e_test.go

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package hypernode
2+
3+
import (
4+
"testing"
5+
6+
. "github.com/onsi/ginkgo/v2"
7+
. "github.com/onsi/gomega"
8+
)
9+
10+
func TestE2E(t *testing.T) {
11+
RegisterFailHandler(Fail)
12+
RunSpecs(t, "Volcano Network Topology Test Suite")
13+
}

test/e2e/hypernode/main_test.go

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package hypernode
2+
3+
import (
4+
"os"
5+
"testing"
6+
7+
"k8s.io/client-go/kubernetes"
8+
"k8s.io/client-go/tools/clientcmd"
9+
10+
vcclient "volcano.sh/apis/pkg/client/clientset/versioned"
11+
e2eutil "volcano.sh/volcano/test/e2e/util"
12+
)
13+
14+
func TestMain(m *testing.M) {
15+
home := e2eutil.HomeDir()
16+
configPath := e2eutil.KubeconfigPath(home)
17+
config, _ := clientcmd.BuildConfigFromFlags(e2eutil.MasterURL(), configPath)
18+
e2eutil.VcClient = vcclient.NewForConfigOrDie(config)
19+
e2eutil.KubeClient = kubernetes.NewForConfigOrDie(config)
20+
os.Exit(m.Run())
21+
}

0 commit comments

Comments
 (0)