Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pipelines/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ RUN echo "deb http://archive.ubuntu.com/ubuntu/ bionic multiverse" | sudo tee -a
RUN echo "deb http://archive.ubuntu.com/ubuntu/ bionic universe" | sudo tee -a /etc/apt/sources.list
RUN echo "deb http://archive.ubuntu.com/ubuntu/ bionic main" | sudo tee -a /etc/apt/sources.list
RUN apt-get update && apt-get install -y iptables ipset iproute2 ebtables
RUN wget -qO- https://golang.org/dl/go1.14.6.linux-amd64.tar.gz | tar zxf - -C /usr/lib/
RUN wget -qO- https://golang.org/dl/go1.15.linux-amd64.tar.gz | tar zxf - -C /usr/lib/
ENV PATH="/usr/lib/go/bin/:${PATH}"
ENV GOROOT="/usr/lib/go"
ENV GOPATH="/root/go"
Expand Down
201 changes: 201 additions & 0 deletions .pipelines/npm/npm-conformance-tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,201 @@
trigger:
- main

variables:
- name: AZURE_CLUSTER
value: azure-npm
- name: VNET_NAME
value: npm-vnet
- name: LOCATION
value: westus2
- name: FQDN
value: empty

jobs:
- job: setup
displayName: "Configure Test Environment"
pool:
name: Networking-ContainerNetworking
demands:
- agent.os -equals Linux
- Role -equals Build
container:
image: "$(BUILD_IMAGE)" # build image set as variable in pipeline runtime for flexibility
steps:

- checkout: self

- script: |
go env
go version
mkdir -p '$(GOBIN)'
mkdir -p '$(GOPATH)/pkg'
BUILD_NUMBER=$(Build.BuildNumber)
RG=kubernetes-$(echo "npm-conformance-`date "+%Y-%m-%d-%S"`")
TAG=$(git describe --tags --always --dirty)-conformance-test
echo "Resource group: $RG"
echo "Image tag: $TAG"

echo "##vso[task.setvariable variable=RESOURCE_GROUP;isOutput=true;]$RG"
echo "##vso[task.setvariable variable=TAG;isOutput=true;]$TAG"

name: "EnvironmentalVariables"
displayName: "Set environmental variables"
condition: always()

- job: Build_test
displayName: "Build NPM and Kubernetes Test Suite"
pool:
name: Networking-ContainerNetworking
demands:
- agent.os -equals Linux
- Role -equals Build
container:
image: "$(BUILD_IMAGE)" # build image set as variable in pipeline runtime for flexibility
dependsOn: [setup]
variables:
GOBIN: "$(GOPATH)/bin" # Go binaries path
GOPATH: "$(System.DefaultWorkingDirectory)/gopath" # Go workspace path
RESOURCE_GROUP: $[ dependencies.setup.outputs['EnvironmentalVariables.RESOURCE_GROUP'] ]
TAG: $[ dependencies.setup.outputs['EnvironmentalVariables.TAG'] ]

