Selaa lähdekoodia

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>
Roman Volosatovs 4 vuotta sitten
vanhempi
commit
3af2217dc4
2 muutettua tiedostoa jossa 32 lisäystä ja 13 poistoa
  1. 5 5
      Jenkinsfile
  2. 27 8
      hack/test/unit

+ 5 - 5
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
                                 }
                             }
                         }

+ 27 - 8
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