Skip to content

Commit 39c9ad3

Browse files
authored
test: Add Swift Testing Pipeline (#712)
* Add new Swift test scenarios
1 parent cc3f970 commit 39c9ad3

33 files changed

+1116
-166
lines changed

.pipelines/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,5 @@ RUN go get github.com/gorilla/mux
2121
RUN go get github.com/jstemmer/go-junit-report
2222
RUN go get github.com/axw/gocov/gocov
2323
RUN go get github.com/AlekSi/gocov-xml
24-
RUN go get -u gopkg.in/matm/v1/gocov-html
24+
RUN go get -u gopkg.in/matm/v1/gocov-html
25+
RUN go get -u github.com/onsi/ginkgo/ginkgo

.pipelines/pipeline.yaml

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ stages:
1616
displayName: CNI, NPM, CNS, CNM
1717
pool:
1818
name: Networking-ContainerNetworking
19-
demands: agent.os -equals Linux
19+
demands:
20+
- agent.os -equals Linux
21+
- Role -equals Build
2022

2123
container:
2224
image: "$(BUILD_IMAGE)" # build image set as variable in pipeline runtime for flexibility
@@ -58,11 +60,7 @@ stages:
5860
echo "##vso[task.setvariable variable=StorageID;isOutput=true]$(echo ${BUILD_NUMBER//./-})"
5961
echo "##vso[task.setvariable variable=CommitHash;isOutput=true]$(git rev-parse HEAD)"
6062
echo "##vso[task.setvariable variable=Tag;isOutput=true]$(git describe --tags --always --dirty)"
61-
export BRANCH=$(Build.SourceBranchName)
62-
echo Building branch $BRANCH from $(Build.SourceBranch)
63-
if [[ "$BRANCH" == "master" ]]; then
64-
echo "##vso[task.setvariable variable=Tag;isOutput=true]$(git describe --tags --abbrev=0)"
65-
fi
63+
echo "##vso[task.setvariable variable=ImageTag;isOutput=true]$(git describe --tags --always --dirty)-test"
6664
workingDirectory: "$(modulePath)"
6765
name: "EnvironmentalVariables"
6866
displayName: "Set environmental variables"
@@ -75,13 +73,12 @@ stages:
7573
go get github.com/axw/gocov/gocov
7674
go get github.com/AlekSi/gocov-xml
7775
go get github.com/matm/gocov-html
76+
go get github.com/rakyll/gotest
7877
workingDirectory: "$(modulePath)"
7978
name: "GoDependencies"
8079
displayName: "Install Go dependencies"
8180
8281
- script: |
83-
echo Building in $(pwd)
84-
echo Build tag is $(EnvironmentalVariables.Tag)
8582
export GOOS=windows
8683
make all-binaries VERSION=$(EnvironmentalVariables.Tag)
8784
workingDirectory: "$(modulePath)"
@@ -109,11 +106,11 @@ stages:
109106
displayName: "Run Tests"
110107
111108
- script: |
112-
make all-binaries VERSION=$(EnvironmentalVariables.Tag)
113-
sudo make azure-npm-image VERSION=$(EnvironmentalVariables.Tag)
109+
sudo make hack-images VERSION=$(EnvironmentalVariables.Tag)
110+
sudo make all-images VERSION=$(EnvironmentalVariables.Tag)
114111
workingDirectory: "$(modulePath)"
115-
name: "BuildNPMImage"
116-
displayName: "Build NPM Image"
112+
name: "BuildImages"
113+
displayName: "Build Images"
117114
118115
- bash: |
119116
export CODECOV_TOKEN=$(CODECOV_TOKEN)
@@ -130,6 +127,12 @@ stages:
130127
docker tag $IMAGE_REGISTRY/azure-npm:$(EnvironmentalVariables.Tag) $IMAGE_REGISTRY/azure-npm:$(EnvironmentalVariables.Tag)-test
131128
docker push $IMAGE_REGISTRY/azure-npm:$(EnvironmentalVariables.Tag)-test
132129
130+
docker tag $IMAGE_REGISTRY/azure-cns:$(EnvironmentalVariables.Tag) $IMAGE_REGISTRY/azure-cns:$(EnvironmentalVariables.Tag)-test
131+
docker push $IMAGE_REGISTRY/azure-cns:$(EnvironmentalVariables.Tag)-test
132+
133+
docker tag $IMAGE_REGISTRY/azure-cni-manager:$(EnvironmentalVariables.Tag) $IMAGE_REGISTRY/azure-cni-manager:$(EnvironmentalVariables.Tag)-test
134+
docker push $IMAGE_REGISTRY/azure-cni-manager:$(EnvironmentalVariables.Tag)-test
135+
133136
function auto-retry()
134137
{
135138
export i="1"
@@ -139,7 +142,10 @@ stages:
139142
printf "Attempt $i/$attempts - " && "$@" && break || sleep 3 && i=$[$i+1] && false
140143
done
141144
}
145+
142146
auto-retry docker pull $IMAGE_REGISTRY/azure-npm:$(EnvironmentalVariables.Tag)-test
147+
auto-retry docker pull $IMAGE_REGISTRY/azure-cns:$(EnvironmentalVariables.Tag)-test
148+
auto-retry docker pull $IMAGE_REGISTRY/azure-cni-manager:$(EnvironmentalVariables.Tag)-test
143149
workingDirectory: "$(modulePath)"
144150
name: "mcrreplication"
145151
displayName: "Push NPM Image and Wait for Repository"
@@ -194,7 +200,13 @@ stages:
194200
displayName: Create artifact storage container
195201
condition: succeeded()
196202

197-
- template: e2e-job-template.yaml
203+
- template: singletenancy/aks-swift/e2e-job-template.yaml
204+
parameters:
205+
name: "aks_on_swift_e2e"
206+
displayName: AKS on Swift
207+
pipelineBuildImage: "$(BUILD_IMAGE)"
208+
209+
- template: singletenancy/aks-engine/e2e-job-template.yaml
198210
parameters:
199211
name: "ubuntu_16_04_linux_e2e"
200212
displayName: Ubuntu 16.04
@@ -204,7 +216,7 @@ stages:
204216
clusterDefinitionCniBuildOS: "linux"
205217
clusterDefinitionCniBuildExt: ".tgz"
206218

207-
- template: e2e-job-template.yaml
219+
- template: singletenancy/aks-engine/e2e-job-template.yaml
208220
parameters:
209221
name: "ubuntu_18_04_linux_e2e"
210222
displayName: Ubuntu 18.04
@@ -214,7 +226,7 @@ stages:
214226
clusterDefinitionCniBuildOS: "linux"
215227
clusterDefinitionCniBuildExt: ".tgz"
216228

217-
- template: e2e-job-template.yaml
229+
- template: singletenancy/aks-engine/e2e-job-template.yaml
218230
parameters:
219231
name: "windows_18_09_e2e"
220232
displayName: "Windows 1809"
@@ -224,7 +236,7 @@ stages:
224236
clusterDefinitionCniBuildOS: "windows"
225237
clusterDefinitionCniBuildExt: ".zip"
226238

227-
- template: e2e-job-template.yaml
239+
- template: singletenancy/aks-engine/e2e-job-template.yaml
228240
parameters:
229241
name: "windows_19_03_e2e"
230242
displayName: "Windows 1903"
@@ -237,6 +249,7 @@ stages:
237249
- stage: cleanup
238250
displayName: Cleanup
239251
dependsOn:
252+
- "aks_on_swift_e2e"
240253
- "ubuntu_16_04_linux_e2e"
241254
- "ubuntu_18_04_linux_e2e"
242255
- "windows_18_09_e2e"
@@ -260,5 +273,7 @@ stages:
260273
BUILD_NUMBER=${BUILD_NUMBER//./-}
261274
echo Deleting storage container with name acn-$BUILD_NUMBER and account name $(STORAGE_ACCOUNT_NAME)
262275
az storage container delete -n acn-$BUILD_NUMBER --account-name $(STORAGE_ACCOUNT_NAME)
276+
echo Pruning old docker images...
277+
sudo docker system prune -f
263278
workingDirectory: "$(modulePath)"
264279
displayName: Cleanup remote Azure storage container

.pipelines/e2e-job-template.yaml renamed to .pipelines/singletenancy/aks-engine/e2e-job-template.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ stages:
1717
timeoutInMinutes: 120
1818
pool:
1919
name: Networking-ContainerNetworking
20-
demands: agent.os -equals Linux
20+
demands:
21+
- agent.os -equals Linux
22+
- Role -equals Build
2123
container:
2224
image: ${{ parameters.pipelineBuildImage }}
2325
variables:
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
parameters:
2+
name: ""
3+
displayName: ""
4+
pipelineBuildImage: "$(BUILD_IMAGE)"
5+
6+
stages:
7+
- stage: ${{ parameters.name }}
8+
displayName: E2E - ${{ parameters.displayName }}
9+
dependsOn: build_and_test
10+
jobs:
11+
- job: ${{ parameters.name }}
12+
displayName: Singletenancy AKS on Swift Suite - (${{ parameters.name }})
13+
timeoutInMinutes: 120
14+
pool:
15+
name: Networking-ContainerNetworking
16+
demands:
17+
- agent.os -equals Linux
18+
- Role -equals $(CUSTOM_E2E_ROLE)
19+
container:
20+
image: "$(BUILD_IMAGE)" # build image set as variable in pipeline runtime for flexibilit
21+
22+
variables:
23+
GOPATH: "$(Agent.TempDirectory)/go" # Go workspace path
24+
GOBIN: "$(GOPATH)/bin" # Go binaries path
25+
ImageTag: $[ stagedependencies.build_and_test.unit_tests.outputs['EnvironmentalVariables.ImageTag'] ]
26+
steps:
27+
- template: e2e-step-template.yaml
28+
parameters:
29+
name: ${{ parameters.name }}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
parameters:
2+
name: ""
3+
4+
steps:
5+
- bash: |
6+
echo $UID
7+
sudo rm -rf $(System.DefaultWorkingDirectory)/*
8+
displayName: "Set up OS environment"
9+
10+
- checkout: self
11+
12+
- bash: |
13+
go version
14+
go env
15+
mkdir -p '$(GOBIN)'
16+
mkdir -p '$(GOPATH)/pkg'
17+
mkdir -p '$(modulePath)'
18+
echo '##vso[task.prependpath]$(GOBIN)'
19+
echo '##vso[task.prependpath]$(GOROOT)/bin'
20+
name: "GoEnv"
21+
displayName: "Set up the Go environment"
22+
23+
- bash: |
24+
echo $(ImageTag)
25+
displayName: Echo Tag
26+
27+
- task: AzureCLI@1
28+
inputs:
29+
azureSubscription: $(ARTIFACT_SUBSCRIPTION)
30+
scriptLocation: "inlineScript"
31+
addSpnToEnvironment: true
32+
inlineScript: |
33+
mkdir -p ~/.kube/
34+
az keyvault secret show --name $(KV_AKS_SWIFT_SECRET_NAME) --vault-name $(KV_NAME) --query value | sed 's/\\n/\n/g' | sed -e 's/^"//' -e 's/"$//'
35+
az keyvault secret show --name $(KV_AKS_SWIFT_SECRET_NAME) --vault-name $(KV_NAME) --query value | sed 's/\\n/\n/g' | sed -e 's/^"//' -e 's/"$//' > ~/.kube/config
36+
displayName: Pull Kubeconfig from Keyvault
37+
condition: succeeded()
38+
39+
- script: |
40+
ls -lah
41+
pwd
42+
sudo -E env "PATH=$PATH" VERSION=$(ImageTag) INSTALL_CNI=true INSTALL_CNS=true make test-integration
43+
name: "aksswifte2e"
44+
displayName: "Run AKS Swift E2E"
45+
46+

Makefile

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -181,12 +181,13 @@ all-binaries: azure-cnm-plugin azure-cni-plugin azure-cns
181181
endif
182182

183183
ifeq ($(GOOS),linux)
184-
all-images: azure-npm-image azure-vnet-telemetry-image
184+
all-images: azure-npm-image azure-cns-aks-swift-image
185185
else
186186
all-images:
187187
@echo "Nothing to build. Skip."
188188
endif
189189

190+
190191
# Clean all build artifacts.
191192
.PHONY: clean
192193
clean:
@@ -233,7 +234,7 @@ $(NPM_BUILD_DIR)/azure-npm$(EXE_EXT): $(NPMFILES)
233234
.PHONY: all-containerized
234235
all-containerized:
235236
pwd && ls -l
236-
docker build -f Dockerfile.build -t $(BUILD_CONTAINER_IMAGE):$(VERSION) .
237+
docker build -f Dockerfile.build -t $(BUILD_CONTAINER_IMAGE):$(VERSION) --no-cache .
237238
docker run --name $(BUILD_CONTAINER_NAME) \
238239
-v /usr/bin/docker:/usr/bin/docker \
239240
-v /var/run/docker.sock:/var/run/docker.sock \
@@ -269,7 +270,7 @@ hack-images:
269270
azure-vnet-plugin-image: azure-cnm-plugin
270271
# Build the plugin image, keeping any old image during build for cache, but remove it afterwards.
271272
docker images -q $(CNM_PLUGIN_ROOTFS):$(VERSION) > cid
272-
docker build \
273+
docker build --no-cache \
273274
-f Dockerfile.cnm \
274275
-t $(CNM_PLUGIN_ROOTFS):$(VERSION) \
275276
--build-arg CNM_BUILD_DIR=$(CNM_BUILD_DIR) \
@@ -450,7 +451,15 @@ ifeq ($(GOOS),linux)
450451
chown $(BUILD_USER):$(BUILD_USER) $(NPM_BUILD_DIR)/$(NPM_ARCHIVE_NAME)
451452
endif
452453

454+
455+
PRETTYGOTEST := $(shell command -v gotest 2> /dev/null)
456+
453457
# run all tests
454458
.PHONY: test-all
455459
test-all:
456-
go test -coverpkg=./... -v -race -covermode atomic -coverprofile=coverage.out ./...
460+
go test -coverpkg=./... -v -race -covermode atomic -coverprofile=coverage.out ./...
461+
462+
# run all tests
463+
.PHONY: test-integration
464+
test-integration:
465+
go test -coverpkg=./... -v -race -covermode atomic -coverprofile=coverage.out -tags=integration ./test/integration...

cns/azure-cns.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ spec:
9393
effect: NoSchedule
9494
containers:
9595
- name: cns-container
96-
image: mcr.microsoft.com/containernetworking/azure-cns:v1.2.0
96+
image: mcr.microsoft.com/containernetworking/azure-cns:v1.2.0-alpha
9797
imagePullPolicy: IfNotPresent
9898
args: [ "-c", "tcp://$(CNSIpAddress):$(CNSPort)", "-t", "$(CNSLogTarget)"]
9999
volumeMounts:
@@ -158,4 +158,4 @@ data:
158158
"NodeSyncIntervalInSeconds": 30
159159
},
160160
"ChannelMode": "CRD"
161-
}
161+
}

cns/cnsclient/cli.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package cnsclient
22

33
import (
44
"fmt"
5+
"os"
56
"sort"
67
"strings"
78

@@ -20,7 +21,8 @@ const (
2021
eth0InterfaceName = "eth0"
2122
azure0InterfaceName = "azure0"
2223

23-
defaultCNSURl = "http://localhost:10090"
24+
envCNSIPAddress = "CNSIpAddress"
25+
envCNSPort = "CNSPort"
2426
)
2527

2628
var (
@@ -36,7 +38,11 @@ var (
3638
)
3739

3840
func HandleCNSClientCommands(cmd, arg string) error {
39-
cnsClient, err := InitCnsClient(defaultCNSURl)
41+
42+
cnsIPAddress := os.Getenv(envCNSIPAddress)
43+
cnsPort := os.Getenv(envCNSPort)
44+
45+
cnsClient, err := InitCnsClient("http://" + cnsIPAddress + ":" + cnsPort)
4046
if err != nil {
4147
return err
4248
}

0 commit comments

Comments
 (0)