Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI integration of networkservicemesh integration tests (NSMNSE-79) #23

Open
wants to merge 64 commits into
base: vl3_latest
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
25366f8
Initial commit
Jan 27, 2021
5159511
Add stage for installing docker client to jenkinsfile
Jan 27, 2021
f9c29c9
Add stage for installing yq in jenkinsfile
Jan 27, 2021
b5756fa
Add stage for installing kubectl in jenkinsfile
Jan 27, 2021
7656f1c
escape dollar sign
Jan 27, 2021
3215b2d
Add stage to install helm to jenkinsfile
Jan 27, 2021
8377e22
Add environment vars to jenkinsfile
Jan 27, 2021
2f1e4f9
Add stage to install kind to jenkinsfile
Jan 27, 2021
8e3fa80
Add stage to install cloudtest to jenkinsfile
Jan 27, 2021
aeef96b
Add stage to run tests in jenkinsfile
Jan 27, 2021
e6d59f9
Add docker host networking to jenkinsfile
Jan 27, 2021
51afdd1
Run single cluster tests in jenkins
Jan 27, 2021
93ccd37
Run single cluster tests in jenkins
Jan 27, 2021
8239b95
Increase cloudtest timeout to 2 hours
Jan 28, 2021
9ca800f
Add 'wcm' label to jenkinsfile so it runs on the right nodes
Jan 28, 2021
38cd1d4
modify the way kind is installed in jenkinsfile
Jan 28, 2021
f2520e4
reduce stats prints frequency and cleanup jenkinsfile
Jan 28, 2021
b8edfc1
create two kind clusters for interdomain tests
Feb 1, 2021
0365ef6
try again to create two kind clusters for interdomain tests
Feb 1, 2021
2f52c5b
move all config into cloudtest config file
Feb 1, 2021
a355cf9
use separate cloudtest config files for now to make it easier to trig…
Feb 1, 2021
4ccfbae
add interdomain tests to the jenkinsfile in a separate stage
Feb 1, 2021
95553fa
add cluster selector to interdomain tests to see if that helps them run
Feb 1, 2021
aedaf82
try adding a second kind cluster selector to interdomain tests to see…
Feb 1, 2021
ddfbba0
fix prepare section of cloudtest config
Feb 1, 2021
04d69f4
use hardcoded cluster names to see if it will run
Feb 1, 2021
d7007c4
change instances to 1 to see if that helps
Feb 1, 2021
f2eba70
try to fix path to kubeconfig
Feb 1, 2021
01ffb5b
pass kubeconfig locations directly into go test
Feb 1, 2021
cbbe6b9
catch errors in interdomain tests
Feb 1, 2021
b92b097
change 'steps' to 'step' in jenkinsfile
Feb 1, 2021
a5906a0
use try/catch in jenkinsfile instead of catchError inside step
Feb 1, 2021
e155706
add another interdomain test to the jenkinsfile
Feb 1, 2021
d0ca32f
try to run interdomain tests using cloudtest
Feb 2, 2021
a5e53c3
modify cluster-selector in cloudtest interdomain test config
Feb 2, 2021
9ebeca5
try two different kind providers
Feb 2, 2021
42e0393
fix yaml file
Feb 2, 2021
4a842fa
try to save test results as an artifact
Feb 2, 2021
02a03e9
try to save test results as an artifact
Feb 2, 2021
5addda7
try to save test results as an artifact
Feb 2, 2021
e74f800
try to save test results as an artifact
Feb 2, 2021
8140068
try to save test results as an artifact
Feb 2, 2021
1978eda
add single cluster tests to junit reporting and save report as an art…
Feb 2, 2021
68931b1
add cloudtest logs to artifacts in jenkinsfile
Feb 2, 2021
59817d6
add everything under .tests/cloud_test dir to artifacts in jenkinsfile
Feb 2, 2021
b8fded3
add interdomain tests back in
Feb 2, 2021
c188e63
try to save test results as an artifact
Feb 3, 2021
10f96b8
clean up jenkins file
Feb 3, 2021
1c68a87
archive artifacts for more often
Feb 3, 2021
815833b
catch test errors so that future test stages can run in jenkinsfile
Feb 3, 2021
bcac0b7
store cloudtest artificats for each group of tests in a separate dire…
Feb 3, 2021
6912e0f
a
Feb 3, 2021
58debbe
add back in interdomainl
Feb 3, 2021
cd31d11
find files recursively to archive
Feb 3, 2021
8fb9d7a
a
Feb 4, 2021
8064ba6
a
Feb 4, 2021
cbb7aa4
a
Feb 4, 2021
a15c242
remove unused files
Feb 4, 2021
23b4804
remove more unused files
Feb 4, 2021
3c7e2ac
use helm 3 instead of helm 2
Feb 4, 2021
6d85130
use helm 3 instead of helm 2
Feb 4, 2021
a3c03fb
undo changes to helm-init-wrapper.sh
Feb 4, 2021
34146a0
add back deleted .cloudtest/execution folder and files to minimize ch…
Feb 5, 2021
1f6abff
revert changes to go.mod and go.sum
Feb 5, 2021
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
44 changes: 44 additions & 0 deletions .cloudtest-bench.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---
version: 1.0
root: "./.tests/cloud_test/bench/"
timeout: 7200 # 2 hour total total timeout
shuffle-enabled: false
statistics:
enabled: true
interval: 30 # 30 seconds for statistics
providers:
- name: "kind" # A name of our provider
kind: "shell" # A type of provider, shell indicate we need to specify all operations with shell commands.
instances: 1 # We need to have 1 instance of cloud.
node-count: 3 # With 3 nodes, CloudTest will validate if cloud has 3 nodes alive.
retry: 1 # A retry count if cloud is failed to start tool will try again.
enabled: true # Indicate Provider is active with config by default, if set to false, values could be overriden using command line arguments.
timeout: 300 # 5 minutes to start cluster
stop-delay: 10
env:
- KIND_CLUSTER_NAME=cloudtest-kind-$(rands10) # Generate a uniq cluster name
- CONFIG_LOCATION=$(tempdir)/config # Put Kubernetes configuration file here, $(tempdir) a executable variable name pointing to temporary folder.
scripts:
start: make kind-start
config: make kind-export-kubeconfig # Use make file to generate kind config and put it into a file specified with CONFIG_LOCATION environment variable.
stop: make kind-stop
prepare: |
make k8s-load-images
make spire-install
make k8s-config
executions:
- name: "Benchmark tests"
env:
- ARTIFACTS_ARCHIVE=true
source:
tags:
- bench
root: ./test/integration
timeout: 600
cluster-count: 1
cluster-env:
- KUBECONFIG
on-fail: |
make k8s-reset
reporting:
junit-report: "results/junit-benchmark-tests.xml"
49 changes: 49 additions & 0 deletions .cloudtest-interdomain.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
---
version: 1.0
root: "./.tests/cloud_test/interdomain/"
timeout: 7200 # 2 hour total total timeout
shuffle-enabled: false
statistics:
enabled: true
interval: 30 # 30 seconds for statistics
providers:
- name: "kind" # A name of our provider
kind: "shell" # A type of provider, shell indicate we need to specify all operations with shell commands.
instances: 2
node-count: 3 # With 3 nodes, CloudTest will validate if cloud has 3 nodes alive.
retry: 1 # A retry count if cloud is failed to start tool will try again.
enabled: true # Indicate Provider is active with config by default, if set to false, values could be overriden using command line arguments.
timeout: 300 # 5 minutes to start cluster
stop-delay: 10
env:
- KIND_CLUSTER_NAME=cloudtest-kind-$(rands10) # Generate a uniq cluster name
- CONFIG_LOCATION=$(tempdir)/config # Put Kubernetes configuration file here, $(tempdir) a executable variable name pointing to temporary folder.
scripts:
start: make kind-start
config: make kind-export-kubeconfig # Use make file to generate kind config and put it into a file specified with CONFIG_LOCATION environment variable.
stop: make kind-stop
prepare: |
make k8s-load-images
make spire-install
make k8s-config
executions:
- name: "Interdomain tests"
env:
- ARTIFACTS_ARCHIVE=true
- USE_JAEGER_SERVICE=true
source:
tags:
- interdomain
root: ./test/integration
timeout: 600
cluster-count: 2
cluster-selector:
- kind
- kind
cluster-env:
- KUBECONFIG_CLUSTER_1
- KUBECONFIG_CLUSTER_2
on-fail: |
make k8s-reset
reporting:
junit-report: "results/junit-interdomain-tests.xml"
46 changes: 46 additions & 0 deletions .cloudtest-single-cluster.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
---
version: 1.0
root: "./.tests/cloud_test/single-cluster/"
timeout: 7200 # 2 hour total total timeout
shuffle-enabled: false
statistics:
enabled: true
interval: 30 # 30 seconds for statistics
providers:
- name: "kind" # A name of our provider
kind: "shell" # A type of provider, shell indicate we need to specify all operations with shell commands.
instances: 1 # We need to have 1 instance of cloud.
node-count: 3 # With 3 nodes, CloudTest will validate if cloud has 3 nodes alive.
retry: 1 # A retry count if cloud is failed to start tool will try again.
enabled: true # Indicate Provider is active with config by default, if set to false, values could be overriden using command line arguments.
timeout: 300 # 5 minutes to start cluster
stop-delay: 10
env:
- KIND_CLUSTER_NAME=cloudtest-kind-$(rands10) # Generate a uniq cluster name
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does the injection of the $(rands10) actually work? Does cloudtest process the yaml file content in a way that a bash shell would exec that?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I see that a makefile target is wrapping usage of the env var with $() exec... interesting

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cloudtest does do extra processing.
https://github.com/networkservicemesh/cloudtest/blob/master/docs/README.md#environment-variables-processing

