Skip to content

Commit

Permalink
Merge pull request #478 from shaleman/integtest
Browse files Browse the repository at this point in the history
add integration test
  • Loading branch information
shaleman authored Aug 5, 2016
2 parents 4ead7cb + 33a9734 commit 93abf9b
Show file tree
Hide file tree
Showing 60 changed files with 2,398 additions and 1,080 deletions.
10 changes: 5 additions & 5 deletions Godeps/Godeps.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 9 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

# find all verifiable packages.
# XXX: explore a better way that doesn't need multiple 'find'
PKGS := `find . -mindepth 1 -maxdepth 1 -type d -name '*' | grep -vE '/\..*$\|Godeps|examples|docs|scripts|mgmtfn|bin|vagrant|vendor'`
PKGS := `find . -mindepth 1 -maxdepth 1 -type d -name '*' | grep -vE '/\..*$\|Godeps|examples|docs|scripts|mgmtfn|bin|vagrant|test|vendor'`
PKGS += `find . -mindepth 2 -maxdepth 2 -type d -name '*'| grep -vE '/\..*$\|Godeps|examples|docs|scripts|bin|vagrant|vendor'`
TO_BUILD := ./netplugin/ ./netmaster/ ./netctl/netctl/ ./mgmtfn/k8splugin/contivk8s/
HOST_GOBIN := `if [ -n "$$(go env GOBIN)" ]; then go env GOBIN; else dirname $$(which go); fi`
Expand All @@ -27,6 +27,7 @@ all: build unit-test system-test ubuntu-tests
all-CI: stop clean start
make ssh-build
vagrant ssh netplugin-node1 -c 'sudo -i bash -lc "source /etc/profile.d/envvar.sh && cd /opt/gopath/src/github.com/contiv/netplugin && make host-unit-test"'
vagrant ssh netplugin-node1 -c 'sudo -i bash -lc "source /etc/profile.d/envvar.sh && cd /opt/gopath/src/github.com/contiv/netplugin && make host-integ-test"'
make system-test

test: build unit-test system-test ubuntu-tests
Expand Down Expand Up @@ -139,7 +140,7 @@ ubuntu-tests:
CONTIV_NODE_OS=ubuntu make clean build unit-test system-test stop

system-test:start
go test -v -timeout 240m ./systemtests -check.v -check.f "00SSH|Basic|Network|Policy|TestTrigger|ACIM"
go test -v -timeout 240m ./test/systemtests -check.v -check.f "00SSH|Basic|Network|Policy|TestTrigger|ACIM"

l3-test:
CONTIV_L3=2 CONTIV_NODES=3 make stop
Expand All @@ -164,6 +165,12 @@ host-unit-test-coverage-detail:
@echo dev: running unit tests...
cd $(GOPATH)/src/github.com/contiv/netplugin && sudo -E PATH=$(PATH) scripts/unittests --coverage-detail

host-integ-test: host-cleanup
@echo dev: running integration tests...
sudo -E /usr/local/go/bin/go test -v ./test/integration/ -check.v -encap vlan -fwd-mode bridge
sudo -E /usr/local/go/bin/go test -v ./test/integration/ -check.v -encap vxlan -fwd-mode bridge
sudo -E /usr/local/go/bin/go test -v ./test/integration/ -check.v -encap vxlan -fwd-mode routing

