Skip to content

Commit 2671f2f

Browse files
authored
Merge pull request #473 from abhinandanpb/kubernetes_test
Scheduler Systemtest Framwork (with k8s)
2 parents c514779 + c5a7ada commit 2671f2f

35 files changed

+1774
-798
lines changed

Godeps/Godeps.json

+5-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Makefile

+9-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,15 @@ k8s-demo-start:
8686
cd vagrant/k8s/ && ./restart_cluster.sh && vagrant ssh k8master
8787
k8s-destroy:
8888
cd vagrant/k8s/ && vagrant destroy -f
89-
89+
k8s-sanity-cluster:
90+
cd vagrant/k8s/ && ./setup_cluster.sh
91+
k8s-test:
92+
CONTIV_K8=1 make k8s-sanity-cluster
93+
#make ssh-build
94+
cd vagrant/k8s/ && CONTIV_K8=1 vagrant ssh k8master -c 'sudo -i bash -lc "cd /opt/gopath/src/github.com/contiv/netplugin && make run-build"'
95+
CONTIV_K8=1 cd vagrant/k8s/ && ./start_sanity_service.sh
96+
CONTIV_K8=1 CONTIV_NODES=3 godep go test -v -timeout 540m ./systemtests -check.v -check.f "Cluster"
97+
cd vagrant/k8s && vagrant destroy -f
9098
# Mesos demo targets
9199
mesos-docker-demo:
92100
cd vagrant/mesos-docker && vagrant up

netmaster/objApi/objapi_test.go

