From 8a515b2eb29f3ed0f009b78ec7b623151f35a567 Mon Sep 17 00:00:00 2001 From: Mathew Merrick Date: Thu, 12 Sep 2019 17:23:02 -0700 Subject: [PATCH 01/23] Initial Azure Pipelines config (#314) * initial azure-pipeline config * remove cns restserver from ci * publish coverage report to pipelines * use default go version on runner --- .codecov/codecov.yml | 3 ++ .gitignore | 3 ++ .pipelines/pipeline.yml | 102 ++++++++++++++++++++++++++++++++++++++++ Makefile | 18 ++++++- 4 files changed, 125 insertions(+), 1 deletion(-) create mode 100644 .codecov/codecov.yml create mode 100644 .pipelines/pipeline.yml diff --git a/.codecov/codecov.yml b/.codecov/codecov.yml new file mode 100644 index 0000000000..e2a23c23d8 --- /dev/null +++ b/.codecov/codecov.yml @@ -0,0 +1,3 @@ +codecov: + notify: + require_ci_to_pass: no diff --git a/.gitignore b/.gitignore index 331501803f..c9274d2f13 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,6 @@ ipam-*.xml # Environment .vscode/* + +# Coverage +*.out \ No newline at end of file diff --git a/.pipelines/pipeline.yml b/.pipelines/pipeline.yml new file mode 100644 index 0000000000..2820f83d00 --- /dev/null +++ b/.pipelines/pipeline.yml @@ -0,0 +1,102 @@ +pr: +- master + +trigger: + branches: + include: + - master + +jobs: +- job: Test + pool: + vmImage: 'Ubuntu-16.04' + + # Go setup for the vmImage: + # https://github.com/Microsoft/azure-pipelines-image-generation/blob/master/images/linux/scripts/installers/go.sh + variables: + GOBIN: '$(GOPATH)/bin' # Go binaries path + GOPATH: '$(System.DefaultWorkingDirectory)/gopath' # Go workspace path + modulePath: '$(GOPATH)/src/github.com/Azure/azure-container-networking' # $(build.repository.name)' # Path to the module's code + + steps: + - script: | + echo $UID + sudo apt-get update + sudo apt-get install -y ebtables ipset python3-dev gcc zip + sudo pip install coverage + displayName: 'Install OS dependencies' + + - script: | + go version + go env + mkdir -p '$(GOBIN)' + mkdir -p '$(GOPATH)/pkg' + mkdir -p '$(modulePath)' + shopt -s extglob + shopt -s dotglob + mv !(gopath) '$(modulePath)' + echo '##vso[task.prependpath]$(GOBIN)' + echo '##vso[task.prependpath]$(GOROOT)/bin' + displayName: 'Set up the Go workspace' + + - script: | + go get -v -t -d ./... + if [ -f Gopkg.toml ]; then + curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh + dep ensure + fi + go get github.com/docker/libnetwork/driverapi + go get github.com/gorilla/mux + go get github.com/jstemmer/go-junit-report + go get github.com/axw/gocov/gocov + go get github.com/AlekSi/gocov-xml + go get -u gopkg.in/matm/v1/gocov-html + workingDirectory: '$(modulePath)' + displayName: 'Install Go dependencies' + + - script: | + set -o pipefail + set -e + sudo -E env "PATH=$PATH" make test-all 2>&1 | tee >(go-junit-report > report.xml) + bash <(curl -s https://codecov.io/bash) + gocov convert coverage.out > coverage.json + gocov-xml < coverage.json > coverage.xml + workingDirectory: '$(modulePath)' + displayName: 'RunTest' + + - task: PublishTestResults@2 + inputs: + testRunner: JUnit + testResultsFiles: $(System.DefaultWorkingDirectory)/**/report.xml + condition: always() + + - task: PublishCodeCoverageResults@1 + inputs: + codeCoverageTool: Cobertura + summaryFileLocation: $(System.DefaultWorkingDirectory)/**/coverage.xml + condition: always() + + - script: | + export GOOS=linux + sudo -E env "PATH=$PATH" make all-binaries + export GOOS=windows + sudo -E env "PATH=$PATH" make all-binaries + cd output + sudo find . -mindepth 2 -type f -print -exec mv {} . \; + sudo rm -R -- */ + sudo find . -type f -regextype posix-extended ! -iregex '.*\.(zip|tgz)$' -delete + workingDirectory: '$(modulePath)' + displayName: 'Build' + condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master')) + + - task: CopyFiles@2 + inputs: + sourceFolder: '$(modulePath)/output' + targetFolder: $(Build.ArtifactStagingDirectory) + condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master')) + + - task: PublishBuildArtifacts@1 + inputs: + artifactName: 'output' + pathtoPublish: '$(Build.ArtifactStagingDirectory)' + condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master')) diff --git a/Makefile b/Makefile index af3b7b4a84..d04844f00d 100644 --- a/Makefile +++ b/Makefile @@ -301,4 +301,20 @@ ifeq ($(GOOS),linux) cp telemetry/azure-vnet-telemetry.config $(NPM_BUILD_DIR)/azure-vnet-telemetry.config cd $(NPM_BUILD_DIR) && $(ARCHIVE_CMD) $(NPM_ARCHIVE_NAME) azure-npm$(EXE_EXT) azure-vnet-telemetry$(EXE_EXT) azure-vnet-telemetry.config chown $(BUILD_USER):$(BUILD_USER) $(NPM_BUILD_DIR)/$(NPM_ARCHIVE_NAME) -endif \ No newline at end of file +endif + +# run all tests +.PHONY: test-all +test-all: + go test -v -covermode count -coverprofile=coverage.out \ + ./ipam/ \ + ./log/ \ + ./netlink/ \ + ./store/ \ + ./telemetry/ \ + ./cnm/network/ \ + ./cni/ipam/ \ + ./cns/ipamclient/ \ + ./npm/iptm/ \ + ./npm/ipsm/ \ + ./npm \ No newline at end of file From fb13488cb187cadbd34d261491abfc7384b9fa3a Mon Sep 17 00:00:00 2001 From: Mathew Merrick Date: Fri, 13 Sep 2019 11:18:57 -0700 Subject: [PATCH 02/23] emit correct exit status code during test --- .pipelines/pipeline.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.pipelines/pipeline.yml b/.pipelines/pipeline.yml index 2820f83d00..d2d7f5cd15 100644 --- a/.pipelines/pipeline.yml +++ b/.pipelines/pipeline.yml @@ -57,7 +57,8 @@ jobs: - script: | set -o pipefail set -e - sudo -E env "PATH=$PATH" make test-all 2>&1 | tee >(go-junit-report > report.xml) + # run test, echo exit status code to fd 3, pipe output from test to tee, which splits output to stdout and go-junit-report (which converts test output to report.xml), stdout from tee is redirected to fd 4. Take output written to fd 3 (which is the exit code of test), redirect to a subshell stdout, pipe to read from stdout then exit with that status code. Read all output from fd 4 (output from tee) and write to top shell stdout + ((((sudo -E env "PATH=$PATH" make test-all; echo $? >&3) | tee >(go-junit-report > report.xml) >&4) 3>&1) | (read xs; exit $xs)) 4>&1 bash <(curl -s https://codecov.io/bash) gocov convert coverage.out > coverage.json gocov-xml < coverage.json > coverage.xml From 01905a67c4ca648a3eb633ab80fa9a5654978157 Mon Sep 17 00:00:00 2001 From: Mathew Merrick Date: Fri, 13 Sep 2019 11:48:27 -0700 Subject: [PATCH 03/23] Update pipeline.yml for Azure Pipelines --- .pipelines/pipeline.yml | 55 ++++++++++++++++++++++++----------------- 1 file changed, 32 insertions(+), 23 deletions(-) diff --git a/.pipelines/pipeline.yml b/.pipelines/pipeline.yml index d2d7f5cd15..c8e0e91ec5 100644 --- a/.pipelines/pipeline.yml +++ b/.pipelines/pipeline.yml @@ -19,14 +19,14 @@ jobs: modulePath: '$(GOPATH)/src/github.com/Azure/azure-container-networking' # $(build.repository.name)' # Path to the module's code steps: - - script: | + - bash: | echo $UID sudo apt-get update sudo apt-get install -y ebtables ipset python3-dev gcc zip sudo pip install coverage displayName: 'Install OS dependencies' - - script: | + - bash: | go version go env mkdir -p '$(GOBIN)' @@ -39,7 +39,7 @@ jobs: echo '##vso[task.prependpath]$(GOROOT)/bin' displayName: 'Set up the Go workspace' - - script: | + - bash: | go get -v -t -d ./... if [ -f Gopkg.toml ]; then curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh @@ -54,17 +54,39 @@ jobs: workingDirectory: '$(modulePath)' displayName: 'Install Go dependencies' - - script: | - set -o pipefail - set -e - # run test, echo exit status code to fd 3, pipe output from test to tee, which splits output to stdout and go-junit-report (which converts test output to report.xml), stdout from tee is redirected to fd 4. Take output written to fd 3 (which is the exit code of test), redirect to a subshell stdout, pipe to read from stdout then exit with that status code. Read all output from fd 4 (output from tee) and write to top shell stdout - ((((sudo -E env "PATH=$PATH" make test-all; echo $? >&3) | tee >(go-junit-report > report.xml) >&4) 3>&1) | (read xs; exit $xs)) 4>&1 + - bash: | + export GOOS=linux + sudo -E env "PATH=$PATH" make all-binaries + export GOOS=windows + sudo -E env "PATH=$PATH" make all-binaries + cd output + sudo find . -mindepth 2 -type f -print -exec mv {} . \; + sudo rm -R -- */ + sudo find . -type f -regextype posix-extended ! -iregex '.*\.(zip|tgz)$' -delete + workingDirectory: '$(modulePath)' + displayName: 'Build' + + - bash: | + # run test, echo exit status code to fd 3, pipe output from test to tee, which splits output to stdout and go-junit-report (which converts test output to report.xml), stdout from tee is redirected to fd 4. Take output written to fd 3 (which is the exit code of test), redirect to stdout, pipe to read from stdout then exit with that status code. Read all output from fd 4 (output from tee) and write to top stdout + { { { { + sudo -E env "PATH=$PATH" make test-all; + echo $? >&3; + } | tee > go-junit-report > report.xml >&4; + } 3>&1; + } | { read xs; exit $xs; } + } 4>&1 + workingDirectory: '$(modulePath)' + failOnStderr: true + displayName: 'Run Tests' + + - bash: | bash <(curl -s https://codecov.io/bash) gocov convert coverage.out > coverage.json gocov-xml < coverage.json > coverage.xml workingDirectory: '$(modulePath)' - displayName: 'RunTest' - + displayName: 'Generate Coverage Reports' + condition: always() + - task: PublishTestResults@2 inputs: testRunner: JUnit @@ -77,19 +99,6 @@ jobs: summaryFileLocation: $(System.DefaultWorkingDirectory)/**/coverage.xml condition: always() - - script: | - export GOOS=linux - sudo -E env "PATH=$PATH" make all-binaries - export GOOS=windows - sudo -E env "PATH=$PATH" make all-binaries - cd output - sudo find . -mindepth 2 -type f -print -exec mv {} . \; - sudo rm -R -- */ - sudo find . -type f -regextype posix-extended ! -iregex '.*\.(zip|tgz)$' -delete - workingDirectory: '$(modulePath)' - displayName: 'Build' - condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master')) - - task: CopyFiles@2 inputs: sourceFolder: '$(modulePath)/output' From 56cf5db03cfe82437daf1d49da342084160b4b3a Mon Sep 17 00:00:00 2001 From: Mathew Merrick Date: Tue, 17 Sep 2019 13:53:52 -0700 Subject: [PATCH 04/23] better logging lines in npm --- .pipelines/pipeline.yml | 2 +- npm/ipsm/ipsm.go | 4 ++-- npm/ipsm/ipsm_test.go | 17 ++++++++++++++++- npm/iptm/iptm.go | 5 +++-- npm/iptm/iptm_test.go | 5 ++++- npm/namespace_test.go | 5 ++++- npm/nwpolicy_test.go | 27 +++++++++++++++++++++------ 7 files changed, 51 insertions(+), 14 deletions(-) diff --git a/.pipelines/pipeline.yml b/.pipelines/pipeline.yml index c8e0e91ec5..bc348c5aec 100644 --- a/.pipelines/pipeline.yml +++ b/.pipelines/pipeline.yml @@ -71,7 +71,7 @@ jobs: { { { { sudo -E env "PATH=$PATH" make test-all; echo $? >&3; - } | tee > go-junit-report > report.xml >&4; + } | tee >(go-junit-report > report.xml) >&4; } 3>&1; } | { read xs; exit $xs; } } 4>&1 diff --git a/npm/ipsm/ipsm.go b/npm/ipsm/ipsm.go index 79c08fc853..0aab88fc46 100644 --- a/npm/ipsm/ipsm.go +++ b/npm/ipsm/ipsm.go @@ -350,8 +350,8 @@ func (ipsMgr *IpsetManager) Run(entry *ipsEntry) (int, error) { _, err := exec.Command(cmdName, cmdArgs...).Output() if msg, failed := err.(*exec.ExitError); failed { errCode := msg.Sys().(syscall.WaitStatus).ExitStatus() - if errCode > 1 { - log.Errorf("Error: There was an error running command: %s %s Arguments:%v", err, cmdName, cmdArgs) + if errCode > 0 { + log.Errorf("Error: There was an error running command: [%s %v] Stderr: [%v, %s]", cmdName, strings.Join(cmdArgs, " "), err, strings.TrimSuffix(string(msg.Stderr), "\n")) } return errCode, err diff --git a/npm/ipsm/ipsm_test.go b/npm/ipsm/ipsm_test.go index 818941d4dc..5735ae1a1f 100644 --- a/npm/ipsm/ipsm_test.go +++ b/npm/ipsm/ipsm_test.go @@ -4,6 +4,7 @@ package ipsm import ( "testing" + "os" "github.com/Azure/azure-container-networking/npm/util" ) @@ -76,6 +77,10 @@ func TestAddToList(t *testing.T) { } }() + if err := ipsMgr.CreateSet("test-set"); err != nil { + t.Errorf("TestAddToList failed @ ipsMgr.CreateSet") + } + if err := ipsMgr.AddToList("test-list", "test-set"); err != nil { t.Errorf("TestAddToList failed @ ipsMgr.AddToList") } @@ -93,6 +98,10 @@ func TestDeleteFromList(t *testing.T) { } }() + if err := ipsMgr.CreateSet("test-set"); err != nil { + t.Errorf("TestDeleteFromList failed @ ipsMgr.CreateSet") + } + if err := ipsMgr.AddToList("test-list", "test-set"); err != nil { t.Errorf("TestDeleteFromList failed @ ipsMgr.AddToList") } @@ -100,6 +109,10 @@ func TestDeleteFromList(t *testing.T) { if err := ipsMgr.DeleteFromList("test-list", "test-set"); err != nil { t.Errorf("TestDeleteFromList failed @ ipsMgr.DeleteFromList") } + + if err := ipsMgr.DeleteSet("test-set"); err != nil { + t.Errorf("TestDeleteSet failed @ ipsMgr.DeleteSet") + } } func TestCreateSet(t *testing.T) { @@ -246,7 +259,9 @@ func TestMain(m *testing.M) { ipsMgr := NewIpsetManager() ipsMgr.Save(util.IpsetConfigFile) - m.Run() + exitCode := m.Run() ipsMgr.Restore(util.IpsetConfigFile) + + os.Exit(exitCode) } diff --git a/npm/iptm/iptm.go b/npm/iptm/iptm.go index 5d2e0d74a2..ea4705ee5c 100644 --- a/npm/iptm/iptm.go +++ b/npm/iptm/iptm.go @@ -9,6 +9,7 @@ package iptm import ( "os" "os/exec" + "strings" "syscall" "time" @@ -365,8 +366,8 @@ func (iptMgr *IptablesManager) Run(entry *IptEntry) (int, error) { if msg, failed := err.(*exec.ExitError); failed { errCode := msg.Sys().(syscall.WaitStatus).ExitStatus() - if errCode > 1 { - log.Errorf("Error: There was an error running command: %s %s Arguments:%v", err, cmdName, cmdArgs) + if errCode > 0 { + log.Errorf("Error: There was an error running command: [%s %v] Stderr: [%v, %s]", cmdName, strings.Join(cmdArgs, " "), err, strings.TrimSuffix(string(msg.Stderr), "\n")) } return errCode, err diff --git a/npm/iptm/iptm_test.go b/npm/iptm/iptm_test.go index ba483a9bf9..04a454d6a5 100644 --- a/npm/iptm/iptm_test.go +++ b/npm/iptm/iptm_test.go @@ -2,6 +2,7 @@ package iptm import ( "testing" + "os" "github.com/Azure/azure-container-networking/npm/util" ) @@ -204,7 +205,9 @@ func TestMain(m *testing.M) { iptMgr := NewIptablesManager() iptMgr.Save(util.IptablesConfigFile) - m.Run() + exitCode := m.Run() iptMgr.Restore(util.IptablesConfigFile) + + os.Exit(exitCode) } diff --git a/npm/namespace_test.go b/npm/namespace_test.go index a446ad70d8..74814fc9e3 100644 --- a/npm/namespace_test.go +++ b/npm/namespace_test.go @@ -4,6 +4,7 @@ package npm import ( "testing" + "os" "github.com/Azure/azure-container-networking/npm/iptm" "github.com/Azure/azure-container-networking/telemetry" @@ -190,8 +191,10 @@ func TestMain(m *testing.M) { ipsMgr := ipsm.NewIpsetManager() ipsMgr.Save(util.IpsetConfigFile) - m.Run() + exitCode := m.Run() iptMgr.Restore(util.IptablesConfigFile) ipsMgr.Restore(util.IpsetConfigFile) + + os.Exit(exitCode) } diff --git a/npm/nwpolicy_test.go b/npm/nwpolicy_test.go index e6f48ce72d..352cd5b5b6 100644 --- a/npm/nwpolicy_test.go +++ b/npm/nwpolicy_test.go @@ -42,6 +42,11 @@ func TestAddNetworkPolicy(t *testing.T) { t.Errorf("TestAddNetworkPolicy failed @ ipsMgr.Save") } + // Create ns-kube-system set + if err := ipsMgr.CreateSet("ns-" + util.KubeSystemFlag); err != nil { + t.Errorf("TestAddNetworkPolicy failed @ ipsMgr.CreateSet, adding kube-system set%+v", err) + } + defer func() { if err := iptMgr.Restore(util.IptablesTestConfigFile); err != nil { t.Errorf("TestAddNetworkPolicy failed @ iptMgr.Restore") @@ -140,24 +145,29 @@ func TestUpdateNetworkPolicy(t *testing.T) { iptMgr := iptm.NewIptablesManager() if err := iptMgr.Save(util.IptablesTestConfigFile); err != nil { - t.Errorf("UpdateAddNetworkPolicy failed @ iptMgr.Save") + t.Errorf("TestUpdateNetworkPolicy failed @ iptMgr.Save") } ipsMgr := ipsm.NewIpsetManager() if err := ipsMgr.Save(util.IpsetTestConfigFile); err != nil { - t.Errorf("UpdateAddNetworkPolicy failed @ ipsMgr.Save") + t.Errorf("TestUpdateNetworkPolicy failed @ ipsMgr.Save") } defer func() { if err := iptMgr.Restore(util.IptablesTestConfigFile); err != nil { - t.Errorf("UpdateAddNetworkPolicy failed @ iptMgr.Restore") + t.Errorf("TestUpdateNetworkPolicy failed @ iptMgr.Restore") } if err := ipsMgr.Restore(util.IpsetTestConfigFile); err != nil { - t.Errorf("UpdateAddNetworkPolicy failed @ ipsMgr.Restore") + t.Errorf("TestUpdateNetworkPolicy failed @ ipsMgr.Restore") } }() + // Create ns-kube-system set + if err := ipsMgr.CreateSet("ns-" + util.KubeSystemFlag); err != nil { + t.Errorf("TestUpdateNetworkPolicy failed @ ipsMgr.CreateSet, adding kube-system set%+v", err) + } + nsObj := &corev1.Namespace{ ObjectMeta: metav1.ObjectMeta{ Name: "test-nwpolicy", @@ -168,7 +178,7 @@ func TestUpdateNetworkPolicy(t *testing.T) { } if err := npMgr.AddNamespace(nsObj); err != nil { - t.Errorf("TestAddNetworkPolicy @ npMgr.AddNamespace") + t.Errorf("TestUpdateNetworkPolicy @ npMgr.AddNamespace") } tcp, udp := corev1.ProtocolTCP, corev1.ProtocolUDP @@ -265,6 +275,11 @@ func TestDeleteNetworkPolicy(t *testing.T) { } }() + // Create ns-kube-system set + if err := ipsMgr.CreateSet("ns-" + util.KubeSystemFlag); err != nil { + t.Errorf("TestDeleteNetworkPolicy failed @ ipsMgr.CreateSet, adding kube-system set%+v", err) + } + nsObj := &corev1.Namespace{ ObjectMeta: metav1.ObjectMeta{ Name: "test-nwpolicy", @@ -308,6 +323,6 @@ func TestDeleteNetworkPolicy(t *testing.T) { } if err := npMgr.DeleteNetworkPolicy(allow); err != nil { - t.Errorf("TestAddNetworkPolicy failed @ DeleteNetworkPolicy") + t.Errorf("TestDeleteNetworkPolicy failed @ DeleteNetworkPolicy") } } From d1b2a59e2bbda2d18c0ef73fbb70c23c4f71a243 Mon Sep 17 00:00:00 2001 From: Mathew Merrick Date: Wed, 18 Sep 2019 17:58:34 -0700 Subject: [PATCH 05/23] publish build artifacts on succeed --- .pipelines/pipeline.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pipelines/pipeline.yml b/.pipelines/pipeline.yml index bc348c5aec..f70bf8c1ed 100644 --- a/.pipelines/pipeline.yml +++ b/.pipelines/pipeline.yml @@ -103,10 +103,10 @@ jobs: inputs: sourceFolder: '$(modulePath)/output' targetFolder: $(Build.ArtifactStagingDirectory) - condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master')) + condition: and(succeeded()) - task: PublishBuildArtifacts@1 inputs: artifactName: 'output' pathtoPublish: '$(Build.ArtifactStagingDirectory)' - condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master')) + condition: and(succeeded()) From 3bb17bb706ee7ea5c0c8f93f530642de5f0b4ca7 Mon Sep 17 00:00:00 2001 From: Mathew Merrick Date: Wed, 18 Sep 2019 18:05:00 -0700 Subject: [PATCH 06/23] remove codecov yaml --- .codecov/codecov.yml | 3 --- .pipelines/pipeline.yml | 4 ++-- 2 files changed, 2 insertions(+), 5 deletions(-) delete mode 100644 .codecov/codecov.yml diff --git a/.codecov/codecov.yml b/.codecov/codecov.yml deleted file mode 100644 index e2a23c23d8..0000000000 --- a/.codecov/codecov.yml +++ /dev/null @@ -1,3 +0,0 @@ -codecov: - notify: - require_ci_to_pass: no diff --git a/.pipelines/pipeline.yml b/.pipelines/pipeline.yml index f70bf8c1ed..9c4d77aafb 100644 --- a/.pipelines/pipeline.yml +++ b/.pipelines/pipeline.yml @@ -103,10 +103,10 @@ jobs: inputs: sourceFolder: '$(modulePath)/output' targetFolder: $(Build.ArtifactStagingDirectory) - condition: and(succeeded()) + condition: succeeded() - task: PublishBuildArtifacts@1 inputs: artifactName: 'output' pathtoPublish: '$(Build.ArtifactStagingDirectory)' - condition: and(succeeded()) + condition: succeeded() From e85aec36521b4efcae05aa9fc0f3a2cb585be33f Mon Sep 17 00:00:00 2001 From: Mathew Merrick Date: Wed, 18 Sep 2019 18:24:01 -0700 Subject: [PATCH 07/23] update readme with azure pipelines badge --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9634a1d896..6c51c86e91 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Microsoft Azure Container Networking -[![CircleCI](https://circleci.com/gh/Azure/azure-container-networking/tree/master.svg?style=svg)](https://circleci.com/gh/Azure/azure-container-networking/tree/master) [![Go Report Card](https://goreportcard.com/badge/github.com/Azure/azure-container-networking)](https://goreportcard.com/report/github.com/Azure/azure-container-networking) ![GitHub release](https://img.shields.io/github/release/Azure/azure-container-networking.svg) +[![Build Status](https://msazure.visualstudio.com/One/_apis/build/status/Custom/Networking/ContainerNetworking/Azure.azure-container-networking?branchName=master)](https://msazure.visualstudio.com/One/_build/latest?definitionId=95007&branchName=master) [![Go Report Card](https://goreportcard.com/badge/github.com/Azure/azure-container-networking)](https://goreportcard.com/report/github.com/Azure/azure-container-networking) ![GitHub release](https://img.shields.io/github/release/Azure/azure-container-networking.svg) [![codecov](https://codecov.io/gh/Azure/azure-container-networking/branch/master/graph/badge.svg)](https://codecov.io/gh/Azure/azure-container-networking) ## Overview From 74f72d8987649232d28f4a25234f9d8455d8df17 Mon Sep 17 00:00:00 2001 From: Mathew Merrick Date: Thu, 19 Sep 2019 12:26:53 -0700 Subject: [PATCH 08/23] update published artifacts --- .pipelines/pipeline.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pipelines/pipeline.yml b/.pipelines/pipeline.yml index 9c4d77aafb..5e39856478 100644 --- a/.pipelines/pipeline.yml +++ b/.pipelines/pipeline.yml @@ -60,9 +60,9 @@ jobs: export GOOS=windows sudo -E env "PATH=$PATH" make all-binaries cd output + sudo find . -mindepth 2 -type f -regextype posix-extended ! -iregex '.*\.(zip|tgz)$' -delete sudo find . -mindepth 2 -type f -print -exec mv {} . \; sudo rm -R -- */ - sudo find . -type f -regextype posix-extended ! -iregex '.*\.(zip|tgz)$' -delete workingDirectory: '$(modulePath)' displayName: 'Build' From be54e9ffa9e2aae95e1831402d624a81d9ef6f58 Mon Sep 17 00:00:00 2001 From: Mathew Merrick Date: Thu, 19 Sep 2019 14:26:56 -0700 Subject: [PATCH 09/23] example policy has ingress and egress --- npm/translatePolicy_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/npm/translatePolicy_test.go b/npm/translatePolicy_test.go index 200b81546a..7039fe51bb 100644 --- a/npm/translatePolicy_test.go +++ b/npm/translatePolicy_test.go @@ -2807,7 +2807,7 @@ func TestTranslatePolicy(t *testing.T) { }, } expectedIptEntries = append(expectedIptEntries, nonKubeSystemEntries...) - expectedIptEntries = append(expectedIptEntries, getDefaultDropEntries("testnamespace", targetSelector, false, true)...) + expectedIptEntries = append(expectedIptEntries, getDefaultDropEntries("testnamespace", targetSelector, true, true)...) if !reflect.DeepEqual(iptEntries, expectedIptEntries) { t.Errorf("translatedPolicy failed @ k8s-example-policy policy comparison") marshalledIptEntries, _ := json.Marshal(iptEntries) From 290c620704d536110ad0900aa5b8ac1a9b1660ab Mon Sep 17 00:00:00 2001 From: Mathew Merrick Date: Thu, 19 Sep 2019 16:32:44 -0700 Subject: [PATCH 10/23] specify runner pool --- .pipelines/pipeline.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.pipelines/pipeline.yml b/.pipelines/pipeline.yml index 5e39856478..5af470023c 100644 --- a/.pipelines/pipeline.yml +++ b/.pipelines/pipeline.yml @@ -7,9 +7,10 @@ trigger: - master jobs: -- job: Test +- job: Build and run Unit Tests pool: - vmImage: 'Ubuntu-16.04' + name: Networking-ContainerNetworking + demands: agent.os -equals Linux # Go setup for the vmImage: # https://github.com/Microsoft/azure-pipelines-image-generation/blob/master/images/linux/scripts/installers/go.sh From 0229c609111d7587a2a7097c03e041f219d21739 Mon Sep 17 00:00:00 2001 From: Mathew Merrick Date: Thu, 19 Sep 2019 16:34:24 -0700 Subject: [PATCH 11/23] job name --- .pipelines/pipeline.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pipelines/pipeline.yml b/.pipelines/pipeline.yml index 5af470023c..09471180b6 100644 --- a/.pipelines/pipeline.yml +++ b/.pipelines/pipeline.yml @@ -7,7 +7,7 @@ trigger: - master jobs: -- job: Build and run Unit Tests +- job: UnitTest pool: name: Networking-ContainerNetworking demands: agent.os -equals Linux From 10ebb6163ab5b6f7d7711f2c4457650ef5a69b85 Mon Sep 17 00:00:00 2001 From: Mathew Merrick Date: Thu, 19 Sep 2019 17:29:48 -0700 Subject: [PATCH 12/23] cnm fixes --- network/network_linux.go | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/network/network_linux.go b/network/network_linux.go index b2966790de..380f9bc6f4 100644 --- a/network/network_linux.go +++ b/network/network_linux.go @@ -269,14 +269,19 @@ func (nm *networkManager) applyIPConfig(extIf *externalInterface, targetIf *net. } func applyDnsConfig(extIf *externalInterface, ifName string) error { - cmd := fmt.Sprintf("systemd-resolve --interface=%s --set-dns=%s", ifName, extIf.DNSInfo.Servers[0]) - _, err := platform.ExecuteCommand(cmd) - if err != nil { - return err + var err error + + if(extIf != nil && len(extIf.DNSInfo.Servers) > 0) { + cmd := fmt.Sprintf("systemd-resolve --interface=%s --set-dns=%s", ifName, extIf.DNSInfo.Servers[0]) + _, err = platform.ExecuteCommand(cmd) + if err != nil { + return err + } + + cmd = fmt.Sprintf("systemd-resolve --interface=%s --set-domain=%s", ifName, extIf.DNSInfo.Suffix) + _, err = platform.ExecuteCommand(cmd) } - cmd = fmt.Sprintf("systemd-resolve --interface=%s --set-domain=%s", ifName, extIf.DNSInfo.Suffix) - _, err = platform.ExecuteCommand(cmd) return err } From 6321f88d70e8c63420865b92f6821e871eb47b26 Mon Sep 17 00:00:00 2001 From: Mathew Merrick Date: Thu, 19 Sep 2019 17:40:06 -0700 Subject: [PATCH 13/23] remove test.sock --- .pipelines/pipeline.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.pipelines/pipeline.yml b/.pipelines/pipeline.yml index 09471180b6..7f2ebc118f 100644 --- a/.pipelines/pipeline.yml +++ b/.pipelines/pipeline.yml @@ -36,6 +36,7 @@ jobs: shopt -s extglob shopt -s dotglob mv !(gopath) '$(modulePath)' + sudo rm /run/docker/plugins/test.sock echo '##vso[task.prependpath]$(GOBIN)' echo '##vso[task.prependpath]$(GOROOT)/bin' displayName: 'Set up the Go workspace' From f6cc628d17c4a83f43a78287c1827e8670ff332f Mon Sep 17 00:00:00 2001 From: Mathew Merrick Date: Thu, 19 Sep 2019 17:43:25 -0700 Subject: [PATCH 14/23] make as non-root --- .pipelines/pipeline.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pipelines/pipeline.yml b/.pipelines/pipeline.yml index 7f2ebc118f..a3465e5802 100644 --- a/.pipelines/pipeline.yml +++ b/.pipelines/pipeline.yml @@ -58,9 +58,9 @@ jobs: - bash: | export GOOS=linux - sudo -E env "PATH=$PATH" make all-binaries + make all-binaries export GOOS=windows - sudo -E env "PATH=$PATH" make all-binaries + make all-binaries cd output sudo find . -mindepth 2 -type f -regextype posix-extended ! -iregex '.*\.(zip|tgz)$' -delete sudo find . -mindepth 2 -type f -print -exec mv {} . \; From 652a8b1c7c67f7ab9842816261bba975a987e649 Mon Sep 17 00:00:00 2001 From: Mathew Merrick Date: Thu, 19 Sep 2019 17:59:14 -0700 Subject: [PATCH 15/23] test cleanup --- .pipelines/pipeline.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.pipelines/pipeline.yml b/.pipelines/pipeline.yml index a3465e5802..acc1fb4f9e 100644 --- a/.pipelines/pipeline.yml +++ b/.pipelines/pipeline.yml @@ -36,7 +36,6 @@ jobs: shopt -s extglob shopt -s dotglob mv !(gopath) '$(modulePath)' - sudo rm /run/docker/plugins/test.sock echo '##vso[task.prependpath]$(GOBIN)' echo '##vso[task.prependpath]$(GOROOT)/bin' displayName: 'Set up the Go workspace' @@ -88,6 +87,13 @@ jobs: workingDirectory: '$(modulePath)' displayName: 'Generate Coverage Reports' condition: always() + + - bash: | + sudo rm /run/docker/plugins/test.sock + sudo ip link del dev dummy + workingDirectory: '$(modulePath)' + displayName: 'Test cleanup' + condition: always() - task: PublishTestResults@2 inputs: From 075033d6d71fe5bc82a2ea56156b1cd0c2694b02 Mon Sep 17 00:00:00 2001 From: Mathew Merrick Date: Thu, 19 Sep 2019 18:20:46 -0700 Subject: [PATCH 16/23] remove test cleanup --- .pipelines/pipeline.yml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/.pipelines/pipeline.yml b/.pipelines/pipeline.yml index acc1fb4f9e..e0b0bf647f 100644 --- a/.pipelines/pipeline.yml +++ b/.pipelines/pipeline.yml @@ -87,13 +87,6 @@ jobs: workingDirectory: '$(modulePath)' displayName: 'Generate Coverage Reports' condition: always() - - - bash: | - sudo rm /run/docker/plugins/test.sock - sudo ip link del dev dummy - workingDirectory: '$(modulePath)' - displayName: 'Test cleanup' - condition: always() - task: PublishTestResults@2 inputs: From 5545c2b6b3896a078d0f4838ef48cad28b9b13a7 Mon Sep 17 00:00:00 2001 From: Mathew Merrick Date: Fri, 20 Sep 2019 10:45:43 -0700 Subject: [PATCH 17/23] add test setup --- .pipelines/pipeline.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.pipelines/pipeline.yml b/.pipelines/pipeline.yml index e0b0bf647f..67182a949c 100644 --- a/.pipelines/pipeline.yml +++ b/.pipelines/pipeline.yml @@ -55,6 +55,13 @@ jobs: workingDirectory: '$(modulePath)' displayName: 'Install Go dependencies' + - bash: | + sudo rm /run/docker/plugins/test.sock || true + sudo ip link del dev dummy || true + workingDirectory: '$(modulePath)' + displayName: 'Workspace setup' + condition: always() + - bash: | export GOOS=linux make all-binaries From 482710bc57ec216ad0529f519500d1df9b9ea6e8 Mon Sep 17 00:00:00 2001 From: Mathew Merrick Date: Fri, 20 Sep 2019 11:24:37 -0700 Subject: [PATCH 18/23] address comments --- .pipelines/pipeline.yml | 203 +++++++++++++++++++-------------------- network/network_linux.go | 2 +- 2 files changed, 102 insertions(+), 103 deletions(-) diff --git a/.pipelines/pipeline.yml b/.pipelines/pipeline.yml index 67182a949c..496f294802 100644 --- a/.pipelines/pipeline.yml +++ b/.pipelines/pipeline.yml @@ -1,120 +1,119 @@ pr: -- master + - master trigger: branches: include: - - master + - master jobs: -- job: UnitTest - pool: - name: Networking-ContainerNetworking - demands: agent.os -equals Linux + - job: UnitTest + pool: + name: Networking-ContainerNetworking + demands: agent.os -equals Linux - # Go setup for the vmImage: - # https://github.com/Microsoft/azure-pipelines-image-generation/blob/master/images/linux/scripts/installers/go.sh - variables: - GOBIN: '$(GOPATH)/bin' # Go binaries path - GOPATH: '$(System.DefaultWorkingDirectory)/gopath' # Go workspace path - modulePath: '$(GOPATH)/src/github.com/Azure/azure-container-networking' # $(build.repository.name)' # Path to the module's code + # Go setup for the vmImage: + # https://github.com/Microsoft/azure-pipelines-image-generation/blob/master/images/linux/scripts/installers/go.sh + variables: + GOBIN: "$(GOPATH)/bin" # Go binaries path + GOPATH: "$(System.DefaultWorkingDirectory)/gopath" # Go workspace path + modulePath: "$(GOPATH)/src/github.com/Azure/azure-container-networking" # $(build.repository.name)' # Path to the module's code - steps: - - bash: | - echo $UID - sudo apt-get update - sudo apt-get install -y ebtables ipset python3-dev gcc zip - sudo pip install coverage - displayName: 'Install OS dependencies' + steps: + - bash: | + echo $UID + sudo apt-get update + sudo apt-get install -y ebtables ipset python3-dev gcc zip + sudo pip install coverage + displayName: "Install OS dependencies" - - bash: | - go version - go env - mkdir -p '$(GOBIN)' - mkdir -p '$(GOPATH)/pkg' - mkdir -p '$(modulePath)' - shopt -s extglob - shopt -s dotglob - mv !(gopath) '$(modulePath)' - echo '##vso[task.prependpath]$(GOBIN)' - echo '##vso[task.prependpath]$(GOROOT)/bin' - displayName: 'Set up the Go workspace' + - bash: | + go version + go env + mkdir -p '$(GOBIN)' + mkdir -p '$(GOPATH)/pkg' + mkdir -p '$(modulePath)' + shopt -s extglob + shopt -s dotglob + mv !(gopath) '$(modulePath)' + echo '##vso[task.prependpath]$(GOBIN)' + echo '##vso[task.prependpath]$(GOROOT)/bin' + displayName: "Set up the Go workspace" - - bash: | - go get -v -t -d ./... - if [ -f Gopkg.toml ]; then - curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh - dep ensure - fi - go get github.com/docker/libnetwork/driverapi - go get github.com/gorilla/mux - go get github.com/jstemmer/go-junit-report - go get github.com/axw/gocov/gocov - go get github.com/AlekSi/gocov-xml - go get -u gopkg.in/matm/v1/gocov-html - workingDirectory: '$(modulePath)' - displayName: 'Install Go dependencies' + - bash: | + go get -v -t -d ./... + if [ -f Gopkg.toml ]; then + curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh + fi + go get github.com/docker/libnetwork/driverapi + go get github.com/gorilla/mux + go get github.com/jstemmer/go-junit-report + go get github.com/axw/gocov/gocov + go get github.com/AlekSi/gocov-xml + go get -u gopkg.in/matm/v1/gocov-html + workingDirectory: "$(modulePath)" + displayName: "Install Go dependencies" - - bash: | - sudo rm /run/docker/plugins/test.sock || true - sudo ip link del dev dummy || true - workingDirectory: '$(modulePath)' - displayName: 'Workspace setup' - condition: always() + - bash: | + sudo rm /run/docker/plugins/test.sock || true + sudo ip link del dev dummy || true + workingDirectory: "$(modulePath)" + displayName: "Workspace setup" + condition: always() - - bash: | - export GOOS=linux - make all-binaries - export GOOS=windows - make all-binaries - cd output - sudo find . -mindepth 2 -type f -regextype posix-extended ! -iregex '.*\.(zip|tgz)$' -delete - sudo find . -mindepth 2 -type f -print -exec mv {} . \; - sudo rm -R -- */ - workingDirectory: '$(modulePath)' - displayName: 'Build' + - bash: | + export GOOS=linux + make all-binaries + export GOOS=windows + make all-binaries + cd output + sudo find . -mindepth 2 -type f -regextype posix-extended ! -iregex '.*\.(zip|tgz)$' -delete + sudo find . -mindepth 2 -type f -print -exec mv {} . \; + sudo rm -R -- */ + workingDirectory: "$(modulePath)" + displayName: "Build" - - bash: | - # run test, echo exit status code to fd 3, pipe output from test to tee, which splits output to stdout and go-junit-report (which converts test output to report.xml), stdout from tee is redirected to fd 4. Take output written to fd 3 (which is the exit code of test), redirect to stdout, pipe to read from stdout then exit with that status code. Read all output from fd 4 (output from tee) and write to top stdout - { { { { - sudo -E env "PATH=$PATH" make test-all; - echo $? >&3; - } | tee >(go-junit-report > report.xml) >&4; - } 3>&1; - } | { read xs; exit $xs; } - } 4>&1 - workingDirectory: '$(modulePath)' - failOnStderr: true - displayName: 'Run Tests' + - bash: | + # run test, echo exit status code to fd 3, pipe output from test to tee, which splits output to stdout and go-junit-report (which converts test output to report.xml), stdout from tee is redirected to fd 4. Take output written to fd 3 (which is the exit code of test), redirect to stdout, pipe to read from stdout then exit with that status code. Read all output from fd 4 (output from tee) and write to top stdout + { { { { + sudo -E env "PATH=$PATH" make test-all; + echo $? >&3; + } | tee >(go-junit-report > report.xml) >&4; + } 3>&1; + } | { read xs; exit $xs; } + } 4>&1 + workingDirectory: "$(modulePath)" + failOnStderr: true + displayName: "Run Tests" - - bash: | - bash <(curl -s https://codecov.io/bash) - gocov convert coverage.out > coverage.json - gocov-xml < coverage.json > coverage.xml - workingDirectory: '$(modulePath)' - displayName: 'Generate Coverage Reports' - condition: always() - - - task: PublishTestResults@2 - inputs: - testRunner: JUnit - testResultsFiles: $(System.DefaultWorkingDirectory)/**/report.xml - condition: always() + - bash: | + bash <(curl -s https://codecov.io/bash) + gocov convert coverage.out > coverage.json + gocov-xml < coverage.json > coverage.xml + workingDirectory: "$(modulePath)" + displayName: "Generate Coverage Reports" + condition: always() - - task: PublishCodeCoverageResults@1 - inputs: - codeCoverageTool: Cobertura - summaryFileLocation: $(System.DefaultWorkingDirectory)/**/coverage.xml - condition: always() + - task: PublishTestResults@2 + inputs: + testRunner: JUnit + testResultsFiles: $(System.DefaultWorkingDirectory)/**/report.xml + condition: always() - - task: CopyFiles@2 - inputs: - sourceFolder: '$(modulePath)/output' - targetFolder: $(Build.ArtifactStagingDirectory) - condition: succeeded() + - task: PublishCodeCoverageResults@1 + inputs: + codeCoverageTool: Cobertura + summaryFileLocation: $(System.DefaultWorkingDirectory)/**/coverage.xml + condition: always() - - task: PublishBuildArtifacts@1 - inputs: - artifactName: 'output' - pathtoPublish: '$(Build.ArtifactStagingDirectory)' - condition: succeeded() + - task: CopyFiles@2 + inputs: + sourceFolder: "$(modulePath)/output" + targetFolder: $(Build.ArtifactStagingDirectory) + condition: succeeded() + + - task: PublishBuildArtifacts@1 + inputs: + artifactName: "output" + pathtoPublish: "$(Build.ArtifactStagingDirectory)" + condition: succeeded() diff --git a/network/network_linux.go b/network/network_linux.go index 380f9bc6f4..195fcccc86 100644 --- a/network/network_linux.go +++ b/network/network_linux.go @@ -271,7 +271,7 @@ func (nm *networkManager) applyIPConfig(extIf *externalInterface, targetIf *net. func applyDnsConfig(extIf *externalInterface, ifName string) error { var err error - if(extIf != nil && len(extIf.DNSInfo.Servers) > 0) { + if extIf != nil && len(extIf.DNSInfo.Servers) > 0 { cmd := fmt.Sprintf("systemd-resolve --interface=%s --set-dns=%s", ifName, extIf.DNSInfo.Servers[0]) _, err = platform.ExecuteCommand(cmd) if err != nil { From b9ab4e0413a8476d5eec5b9831e56e6241d4c951 Mon Sep 17 00:00:00 2001 From: Mathew Merrick Date: Fri, 20 Sep 2019 11:44:16 -0700 Subject: [PATCH 19/23] run in container on custom agent test --- .pipelines/pipeline.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.pipelines/pipeline.yml b/.pipelines/pipeline.yml index 496f294802..d08851b5f2 100644 --- a/.pipelines/pipeline.yml +++ b/.pipelines/pipeline.yml @@ -12,6 +12,8 @@ jobs: name: Networking-ContainerNetworking demands: agent.os -equals Linux + container: golang:1.12 + # Go setup for the vmImage: # https://github.com/Microsoft/azure-pipelines-image-generation/blob/master/images/linux/scripts/installers/go.sh variables: From eb818683e4a9964030dcc9c52b8991e46388161d Mon Sep 17 00:00:00 2001 From: Mathew Merrick Date: Fri, 20 Sep 2019 14:52:13 -0700 Subject: [PATCH 20/23] custom container image env --- .pipelines/Dockerfile | 12 ++++++++++++ .pipelines/pipeline.yml | 25 +++---------------------- 2 files changed, 15 insertions(+), 22 deletions(-) create mode 100644 .pipelines/Dockerfile diff --git a/.pipelines/Dockerfile b/.pipelines/Dockerfile new file mode 100644 index 0000000000..600a775b5f --- /dev/null +++ b/.pipelines/Dockerfile @@ -0,0 +1,12 @@ +FROM ubuntu:16.04 +RUN apt-get update && apt-get install -y software-properties-common sudo +RUN add-apt-repository ppa:longsleep/golang-backports && apt-get update +RUN apt-get install -y git golang-go=2:1.13~1longsleep1+xenial iptables ipset iproute2 ebtables +RUN go get -v -t -d ./... +RUN if [ -f Gopkg.toml ]; then curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh ; fi +RUN go get github.com/docker/libnetwork/driverapi +RUN go get github.com/gorilla/mux +RUN go get github.com/jstemmer/go-junit-report +RUN go get github.com/axw/gocov/gocov +RUN go get github.com/AlekSi/gocov-xml +RUN go get -u gopkg.in/matm/v1/gocov-html diff --git a/.pipelines/pipeline.yml b/.pipelines/pipeline.yml index d08851b5f2..0fdf0d3d07 100644 --- a/.pipelines/pipeline.yml +++ b/.pipelines/pipeline.yml @@ -12,7 +12,9 @@ jobs: name: Networking-ContainerNetworking demands: agent.os -equals Linux - container: golang:1.12 + container: + image: containernetworking/pipeline-ci:1.0 + options: "--privileged" # Go setup for the vmImage: # https://github.com/Microsoft/azure-pipelines-image-generation/blob/master/images/linux/scripts/installers/go.sh @@ -22,13 +24,6 @@ jobs: modulePath: "$(GOPATH)/src/github.com/Azure/azure-container-networking" # $(build.repository.name)' # Path to the module's code steps: - - bash: | - echo $UID - sudo apt-get update - sudo apt-get install -y ebtables ipset python3-dev gcc zip - sudo pip install coverage - displayName: "Install OS dependencies" - - bash: | go version go env @@ -42,20 +37,6 @@ jobs: echo '##vso[task.prependpath]$(GOROOT)/bin' displayName: "Set up the Go workspace" - - bash: | - go get -v -t -d ./... - if [ -f Gopkg.toml ]; then - curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh - fi - go get github.com/docker/libnetwork/driverapi - go get github.com/gorilla/mux - go get github.com/jstemmer/go-junit-report - go get github.com/axw/gocov/gocov - go get github.com/AlekSi/gocov-xml - go get -u gopkg.in/matm/v1/gocov-html - workingDirectory: "$(modulePath)" - displayName: "Install Go dependencies" - - bash: | sudo rm /run/docker/plugins/test.sock || true sudo ip link del dev dummy || true From e0f49ae9a2289df901afe26363ca96b8eb3c4a66 Mon Sep 17 00:00:00 2001 From: Mathew Merrick Date: Fri, 20 Sep 2019 15:02:13 -0700 Subject: [PATCH 21/23] update ci image --- .pipelines/pipeline.yml | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/.pipelines/pipeline.yml b/.pipelines/pipeline.yml index 0fdf0d3d07..465f422297 100644 --- a/.pipelines/pipeline.yml +++ b/.pipelines/pipeline.yml @@ -13,7 +13,7 @@ jobs: demands: agent.os -equals Linux container: - image: containernetworking/pipeline-ci:1.0 + image: containernetworking/pipeline-ci:1.0.1 options: "--privileged" # Go setup for the vmImage: @@ -24,6 +24,12 @@ jobs: modulePath: "$(GOPATH)/src/github.com/Azure/azure-container-networking" # $(build.repository.name)' # Path to the module's code steps: + - bash: | + echo $UID + sudo apt-get install -y ebtables ipset python3-dev gcc zip iptables ipset + sudo pip install coverage + displayName: "Install OS dependencies" + - bash: | go version go env @@ -37,6 +43,20 @@ jobs: echo '##vso[task.prependpath]$(GOROOT)/bin' displayName: "Set up the Go workspace" + - bash: | + go get -v -t -d ./... + if [ -f Gopkg.toml ]; then + curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh + fi + go get github.com/docker/libnetwork/driverapi + go get github.com/gorilla/mux + go get github.com/jstemmer/go-junit-report + go get github.com/axw/gocov/gocov + go get github.com/AlekSi/gocov-xml + go get -u gopkg.in/matm/v1/gocov-html + workingDirectory: "$(modulePath)" + displayName: "Install Go dependencies" + - bash: | sudo rm /run/docker/plugins/test.sock || true sudo ip link del dev dummy || true From 2ba855b30293d435ccbb9cea0d015debde243a7d Mon Sep 17 00:00:00 2001 From: Mathew Merrick Date: Fri, 20 Sep 2019 15:28:01 -0700 Subject: [PATCH 22/23] update ci image 2 --- .pipelines/pipeline.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pipelines/pipeline.yml b/.pipelines/pipeline.yml index 465f422297..948b5eba14 100644 --- a/.pipelines/pipeline.yml +++ b/.pipelines/pipeline.yml @@ -13,7 +13,7 @@ jobs: demands: agent.os -equals Linux container: - image: containernetworking/pipeline-ci:1.0.1 + image: containernetworking/pipeline-ci:1.0.2 options: "--privileged" # Go setup for the vmImage: From a16543cf3d3e9399b029a57719de6522a961f19f Mon Sep 17 00:00:00 2001 From: Mathew Merrick Date: Fri, 20 Sep 2019 15:59:24 -0700 Subject: [PATCH 23/23] update ci image 3 --- .pipelines/Dockerfile | 10 +++++++--- .pipelines/pipeline.yml | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.pipelines/Dockerfile b/.pipelines/Dockerfile index 600a775b5f..f515ab9a45 100644 --- a/.pipelines/Dockerfile +++ b/.pipelines/Dockerfile @@ -1,8 +1,10 @@ FROM ubuntu:16.04 -RUN apt-get update && apt-get install -y software-properties-common sudo +RUN apt-get update && apt-get install -y software-properties-common sudo wget apt-transport-https curl +RUN wget -q https://packages.microsoft.com/config/ubuntu/16.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb +RUN sudo dpkg -i packages-microsoft-prod.deb RUN add-apt-repository ppa:longsleep/golang-backports && apt-get update -RUN apt-get install -y git golang-go=2:1.13~1longsleep1+xenial iptables ipset iproute2 ebtables -RUN go get -v -t -d ./... +RUN apt-get install -y git golang-go=2:1.13~1longsleep1+xenial iptables ipset iproute2 ebtables python-pip gcc zip dotnet-sdk-2.2 +RUN sudo pip install coverage RUN if [ -f Gopkg.toml ]; then curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh ; fi RUN go get github.com/docker/libnetwork/driverapi RUN go get github.com/gorilla/mux @@ -10,3 +12,5 @@ RUN go get github.com/jstemmer/go-junit-report RUN go get github.com/axw/gocov/gocov RUN go get github.com/AlekSi/gocov-xml RUN go get -u gopkg.in/matm/v1/gocov-html +ENV PATH="/root/go/bin:${PATH}" + diff --git a/.pipelines/pipeline.yml b/.pipelines/pipeline.yml index 948b5eba14..c4d07f51b3 100644 --- a/.pipelines/pipeline.yml +++ b/.pipelines/pipeline.yml @@ -13,7 +13,7 @@ jobs: demands: agent.os -equals Linux container: - image: containernetworking/pipeline-ci:1.0.2 + image: containernetworking/pipeline-ci:1.0.3 options: "--privileged" # Go setup for the vmImage: