Skip to content

Commit 154b31b

Browse files
author
Klaus Ma
authored
Merge pull request #28 from volcano-sh/bug/fix_ci_issue
Support Travis CI
2 parents ada7a7b + ec6debb commit 154b31b

File tree

6 files changed

+67
-91
lines changed

6 files changed

+67
-91
lines changed

.travis.yml

+26-16
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,33 @@
1+
dist: xenial
12
language: go
2-
3+
go:
4+
- '1.11.x'
35
sudo: required
4-
56
env:
67
- HOME=/home/travis
7-
88
services:
99
- docker
10-
11-
go:
12-
- "1.11"
13-
1410
go_import_path: volcano.sh/volcano
15-
16-
install:
17-
- go get -u golang.org/x/lint/golint
18-
19-
script:
20-
- make
21-
- make verify
22-
- make e2e-test
23-
11+
jobs:
12+
include:
13+
- stage: Golint & Gofmt
14+
before_script:
15+
- go get -u golang.org/x/lint/golint
16+
script:
17+
- make
18+
- make verify
19+
- stage: E2E Tests
20+
before_script:
21+
# Download kubectl
22+
- sudo apt-get update && sudo apt-get install -y apt-transport-https
23+
- curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
24+
- echo "deb https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee -a /etc/apt/sources.list.d/kubernetes.list
25+
- sudo apt-get update
26+
- sudo apt-get install -y kubectl
27+
# Download kind binary (0.2.0)
28+
- sudo curl -o /usr/local/bin/kind -L https://github.com/kubernetes-sigs/kind/releases/download/0.2.0/kind-linux-amd64
29+
- sudo chmod +x /usr/local/bin/kind
30+
script:
31+
- make cli
32+
- make docker
33+
- make e2e-test-kind

Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
BIN_DIR=_output/bin
2-
IMAGE=volcano
3-
TAG = 1.0
2+
export IMAGE=volcano
3+
export TAG = 1.0
44

55
all: controllers scheduler cli admission
66

hack/.golint_failures

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@ volcano.sh/volcano/pkg/scheduler/plugins/predicates
2222
volcano.sh/volcano/pkg/scheduler/plugins/priority
2323
volcano.sh/volcano/pkg/scheduler/plugins/proportion
2424
volcano.sh/volcano/pkg/scheduler/util
25-
volcano.sh/volcano/test/e2e
25+
volcano.sh/volcano/test/e2e

hack/e2e-kind-config.yaml

+2-18
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,7 @@ apiVersion: kind.sigs.k8s.io/v1alpha2
55
nodes:
66
# the control plane node config
77
- role: control-plane
8-
# patch the generated kubeadm config with some extra settings
9-
kubeadmConfigPatches:
10-
- |
11-
apiVersion: kubeadm.k8s.io/v1beta1
12-
kind: ClusterConfiguration
13-
networking:
14-
serviceSubnet: 10.0.0.0/16
15-
# patch it further using a JSON 6902 patch
16-
kubeadmConfigPatchesJson6902:
17-
- group: kubeadm.k8s.io
18-
version: v1beta1
19-
kind: ClusterConfiguration
20-
patch: |
21-
- op: add
22-
path: /apiServer/certSANs/-
23-
value: my-hostname
248
# the three workers
259
- role: worker
26-
# replicas specifes the number of nodes to create with this configuration
27-
replicas: 3
10+
# replicas specifies the number of nodes to create with this configuration
11+
replicas: 3

hack/run-e2e-kind.sh

+35-53
Original file line numberDiff line numberDiff line change
@@ -1,80 +1,71 @@
11
#!/bin/bash
22

3-
export VK_ROOT=$(dirname "${BASH_SOURCE}")/..
3+
export VK_ROOT=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/..
44
export VK_BIN=${VK_ROOT}/_output/bin
55
export LOG_LEVEL=3
66
export SHOW_VOLCANO_LOGS=${SHOW_VOLCANO_LOGS:-1}
77

8-
if [ "${CLUSTER_NAME}xxx" != "xxx" ];then
8+
if [[ "${CLUSTER_NAME}xxx" != "xxx" ]];then
99
export CLUSTER_CONTEXT="--name ${CLUSTER_NAME}"
10+
else
11+
export CLUSTER_CONTEXT="--name integration"
1012
fi
1113

