Skip to content

Commit

Permalink
docker: Run tests in parallel
Browse files Browse the repository at this point in the history
Most of our docker tests can be executed in parallel.
Use the `ginkgo -nodes` option to achieve this.
The ones that cannot be run in parallel are now tagged in
the test name as [Serial Test] to run them after we run
the tests that can be run in parallel.

After running several tests locally on different distros,
the number of processes that we can spawn in parallel for
these tests is `$(nproc) - 2`. If using `$(nproc)` or
`$(nproc -1)`, some jobs become unstable.

For firecracker, run all tests serialized.

Fixes: kata-containers#1256.

Signed-off-by: Salvador Fuentes <[email protected]>
  • Loading branch information
chavafg committed Mar 5, 2019
1 parent 54e02fb commit a59331a
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
20 changes: 19 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ ARCH_DIR = arch
ARCH_FILE_SUFFIX = -options.mk
ARCH_FILE = $(ARCH_DIR)/$(ARCH)$(ARCH_FILE_SUFFIX)

# Number of processor units available
NPROCS := $(shell grep -c ^processor /proc/cpuinfo)
# Number of `go test` processes that ginkgo will spawn.
GINKGO_NODES := $(shell echo $(NPROCS)\-2 | bc)

# Load architecture-dependent settings
ifneq ($(wildcard $(ARCH_FILE)),)
include $(ARCH_FILE)
Expand All @@ -49,8 +54,21 @@ endif
docker: ginkgo
ifeq ($(RUNTIME),)
$(error RUNTIME is not set)
endif

ifeq ($(KATA_HYPERVISOR),firecracker)
./ginkgo -v -focus "${FOCUS}" -skip "${SKIP}" \
./integration/docker/ -- -runtime=${RUNTIME} -timeout=${TIMEOUT}
else ifeq ($(ARCH),aarch64)
./ginkgo -v -focus "${FOCUS}" -skip "${SKIP}" \
./integration/docker/ -- -runtime=${RUNTIME} -timeout=${TIMEOUT}
else
./ginkgo -v -focus "${FOCUS}" -skip "${SKIP}" ./integration/docker/ -- -runtime=${RUNTIME} -timeout=${TIMEOUT}
# Run tests in parallel, skip tests that need to be run serialized
./ginkgo -nodes=${GINKGO_NODES} -v -focus "${FOCUS}" -skip "${SKIP}" -skip "\[Serial Test\]" \
./integration/docker/ -- -runtime=${RUNTIME} -timeout=${TIMEOUT}
# Now run serialized tests
./ginkgo -v -focus "${FOCUS}" -focus "\[Serial Test\]" -skip "${SKIP}" \
./integration/docker/ -- -runtime=${RUNTIME} -timeout=${TIMEOUT}
bash sanity/check_sanity.sh
endif

Expand Down
4 changes: 2 additions & 2 deletions integration/docker/cp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ var _ = Describe("docker cp", func() {
})
})

var _ = Describe("docker cp with volume attached", func() {
var _ = Describe("[Serial Test] docker cp with volume attached", func() {
var (
id string
exitCode int
Expand Down Expand Up @@ -102,7 +102,7 @@ var _ = Describe("docker cp with volume attached", func() {
})
})

var _ = Describe("docker cp with volume", func() {
var _ = Describe("[Serial Test] docker cp with volume", func() {
var (
id string
exitCode int
Expand Down
2 changes: 1 addition & 1 deletion integration/docker/volume_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
. "github.com/onsi/gomega"
)

var _ = Describe("docker volume", func() {
var _ = Describe("[Serial Test] docker volume", func() {
var (
args []string
id string = randomDockerName()
Expand Down

0 comments on commit a59331a

Please sign in to comment.