hack/test/unit: run libnetwork tests sequentially

Run all tests within `libnetwork` namespace with `-p=1`
in a separate `gotestsum` invocation.

Signed-off-by: Roman Volosatovs <roman.volosatovs@docker.com>
This commit is contained in:
Roman Volosatovs 2021-07-02 21:29:04 +02:00
parent 656a5e2bdf
commit 3af2217dc4
No known key found for this signature in database
GPG key ID: 216DD5F8CA6618A1
2 changed files with 32 additions and 13 deletions

10
Jenkinsfile vendored
View file

@ -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
}
}
}

View file

@ -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