From 7e6767ddf8f44d2df47f652f38fc544654485ca5 Mon Sep 17 00:00:00 2001 From: Seth Hoenig Date: Thu, 17 Mar 2022 08:37:34 -0500 Subject: [PATCH] e2e: have e2e use ci.Parallel This is a followup to having tests run in serial in CI. The e2e package isn't in CI, but lets use the helper anyway so we can setup semgrep rules covering the entire repository. --- e2e/clientstate/clientstate.go | 7 ++++--- e2e/framework/framework.go | 3 ++- e2e/nomad09upgrade/upgrade.go | 6 +++--- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/e2e/clientstate/clientstate.go b/e2e/clientstate/clientstate.go index 71ac22a28..9fadccf55 100644 --- a/e2e/clientstate/clientstate.go +++ b/e2e/clientstate/clientstate.go @@ -14,6 +14,7 @@ import ( "time" "github.com/hashicorp/nomad/api" + "github.com/hashicorp/nomad/ci" "github.com/hashicorp/nomad/client/state" "github.com/hashicorp/nomad/e2e/e2eutil" "github.com/hashicorp/nomad/e2e/execagent" @@ -82,7 +83,7 @@ func getPID(client *api.Client, alloc *api.Allocation, path string) (int, error) // loop to assert Nomad is crash safe. func (tc *ClientStateTC) TestClientState_Kill(f *framework.F) { t := f.T() - t.Parallel() + ci.Parallel(t) serverOut := testlog.NewPrefixWriter(t, "SERVER: ") clientOut := testlog.NewPrefixWriter(t, "CLIENT: ") @@ -223,7 +224,7 @@ func (tc *ClientStateTC) TestClientState_Kill(f *framework.F) { // in a tight loop to assert Nomad is crash safe while a task is restarting. func (tc *ClientStateTC) TestClientState_KillDuringRestart(f *framework.F) { t := f.T() - t.Parallel() + ci.Parallel(t) serverOut := testlog.NewPrefixWriter(t, "SERVER: ") clientOut := testlog.NewPrefixWriter(t, "CLIENT: ") @@ -345,7 +346,7 @@ func (tc *ClientStateTC) TestClientState_KillDuringRestart(f *framework.F) { // assert it recovers. func (tc *ClientStateTC) TestClientState_Corrupt(f *framework.F) { t := f.T() - t.Parallel() + ci.Parallel(t) serverOut := testlog.NewPrefixWriter(t, "SERVER: ") clientOut := testlog.NewPrefixWriter(t, "CLIENT: ") diff --git a/e2e/framework/framework.go b/e2e/framework/framework.go index aff77ac3f..b783a2396 100644 --- a/e2e/framework/framework.go +++ b/e2e/framework/framework.go @@ -8,6 +8,7 @@ import ( "strings" "testing" + "github.com/hashicorp/nomad/ci" "github.com/stretchr/testify/require" ) @@ -212,7 +213,7 @@ func (f *Framework) runCase(t *testing.T, s *TestSuite, c TestCase) { t.Run(c.Name(), func(t *testing.T) { // If the TestSuite has Parallel set, all cases run in parallel if s.Parallel { - t.Parallel() + ci.Parallel(t) } f := newF(t) diff --git a/e2e/nomad09upgrade/upgrade.go b/e2e/nomad09upgrade/upgrade.go index 88f2fc88d..a2d204975 100644 --- a/e2e/nomad09upgrade/upgrade.go +++ b/e2e/nomad09upgrade/upgrade.go @@ -119,7 +119,7 @@ func (tc *UpgradePathTC) TestRawExecTaskUpgrade(f *framework.F) { for _, ver := range nomadVersions { ver := ver f.T().Run(ver, func(t *testing.T) { - t.Parallel() + ci.Parallel(t) tc.testUpgradeForJob(t, ver, "nomad09upgrade/rawexec.nomad") }) } @@ -129,7 +129,7 @@ func (tc *UpgradePathTC) TestExecTaskUpgrade(f *framework.F) { for _, ver := range nomadVersions { ver := ver f.T().Run(ver, func(t *testing.T) { - t.Parallel() + ci.Parallel(t) tc.testUpgradeForJob(t, ver, "nomad09upgrade/exec.nomad") }) } @@ -139,7 +139,7 @@ func (tc *UpgradePathTC) TestDockerTaskUpgrade(f *framework.F) { for _, ver := range nomadVersions { ver := ver f.T().Run(ver, func(t *testing.T) { - t.Parallel() + ci.Parallel(t) tc.testUpgradeForJob(t, ver, "nomad09upgrade/docker.nomad") }) }