Skip to content

Commit

Permalink
Merge pull request #12 from rastislavszabo/master
Browse files Browse the repository at this point in the history
CNI enhancements
  • Loading branch information
rastislavs authored Oct 6, 2017
2 parents 051b2a6 + b43fa16 commit 01be81c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
8 changes: 5 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ endef
# run all tests
define test_only
@echo "# running unit tests"
@go test ./cmd/contiv-cni
@go test ./plugins/contiv
@go test ./plugins/kvdbproxy
@echo "# done"
Expand All @@ -37,11 +38,12 @@ endef
# run all tests with coverage
define test_cover_only
@echo "# running unit tests with coverage analysis"
@go test -covermode=count -coverprofile=${COVER_DIR}coverage_unit1.out ./plugins/contiv
@go test -covermode=count -coverprofile=${COVER_DIR}coverage_unit2.out ./plugins/kvdbproxy
@go test -covermode=count -coverprofile=${COVER_DIR}cov_u1.out ./cmd/contiv-cni
@go test -covermode=count -coverprofile=${COVER_DIR}cov_u2.out ./plugins/contiv
@go test -covermode=count -coverprofile=${COVER_DIR}cov_u3.out ./plugins/kvdbproxy
@echo "# merging coverage results"
@cd vendor/github.com/wadey/gocovmerge && go install -v
@gocovmerge ${COVER_DIR}coverage_unit1.out ${COVER_DIR}coverage_unit2.out > ${COVER_DIR}coverage.out
@gocovmerge ${COVER_DIR}cov_u1.out ${COVER_DIR}cov_u2.out ${COVER_DIR}cov_u3.out > ${COVER_DIR}coverage.out
@echo "# coverage data generated into ${COVER_DIR}coverage.out"
@echo "# done"
endef
Expand Down
8 changes: 6 additions & 2 deletions cmd/contiv-cni/contiv_cni.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func grpcConnect(grpcServer string) (*grpc.ClientConn, cninb.RemoteCNIClient, er
}

// cmdAdd implements the CNI request to add a container to network.
// It forwards the request to he remote gRPC server and prints the result recieved from gRPC.
// It forwards the request to he remote gRPC server and prints the result received from gRPC.
func cmdAdd(args *skel.CmdArgs) error {
// parse CNI config
cfg, err := parseCNIConfig(args.StdinData)
Expand All @@ -96,6 +96,8 @@ func cmdAdd(args *skel.CmdArgs) error {
ContainerId: args.ContainerID,
InterfaceName: args.IfName,
NetworkNamespace: args.Netns,
ExtraArguments: args.Args,
ExtraNwConfig: string(args.StdinData),
})
if err != nil {
return err
Expand Down Expand Up @@ -168,7 +170,7 @@ func cmdAdd(args *skel.CmdArgs) error {
}

// cmdDel implements the CNI request to delete a container from network.
// It forwards the request to he remote gRPC server and returns the result recieved from gRPC.
// It forwards the request to he remote gRPC server and returns the result received from gRPC.
func cmdDel(args *skel.CmdArgs) error {
// parse CNI config
n, err := parseCNIConfig(args.StdinData)
Expand All @@ -189,6 +191,8 @@ func cmdDel(args *skel.CmdArgs) error {
ContainerId: args.ContainerID,
InterfaceName: args.IfName,
NetworkNamespace: args.Netns,
ExtraArguments: args.Args,
ExtraNwConfig: string(args.StdinData),
})
if err != nil {
return err
Expand Down
3 changes: 1 addition & 2 deletions cmd/contiv-cni/contiv_cni_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,7 @@ func TestCNIAddDelete(t *testing.T) {
RegisterTestingT(t)

// start testing gRPC server
grpcServer := runTestGrpcServer()
defer grpcServer.Stop()
runTestGrpcServer()

// prepare CNI config
conf := `{
Expand Down

0 comments on commit 01be81c

Please sign in to comment.