Skip to content

Commit

Permalink
Enable CI for Go API
Browse files Browse the repository at this point in the history
Change-Id: I88775f85dd793c32c27a4e397f39a6bbe4d8295c
Partial-Bug: 1752726
  • Loading branch information
nati committed Mar 7, 2018
1 parent cde0ce4 commit 5b52c82
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 16 deletions.
6 changes: 3 additions & 3 deletions .zuul.yaml
Expand Up @@ -20,6 +20,6 @@
vars:
docker:
- image: circleci/golang:1.9.2
# - image: circleci/mysql:5.7
# environment:
# MYSQL_ROOT_PASSWORD: contrail123
- image: circleci/mysql:5.7
environment:
MYSQL_ROOT_PASSWORD: contrail123
13 changes: 13 additions & 0 deletions Makefile
Expand Up @@ -26,6 +26,19 @@ generate: ## Run the source code generator
package: ## Generate the packages
go run cmd/contrailutil/main.go package

reset_gen:
git checkout master pkg/models/gen_*
git checkout master pkg/services/gen_*
git checkout master pkg/db/gen_*
git checkout master doc/proto_model.md
git checkout master doc/proto_service.md
git checkout master public
git checkout master proto
git checkout master tools/init_mysql.sql
git checkout master tools/init_psql.sql
git checkout master pkg/serviceif/serviceif.go


reset_db: ## Reset Database with latest schema.
./tools/reset_db.sh

Expand Down
7 changes: 2 additions & 5 deletions README.md
@@ -1,8 +1,5 @@
# Go code base for contrail projects

![CircleCI](https://circleci.com/gh/Juniper/contrail.svg?style=svg&circle-token=b744fe7f84003a898e897e0e4fe335e1e69944fd)
[![Coverage Status](https://coveralls.io/repos/github/Juniper/contrail/badge.svg?t=kKzcsv)](https://coveralls.io/github/Juniper/contrail)

## Important principal

- Apply lint tools
Expand Down Expand Up @@ -63,7 +60,7 @@ It is expected that the root password is 'contrail123', you can set this on an e
from the mysql prompt as follows:

``` shell
MariaDB [(none)]> ALTER USER 'root'@'localhost' IDENTIFIED BY 'contrail123';
[(none)]> ALTER USER 'root'@'localhost' IDENTIFIED BY 'contrail123';
```

Executing the script below, will drop the contrail_test schema if it exists, recreate it and initialise this schema
Expand All @@ -87,7 +84,7 @@ make integration
## Commands

Repository holds source code for following CLI applications:
- `contrail` - contains API Server, [Agent](doc/agent.md) and [API Server command line client][cli]
- `contrail` - contains API Server, [Agent](doc/agent.md) and [API Server command line client][cli]
- `contrailcli` - contains [API Server command line client][cli]
- `contrailutil` - contains development utilities

Expand Down
1 change: 1 addition & 0 deletions integration/cli/testdata/virtual_network_schema.yml
Expand Up @@ -17,6 +17,7 @@
mac_limit_control: # (object)
router_external: # (boolean)
uuid: # (string)
configuration_version: # (integer)
mac_learning_enabled: False # (boolean)
address_allocation_mode: # (string)
pbb_etree_enable: False # (boolean)
Expand Down
11 changes: 8 additions & 3 deletions pkg/agent/task_handler.go
Expand Up @@ -76,16 +76,21 @@ func commandHandler(handler handler, task *task, context map[string]interface{})

var output bytes.Buffer
stdout, _ := cmd.StdoutPipe()
cmd.Start()

err = cmd.Start()
if err != nil {
return "", err
}
scanner := bufio.NewScanner(stdout)
for scanner.Scan() {
m := scanner.Text()
output.WriteString(m) // nolint
log.Debug(m)
}

cmd.Wait()
err = cmd.Wait()
if err != nil {
return "", err
}
return output.String(), nil
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/cluster/report.go
Expand Up @@ -20,7 +20,7 @@ func (r *Reporter) reportStatus(status string) {
//TODO(ijohnson) Implement status update
}

func (r *Reporter) reportLog(stdout io.ReadCloser) {
func (r *Reporter) reportLog(stdout io.Reader) {
var output bytes.Buffer
scanner := bufio.NewScanner(stdout)
for scanner.Scan() {
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/contrailutil/package.go
Expand Up @@ -131,7 +131,7 @@ func createPackage(options linuxPackageOptions) {
// copy json schema
runPrint("cp", "-rp", filepath.Join(wd, "public"), homeDir)
// default config
runPrint("cp", "-p", filepath.Join(wd, "tools", "init.sql"), homeDir)
runPrint("cp", "-p", filepath.Join(wd, "tools", "init_mysql.sql"), homeDir)
runPrint("cp", "-p", filepath.Join(wd, "packaging", "apisrv.yml"), homeDir)
// remove bin path
runPrint("rm", "-rf", filepath.Join(packageRoot, options.homeDir, "bin"))
Expand Down
10 changes: 9 additions & 1 deletion playbooks/contrail-go-docker/run.yaml
Expand Up @@ -8,13 +8,21 @@
tasks:
- include: build-setup.yaml

- name: run
- name: run
include: build-step.yaml
loop_control:
label: "{{ item.name }}"
with_items: # Insert tasks here
- name: Install deps
command: make deps
- name: install mysql client
command: sudo apt install mysql-client
- name: make lint
command: make lint
- name: reset db
command: make reset_db
- name: make test
command: make test
- name: Install packaging tools
command: |
sudo apt-get install -y zip build-essential rpm rubygems ruby-dev curl;
Expand Down
4 changes: 2 additions & 2 deletions tools/lint.sh
Expand Up @@ -33,7 +33,7 @@ gometalinter \
--tests \
--aggregate \
--sort path \
--deadline 1m \
--deadline 10m \
--concurrency 1 \
--line-length 120 \
--dupl-threshold=70 \
Expand All @@ -55,7 +55,7 @@ gometalinter \
--tests \
--aggregate \
--sort path \
--deadline 1m \
--deadline 10m \
--concurrency 1 \
--line-length 120 \
--dupl-threshold=70 \
Expand Down

0 comments on commit 5b52c82

Please sign in to comment.