you get environment variables and a handful of other useful commands, like rands10. I'm not sure if this is executed by bash or not, they may have just borrowed the syntax.

- CONFIG_LOCATION=$(tempdir)/config # Put Kubernetes configuration file here, $(tempdir) a executable variable name pointing to temporary folder.
scripts:
start: make kind-start
config: make kind-export-kubeconfig # Use make file to generate kind config and put it into a file specified with CONFIG_LOCATION environment variable.
stop: make kind-stop
prepare: |
make k8s-load-images
make spire-install
make k8s-config
executions:
- name: "Single cluster tests"
env:
- ARTIFACTS_ARCHIVE=true
source:
tags:
- basic
- recover
- usecase
root: ./test/integration
timeout: 300
cluster-count: 1
cluster-env:
- KUBECONFIG
on-fail: |
make k8s-reset
reporting:
junit-report: "results/junit-single-cluster-tests.xml"
36 changes: 0 additions & 36 deletions .cloudtest.yaml

This file was deleted.

23 changes: 12 additions & 11 deletions .cloudtest/kind.yaml
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@

---
version: 1.0
providers:
- name: "kind"
kind: "shell"
instances: 1
node-count: 3
retry: 10
enabled: false
timeout: 300 # 5 minutes to start cluster
- name: "kind" # A name of our provider
kind: "shell" # A type of provider, shell indicate we need to specify all operations with shell commands.
instances: 1 # We need to have 1 instance of cloud.
node-count: 3 # With 3 nodes, CloudTest will validate if cloud has 3 nodes alive.
retry: 1 # A retry count if cloud is failed to start tool will try again.
enabled: true # Indicate Provider is active with config by default, if set to false, values could be overriden using command line arguments.
timeout: 300 # 5 minutes to start cluster
stop-delay: 10
env:
- CLUSTER_RULES_PREFIX=kind
- KIND_CLUSTER_NAME=cloudtest-kind-$(rands10) # Generate a uniq cluster name
- CONFIG_LOCATION=$(tempdir)/config # Put Kubernetes configuration file here, $(tempdir) a executable variable name pointing to temporary folder.
scripts:
start: |
make kind-config
make kind-start
start: make kind-start
config: make kind-export-kubeconfig # Use make file to generate kind config and put it into a file specified with CONFIG_LOCATION environment variable.
stop: make kind-stop
prepare: |
make k8s-load-images
Expand Down
30 changes: 17 additions & 13 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,27 @@
*

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you comment on how these changes came about?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I basically rearranged them in alphabetical order, and then added some folders and files that were needed by cloudtest.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was using a dockerfile for local testing on my mac before I started using the cisco-hosted-jenkins environment.