12-
export KIND_OPT=${KIND_OPT:="--image kindest/node:v1.13.2 --config ${VK_ROOT}/hack/e2e-kind-config.yaml"}
13-
14-
export KIND_IMAGE=$(echo ${KIND_OPT} |grep -E -o "image \w+\/[^ ]*" | sed "s/image //")
14+
export KIND_OPT=${KIND_OPT:=" --config ${VK_ROOT}/hack/e2e-kind-config.yaml"}
1515

1616
# check if kind installed
1717
function check-prerequisites {
1818
echo "checking prerequisites"
1919
which kind >/dev/null 2>&1
20-
if [ $? -ne 0 ]; then
20+
if [[ $? -ne 0 ]]; then
2121
echo "kind not installed, exiting."
2222
exit 1
2323
else
2424
echo -n "found kind, version: " && kind version
2525
fi
2626

2727
which kubectl >/dev/null 2>&1
28-
if [ $? -ne 0 ]; then
28+
if [[ $? -ne 0 ]]; then
2929
echo "kubectl not installed, exiting."
3030
exit 1
3131
else
3232
echo -n "found kubectl, " && kubectl version --short --client
3333
fi
3434
}
3535

36-
# check if the images that kind use exists.
37-
function check-kind-image {
38-
docker images | awk '{print $1":"$2}' | grep -q "${KIND_IMAGE}"
39-
if [ $? -ne 0 ]; then
40-
echo "image: ${KIND_IMAGE} not found."
41-
exit 1
42-
fi
43-
}
44-
4536
# spin up cluster with kind command
4637
function kind-up-cluster {
4738
check-prerequisites
48-
check-kind-image
4939
echo "Running kind: [kind create cluster ${CLUSTER_CONTEXT} ${KIND_OPT}]"
5040
kind create cluster ${CLUSTER_CONTEXT} ${KIND_OPT}
5141
}
5242

5343
function install-volcano {
54-
kubectl --kubeconfig ${KUBECONFIG} create -f ${VK_ROOT}/installer/chart/volcano-init/templates/scheduling_v1alpha1_podgroup.yaml
55-
kubectl --kubeconfig ${KUBECONFIG} create -f ${VK_ROOT}/installer/chart/volcano-init/templates/scheduling_v1alpha1_queue.yaml
56-
kubectl --kubeconfig ${KUBECONFIG} create -f ${VK_ROOT}/installer/chart/volcano-init/templates/batch_v1alpha1_job.yaml
57-
kubectl --kubeconfig ${KUBECONFIG} create -f ${VK_ROOT}/installer/chart/volcano-init/templates/bus_v1alpha1_command.yaml
58-
59-
# TODO: make vk-controllers and vk-scheduler run in container / in k8s
60-
# start controller
61-
nohup ${VK_BIN}/vk-controllers --kubeconfig ${KUBECONFIG} --logtostderr --v ${LOG_LEVEL} > controller.log 2>&1 &
62-
echo $! > vk-controllers.pid
63-
64-
# start scheduler
65-
nohup ${VK_BIN}/vk-scheduler --kubeconfig ${KUBECONFIG} --scheduler-conf=example/kube-batch-conf.yaml --logtostderr --v ${LOG_LEVEL} > scheduler.log 2>&1 &
66-
echo $! > vk-scheduler.pid
44+
echo "Preparing helm tiller service account"
45+
kubectl create serviceaccount --namespace kube-system tiller
46+
kubectl create clusterrolebinding tiller-cluster-rule --clusterrole=cluster-admin --serviceaccount=kube-system:tiller
47+
48+
echo "Install helm via script and waiting tiller becomes ready"
49+
curl https://raw.githubusercontent.com/helm/helm/master/scripts/get > get_helm.sh
50+
#TODO: There are some issue with helm's latest version, remove '--version' when it get fixed.
51+
chmod 700 get_helm.sh && ./get_helm.sh --version v2.13.0
52+
helm init --service-account tiller --kubeconfig ${KUBECONFIG} --wait
53+
54+
echo "Loading docker images into kind cluster"
55+
kind load docker-image ${IMAGE}-controllers:${TAG} ${CLUSTER_CONTEXT}
56+
kind load docker-image ${IMAGE}-scheduler:${TAG} ${CLUSTER_CONTEXT}
57+
kind load docker-image ${IMAGE}-admission:${TAG} ${CLUSTER_CONTEXT}
58+
59+
echo "Install volcano plugin into cluster...."
60+
helm plugin install --kubeconfig ${KUBECONFIG} installer/chart/volcano/plugins/gen-admission-secret
61+
helm gen-admission-secret --service integration-admission-service --namespace kube-system
62+
63+
echo "Install volcano chart"
64+
helm install installer/chart/volcano --namespace kube-system --name integration --kubeconfig ${KUBECONFIG}
6765
}
6866