-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
/***
22
Copyright 2014 Cisco Systems Inc. All rights reserved.
3-
43
Licensed under the Apache License, Version 2.0 (the "License");
54
you may not use this file except in compliance with the License.
65
You may obtain a copy of the License at
76
http://www.apache.org/licenses/LICENSE-2.0
8-
97
Unless required by applicable law or agreed to in writing, software
108
distributed under the License is distributed on an "AS IS" BASIS,
119
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

systemtests/aci_test.go

+35-43
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
package systemtests
22

33
import (
4-
"errors"
4+
//"errors"
55
log "github.com/Sirupsen/logrus"
66
"github.com/contiv/contivmodel/client"
7-
"github.com/contiv/vagrantssh"
7+
// "github.com/contiv/vagrantssh"
88
. "gopkg.in/check.v1"
9-
"os"
10-
"strconv"
11-
"strings"
9+
// "os"
10+
// "strconv"
11+
// "strings"
1212
"time"
1313
)
1414

1515
func (s *systemtestSuite) TestACIMode(c *C) {
16-
if s.fwdMode == "routing" {
16+
if s.fwdMode == "routing" || s.scheduler == "k8" {
1717
return
1818
}
1919
c.Assert(s.cli.GlobalPost(&client.Global{
@@ -31,45 +31,38 @@ func (s *systemtestSuite) TestACIMode(c *C) {
3131
Encap: "vlan",
3232
}), IsNil)
3333

34-
err := s.nodes[0].checkDockerNetworkCreated("aciNet", false)
34+
err := s.nodes[0].checkSchedulerNetworkCreated("aciNet", false)
3535
c.Assert(err, IsNil)
3636

3737
c.Assert(s.cli.EndpointGroupPost(&client.EndpointGroup{
3838
TenantName: "default",
3939
NetworkName: "aciNet",
40-
GroupName: "epgA",
40+
GroupName: "epga",
4141
}), IsNil)
4242

43-
err = s.nodes[0].checkDockerNetworkCreated("epgA", true)
43+
err = s.nodes[0].exec.checkSchedulerNetworkCreated("epga", true)
4444
c.Assert(err, IsNil)
4545

4646
c.Assert(s.cli.EndpointGroupPost(&client.EndpointGroup{
4747
TenantName: "default",
4848
NetworkName: "aciNet",
49-
GroupName: "epgB",
49+
GroupName: "epgb",
5050
}), IsNil)
5151

52-
err = s.nodes[0].checkDockerNetworkCreated("epgB", true)
53-
c.Assert(err, IsNil)
54-
55-
cA1, err := s.nodes[0].runContainer(containerSpec{networkName: "epgA"})
56-
c.Assert(err, IsNil)
57-
58-
cA2, err := s.nodes[0].runContainer(containerSpec{networkName: "epgA"})
52+
err = s.nodes[0].checkSchedulerNetworkCreated("epgb", true)
5953
c.Assert(err, IsNil)
6054

61-
cB1, err := s.nodes[0].runContainer(containerSpec{networkName: "epgB"})
55+
containersA, err := s.runContainersOnNode(2, "aciNet", "", "epga", s.nodes[0])
6256
c.Assert(err, IsNil)
63-
64-
cB2, err := s.nodes[0].runContainer(containerSpec{networkName: "epgB"})
57+
containersB, err := s.runContainersOnNode(2, "aciNet", "", "epgb", s.nodes[0])
6558
c.Assert(err, IsNil)
6659

6760
// Verify cA1 can ping cA2
68-
c.Assert(cA1.checkPing(cA2.eth0.ip), IsNil)
61+
c.Assert(s.pingTest(containersA), IsNil)
6962
// Verify cB1 can ping cB2
70-
c.Assert(cB1.checkPing(cB2.eth0.ip), IsNil)
63+
c.Assert(s.pingTest(containersB), IsNil)
7164
// Verify cA1 cannot ping cB1
72-
c.Assert(cA1.checkPingFailure(cB1.eth0.ip), IsNil)
65+
c.Assert(s.pingFailureTest(containersA, containersB), IsNil)
7366

7467
log.Infof("Triggering netplugin restart")
7568
node1 := s.nodes[0]
@@ -80,18 +73,20 @@ func (s *systemtestSuite) TestACIMode(c *C) {
8073
time.Sleep(20 * time.Second)
8174

8275
// Verify cA1 can ping cA2
83-
c.Assert(cA1.checkPingWithCount(cA2.eth0.ip, 3), IsNil)
76+
c.Assert(s.pingTest(containersA), IsNil)
8477
// Verify cB1 can ping cB2
85-
c.Assert(cB1.checkPingWithCount(cB2.eth0.ip, 3), IsNil)
78+
c.Assert(s.pingTest(containersB), IsNil)
8679
// Verify cA1 cannot ping cB1
87-
c.Assert(cA1.checkPingFailureWithCount(cB1.eth0.ip, 5), IsNil)
80+
c.Assert(s.pingFailureTest(containersA, containersB), IsNil)
8881

89-
c.Assert(s.removeContainers([]*container{cA1, cA2, cB1, cB2}), IsNil)
90-
c.Assert(s.cli.EndpointGroupDelete("default", "epgA"), IsNil)
91-
c.Assert(s.cli.EndpointGroupDelete("default", "epgB"), IsNil)
82+
c.Assert(s.removeContainers(containersA), IsNil)
83+
c.Assert(s.removeContainers(containersB), IsNil)
84+
c.Assert(s.cli.EndpointGroupDelete("default", "epga"), IsNil)
85+
c.Assert(s.cli.EndpointGroupDelete("default", "epgb"), IsNil)
9286
c.Assert(s.cli.NetworkDelete("default", "aciNet"), IsNil)
9387
}
9488

89+
/*
9590
func (s *systemtestSuite) TestACIPingGateway(c *C) {
9691
if s.fwdMode == "routing" {
9792
return
@@ -117,27 +112,28 @@ func (s *systemtestSuite) TestACIPingGateway(c *C) {
117112
c.Assert(s.cli.EndpointGroupPost(&client.EndpointGroup{
118113
TenantName: "aciTenant",
119114
NetworkName: "aciNet",
120-
GroupName: "epgA",
115+
GroupName: "epga",
121116
}), IsNil)
122117
123118
c.Assert(s.cli.AppProfilePost(&client.AppProfile{
124119
TenantName: "aciTenant",
125-
EndpointGroups: []string{"epgA"},
120+
EndpointGroups: []string{"epga"},
126121
AppProfileName: "profile1",
127122
}), IsNil)
128123
129-
cA1, err := s.nodes[0].runContainer(containerSpec{networkName: "epgA/aciTenant"})
124+
containersA, err := s.runContainersOnNode(1, "aciNet", "aciTenant", "epga", s.nodes[0])
130125
c.Assert(err, IsNil)
131126
132127
// Verify cA1 can ping default gateway
133-
c.Assert(cA1.checkPingWithCount("20.1.1.254", 5), IsNil)
128+
c.Assert(s.pingTestToNonContainer(containersA, []string{"20.1.1.254"}), IsNil)
134129
135-
c.Assert(s.removeContainers([]*container{cA1}), IsNil)
130+
c.Assert(s.removeContainers(containersA), IsNil)
136131
c.Assert(s.cli.AppProfileDelete("aciTenant", "profile1"), IsNil)
137-
c.Assert(s.cli.EndpointGroupDelete("aciTenant", "epgA"), IsNil)
132+
c.Assert(s.cli.EndpointGroupDelete("aciTenant", "epga"), IsNil)
138133
c.Assert(s.cli.NetworkDelete("aciTenant", "aciNet"), IsNil)
139134
}
140135
136+
141137
func (s *systemtestSuite) TestACIProfile(c *C) {
142138
if s.fwdMode == "routing" {
143139
return
@@ -400,21 +396,17 @@ func (s *systemtestSuite) TestACIProfile(c *C) {
400396
"epgB",
401397
cB2), IsNil)
402398
403-
//cA1.checkPingWithCount("20.1.1.254", 5)
404-
//cB1.checkPingWithCount("20.1.1.254", 5)
405-
406399
c.Assert(s.checkConnectionPairRetry(from, to, 8000, 1, 3), IsNil)
407400
c.Assert(s.checkConnectionPairRetry(from, to, 8001, 1, 3), IsNil)
408-
c.Assert(cA2.checkPingFailureWithCount(cB2.eth0.ip, 5), IsNil)
401+
c.Assert(cA2.node.exec.checkPingFailureWithCount(cA2, cB2.eth0.ip, 5), IsNil)
409402
410403
// Delete the app profile
411404
c.Assert(s.cli.AppProfileDelete("aciTenant", "profile2"), IsNil)
412405
time.Sleep(time.Second * 5)
413-
//cA1.checkPingWithCount("20.1.1.254", 5)
414-
//cB1.checkPingWithCount("20.1.1.254", 5)
406+
415407
c.Assert(s.checkNoConnectionPairRetry(from, to, 8000, 1, 3), IsNil)
416408
c.Assert(s.checkNoConnectionPairRetry(from, to, 8001, 1, 3), IsNil)
417-
c.Assert(cA2.checkPingFailureWithCount(cB2.eth0.ip, 5), IsNil)
409+
c.Assert(cA2.node.exec.checkPingFailureWithCount(cA2, cB2.eth0.ip, 5), IsNil)
418410
419411
c.Assert(s.removeContainers([]*container{cA1, cB1, cA2, cB2}), IsNil)
420412
c.Assert(s.cli.EndpointGroupDelete("aciTenant", "epgA"), IsNil)
@@ -479,4 +471,4 @@ func (s *systemtestSuite) AciTestSetup(c *C) {
479471
s.copyBinary("netctl")
480472
s.copyBinary("contivk8s")
481473
482-
}
474+
}*/

systemtests/aci_util.go

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package systemtests
22

3+
/*
34
import (
45
"bytes"
56
"encoding/json"
@@ -131,3 +132,4 @@ func checkACILearning(tenant, app, epg string, c *container) error {
131132
132133
return nil
133134
}
135+
*/

systemtests/basic_test.go

+10-4
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ func (s *systemtestSuite) testBasicStartRemoveContainer(c *C, encap string) {
3535
}), IsNil)
3636

3737
for i := 0; i < s.iterations; i++ {
38-
containers, err := s.runContainers(s.containers, false, "private", nil, nil)
38+
containers, err := s.runContainers(s.containers, false, "private", "", nil, nil)
3939
c.Assert(err, IsNil)
4040

4141
if s.fwdMode == "routing" && encap == "vlan" {
@@ -73,7 +73,7 @@ func (s *systemtestSuite) testBasicStartStopContainer(c *C, encap string) {
7373
TenantName: "default",
7474
}), IsNil)
7575

76-
containers, err := s.runContainers(s.containers, false, "private", nil, nil)
76+
containers, err := s.runContainers(s.containers, false, "private", "", nil, nil)
7777
c.Assert(err, IsNil)
7878
if s.fwdMode == "routing" && encap == "vlan" {
7979
var err error
@@ -86,15 +86,15 @@ func (s *systemtestSuite) testBasicStartStopContainer(c *C, encap string) {
8686

8787
errChan := make(chan error)
8888
for _, cont := range containers {
89-
go func(cont *container) { errChan <- cont.stop() }(cont)
89+
go func(cont *container) { errChan <- cont.node.exec.stop(cont) }(cont)
9090
}
9191

9292
for range containers {
9393
c.Assert(<-errChan, IsNil)
9494
}
9595

9696
for _, cont := range containers {
97-
go func(cont *container) { errChan <- cont.start() }(cont)
97+
go func(cont *container) { errChan <- cont.node.exec.start(cont) }(cont)
9898
}
9999

100100
for range containers {
@@ -114,10 +114,16 @@ func (s *systemtestSuite) testBasicStartStopContainer(c *C, encap string) {
114114
}
115115

116116
func (s *systemtestSuite) TestBasicSvcDiscoveryVXLAN(c *C) {
117+
if s.scheduler == "k8" {
118+
return
119+
}
117120
s.testBasicSvcDiscovery(c, "vxlan")
118121
}
119122

120123
func (s *systemtestSuite) TestBasicSvcDiscoveryVLAN(c *C) {
124+
if s.scheduler == "k8" {
125+
return
126+
}
121127
s.testBasicSvcDiscovery(c, "vlan")
122128
}
123129

0 commit comments

Comments
 (0)