From c218c4575c1d4c74ecc34178139b394e5f706f89 Mon Sep 17 00:00:00 2001 From: bpopovschi Date: Thu, 5 Dec 2019 14:52:32 +0200 Subject: [PATCH] Added possibility to change numer of vm's for Multiple vm's test Signed-off-by: bpopovschi --- .buildkite/pipeline.yml | 1 + runtime/Makefile | 2 ++ runtime/service_integ_test.go | 29 +++++++++++++++-------------- 3 files changed, 18 insertions(+), 14 deletions(-) diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index 2688669e8..cc5bd8f84 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -60,6 +60,7 @@ steps: queue: "${BUILDKITE_AGENT_META_DATA_QUEUE:-default}" env: DOCKER_IMAGE_TAG: "$BUILDKITE_BUILD_NUMBER" + NUMBER_OF_VMS: 100 EXTRAGOARGS: "-v -count=1 -race" artifact_paths: - "runtime/logs/*" diff --git a/runtime/Makefile b/runtime/Makefile index c3e1467a5..36fb7496b 100644 --- a/runtime/Makefile +++ b/runtime/Makefile @@ -13,6 +13,7 @@ # Set this to pass additional commandline flags to the go compiler, e.g. "make test EXTRAGOARGS=-v" EXTRAGOARGS?= +NUMBER_OF_VMS?= SOURCES:=$(shell find . -name '*.go') GOMOD := $(shell go env GOMOD) @@ -63,6 +64,7 @@ integ-test-%: logs --env FICD_DM_POOL=$(FICD_DM_POOL) \ --env GOPROXY=direct \ --env GOSUMDB=off \ + --env NUMBER_OF_VMS=$(NUMBER_OF_VMS) \ --workdir="/src/runtime" \ --init \ $(FIRECRACKER_CONTAINERD_TEST_IMAGE):$(DOCKER_IMAGE_TAG) \ diff --git a/runtime/service_integ_test.go b/runtime/service_integ_test.go index 74a4d2453..f6af8d8e1 100644 --- a/runtime/service_integ_test.go +++ b/runtime/service_integ_test.go @@ -66,6 +66,9 @@ const ( defaultVMRootfsPath = "/var/lib/firecracker-containerd/runtime/default-rootfs.img" defaultVMNetDevName = "eth0" varRunDir = "/run/firecracker-containerd" + + numberOfVmsEnvName = "NUMBER_OF_VMS" + defaultNumberOfVms = 5 ) // Images are presumed by the isolated tests to have already been pulled @@ -220,6 +223,14 @@ func TestMultipleVMs_Isolated(t *testing.T) { netns, err := ns.GetCurrentNS() require.NoError(t, err, "failed to get a namespace") + // numberOfVmsEnvName = NUMBER_OF_VMS ENV and is configurable from buildkite + numberOfVms, err := strconv.Atoi(os.Getenv(numberOfVmsEnvName)) + require.NoError(t, err, "failed to get NUMBER_OF_VMS env") + if numberOfVms == 0 { + numberOfVms = defaultNumberOfVms + } + t.Logf("TestMultipleVMs_Isolated: will run %d vm's", numberOfVms) + cases := []struct { MaxContainers int32 JailerConfig *proto.JailerConfig @@ -227,18 +238,6 @@ func TestMultipleVMs_Isolated(t *testing.T) { { MaxContainers: 5, }, - { - MaxContainers: 5, - }, - { - MaxContainers: 5, - }, - { - MaxContainers: 3, - JailerConfig: &proto.JailerConfig{ - NetNS: netns.Path(), - }, - }, { MaxContainers: 3, JailerConfig: &proto.JailerConfig{ @@ -265,7 +264,9 @@ func TestMultipleVMs_Isolated(t *testing.T) { // container ends up in the right VM by assigning each VM a network device with a unique mac address and having each container // print the mac address it sees inside its VM. var vmWg sync.WaitGroup - for vmID, c := range cases { + for i := 0; i < numberOfVms; i++ { + caseTypeNumber := i % len(cases) + c := cases[caseTypeNumber] vmWg.Add(1) go func(vmID int, containerCount int32, jailerConfig *proto.JailerConfig) { defer vmWg.Done() @@ -338,7 +339,7 @@ func TestMultipleVMs_Isolated(t *testing.T) { _, err = fcClient.StopVM(ctx, &proto.StopVMRequest{VMID: strconv.Itoa(vmID), TimeoutSeconds: 5}) require.NoError(t, err, "failed to stop VM %d", vmID) - }(vmID, c.MaxContainers, c.JailerConfig) + }(i, c.MaxContainers, c.JailerConfig) } vmWg.Wait()