6967
function uninstall-volcano {
70-
kubectl --kubeconfig ${KUBECONFIG} delete -f ${VK_ROOT}/installer/chart/volcano-init/templates/scheduling_v1alpha1_podgroup.yaml
71-
kubectl --kubeconfig ${KUBECONFIG} delete -f ${VK_ROOT}/installer/chart/volcano-init/templates/scheduling_v1alpha1_queue.yaml
72-
kubectl --kubeconfig ${KUBECONFIG} delete -f ${VK_ROOT}/installer/chart/volcano-init/templates/batch_v1alpha1_job.yaml
73-
kubectl --kubeconfig ${KUBECONFIG} delete -f ${VK_ROOT}/installer/chart/volcano-init/templates/bus_v1alpha1_command.yaml
74-
75-
kill -9 $(cat vk-controllers.pid)
76-
kill -9 $(cat vk-scheduler.pid)
77-
rm vk-controllers.pid vk-scheduler.pid
68+
helm delete integration --purge --kubeconfig ${KUBECONFIG}
7869
}
7970

8071
# clean up
@@ -84,26 +75,17 @@ function cleanup {
8475
echo "Running kind: [kind delete cluster ${CLUSTER_CONTEXT}]"
8576
kind delete cluster ${CLUSTER_CONTEXT}
8677

87-
if [ ${SHOW_VOLCANO_LOGS} -eq 1 ]; then
88-
echo "===================================================================================="
89-
echo "=============================>>>>> Scheduler Logs <<<<<============================="
90-
echo "===================================================================================="
91-
92-
cat scheduler.log
93-
94-
echo "===================================================================================="
95-
echo "=============================>>>>> Controller Logs <<<<<============================"
96-
echo "===================================================================================="
97-
98-
cat controller.log
78+
if [[ ${SHOW_VOLCANO_LOGS} -eq 1 ]]; then
79+
#TODO: Add volcano logs support in future.
80+
echo "Volcano logs are currently not supported."
9981
fi
10082
}
10183

10284
echo $* | grep -E -q "\-\-help|\-h"
103-
if [ $? -eq 0 ]; then
85+
if [[ $? -eq 0 ]]; then
10486
echo "Customize the kind-cluster name:
10587
106-
export CLUSTER_NAME=<custom cluster name>
88+
export CLUSTER_NAME=<custom cluster name> # default: integration
10789
10890
Customize kind options other than --name:
10991
@@ -122,7 +104,7 @@ trap cleanup EXIT
122104

123105
kind-up-cluster
124106

125-
KUBECONFIG="$(kind get kubeconfig-path ${CLUSTER_CONTEXT})"
107+
export KUBECONFIG="$(kind get kubeconfig-path ${CLUSTER_CONTEXT})"
126108

127109
install-volcano
128110

hack/verify-golint.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ for p in "${all_packages[@]}"; do
6060
# and not just the ones for the current platform.
6161
# Packages with a corresponding foo_test package will make golint fail
6262
# with a useless error. Just ignore that, see golang/lint#68.
63-
failedLint=$(golint "$p"/*.go 2>/dev/null)
63+
failedLint=$(golint "$p" 2>/dev/null)
6464
array_contains "$p" "${failing_packages[@]}" && in_failing=$? || in_failing=$?
6565
if [[ -n "${failedLint}" ]] && [[ "${in_failing}" -ne "0" ]]; then
6666
errors+=( "${failedLint}" )

0 commit comments

Comments
 (0)