Skip to content

Commit

Permalink
test: add e2e test cases for hypernode
Browse files Browse the repository at this point in the history
Signed-off-by: xuwentao <[email protected]>
  • Loading branch information
Xu-Wentao committed Jan 23, 2025
1 parent 021fc67 commit 6ffc27b
Show file tree
Hide file tree
Showing 11 changed files with 632 additions and 2 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,9 @@ e2e-test-vcctl: vcctl images
e2e-test-stress: images
E2E_TYPE=STRESS ./hack/run-e2e-kind.sh

e2e-test-hypernode:
E2E_TYPE=HYPERNODE ./hack/run-e2e-kind.sh

generate-yaml: init manifests
./hack/generate-yaml.sh TAG=${RELEASE_VER} CRD_VERSION=${CRD_VERSION}

Expand Down
10 changes: 9 additions & 1 deletion hack/lib/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,12 @@ function install-ginkgo-if-not-exist {
else
echo -n "Found ginkgo, version: " && ginkgo version
fi
}
}

function install-kwok-with-helm {
helm repo add kwok https://kwok.sigs.k8s.io/charts/
helm upgrade --namespace kube-system --install kwok kwok/kwok
helm upgrade --install kwok kwok/stage-fast
# delete pod-complete stage to avoid volcano-job-pod change status to complete.
kubectl delete stage pod-complete
}
7 changes: 7 additions & 0 deletions hack/run-e2e-kind.sh
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ source "${VK_ROOT}/hack/lib/install.sh"

check-prerequisites
kind-up-cluster
install-kwok-with-helm

if [[ -z ${KUBECONFIG+x} ]]; then
export KUBECONFIG="${HOME}/.kube/config"
Expand Down Expand Up @@ -166,6 +167,12 @@ case ${E2E_TYPE} in
echo "Running stress e2e suite..."
KUBECONFIG=${KUBECONFIG} GOOS=${OS} ginkgo -r --slow-spec-threshold='30s' --progress ./test/e2e/stress/
;;
"HYPERNODE")
echo "Creating fake nodes with kwok"
kubectl apply -f test/e2e/hypernode/kwok.yaml
echo "Running hypernode e2e suite..."
KUBECONFIG=${KUBECONFIG} GOOS=${OS} ginkgo -r --slow-spec-threshold='30s' --progress ./test/e2e/hypernode/
;;
esac

if [[ $? -ne 0 ]]; then
Expand Down
13 changes: 13 additions & 0 deletions test/e2e/hypernode/e2e_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package hypernode

import (
"testing"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)

