Skip to content

Commit

Permalink
Merge pull request #40 from linkernetworks/alex/network-controller-test
Browse files Browse the repository at this point in the history
Fix the testing for gRPC client
  • Loading branch information
Hung-Wei Chiu authored Jun 26, 2018
2 parents 016c537 + 5b44c16 commit 92666f2
Show file tree
Hide file tree
Showing 4 changed files with 199 additions and 174 deletions.
5 changes: 3 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@ notifications:

before_install:
- go get -u github.com/kardianos/govendor
- sudo apt-get install -y git build-essential openvswitch-switch
- docker run -d -v /run/openvswitch/db.sock:/var/run/openvswitch/db.sock -p 50051:50051 sdnvortex/network-controller:latest /go/bin/server -tcp=0.0.0.0:50051

install:
- make pre-build

script:
- make build
- make test
- make src.test-coverage
- sudo -E PATH=$PATH TEST_GRPC=1 make src.test-coverage
- docker build --tag sdnvortex/vortex --file ./dockerfiles/Dockerfile .

before_deploy:
Expand Down
8 changes: 5 additions & 3 deletions src/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@ type Config struct {
Mongo *mongo.MongoConfig `json:"mongo"`
Logger logger.LoggerConfig `json:"logger"`

Kubernetes *rest.Config `json:"kubernetes"`
// the version settings of the current application
Version string `json:"version"`

Kubernetes *rest.Config `json:"kubernetes"`
}

func Read(path string) (c Config, err error) {
Expand All @@ -34,14 +33,17 @@ func Read(path string) (c Config, err error) {
if err := decoder.Decode(&c); err != nil {
return c, fmt.Errorf("Failed to load the config file: %v\n", err)
}

// FIXME, we need to find a way to test the fakeclient evne if we don't install the k8s
kubeconfig := filepath.Join(os.Getenv("HOME"), ".kube", "config")
c.Kubernetes, err = clientcmd.BuildConfigFromFlags("", kubeconfig)
if err != nil {
c.Kubernetes, err = rest.InClusterConfig()
if err != nil {
return c, fmt.Errorf("Failed to open the kubernetes config file: %v\n", err)
fmt.Errorf("Load the kubernetes config fail, use the fake k8s clinet instead")
}
}

return c, nil
}

Expand Down
Loading

0 comments on commit 92666f2

Please sign in to comment.