Skip to content

Commit 923b7d5

Browse files
authored
E2E CI (#403)
* E2E Azure Pipelines config
1 parent 65f7869 commit 923b7d5

File tree

5 files changed

+280
-125
lines changed

5 files changed

+280
-125
lines changed

.pipelines/Dockerfile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
FROM ubuntu:16.04
2-
RUN apt-get update && apt-get install -y software-properties-common sudo wget apt-transport-https curl
2+
RUN apt-get update && apt-get install -y software-properties-common sudo wget apt-transport-https curl lsb-release gnupg
33
RUN wget -q https://packages.microsoft.com/config/ubuntu/16.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
44
RUN sudo dpkg -i packages-microsoft-prod.deb
5-
RUN add-apt-repository ppa:longsleep/golang-backports && apt-get update
6-
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
5+
RUN add-apt-repository ppa:longsleep/golang-backports
6+
RUN curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
7+
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 azure-cli
78
RUN sudo pip install coverage
89
RUN if [ -f Gopkg.toml ]; then curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh ; fi
910
RUN go get github.com/docker/libnetwork/driverapi

.pipelines/e2e-job-template.yaml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
parameters:
2+
name: ""
3+
pipelineBuildImage: "containernetworking/pipeline-ci:1.0.4"
4+
clusterDefinitionUrl: "https://raw.githubusercontent.com/Azure/azure-container-networking/master/test/e2e/kubernetes/cniLinux.json"
5+
clusterDefinitionCniTypeKey: ""
6+
clusterDefinitionCniBuildOS: ""
7+
clusterDefinitionCniBuildExt: ""
8+
9+
jobs:
10+
- job: ${{ parameters.name }}
11+
dependsOn: unit_tests
12+
pool:
13+
name: Networking-ContainerNetworking
14+
demands: agent.os -equals Linux
15+
container:
16+
image: ${{ parameters.pipelineBuildImage }}
17+
variables:
18+
GOPATH: "$(System.DefaultWorkingDirectory)/gopath"
19+
GOBIN: "$(GOPATH)/bin" # Go binaries path
20+
modulePath: "$(GOPATH)/src/github.com/Azure/aks-engine"
21+
Tag: $[ dependencies.unit_tests.outputs['EnvironmentalVariables.Tag'] ]
22+
CommitHash: $[ dependencies.unit_tests.outputs['EnvironmentalVariables.CommitHash'] ]
23+
24+
steps:
25+
- template: e2e-step-template.yaml
26+
parameters:
27+
clusterDefinitionUrl: ${{ parameters.clusterDefinitionUrl }}
28+
clusterDefinitionCniTypeKey: ${{ parameters.clusterDefinitionCniTypeKey }}
29+
clusterDefinitionCniBuildOS: ${{ parameters.clusterDefinitionCniBuildOS }}
30+
clusterDefinitionCniBuildExt: ${{ parameters.clusterDefinitionCniBuildExt }}

.pipelines/e2e-step-template.yaml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
parameters:
2+
name: ""
3+
clusterDefinitionUrl: ""
4+
clusterDefinitionCniTypeKey: ""
5+
clusterDefinitionCniBuildOS: ""
6+
clusterDefinitionCniBuildExt: ""
7+
8+
steps:
9+
- checkout: none
10+
- bash: |
11+
go version
12+
go env
13+
go get -v github.com/Azure/aks-engine
14+
mkdir -p '$(GOBIN)'
15+
mkdir -p '$(GOPATH)/pkg'
16+
mkdir -p '$(modulePath)'
17+
echo '##vso[task.prependpath]$(GOBIN)'
18+
echo '##vso[task.prependpath]$(GOROOT)/bin'
19+
name: "GoEnv"
20+
displayName: "Set up the Go environment"
21+
22+
- bash: |
23+
rm -f clusterDefinition.json*
24+
wget '${{ parameters.clusterDefinitionUrl }}' -O clusterDefinition.json
25+
export CNI_URL='"'https://$(ARTIFACT_STORAGE).blob.core.windows.net/acn-$(CommitHash)/azure-vnet-cni-${{ parameters.clusterDefinitionCniBuildOS }}-amd64-$(Tag)${{ parameters.clusterDefinitionCniBuildExt }}'"'
26+
export CNI_TYPE=${{ parameters.clusterDefinitionCniTypeKey }}
27+
echo CNI type is $CNI_TYPE
28+
sed -i "s|\"$CNI_TYPE\":\".*\"|\"$CNI_TYPE\":$CNI_URL|g" clusterDefinition.json
29+
sed -i "s|\"azureCNIVersion\":\".*\"|\"azureCNIVersion\":\"$(Tag)\"|g" clusterDefinition.json
30+
echo "Running E2E tests against a cluster built with the following API model:"
31+
cat ./clusterDefinition.json
32+
curl -L https://dl.k8s.io/v1.16.0/kubernetes-client-linux-amd64.tar.gz | tar xvzf -
33+
sudo cp kubernetes/client/bin/kubectl /usr/local/bin/kubectl
34+
sudo cp kubernetes/client/bin/kubectl /usr/local/bin/k
35+
make bootstrap
36+
make build-binary
37+
displayName: Build AKS-Engine
38+
workingDirectory: "$(modulePath)"
39+
40+
- bash: |
41+
export CLUSTER_DEFINITION=./clusterDefinition.json
42+
export ORCHESTRATOR=kubernetes
43+
export CREATE_VNET=false
44+
export TIMEOUT=10m
45+
export CLIENT_ID=$(AKS_ENGINE_CLIENT_ID)
46+
export CLIENT_SECRET=$(AKS_ENGINE_CLIENT_SECRET)
47+
export TENANT_ID=$(AKS_ENGINE_TENANT_ID)
48+
export SUBSCRIPTION_ID=$(AKS_ENGINE_SUBSCRIPTION_ID)
49+
export CLEANUP_ON_EXIT=true
50+
export REGIONS=$(AKS_ENGINE_REGION)
51+
export IS_JENKINS=false
52+
make test-kubernetes
53+
name: DeployAKSEngine
54+
displayName: Deploy AKS-Engine
55+
workingDirectory: "$(modulePath)"

.pipelines/pipeline.yaml

Lines changed: 191 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,191 @@
1+
pr:
2+
branches:
3+
include:
4+
- master
5+
6+
trigger:
7+
branches:
8+
include:
9+
- master
10+
11+
stages:
12+
- stage: build_and_test
13+
jobs:
14+
- job: unit_tests
15+
pool:
16+
name: Networking-ContainerNetworking
17+
demands: agent.os -equals Linux
18+
19+
container:
20+
image: containernetworking/pipeline-ci:1.0.4
21+
options: "--privileged"
22+
23+
# Go setup for the vmImage:
24+
# https://github.com/Microsoft/azure-pipelines-image-generation/blob/master/images/linux/scripts/installers/go.sh
25+
variables:
26+
GOBIN: "$(GOPATH)/bin" # Go binaries path
27+
GOPATH: "$(System.DefaultWorkingDirectory)/gopath" # Go workspace path
28+
modulePath: "$(GOPATH)/src/github.com/Azure/azure-container-networking" # $(build.repository.name)' # Path to the module's code
29+
30+
steps:
31+
- bash: |
32+
echo $UID
33+
sudo rm /run/docker/plugins/test.sock || true
34+
sudo ip link del dev dummy || true
35+
displayName: "Set up OS environment"
36+
37+
- bash: |
38+
go version
39+
go env
40+
mkdir -p '$(GOBIN)'
41+
mkdir -p '$(GOPATH)/pkg'
42+
mkdir -p '$(modulePath)'
43+
shopt -s extglob
44+
shopt -s dotglob
45+
mv !(gopath) '$(modulePath)'
46+
echo '##vso[task.prependpath]$(GOBIN)'
47+
echo '##vso[task.prependpath]$(GOROOT)/bin'
48+
name: "GoEnv"
49+
displayName: "Set up the Go environment"
50+
51+
- script: |
52+
echo "##vso[task.setvariable variable=CommitHash;isOutput=true]$(git rev-parse HEAD)"
53+
BRANCH=$(git rev-parse --abbrev-ref HEAD)
54+
if [[ "$BRANCH" == "master" ]]; then
55+
echo "##vso[task.setvariable variable=Tag;isOutput=true]$(git describe --tags --abbrev=0)"
56+
echo "Set tag to $(git describe --tags --abbrev=0)"
57+
else
58+
echo "##vso[task.setvariable variable=Tag;isOutput=true]$(git describe --tags --always --dirty)"
59+
echo "Set tag to $(git describe --tags --always --dirty)"
60+
fi
61+
workingDirectory: "$(modulePath)"
62+
name: "EnvironmentalVariables"
63+
displayName: "Set build environmental variables"
64+
condition: always()
65+
66+
- script: |
67+
go get -v -t -d ./...
68+
if [ -f Gopkg.toml ]; then
69+
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
70+
fi
71+
go get github.com/docker/libnetwork/driverapi
72+
go get github.com/gorilla/mux
73+
go get github.com/jstemmer/go-junit-report
74+
go get github.com/axw/gocov/gocov
75+
go get github.com/AlekSi/gocov-xml
76+
go get -u gopkg.in/matm/v1/gocov-html
77+
workingDirectory: "$(modulePath)"
78+
name: "GoDependencies"
79+
displayName: "Install Go dependencies"
80+
81+
- script: |
82+
echo Build tag is $(EnvironmentalVariables.Tag)
83+
export GOOS=linux
84+
make all-binaries VERSION=$(EnvironmentalVariables.Tag)
85+
export GOOS=windows
86+
make all-binaries VERSION=$(EnvironmentalVariables.Tag)
87+
cd output
88+
sudo find . -mindepth 2 -type f -regextype posix-extended ! -iregex '.*\.(zip|tgz)$' -delete
89+
sudo find . -mindepth 2 -type f -print -exec mv {} . \;
90+
sudo rm -R -- */
91+
workingDirectory: "$(modulePath)"
92+
name: "Build"
93+
displayName: "Build"
94+
95+
- bash: |
96+
# 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
97+
{ { { {
98+
sudo -E env "PATH=$PATH" make test-all;
99+
echo $? >&3;
100+
} | tee >(go-junit-report > report.xml) >&4;
101+
} 3>&1;
102+
} | { read xs; exit $xs; }
103+
} 4>&1
104+
workingDirectory: "$(modulePath)"
105+
failOnStderr: true
106+
name: "Test"
107+
displayName: "Run Tests"
108+
109+
- bash: |
110+
bash <(curl -s https://codecov.io/bash)
111+
gocov convert coverage.out > coverage.json
112+
gocov-xml < coverage.json > coverage.xml
113+
workingDirectory: "$(modulePath)"
114+
name: "Coverage"
115+
displayName: "Generate Coverage Reports"
116+
condition: always()
117+
118+
- task: PublishTestResults@2
119+
inputs:
120+
testRunner: JUnit
121+
testResultsFiles: $(System.DefaultWorkingDirectory)/**/report.xml
122+
condition: always()
123+
124+
- task: PublishCodeCoverageResults@1
125+
inputs:
126+
codeCoverageTool: Cobertura
127+
summaryFileLocation: $(System.DefaultWorkingDirectory)/**/coverage.xml
128+
condition: always()
129+
130+
- task: CopyFiles@2
131+
inputs:
132+
sourceFolder: "$(modulePath)/output"
133+
targetFolder: $(Build.ArtifactStagingDirectory)
134+
condition: succeeded()
135+
136+
- task: PublishBuildArtifacts@1
137+
inputs:
138+
artifactName: "output"
139+
pathtoPublish: "$(Build.ArtifactStagingDirectory)"
140+
condition: succeeded()
141+
142+
- task: AzureCLI@1
143+
inputs:
144+
azureSubscription: $(ARTIFACT_SUBSCRIPTION)
145+
scriptLocation: "inlineScript"
146+
inlineScript: |
147+
az storage container create -n acn-$(EnvironmentalVariables.CommitHash) --account-name $(STORAGE_ACCOUNT_NAME) --public-access container
148+
az storage blob upload-batch -d acn-$(EnvironmentalVariables.CommitHash) -s ./output/ --account-name $(STORAGE_ACCOUNT_NAME)
149+
workingDirectory: "$(modulePath)"
150+
displayName: Create artifact storage container
151+
152+
- template: e2e-job-template.yaml
153+
parameters:
154+
name: "ubuntu_16_04_linux_e2e"
155+
pipelineBuildImage: "containernetworking/pipeline-ci:1.0.4"
156+
clusterDefinitionUrl: "https://raw.githubusercontent.com/Azure/azure-container-networking/master/test/e2e/kubernetes/cniLinux.json"
157+
clusterDefinitionCniTypeKey: "azureCNIURLLinux"
158+
clusterDefinitionCniBuildOS: "linux"
159+
clusterDefinitionCniBuildExt: ".tgz"
160+
161+
- template: e2e-job-template.yaml
162+
parameters:
163+
name: "windows_e2e"
164+
pipelineBuildImage: "containernetworking/pipeline-ci:1.0.4"
165+
clusterDefinitionUrl: "https://raw.githubusercontent.com/Azure/azure-container-networking/master/test/e2e/kubernetes/cniWindows.json"
166+
clusterDefinitionCniTypeKey: "azureCNIURLWindows"
167+
clusterDefinitionCniBuildOS: "windows"
168+
clusterDefinitionCniBuildExt: ".zip"
169+
170+
- stage: cleanup
171+
jobs:
172+
- job: delete_remote_artifacts
173+
pool:
174+
name: Networking-ContainerNetworking
175+
demands: agent.os -equals Linux
176+
container:
177+
image: containernetworking/pipeline-ci:1.0.4
178+
variables:
179+
Tag: $[ dependencies.unit_tests.outputs['EnvironmentalVariables.Tag'] ]
180+
181+
steps:
182+
- checkout: none
183+
- task: AzureCLI@1
184+
inputs:
185+
azureSubscription: $(ARTIFACT_SUBSCRIPTION)
186+
scriptLocation: "inlineScript"
187+
inlineScript: |
188+
export CommitHash=(git rev-parse HEAD)
189+
az storage container delete -n acn-$CommitHash --account-name $(STORAGE_ACCOUNT_NAME)
190+
workingDirectory: "$(modulePath)"
191+
displayName: Cleanup remote Azure storage container

0 commit comments

Comments
 (0)