diff --git a/Jenkinsfile b/Jenkinsfile index f2ef6efbeb..258b11b31e 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -199,7 +199,7 @@ pipeline { } post { always { - junit testResults: 'bundles/junit-report.xml', allowEmptyResults: true + junit testResults: 'bundles/junit-report*.xml', allowEmptyResults: true } } } @@ -238,7 +238,7 @@ pipeline { sh ''' bundleName=unit echo "Creating ${bundleName}-bundles.tar.gz" - tar -czvf ${bundleName}-bundles.tar.gz bundles/junit-report.xml bundles/go-test-report.json bundles/profile.out + tar -czvf ${bundleName}-bundles.tar.gz bundles/junit-report*.xml bundles/go-test-report*.json bundles/profile*.out ''' archiveArtifacts artifacts: '*-bundles.tar.gz', allowEmptyArchive: true @@ -599,7 +599,7 @@ pipeline { } post { always { - junit testResults: 'bundles/junit-report.xml', allowEmptyResults: true + junit testResults: 'bundles/junit-report*.xml', allowEmptyResults: true } } } @@ -801,7 +801,7 @@ pipeline { } post { always { - junit testResults: 'bundles/junit-report.xml', allowEmptyResults: true + junit testResults: 'bundles/junit-report*.xml', allowEmptyResults: true } } } @@ -1000,7 +1000,7 @@ pipeline { } post { always { - junit testResults: 'bundles/junit-report.xml', allowEmptyResults: true + junit testResults: 'bundles/junit-report*.xml', allowEmptyResults: true } } } diff --git a/hack/test/unit b/hack/test/unit index 00880adb36..7c8ff53adc 100755 --- a/hack/test/unit +++ b/hack/test/unit @@ -18,16 +18,35 @@ TESTDIRS="${TESTDIRS:-./...}" exclude_paths='/vendor/|/integration' pkg_list=$(go list $TESTDIRS | grep -vE "($exclude_paths)") -echo "${pkg_list}" | grep --fixed-strings "libnetwork/drivers/bridge" \ +base_pkg_list=$(echo "${pkg_list}" | grep --fixed-strings -v "/libnetwork" || :) +libnetwork_pkg_list=$(echo "${pkg_list}" | grep --fixed-strings "/libnetwork" || :) + +echo "${libnetwork_pkg_list}" | grep --fixed-strings "libnetwork/drivers/bridge" \ && if ! type docker-proxy; then hack/make.sh binary-proxy install-proxy fi mkdir -p bundles -gotestsum --format=standard-quiet --jsonfile=bundles/go-test-report.json --junitfile=bundles/junit-report.xml -- \ - "${BUILDFLAGS[@]}" \ - -cover \ - -coverprofile=bundles/profile.out \ - -covermode=atomic \ - ${TESTFLAGS} \ - ${pkg_list} + +if [ -n "${base_pkg_list}" ]; then + gotestsum --format=standard-quiet --jsonfile=bundles/go-test-report.json --junitfile=bundles/junit-report.xml -- \ + "${BUILDFLAGS[@]}" \ + -cover \ + -coverprofile=bundles/profile.out \ + -covermode=atomic \ + ${TESTFLAGS} \ + ${base_pkg_list} +fi +if [ -n "${libnetwork_pkg_list}" ]; then + # libnetwork tests invoke iptables, and cannot be run in parallel. Execute + # tests within /libnetwork with '-p=1' to run them sequentially. See + # https://github.com/moby/moby/issues/42458#issuecomment-873216754 for details. + gotestsum --format=standard-quiet --jsonfile=bundles/go-test-report-libnetwork.json --junitfile=bundles/junit-report-libnetwork.xml -- \ + "${BUILDFLAGS[@]}" \ + -cover \ + -coverprofile=bundles/profile-libnetwork.out \ + -covermode=atomic \ + -p=1 \ + ${TESTFLAGS} \ + ${libnetwork_pkg_list} +fi