# ... except these
!.cloudtest
!.env
!.git
!.mk
!applications
!build
!controlplane
!forwarder
!deployments
!docker
!test/applications
!test/go.mod
!test/go.sum
!side-cars
!go.mod
!go.sum
!k8s/api
!k8s/cmd
!k8s/pkg
!k8s/go.mod
!k8s/go.sum
!forwarder
!k8s
!pkg
!scripts
!sdk
!side-cars
!test
!utils
!.cloudtest-bench.yaml
!.cloudtest-single-cluster.yaml
!.cloudtest-interdomain.yaml
!go.mod
!go.sum
!Makefile
!vendor
!scripts/go-mod-download.sh
93 changes: 93 additions & 0 deletions .jenkins/Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
//The Jenkinsfile runs entire build in a golang container and mounts the /var/run/docker.sock file to allow access to the host docker within the container
node('wcm') {
def build_ok = true
docker.image('golang:1.15-buster').inside('-u root --net=host -v /var/run/docker.sock:/var/run/docker.sock') {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we'll possibly have an issue with using -u root in the long run. Got some feedback on that from the SRE team that it could be causing content to be left on the jenkins slave that the container runs on.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, but I can leave the -u root there for now?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you could try without -u root to see if it's still working the same that'd be good. To get kind cluster create and go get / go mod stuff to run in nsm-nse I had to add the following to env vars:

        HOME        = "${WORKSPACE}"
        GOCACHE     = "/go/.cache"

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I can give that a go and see what happens.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally, we would have access to an ephemeral docker host, or the build agent would be ephemeral, so that we can easily guarantee that our environments are consistent. There's too many hands touching those build agents to have any sort of guarantee that they're going to be in a consistent state.

environment{
CGO_ENABLED = 0
GO111MODULE = on
}
stage ('Install Docker Client') {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I refactored what was in nsm-nse to use the same base for our runner container we use in circleci to avoid having to install all these type of dependencies--docker client, kubectl, helm, kind, go, git, etc. I'm looking to get a more standard set of base container images curated by the SRE team that we can use as our jenkins agent setting. We don't have to change this now but it'll be something we want to follow-up on.

See here: https://github.com/cisco-app-networking/nsm-nse/blob/devop_jenkins/.jenkins/Jenkinsfile#L14

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok thanks, good to know.

sh "apt-get update"
sh '''
apt-get install -y \
apt-transport-https \
ca-certificates \
curl \
gnupg-agent \
software-properties-common
'''
sh "curl -fsSL https://download.docker.com/linux/debian/gpg | apt-key add -"
sh '''
add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/debian \
$(lsb_release -cs) \
stable"
'''
sh "apt-get update && apt-get install -y docker-ce-cli"
}
stage ('Install yq') {
sh "wget -O /usr/bin/yq https://github.com/mikefarah/yq/releases/download/2.1.2/yq_linux_amd64"
sh "chmod 555 /usr/bin/yq"
}
stage ('Install kubectl') {
sh "curl -LO https://storage.googleapis.com/kubernetes-release/release/\"\$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)\"/bin/linux/amd64/kubectl"
sh "chmod +x kubectl && mv kubectl /usr/local/bin/"
}
stage ('Install Helm') {
sh "curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3"
sh "chmod 700 get_helm.sh"
sh "./get_helm.sh"
}
stage ('Checkout code') {
checkout scm
}
stage ('Install kind') {
sh "go get -u sigs.k8s.io/[email protected]"
}
stage ('Install cloudtest version 0.2.0') {
sh "go get github.com/networkservicemesh/[email protected]"
}

try {
stage ('Run single cluster tests') {
sh "cloudtest --config .cloudtest-single-cluster.yaml"
}
} catch (e) {
build_ok = false
} finally {
junit '.tests/cloud_test/single-cluster/results/junit-single-cluster-tests.xml'
}

try {
stage ('Run interdomain tests') {
sh "cloudtest --config .cloudtest-interdomain.yaml"
}
} catch (e) {
build_ok = false
} finally {
junit '.tests/cloud_test/interdomain/results/junit-interdomain-tests.xml'
}

try {
stage ('Run benchmark tests') {
sh "cloudtest --config .cloudtest-bench.yaml"
}
} catch (e) {
build_ok = false
} finally {
junit '.tests/cloud_test/bench/results/junit-benchmark-tests.xml'
}

stage ('Archive all test results and logs') {
dir('.tests/cloud_test') {
archiveArtifacts artifacts: '**', fingerprint: true, onlyIfSuccessful: false
}
}

if (build_ok) {
currentBuild.result = "SUCCESS"
} else {
currentBuild.result = "FAILURE"
}
}
}
2 changes: 1 addition & 1 deletion .mk/k8s.mk
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ k8s-%-load-images: k8s-start $(CLUSTER_RULES_PREFIX)-%-load-images

