diff --git a/ci/jenkins/README.md b/ci/jenkins/README.md index ddc2b896612..5f3cf2a5bfd 100644 --- a/ci/jenkins/README.md +++ b/ci/jenkins/README.md @@ -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. diff --git a/ci/jenkins/jobs/macros.yaml b/ci/jenkins/jobs/macros.yaml index 6b2593063c6..1ee64ca03bd 100644 --- a/ci/jenkins/jobs/macros.yaml +++ b/ci/jenkins/jobs/macros.yaml @@ -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 + diff --git a/ci/jenkins/jobs/projects-lab.yaml b/ci/jenkins/jobs/projects-lab.yaml index f45f731587d..8ad32b95987 100644 --- a/ci/jenkins/jobs/projects-lab.yaml +++ b/ci/jenkins/jobs/projects-lab.yaml @@ -819,4 +819,56 @@ case-sensitive: true default-excludes: true fingerprint: false - only-if-success: false \ No newline at end of file + 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: [] diff --git a/ci/jenkins/test.sh b/ci/jenkins/test.sh index 9f552fd5817..2ab51976090 100755 --- a/ci/jenkins/test.sh +++ b/ci/jenkins/test.sh @@ -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 @@ -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" @@ -78,6 +80,10 @@ do key="$1" case $key in + --kind-cluster-name) + KIND_CLUSTER="$2" + shift 2 + ;; --kubeconfig) KUBECONFIG_PATH="$2" shift 2 @@ -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