func TestE2E(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "Volcano Network Topology Test Suite")
}
245 changes: 245 additions & 0 deletions test/e2e/hypernode/kwok.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,245 @@
apiVersion: v1
kind: Node
metadata:
annotations:
node.alpha.kubernetes.io/ttl: "0"
kwok.x-k8s.io/node: fake
labels:
beta.kubernetes.io/arch: amd64
beta.kubernetes.io/os: linux
kubernetes.io/arch: amd64
kubernetes.io/hostname: kwok-node-0
kubernetes.io/os: linux
kubernetes.io/role: agent
node-role.kubernetes.io/agent: ""
type: kwok
name: kwok-node-0
spec:
taints: # Avoid scheduling actual running pods to fake Node
- effect: NoSchedule
key: kwok.x-k8s.io/node
value: fake
status:
capacity:
cpu: "4"
memory: "4Gi"
pods: "110"
allocatable:
cpu: "4"
memory: "4Gi"
pods: "110"
---
apiVersion: v1
kind: Node
metadata:
annotations:
node.alpha.kubernetes.io/ttl: "0"
kwok.x-k8s.io/node: fake
labels:
beta.kubernetes.io/arch: amd64
beta.kubernetes.io/os: linux
kubernetes.io/arch: amd64
kubernetes.io/hostname: kwok-node-1
kubernetes.io/os: linux
kubernetes.io/role: agent
node-role.kubernetes.io/agent: ""
type: kwok
name: kwok-node-1
spec:
taints: # Avoid scheduling actual running pods to fake Node
- effect: NoSchedule
key: kwok.x-k8s.io/node
value: fake
status:
capacity:
cpu: "4"
memory: "4Gi"
pods: "110"
allocatable:
cpu: "4"
memory: "4Gi"
pods: "110"
---
apiVersion: v1
kind: Node
metadata:
annotations:
node.alpha.kubernetes.io/ttl: "0"
kwok.x-k8s.io/node: fake
labels:
beta.kubernetes.io/arch: amd64
beta.kubernetes.io/os: linux
kubernetes.io/arch: amd64
kubernetes.io/hostname: kwok-node-2
kubernetes.io/os: linux
kubernetes.io/role: agent
node-role.kubernetes.io/agent: ""
type: kwok
name: kwok-node-2
spec:
taints: # Avoid scheduling actual running pods to fake Node
- effect: NoSchedule
key: kwok.x-k8s.io/node
value: fake
status:
capacity:
cpu: "4"
memory: "4Gi"
pods: "110"
allocatable:
cpu: "4"
memory: "4Gi"
pods: "110"
---
apiVersion: v1
kind: Node
metadata:
annotations:
node.alpha.kubernetes.io/ttl: "0"
kwok.x-k8s.io/node: fake
labels:
beta.kubernetes.io/arch: amd64
beta.kubernetes.io/os: linux
kubernetes.io/arch: amd64
kubernetes.io/hostname: kwok-node-3
kubernetes.io/os: linux
kubernetes.io/role: agent
node-role.kubernetes.io/agent: ""
type: kwok
name: kwok-node-3
spec:
taints: # Avoid scheduling actual running pods to fake Node
- effect: NoSchedule
key: kwok.x-k8s.io/node
value: fake
status:
capacity:
cpu: "4"
memory: "4Gi"
pods: "110"
allocatable:
cpu: "4"
memory: "4Gi"
pods: "110"
---
apiVersion: v1
kind: Node
metadata:
annotations:
node.alpha.kubernetes.io/ttl: "0"
kwok.x-k8s.io/node: fake
labels:
beta.kubernetes.io/arch: amd64
beta.kubernetes.io/os: linux
kubernetes.io/arch: amd64
kubernetes.io/hostname: kwok-node-4
kubernetes.io/os: linux
kubernetes.io/role: agent
node-role.kubernetes.io/agent: ""
type: kwok
name: kwok-node-4
spec:
taints: # Avoid scheduling actual running pods to fake Node
- effect: NoSchedule
key: kwok.x-k8s.io/node
value: fake
status:
capacity:
cpu: "4"
memory: "4Gi"
pods: "110"
allocatable:
cpu: "4"
memory: "4Gi"
pods: "110"
---
apiVersion: v1
kind: Node
metadata:
annotations:
node.alpha.kubernetes.io/ttl: "0"
kwok.x-k8s.io/node: fake
labels:
beta.kubernetes.io/arch: amd64
beta.kubernetes.io/os: linux
kubernetes.io/arch: amd64
kubernetes.io/hostname: kwok-node-5
kubernetes.io/os: linux
kubernetes.io/role: agent
node-role.kubernetes.io/agent: ""
type: kwok
name: kwok-node-5
spec:
taints: # Avoid scheduling actual running pods to fake Node
- effect: NoSchedule
key: kwok.x-k8s.io/node
value: fake
status:
capacity:
cpu: "4"
memory: "4Gi"
pods: "110"
allocatable:
cpu: "4"
memory: "4Gi"
pods: "110"
---
apiVersion: v1
kind: Node
metadata:
annotations:
node.alpha.kubernetes.io/ttl: "0"
kwok.x-k8s.io/node: fake
labels:
beta.kubernetes.io/arch: amd64
beta.kubernetes.io/os: linux
kubernetes.io/arch: amd64
kubernetes.io/hostname: kwok-node-6
kubernetes.io/os: linux
kubernetes.io/role: agent
node-role.kubernetes.io/agent: ""
type: kwok
name: kwok-node-6
spec:
taints: # Avoid scheduling actual running pods to fake Node
- effect: NoSchedule
key: kwok.x-k8s.io/node
value: fake
status:
capacity:
cpu: "4"
memory: "4Gi"
pods: "110"
allocatable:
cpu: "4"
memory: "4Gi"
pods: "110"
---
apiVersion: v1
kind: Node
metadata:
annotations:
node.alpha.kubernetes.io/ttl: "0"
kwok.x-k8s.io/node: fake
labels:
beta.kubernetes.io/arch: amd64
beta.kubernetes.io/os: linux
kubernetes.io/arch: amd64
kubernetes.io/hostname: kwok-node-7
kubernetes.io/os: linux
kubernetes.io/role: agent
node-role.kubernetes.io/agent: ""
type: kwok
name: kwok-node-7
spec:
taints: # Avoid scheduling actual running pods to fake Node
- effect: NoSchedule
key: kwok.x-k8s.io/node
value: fake
status:
capacity:
cpu: "2"
memory: "4Gi"
allocatable:
cpu: "2"
memory: "4Gi"
21 changes: 21 additions & 0 deletions test/e2e/hypernode/main_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package hypernode

import (
"os"
"testing"

"k8s.io/client-go/kubernetes"
"k8s.io/client-go/tools/clientcmd"

vcclient "volcano.sh/apis/pkg/client/clientset/versioned"
e2eutil "volcano.sh/volcano/test/e2e/util"
)

func TestMain(m *testing.M) {
home := e2eutil.HomeDir()
configPath := e2eutil.KubeconfigPath(home)
config, _ := clientcmd.BuildConfigFromFlags(e2eutil.MasterURL(), configPath)
e2eutil.VcClient = vcclient.NewForConfigOrDie(config)
e2eutil.KubeClient = kubernetes.NewForConfigOrDie(config)
os.Exit(m.Run())
}
Loading

0 comments on commit 6ffc27b

Please sign in to comment.