steps:
- script: |
rm -rf ./*
displayName: "Set up OS environment"

- checkout: self

- script: |
go env
echo Tag: $(TAG)
echo ResourceGroup: $(RESOURCE_GROUP)
VERSION=$(TAG) make azure-npm-image
echo '$(DOCKER_PASSWORD)' | docker login $IMAGE_REGISTRY -u '$(DOCKER_USERNAME)' --password-stdin
docker push $IMAGE_REGISTRY/azure-npm:$(TAG)
displayName: 'Build and Push NPM Image'

- script: git clone https://github.com/vakalapa/kubernetes.git
displayName: 'Clone Kubernetes Repo'
- bash: |
cd kubernetes
git checkout vakr/sleepinnpmtests
make WHAT=test/e2e/e2e.test
displayName: 'Build Kubernetes e2e.test'
- publish: $(System.DefaultWorkingDirectory)/kubernetes/_output/local/bin/linux/amd64
artifact: Test


- job: Create_cluster
displayName: "Deploy AKS Cluster"
pool:
name: Networking-ContainerNetworking
demands:
- agent.os -equals Linux
- Role -equals Build
container:
image: "$(BUILD_IMAGE)" # build image set as variable in pipeline runtime for flexibility
dependsOn: [setup]
variables:
RESOURCE_GROUP: $[ dependencies.setup.outputs['EnvironmentalVariables.RESOURCE_GROUP'] ]
TAG: $[ dependencies.setup.outputs['EnvironmentalVariables.TAG'] ]
steps:
- script: |
sudo rm -rf ./*
displayName: "Set up OS environment"

- checkout: self

- task: AzureCLI@2
displayName: "Deploy"
inputs:
azureSubscription: $(BUILD_VALIDATIONS_SUBSCRIPTION)
scriptType: 'bash'
scriptLocation: 'inlineScript'
inlineScript: |
az group create -n $(RESOURCE_GROUP) -l $(LOCATION) -o table
echo created RG $(RESOURCE_GROUP) in $(LOCATION)
az version
az aks create --no-ssh-key \
--resource-group $(RESOURCE_GROUP) \
--name $(AZURE_CLUSTER) \
--network-plugin azure

- job: Run_test
displayName: "Run Kubernetes Network Policy Test Suite"
pool:
name: Networking-ContainerNetworking
demands:
- agent.os -equals Linux
- Role -equals Build
container:
image: "$(BUILD_IMAGE)" # build image set as variable in pipeline runtime for flexibility
dependsOn: [Create_cluster, Build_test, setup]
variables:
RESOURCE_GROUP: $[ dependencies.setup.outputs['EnvironmentalVariables.RESOURCE_GROUP'] ]
TAG: $[ dependencies.setup.outputs['EnvironmentalVariables.TAG'] ]
steps:
- download: current
artifact: Test
- task: AzureCLI@2
displayName: "Deploy NPM to Test Cluster"
inputs:
azureSubscription: $(BUILD_VALIDATIONS_SUBSCRIPTION)
scriptType: 'bash'
scriptLocation: 'inlineScript'
inlineScript: |
echo Cluster $(AZURE_CLUSTER)
echo Resource $(RESOURCE_GROUP)

az aks get-credentials -n $(AZURE_CLUSTER) -g $(RESOURCE_GROUP) --file ./kubeconfig
# get kubectl
curl -LO https://dl.k8s.io/release/v1.20.0/bin/linux/amd64/kubectl
chmod +x kubectl

# deploy azure-npm
./kubectl --kubeconfig=./kubeconfig apply -f https://raw.githubusercontent.com/Azure/azure-container-networking/master/npm/azure-npm.yaml

# swap azure-npm image with one built during run
./kubectl --kubeconfig=./kubeconfig set image daemonset/azure-npm -n kube-system azure-npm=$IMAGE_REGISTRY/azure-npm:$(TAG)

./kubectl --kubeconfig=./kubeconfig describe daemonset azure-npm -n kube-system

FQDN=`az aks show -n $(AZURE_CLUSTER) -g $(RESOURCE_GROUP) --query fqdn -o tsv`
echo "##vso[task.setvariable variable=FQDN]$FQDN"

- bash: |
ls -la
ls
ls -la $(Pipeline.Workspace)
ls -la $(Pipeline.Workspace)/Test
echo $FQDN
ls ~
chmod +x $(Pipeline.Workspace)/Test/e2e.test
KUBERNETES_SERVICE_HOST="$FQDN" KUBERNETES_SERVICE_PORT=443 $(Pipeline.Workspace)/Test/e2e.test --provider=local --ginkgo.focus="NetworkPolicy" --ginkgo.skip="SCTP" --kubeconfig=./kubeconfig
displayName: "Run Test Suite"

- job: Clean_up
displayName: "Cleanup"
pool:
name: Networking-ContainerNetworking
demands:
- agent.os -equals Linux
- Role -equals Build
container:
image: "$(BUILD_IMAGE)" # build image set as variable in pipeline runtime for flexibility
condition: always()
dependsOn: [Run_test, setup]
variables:
RESOURCE_GROUP: $[ dependencies.setup.outputs['EnvironmentalVariables.RESOURCE_GROUP'] ]
TAG: $[ dependencies.setup.outputs['EnvironmentalVariables.TAG'] ]
steps:
- checkout: none
- task: AzureCLI@2
displayName: "Delete Test Cluster Resource Group"
inputs:
azureSubscription: $(BUILD_VALIDATIONS_SUBSCRIPTION)
scriptType: 'bash'
scriptLocation: 'inlineScript'
inlineScript: |
echo Deleting $(RESOURCE_GROUP)
az group delete -n $(RESOURCE_GROUP) --yes