Skip to content

Commit 359c2f5

Browse files
committed
Merge pull request #308 from abhinandanpb/bgp_sanity_cases
Bgp sanity cases
2 parents 174b38e + bf88b08 commit 359c2f5

File tree

17 files changed

+1226
-50
lines changed

17 files changed

+1226
-50
lines changed

Godeps/Godeps.json

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

Godeps/_workspace/src/github.com/contiv/vagrantssh/vagrant.go

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

Godeps/_workspace/src/github.com/contiv/vagrantssh/vagrantcommand.go

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

Makefile

+8-2
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,14 @@ unit-test: stop clean build
100100
centos-tests:
101101
CONTIV_NODE_OS=centos make clean build unit-test system-test stop
102102

103-
system-test: start
104-
godep go test -v -timeout 120m ./systemtests -check.v
103+
system-test:start
104+
godep go test -v -timeout 240m ./systemtests -check.v
105+
106+
l3-test:
107+
CONTIV_L3=2 CONTIV_NODES=3 vagrant destroy -f
108+
CONTIV_L3=2 CONTIV_NODES=3 vagrant up
109+
CONTIV_L3=2 CONTIV_NODES=3 godep go test -v -timeout 240m ./systemtests -check.v
110+
CONTIV_L3=2 CONTIV_NODES=3 vagrant destroy -f
105111

106112
host-build:
107113
@echo "dev: making binaries..."

Vagrantfile

100644100755
+78-14
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ require 'fileutils'
77
gopath_folder="/opt/gopath"
88
FileUtils.cp "/etc/resolv.conf", Dir.pwd
99