.PHONY: k8s-config
k8s-config:
helm --namespace ${NSM_NAMESPACE} install --name config deployments/helm/nsm/charts/config
helm install config deployments/helm/nsm/charts/config --namespace ${NSM_NAMESPACE} --create-namespace

.PHONY: k8s-deconfig
k8s-deconfig:
Expand Down
7 changes: 6 additions & 1 deletion .mk/kind.mk
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
KIND_CLUSTER_NAME?="nsm"
KIND_IMAGE_PATH=$(IMAGE_DIR)

ifeq ($(CONFIG_LOCATION),)
CONFIG_LOCATION := "./.results/config"
endif

.PHONY: kind-config
kind-config:
@which kind >/dev/null 2>&1 || \
Expand All @@ -35,7 +39,8 @@ kind-start: kind-config

.PHONY: kind-export-kubeconfig
kind-export-kubeconfig:
@kind get kubeconfig --name $(KIND_CLUSTER_NAME) > $(KIND_CLUSTER_NAME)-kubeconfig
@touch $(CONFIG_LOCATION); \
kind get kubeconfig --name $(KIND_CLUSTER_NAME) > $(CONFIG_LOCATION); \

.PHONY: kind-stop
kind-stop:
Expand Down
4 changes: 2 additions & 2 deletions .mk/spire.mk
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ endif
.PHONY: spire-install
spire-install:
$(info Self Signed CA = $(selfSignedCA))
@if ! helm install --name=spire \
--wait --timeout 600 \
@if ! helm install spire \
--wait --timeout 600s \
--set org="${CONTAINER_REPO}",tag="${CONTAINER_TAG}" \
--set selfSignedCA="${selfSignedCA}",caDir="${CA_DIR}" \
deployments/helm/nsm/charts/spire ; then \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ spec:
- name: nsm-spire
securityContext:
privileged: true
image: {{ .Values.registry }}/{{ .Values.org }}/nsm-spire:{{ .Values.tag }}
image: '{{ .Values.registry }}/{{ .Values.org }}/nsm-spire:{{ .Values.tag }}'
volumeMounts:
- name: spire-server-socket
mountPath: /run/spire/sockets
Expand Down