Merge pull request #117 from crosbymichael/add-integration-tests
Add integration tests with nice makefile
This commit is contained in:
commit
5d39cecc5f
|
@ -31,4 +31,4 @@ script:
|
|||
- if [ "$TRAVIS_GLOBAL_WTF" ]; then bash "$DOCKER_PATH/hack/make/validate-dco"; fi
|
||||
- if [ "$TRAVIS_GLOBAL_WTF" ]; then bash "$DOCKER_PATH/hack/make/validate-gofmt"; fi
|
||||
- if [ -z "$TRAVIS_GLOBAL_WTF" ]; then go build -v ./...; fi
|
||||
- if [ -z "$TRAVIS_GLOBAL_WTF" -a "$GOARCH" != 'arm' ]; then go test -v ./...; fi
|
||||
- if [ -z "$TRAVIS_GLOBAL_WTF" -a "$GOARCH" != 'arm' ]; then go test -test.short -v ./...; fi
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
FROM crosbymichael/golang
|
||||
|
||||
RUN apt-get update && apt-get install -y gcc
|
||||
RUN go get code.google.com/p/go.tools/cmd/cover
|
||||
|
||||
ADD . /go/src/github.com/docker/libcontainer
|
||||
RUN cd /go/src/github.com/docker/libcontainer && go get -d ./... && go install ./...
|
||||
WORKDIR /go/src/github.com/docker/libcontainer
|
||||
RUN go get -d ./... && go install ./...
|
||||
|
||||
CMD ["nsinit"]
|
||||
CMD ["go", "test", "-cover", "./..."]
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
|
||||
all:
|
||||
docker build -t docker/libcontainer .
|
||||
|
||||
test:
|
||||
# we need NET_ADMIN for the netlink tests
|
||||
docker run --rm --cap-add NET_ADMIN docker/libcontainer
|
|
@ -0,0 +1,55 @@
|
|||
package netlink
|
||||
|
||||
import (
|
||||
"net"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestCreateBridgeWithMac(t *testing.T) {
|
||||
if testing.Short() {
|
||||
return
|
||||
}
|
||||
|
||||
name := "testbridge"
|
||||
|
||||
if err := CreateBridge(name, true); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if _, err := net.InterfaceByName(name); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
// cleanup and tests
|
||||
|
||||
if err := DeleteBridge(name); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if _, err := net.InterfaceByName(name); err == nil {
|
||||
t.Fatal("expected error getting interface because bridge was deleted")
|
||||
}
|
||||
}
|
||||
|
||||
func TestCreateVethPair(t *testing.T) {
|
||||
if testing.Short() {
|
||||
return
|
||||
}
|
||||
|
||||
var (
|
||||
name1 = "veth1"
|
||||
name2 = "veth2"
|
||||
)
|
||||
|
||||
if err := NetworkCreateVethPair(name1, name2); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if _, err := net.InterfaceByName(name1); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if _, err := net.InterfaceByName(name2); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue