Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] test: add e2e test cases for hypernode #3983

Open
wants to merge 1 commit into
base: network-topology
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading