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 <cutenear1993@yahoo.com>
  • Loading branch information
Xu-Wentao committed Feb 17, 2025
1 parent 1d69621 commit 7e4b44f
Show file tree
Hide file tree
Showing 11 changed files with 498 additions and 2 deletions.
60 changes: 60 additions & 0 deletions .github/workflows/e2e_hypernode.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: E2E Hypernode

on:
push:
branches:
- master
tags:
pull_request:

jobs:
e2e_hypernode:
runs-on: ubuntu-24.04
name: E2E about Hypernode
timeout-minutes: 40
steps:
- name: Install Go
uses: actions/setup-go@v4
with:
go-version: 1.22.x

- name: Install musl
run: |
wget http://musl.libc.org/releases/musl-1.2.1.tar.gz
tar -xf musl-1.2.1.tar.gz && cd musl-1.2.1
./configure
make && sudo make install
- uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}

- name: Install dependences
run: |
GO111MODULE="on" go install sigs.k8s.io/kind@v0.24.0
curl -LO https://storage.googleapis.com/kubernetes-release/release/v1.31.0/bin/linux/amd64/kubectl && sudo install kubectl /usr/local/bin/kubectl
- name: Install kwok
run: |
helm repo add kwok https://kwok.sigs.k8s.io/charts/
helm repo update
helm --install --namespace kube-system kwok kwok/kwok
helm --install kwok kwok/stage-fast
# delete pod-complete stage to avoid volcano-job-pod change status to complete.
kubectl delete stage pod-complete
- name: Checkout code
uses: actions/checkout@v3

- name: Run E2E Tests
run: |
export ARTIFACTS_PATH=${{ github.workspace }}/e2e-hypernode-logs
make e2e-test-hypernode CC=/usr/local/musl/bin/musl-gcc
- name: Upload e2e hypernode logs
if: failure()
uses: actions/upload-artifact@v4
with:
name: volcano_e2e_hypernode_logs
path: ${{ github.workspace }}/e2e-hypernode-logs
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: images
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
}
58 changes: 58 additions & 0 deletions hack/run-e2e-kind.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,57 @@ export CLUSTER_CONTEXT=("--name" "${CLUSTER_NAME}")

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

# kwok node config
export KWOK_NODE_CPU=${KWOK_NODE_CPU:-4} # 4 cores
export KWOK_NODE_MEMORY=${KWOK_NODE_MEMORY:-4Gi} # 4GB

# generate kwok node config
function generate-kwok-node-config() {
local node_index=$1
local cpu=$2
local memory=$3

cat <<EOF > "${VK_ROOT}/hack/kwok-node-${node_index}.yaml"
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-${node_index}
kubernetes.io/os: linux
kubernetes.io/role: agent
node-role.kubernetes.io/agent: ""
type: kwok
name: kwok-node-${node_index}
spec:
taints:
- effect: NoSchedule
key: kwok.x-k8s.io/node
value: fake
status:
capacity:
cpu: "${cpu}"
memory: "${memory}"
pods: "110"
allocatable:
cpu: "${cpu}"
memory: "${memory}"
pods: "110"
EOF
}

# install kwok nodes
function install-kwok-nodes(node_count) {
for i in $(seq 0 $((node_count-1))); do
generate-kwok-node-config $i "${KWOK_NODE_CPU}" "${KWOK_NODE_MEMORY}"
kubectl apply -f "${VK_ROOT}/hack/kwok-node-${i}.yaml"
done
}

function install-volcano {
install-helm
Expand Down Expand Up @@ -121,6 +172,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 +218,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 8 kwok nodes for 3-tier topology"
install-kwok-nodes(8)
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")
}
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 7e4b44f

Please # to comment.