10+
$cluster_ip_nodes = ""
11+
1012
provision_common = <<SCRIPT
1113
## setup the environment file. Export the env-vars passed as args to 'vagrant up'
1214
echo Args passed: [[ $@ ]]
@@ -24,11 +26,9 @@ echo 'export GOSRC=$GOPATH/src' >> /etc/profile.d/envvar.sh
2426
echo 'export PATH=$PATH:/usr/local/go/bin:$GOBIN' >> /etc/profile.d/envvar.sh
2527
echo "export http_proxy='$4'" >> /etc/profile.d/envvar.sh
2628
echo "export https_proxy='$5'" >> /etc/profile.d/envvar.sh
27-
echo "export no_proxy=192.168.2.10,192.168.2.11,127.0.0.1,localhost,netmaster" >> /etc/profile.d/envvar.sh
28-
echo "export CLUSTER_NODE_IPS=192.168.2.10,192.168.2.11" >> /etc/profile.d/envvar.sh
2929
echo "export USE_RELEASE=$6" >> /etc/profile.d/envvar.sh
30-
31-
30+
echo "export no_proxy=$7,127.0.0.1,localhost,netmaster" >> /etc/profile.d/envvar.sh
31+
echo "export CLUSTER_NODE_IPS=$7" >> /etc/profile.d/envvar.sh
3232
source /etc/profile.d/envvar.sh
3333
3434
mv /etc/resolv.conf /etc/resolv.conf.bak
@@ -43,21 +43,22 @@ systemctl enable docker-tcp.socket
4343
4444
mkdir /etc/systemd/system/docker.service.d
4545
echo "[Service]" | sudo tee -a /etc/systemd/system/docker.service.d/http-proxy.conf
46-
echo "Environment=\\\"no_proxy=192.168.2.10,192.168.2.11,127.0.0.1,localhost,netmaster\\\" \\\"http_proxy=$http_proxy\\\" \\\"https_proxy=$https_proxy\\\"" | sudo tee -a /etc/systemd/system/docker.service.d/http-proxy.conf
46+
echo "Environment=\\\"no_proxy=$7,127.0.0.1,localhost,netmaster\\\" \\\"http_proxy=$http_proxy\\\" \\\"https_proxy=$https_proxy\\\"" | sudo tee -a /etc/systemd/system/docker.service.d/http-proxy.conf
4747
sudo systemctl daemon-reload
4848
sudo systemctl stop docker
4949
systemctl start docker-tcp.socket
5050
sudo systemctl start docker
5151
52-
if [ $# -gt 6 ]; then
53-
shift; shift; shift; shift; shift; shift
52+
if [ $# -gt 7 ]; then
53+
shift; shift; shift; shift; shift; shifti; shift
5454
echo "export $@" >> /etc/profile.d/envvar.sh
5555
fi
5656
5757
# Get swarm binary
5858
# (wget https://cisco.box.com/shared/static/0txiq5h7282hraujk09eleoevptd5jpl -q -O /usr/bin/swarm &&
5959
# chmod +x /usr/bin/swarm) || exit 1
60-
60+
#Get gobgp binary
61+
wget https://cisco.box.com/shared/static/5leqlo84kjh0thty91ouotilm4ish3nz -q -O #{gopath_folder}/src/github.com/contiv/netplugin/scripts/gobgp && chmod +x #{gopath_folder}/src/github.com/contiv/netplugin/scripts/gobgp
6162
# remove duplicate docker key
6263
rm /etc/docker/key.json
6364
@@ -69,25 +70,71 @@ rm /etc/docker/key.json
6970
docker load --input #{gopath_folder}/src/github.com/contiv/netplugin/scripts/dnscontainer.tar
7071
SCRIPT
7172

73+
provision_bird = <<SCRIPT
74+
## setup the environment file. Export the env-vars passed as args to 'vagrant up'
75+
echo Args passed: [[ $@ ]]
76+
echo "export http_proxy='$1'" >> /etc/profile.d/envvar.sh
77+
echo "export https_proxy='$2'" >> /etc/profile.d/envvar.sh
78+
source /etc/profile.d/envvar.sh
79+
SCRIPT
80+
7281
VAGRANTFILE_API_VERSION = "2"
7382
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
7483
if ENV['CONTIV_NODE_OS'] && ENV['CONTIV_NODE_OS'] == "centos" then
7584
config.vm.box = "contiv/centos71-netplugin"
76-
config.vm.box_version = "0.3.1"
7785
else
7886
config.vm.box = "contiv/ubuntu1504-netplugin"
79-
config.vm.box_version = "0.3.1"
8087
end
8188
num_nodes = 2
8289
if ENV['CONTIV_NODES'] && ENV['CONTIV_NODES'] != "" then
8390
num_nodes = ENV['CONTIV_NODES'].to_i
8491
end
8592
base_ip = "192.168.2."
8693
node_ips = num_nodes.times.collect { |n| base_ip + "#{n+10}" }
94+
$cluster_ip_nodes = node_ips.join(",")
95+
8796
node_names = num_nodes.times.collect { |n| "netplugin-node#{n+1}" }
8897
node_peers = []
89-
90-
num_nodes.times do |n|
98+
if ENV['CONTIV_L3'] then
99+
config.vm.define "quagga1" do |quagga1|
100+
101+
quagga1.vm.box = "contiv/quagga1"
102+
quagga1.vm.host_name = "quagga1"
103+
quagga1.vm.network :private_network, ip: "192.168.1.50", virtualbox__intnet: "true", auto_config: false
104+
quagga1.vm.network "private_network",
105+
ip: "80.1.1.200",
106+
virtualbox__intnet: "contiv_orange"
107+
quagga1.vm.network "private_network",
108+
ip: "70.1.1.2",
109+
virtualbox__intnet: "contiv_blue"
110+
quagga1.vm.provision "shell" do |s|
111+
s.inline = provision_bird
112+
s.args = [ENV["http_proxy"] || "", ENV["https_proxy"] || ""]
113+
end
114+
end
115+
config.vm.define "quagga2" do |quagga2|
116+
117+
quagga2.vm.box = "contiv/quagga2"
118+
quagga2.vm.host_name = "quagga2"
119+
quagga2.vm.network :private_network, ip: "192.168.1.50", virtualbox__intnet: "true", auto_config: false
120+
quagga2.vm.network "private_network",
121+
ip: "70.1.1.1",
122+
virtualbox__intnet: "contiv_blue"
123+
quagga2.vm.network "private_network",
124+
ip: "60.1.1.200",
125+
virtualbox__intnet: "contiv_green"
126+
quagga2.vm.network "private_network",
127+
ip: "50.1.1.200",
128+
virtualbox__intnet: "contiv_yellow"
129+
130+
quagga2.vm.provision "shell" do |s|
131+
s.inline = provision_bird
132+
s.args = [ENV["http_proxy"] || "", ENV["https_proxy"] || ""]
133+
end
134+
end
135+
end
136+
137+
num_nodes.times do |n|
91138
node_name = node_names[n]
92139
node_addr = node_ips[n]
93140
node_peers += ["#{node_name}=http://#{node_addr}:2380,#{node_name}=http://#{node_addr}:7001"]
@@ -103,12 +150,29 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
103150
swarm_flag = "slave"
104151
end
105152
end
153+
net_num = (n+1)%3
154+
if net_num == 0 then
155+
network_name = "contiv_orange"
156+
else
157+
if net_num == 1 then
158+
network_name = "contiv_yellow"
159+
else
160+
network_name = "contiv_green"
161+
end
162+
end
106163
config.vm.define node_name do |node|
164+
node.vm.box_version = "0.3.1"
165+
107166
# node.vm.hostname = node_name
108167
# create an interface for etcd cluster
109168
node.vm.network :private_network, ip: node_addr, virtualbox__intnet: "true", auto_config: false
110169
# create an interface for bridged network
111-
node.vm.network :private_network, ip: "0.0.0.0", virtualbox__intnet: "true", auto_config: false
170+
if ENV['CONTIV_L3'] then
171+
# create an interface for bridged network
172+
node.vm.network :private_network, ip: "0.0.0.0", virtualbox__intnet: network_name, auto_config: false
173+
else
174+
node.vm.network :private_network, ip: "0.0.0.0", virtualbox__intnet: "true", auto_config: false
175+
end
112176
node.vm.provider "virtualbox" do |v|
113177
# make all nics 'virtio' to take benefit of builtin vlan tag
114178
# support, which otherwise needs to be enabled in Intel drivers,
@@ -134,7 +198,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
134198
end
135199
node.vm.provision "shell" do |s|
136200
s.inline = provision_common
137-
s.args = [node_name, ENV["CONTIV_NODE_OS"] || "", node_addr, ENV["http_proxy"] || "", ENV["https_proxy"] || "", ENV["USE_RELEASE"] || "", *ENV['CONTIV_ENV']]
201+
s.args = [node_name, ENV["CONTIV_NODE_OS"] || "", node_addr, ENV["http_proxy"] || "", ENV["https_proxy"] || "", ENV["USE_RELEASE"] || "", *ENV['CONTIV_ENV'],$cluster_ip_nodes]
138202
end
139203
provision_node = <<SCRIPT
140204
## start etcd with generated config

netmaster/objApi/apiController.go

+28
Original file line numberDiff line numberDiff line change
@@ -1054,5 +1054,33 @@ func (ac *APIController) BgpDelete(bgpCfg *contivModel.Bgp) error {
10541054

10551055
//BgpUpdate updates bgp config
10561056
func (ac *APIController) BgpUpdate(oldbgpCfg *contivModel.Bgp, NewbgpCfg *contivModel.Bgp) error {
1057+
log.Infof("Received BgpUpdate: %+v", NewbgpCfg)
1058+
1059+
if NewbgpCfg.Hostname == "" {
1060+
return core.Errorf("Invalid host name")
1061+
}
1062+
1063+
// Get the state driver
1064+
stateDriver, err := utils.GetStateDriver()
1065+
if err != nil {
1066+
return err
1067+
}
1068+
1069+
// Build bgp config
1070+
bgpIntentCfg := intent.ConfigBgp{
1071+
Hostname: NewbgpCfg.Hostname,
1072+
RouterIP: NewbgpCfg.Routerip,
1073+
As: NewbgpCfg.As,
1074+
NeighborAs: NewbgpCfg.NeighborAs,
1075+
Neighbor: NewbgpCfg.Neighbor,
1076+
}
1077+
1078+
// Add the Bgp neighbor
1079+
err = master.AddBgp(stateDriver, &bgpIntentCfg)
1080+
if err != nil {
1081+
log.Errorf("Error creating Bgp neighbor {%+v}. Err: %v", NewbgpCfg.Neighbor, err)
1082+
return err
1083+
}
1084+
10571085
return nil
10581086
}

netplugin/netd.go

+7
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,15 @@ func processStateEvent(netPlugin *plugin.NetPlugin, opts cliOpts, rsps chan core
178178
isDelete = true
179179
eventStr = "delete"
180180
} else if rsp.Prev != nil {
181+
log.Infof("Received a modify event, ignoring it")
182+
if bgpCfg, ok := currentState.(*mastercfg.CfgBgpState); ok {
183+
log.Infof("Received %q for Bgp: %q", eventStr, bgpCfg.Hostname)
184+
processBgpEvent(netPlugin, opts, bgpCfg.Hostname, isDelete)
185+
continue
186+
}
181187
log.Infof("Received a modify event, ignoring it")
182188
continue
189+
183190
}
184191
if nwCfg, ok := currentState.(*mastercfg.CfgNetworkState); ok {
185192
log.Infof("Received %q for network: %q", eventStr, nwCfg.ID)

scripts/gobgp

13.2 MB
Binary file not shown.

systemtests/aci_test.go

+3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ import (
66
)
77

88
func (s *systemtestSuite) TestACIMode(c *C) {
9+
if s.fwdMode == "routing" {
10+
return
11+
}
912
c.Assert(s.cli.GlobalPost(&client.Global{
1013
Name: "global",
1114
NetworkInfraType: "aci",

systemtests/basic_test.go

100644100755
+10
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ func (s *systemtestSuite) TestBasicStartRemoveContainerVLAN(c *C) {
2323
}
2424

2525
func (s *systemtestSuite) testBasicStartRemoveContainer(c *C, encap string) {
26+
27+
if s.fwdMode == "routing" && encap == "vlan" {
28+
s.SetupBgp(c, false)
29+
s.CheckBgpConnection(c)
30+
}
2631
c.Assert(s.cli.NetworkPost(&client.Network{
2732
PktTag: 1001,
2833
NetworkName: "private",
@@ -51,6 +56,11 @@ func (s *systemtestSuite) TestBasicStartStopContainerVLAN(c *C) {
5156
}
5257

5358
func (s *systemtestSuite) testBasicStartStopContainer(c *C, encap string) {
59+
if s.fwdMode == "routing" && encap == "vlan" {
60+
61+
s.SetupBgp(c, false)
62+
s.CheckBgpConnection(c)
63+
}
5464
c.Assert(s.cli.NetworkPost(&client.Network{
5565
PktTag: 1001,
5666
NetworkName: "private",

0 commit comments

Comments
 (0)