Skip to content

Commit

Permalink
Run Conformance and NetworkPolicy tests in Jenkins with Kind (antrea-…
Browse files Browse the repository at this point in the history
…io#4460)

Signed-off-by: KMAnju-2021 <km074btcse18@igdtuw.ac.in>
  • Loading branch information
KMAnju-2021 authored Mar 15, 2023
1 parent db426cc commit c770205
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 2 deletions.
18 changes: 18 additions & 0 deletions ci/jenkins/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,24 @@ DOCKER_REGISTRY="$(head -n1 ci/docker-registry)"
./ci/jenkins/test.sh --testcase e2e --registry ${DOCKER_REGISTRY} --testbed-type "flexible-ipam"
```

* Kind conformance: conformance tests in a kind cluster

```shell
#!/bin/bash
set -e
DOCKER_REGISTRY="$(head -n1 ci/docker-registry)"
./ci/jenkins/test.sh --testcase conformance --registry ${DOCKER_REGISTRY} --testbed-type "kind" --kind-cluster-name "${{JOB_NAME}}-${{BUILD_NUMBER}}"
```

* Kind NetworkPolicy: NetworkPolicy tests in a kind cluster

```shell
#!/bin/bash
set -e
DOCKER_REGISTRY="$(head -n1 ci/docker-registry)"
./ci/jenkins/test.sh --testcase networkpolicy --registry ${DOCKER_REGISTRY} --testbed-type "kind" --kind-cluster-name "${{JOB_NAME}}-${{BUILD_NUMBER}}"
```

* [whole-conformance [daily]](https://jenkins.antrea-ci.rocks/job/antrea-whole-conformance-for-pull-request/):
community tests using sonobuoy, with certified-conformance mode.

Expand Down
17 changes: 17 additions & 0 deletions ci/jenkins/jobs/macros.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -223,3 +223,20 @@
set -e
DOCKER_REGISTRY="$(head -n1 ci/docker-registry)"
./ci/jenkins/test-vm.sh --registry ${DOCKER_REGISTRY} --kubeconfig /var/lib/jenkins/.kube/config
- builder:
name: builder-conformance-kind
builders:
- shell: |-
#!/bin/bash
set -ex
DOCKER_REGISTRY="$(head -n1 ci/docker-registry)"
./ci/kind/kind-setup.sh --antrea-cni create "${{JOB_NAME}}-${{BUILD_NUMBER}}"
kind export kubeconfig -n "${{JOB_NAME}}-${{BUILD_NUMBER}}" --kubeconfig ${{PWD}}/.kube/config
set +ex
./ci/jenkins/test.sh --testcase '{conformance_type}' --registry ${{DOCKER_REGISTRY}} --kubeconfig ${{PWD}}/.kube/config --testbed-type "kind" --kind-cluster-name "${{JOB_NAME}}-${{BUILD_NUMBER}}"
return_code=$?
set -ex
kind delete cluster --name "${{JOB_NAME}}-${{BUILD_NUMBER}}"
exit $return_code
54 changes: 53 additions & 1 deletion ci/jenkins/jobs/projects-lab.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -819,4 +819,56 @@
case-sensitive: true
default-excludes: true
fingerprint: false
only-if-success: false
only-if-success: false
- '{name}-{test_name}-for-pull-request':
test_name: kind-conformance
node: 'antrea-kind-testbed'
description: 'This is for running conformance tests on kind.'
branches:
- ${{sha1}}
builders:
- builder-conformance-kind:
conformance_type: 'conformance'
trigger_phrase: ^(?!Thanks for your PR).*/test-kind-conformance.*
white_list_target_branches: []
allow_whitelist_orgs_as_admins: true
admin_list: '{antrea_admin_list}'
org_list: '{antrea_org_list}'
white_list: '{antrea_white_list}'
only_trigger_phrase: true
trigger_permit_all: true
status_context: jenkins-kind-conformance
status_url: --none--
success_status: Build finished.
failure_status: Failed. Add comment /test-kind-conformance to re-trigger.
error_status: Failed. Add comment /test-kind-conformance to re-trigger.
triggered_status: null
started_status: null
publishers: []
wrappers: []
- '{name}-{test_name}-for-pull-request':
test_name: kind-networkpolicy
node: 'antrea-kind-testbed'
description: 'This is for running networkpolicy tests on kind.'
branches:
- ${{sha1}}
builders:
- builder-conformance-kind:
conformance_type: 'networkpolicy'
trigger_phrase: ^(?!Thanks for your PR).*/test-kind-networkpolicy.*
white_list_target_branches: []
allow_whitelist_orgs_as_admins: true
admin_list: '{antrea_admin_list}'
org_list: '{antrea_org_list}'
white_list: '{antrea_white_list}'
only_trigger_phrase: true
trigger_permit_all: true
status_context: jenkins-kind-networkpolicy
status_url: --none--
success_status: Build finished.
failure_status: Failed. Add comment /test-kind-networkpolicy to re-trigger.
error_status: Failed. Add comment /test-kind-networkpolicy to re-trigger.
triggered_status: null
started_status: null
publishers: []
wrappers: []
11 changes: 10 additions & 1 deletion ci/jenkins/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ function echoerr {
>&2 echo "$@"
}

KIND_CLUSTER=""
DEFAULT_WORKDIR="/var/lib/jenkins"
DEFAULT_KUBECONFIG_PATH=$DEFAULT_WORKDIR/kube.conf
WORKDIR=$DEFAULT_WORKDIR
Expand Down Expand Up @@ -63,7 +64,8 @@ Run K8s e2e community tests (Conformance & Network Policy) or Antrea e2e tests o
--proxyall Enable proxyAll to test AntreaProxy.
--testbed-type The testbed type to run tests. It can be flexible-ipam, jumper or legacy.
--ip-mode IP mode for flexible-ipam e2e test. Default is $DEFAULT_IP_MODE. It can also be ipv6 or ds.
--win-jumper Name of the windows jumper node in containerd cluster. Images are built by docker on this node."
--win-jumper Name of the windows jumper node in containerd cluster. Images are built by docker on this node.
--kind-cluster-name Name of the kind Cluster."

function print_usage {
echoerr "$_usage"
Expand All @@ -78,6 +80,10 @@ do
key="$1"

case $key in
--kind-cluster-name)
KIND_CLUSTER="$2"
shift 2
;;
--kubeconfig)
KUBECONFIG_PATH="$2"
shift 2
Expand Down Expand Up @@ -621,6 +627,9 @@ function deliver_antrea {
scp -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i "${WORKDIR}/jenkins_id_rsa" flow-aggregator.tar jenkins@[${IP}]:${DEFAULT_WORKDIR}/flow-aggregator.tar
ssh -o StrictHostKeyChecking=no -i "${WORKDIR}/jenkins_id_rsa" -n jenkins@${IP} "${CLEAN_STALE_IMAGES}; docker load -i ${DEFAULT_WORKDIR}/antrea-ubuntu.tar; docker load -i ${DEFAULT_WORKDIR}/flow-aggregator.tar" || true
done
elif [[ $TESTBED_TYPE == "kind" ]]; then
kind load docker-image antrea/antrea-ubuntu:latest --name ${KIND_CLUSTER}
kind load docker-image antrea/flow-aggregator:latest --name ${KIND_CLUSTER}
elif [[ $TESTBED_TYPE == "jumper" ]]; then
kubectl get nodes -o wide --no-headers=true | awk '{print $6}' | while read IP; do
scp -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i "${WORKDIR}/.ssh/id_rsa" antrea-ubuntu.tar jenkins@${IP}:${DEFAULT_WORKDIR}/antrea-ubuntu.tar
Expand Down

0 comments on commit c770205

Please sign in to comment.