host-cleanup:
@echo dev: cleaning up services...
cd $(GOPATH)/src/github.com/contiv/netplugin/scripts/python && PYTHONIOENCODING=utf-8 ./cleanup.py -nodes ${CLUSTER_NODE_IPS}
Expand Down
2 changes: 2 additions & 0 deletions core/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,13 @@ type Plugin interface {
type InstanceInfo struct {
StateDriver StateDriver `json:"-"`
HostLabel string `json:"host-label"`
CtrlIP string `json:"ctrl-ip"`
VtepIP string `json:"vtep-ip"`
VlanIntf string `json:"vlan-if"`
RouterIP string `json:"router-ip"`
FwdMode string `json:"fwd-mode"`
DbURL string `json:"db-url"`
PluginMode string `json:"plugin-mode"`
}

// PortSpec defines protocol/port info required to host the service
Expand Down
23 changes: 22 additions & 1 deletion drivers/ovsdbDriver.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ type OvsdbDriver struct {
bridgeName string // Name of the bridge we are operating on
ovs *libovsdb.OvsdbClient
cache map[string]map[libovsdb.UUID]libovsdb.Row
cacheLock sync.Mutex
cacheLock sync.RWMutex // lock to protect cache accesses
}

// NewOvsdbDriver creates a new OVSDB driver instance.
Expand Down Expand Up @@ -105,6 +105,9 @@ func (d *OvsdbDriver) Delete() error {
}

func (d *OvsdbDriver) getRootUUID() libovsdb.UUID {
d.cacheLock.RLock()
defer d.cacheLock.RUnlock()

for uuid := range d.cache[rootTable] {
return uuid
}
Expand Down Expand Up @@ -248,6 +251,10 @@ func (d *OvsdbDriver) GetPortOrIntfNameFromID(id string, isPort bool) (string, e
table = interfaceTable
}

d.cacheLock.RLock()
defer d.cacheLock.RUnlock()

// walk thru all ports
for _, row := range d.cache[table] {
if extIDs, ok := row.Fields["external_ids"]; ok {
extIDMap := extIDs.(libovsdb.OvsMap).GoMap
Expand Down Expand Up @@ -353,13 +360,15 @@ func (d *OvsdbDriver) DeletePort(intfName string) error {
}

// also fetch the port-uuid from cache
d.cacheLock.RLock()
for uuid, row := range d.cache["Port"] {
name := row.Fields["name"].(string)
if name == intfName {
portUUID = []libovsdb.UUID{uuid}
break
}
}
d.cacheLock.RUnlock()

// mutate the Ports column of the row in the Bridge table
mutateSet, _ := libovsdb.NewOvsSet(portUUID)
Expand Down Expand Up @@ -498,6 +507,10 @@ func (d *OvsdbDriver) RemoveController(target string) error {

// IsControllerPresent : Check if Controller already exists
func (d *OvsdbDriver) IsControllerPresent(target string) bool {
d.cacheLock.RLock()
defer d.cacheLock.RUnlock()

// walk the local cache
for tName, table := range d.cache {
if tName == "Controller" {
for _, row := range table {
Expand All @@ -519,6 +532,10 @@ func (d *OvsdbDriver) IsControllerPresent(target string) bool {

// IsPortNamePresent checks if port already exists in OVS bridge
func (d *OvsdbDriver) IsPortNamePresent(intfName string) bool {
d.cacheLock.RLock()
defer d.cacheLock.RUnlock()

// walk the local cache
for tName, table := range d.cache {
if tName == "Port" {
for _, row := range table {
Expand Down Expand Up @@ -572,6 +589,10 @@ func (d *OvsdbDriver) GetOfpPortNo(intfName string) (uint32, error) {

// IsVtepPresent checks if VTEP already exists
func (d *OvsdbDriver) IsVtepPresent(remoteIP string) (bool, string) {
d.cacheLock.RLock()
defer d.cacheLock.RUnlock()

// walk the local cache
for tName, table := range d.cache {
if tName == "Interface" {
for _, row := range table {
Expand Down
6 changes: 6 additions & 0 deletions drivers/ovsdriver.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"os"
"strconv"
"strings"
"sync"

log "github.com/Sirupsen/logrus"
"github.com/contiv/ofnet"
Expand Down Expand Up @@ -75,9 +76,14 @@ type OvsDriver struct {
oper OvsDriverOperState // Oper state of the driver
localIP string // Local IP address
switchDb map[string]*OvsSwitch // OVS switch instances
lock sync.Mutex // lock for modifying shared state
}

func (d *OvsDriver) getIntfName() (string, error) {
// take a lock for modifying shared state
d.lock.Lock()
defer d.lock.Unlock()

// get the next available port number
for i := 0; i < maxIntfRetry; i++ {
// Pick next port number
Expand Down
2 changes: 1 addition & 1 deletion mgmtfn/dockplugin/dockplugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (

log "github.com/Sirupsen/logrus"
"github.com/contiv/netplugin/netplugin/plugin"
"github.com/contiv/netplugin/svcplugin"
"github.com/contiv/netplugin/netplugin/svcplugin"
"github.com/docker/docker/pkg/plugins"
"github.com/docker/libnetwork/drivers/remote/api"
"github.com/gorilla/mux"
Expand Down
Loading

0 comments on commit 93abf9b

Please sign in to comment.