From 0fb9405a2909cbc8e969670a004d81f1f605de4e Mon Sep 17 00:00:00 2001 From: Blake Rouse Date: Mon, 9 Oct 2023 14:12:22 -0400 Subject: [PATCH] Remove isolate. --- pkg/testing/define/batch.go | 13 +- pkg/testing/define/batch_test.go | 180 ------------------ pkg/testing/define/requirements.go | 4 - pkg/testing/define/testdata/sample_test.go | 43 ----- pkg/testing/ogc/provisioner.go | 11 -- pkg/testing/runner/runner.go | 10 - testing/integration/endpoint_security_test.go | 9 +- 7 files changed, 5 insertions(+), 265 deletions(-) diff --git a/pkg/testing/define/batch.go b/pkg/testing/define/batch.go index 9ec117c8b9a..24c71fca4a3 100644 --- a/pkg/testing/define/batch.go +++ b/pkg/testing/define/batch.go @@ -51,9 +51,6 @@ type Batch struct { // Stack defines the stack required for this batch. Stack *Stack `json:"stack,omitempty"` - // Isolate defines that this batch is isolated to a single test. - Isolate bool `json:"isolate"` - // Tests define the set of packages and tests that do not require sudo // privileges to be performed. Tests []BatchPackageTests `json:"tests"` @@ -181,16 +178,12 @@ func appendTest(batches []Batch, tar testActionResult, req Requirements) []Batch } for _, o := range set { var batch Batch - batchIdx := -1 - if !req.Isolate { - batchIdx = findBatchIdx(batches, req.Group, o, req.Stack) - } + batchIdx := findBatchIdx(batches, req.Group, o, req.Stack) if batchIdx == -1 { // new batch required batch = Batch{ Group: req.Group, OS: o, - Isolate: req.Isolate, Tests: nil, SudoTests: nil, } @@ -248,10 +241,6 @@ func appendPackageTest(tests []BatchPackageTests, pkg string, name string, stack func findBatchIdx(batches []Batch, group string, os OS, stack *Stack) int { for i, b := range batches { - if b.Isolate { - // never add to an isolate batch - continue - } if b.Group != group { // must be in the same group continue diff --git a/pkg/testing/define/batch_test.go b/pkg/testing/define/batch_test.go index f54c35e2179..f0f997d41f8 100644 --- a/pkg/testing/define/batch_test.go +++ b/pkg/testing/define/batch_test.go @@ -164,186 +164,6 @@ func TestBatch(t *testing.T) { Tests: windowsLocalTests, SudoTests: windowsSudoTests, }, - { - Group: "default", - OS: OS{ - Type: Darwin, - Arch: AMD64, - }, - Isolate: true, - Tests: []BatchPackageTests{ - { - Name: pkgName, - Tests: []BatchPackageTest{ - { - Name: "TestAnyIsolate", - }, - }, - }, - }, - }, - { - Group: "default", - OS: OS{ - Type: Darwin, - Arch: ARM64, - }, - Isolate: true, - Tests: []BatchPackageTests{ - { - Name: pkgName, - Tests: []BatchPackageTest{ - { - Name: "TestAnyIsolate", - }, - }, - }, - }, - }, - { - Group: "default", - OS: OS{ - Type: Linux, - Arch: AMD64, - }, - Isolate: true, - Tests: []BatchPackageTests{ - { - Name: pkgName, - Tests: []BatchPackageTest{ - { - Name: "TestAnyIsolate", - }, - }, - }, - }, - }, - { - Group: "default", - OS: OS{ - Type: Linux, - Arch: ARM64, - }, - Isolate: true, - Tests: []BatchPackageTests{ - { - Name: pkgName, - Tests: []BatchPackageTest{ - { - Name: "TestAnyIsolate", - }, - }, - }, - }, - }, - { - Group: "default", - OS: OS{ - Type: Windows, - Arch: AMD64, - }, - Isolate: true, - Tests: []BatchPackageTests{ - { - Name: pkgName, - Tests: []BatchPackageTest{ - { - Name: "TestAnyIsolate", - }, - }, - }, - }, - }, - { - Group: "default", - OS: OS{ - Type: Darwin, - Arch: AMD64, - }, - Isolate: true, - Tests: []BatchPackageTests{ - { - Name: pkgName, - Tests: []BatchPackageTest{ - { - Name: "TestDarwinIsolate", - }, - }, - }, - }, - }, - { - Group: "default", - OS: OS{ - Type: Darwin, - Arch: ARM64, - }, - Isolate: true, - Tests: []BatchPackageTests{ - { - Name: pkgName, - Tests: []BatchPackageTest{ - { - Name: "TestDarwinIsolate", - }, - }, - }, - }, - }, - { - Group: "default", - OS: OS{ - Type: Linux, - Arch: AMD64, - }, - Isolate: true, - Tests: []BatchPackageTests{ - { - Name: pkgName, - Tests: []BatchPackageTest{ - { - Name: "TestLinuxIsolate", - }, - }, - }, - }, - }, - { - Group: "default", - OS: OS{ - Type: Linux, - Arch: ARM64, - }, - Isolate: true, - Tests: []BatchPackageTests{ - { - Name: pkgName, - Tests: []BatchPackageTest{ - { - Name: "TestLinuxIsolate", - }, - }, - }, - }, - }, - { - Group: "default", - OS: OS{ - Type: Windows, - Arch: AMD64, - }, - Isolate: true, - Tests: []BatchPackageTests{ - { - Name: pkgName, - Tests: []BatchPackageTest{ - { - Name: "TestWindowsIsolate", - }, - }, - }, - }, - }, { Group: "one", OS: OS{ diff --git a/pkg/testing/define/requirements.go b/pkg/testing/define/requirements.go index ced69cc147b..c62f874009f 100644 --- a/pkg/testing/define/requirements.go +++ b/pkg/testing/define/requirements.go @@ -109,10 +109,6 @@ type Requirements struct { // when a full test run is performed. Local bool `json:"local"` - // Isolate defines that this test must be isolated to its own dedicated VM and the test - // cannot be shared with other tests. - Isolate bool `json:"isolate"` - // Sudo defines that this test must run under superuser permissions. On Mac and Linux the // test gets executed under sudo and on Windows it gets run under Administrator. Sudo bool `json:"sudo"` diff --git a/pkg/testing/define/testdata/sample_test.go b/pkg/testing/define/testdata/sample_test.go index 2485e7da2b3..caecad36bc2 100644 --- a/pkg/testing/define/testdata/sample_test.go +++ b/pkg/testing/define/testdata/sample_test.go @@ -26,13 +26,6 @@ func TestAnySudo(t *testing.T) { }) } -func TestAnyIsolate(t *testing.T) { - define.Require(t, define.Requirements{ - Group: "default", - Isolate: true, - }) -} - func TestDarwinLocal(t *testing.T) { define.Require(t, define.Requirements{ Group: "default", @@ -57,18 +50,6 @@ func TestDarwinSudo(t *testing.T) { }) } -func TestDarwinIsolate(t *testing.T) { - define.Require(t, define.Requirements{ - Group: "default", - OS: []define.OS{ - { - Type: define.Darwin, - }, - }, - Isolate: true, - }) -} - func TestLinuxLocal(t *testing.T) { define.Require(t, define.Requirements{ Group: "default", @@ -93,18 +74,6 @@ func TestLinuxSudo(t *testing.T) { }) } -func TestLinuxIsolate(t *testing.T) { - define.Require(t, define.Requirements{ - Group: "default", - OS: []define.OS{ - { - Type: define.Linux, - }, - }, - Isolate: true, - }) -} - func TestWindowsLocal(t *testing.T) { define.Require(t, define.Requirements{ Group: "default", @@ -129,18 +98,6 @@ func TestWindowsSudo(t *testing.T) { }) } -func TestWindowsIsolate(t *testing.T) { - define.Require(t, define.Requirements{ - Group: "default", - OS: []define.OS{ - { - Type: define.Windows, - }, - }, - Isolate: true, - }) -} - func TestSpecificCombinationOne(t *testing.T) { define.Require(t, define.Requirements{ Group: "default", diff --git a/pkg/testing/ogc/provisioner.go b/pkg/testing/ogc/provisioner.go index 74c92eb0b30..853a9a3502e 100644 --- a/pkg/testing/ogc/provisioner.go +++ b/pkg/testing/ogc/provisioner.go @@ -9,7 +9,6 @@ import ( "context" "fmt" "os" - "path" "path/filepath" "strings" "time" @@ -290,16 +289,6 @@ func osBatchToOGC(cacheDir string, batch runner.OSBatch) Layout { } else { tags = append(tags, strings.ToLower(fmt.Sprintf("%s-%s", batch.OS.Type, strings.Replace(batch.OS.Version, ".", "-", -1)))) } - if batch.Batch.Isolate { - tags = append(tags, "isolate") - var test define.BatchPackageTests - if len(batch.Batch.SudoTests) > 0 { - test = batch.Batch.SudoTests[0] - } else if len(batch.Batch.Tests) > 0 { - test = batch.Batch.Tests[0] - } - tags = append(tags, fmt.Sprintf("%s-%s", path.Base(test.Name), strings.ToLower(test.Tests[0].Name))) - } los, _ := findOSLayout(batch.OS.OS) return Layout{ Name: batch.ID, diff --git a/pkg/testing/runner/runner.go b/pkg/testing/runner/runner.go index 3928eed9e9b..768d9814236 100644 --- a/pkg/testing/runner/runner.go +++ b/pkg/testing/runner/runner.go @@ -962,16 +962,6 @@ func createBatchID(batch OSBatch) string { } id += "-" + strings.Replace(batch.OS.Version, ".", "", -1) id += "-" + strings.Replace(batch.Batch.Group, ".", "", -1) - if batch.Batch.Isolate { - if len(batch.Batch.Tests) > 0 { - // only ever has one test in an isolated batch - id += "-" + batch.Batch.Tests[0].Tests[0].Name - } - if len(batch.Batch.SudoTests) > 0 { - // only ever has one test in an isolated batch - id += "-" + batch.Batch.SudoTests[0].Tests[0].Name - } - } return strings.ToLower(id) } diff --git a/testing/integration/endpoint_security_test.go b/testing/integration/endpoint_security_test.go index 6dbbe46ab83..b5b2e3af4bc 100644 --- a/testing/integration/endpoint_security_test.go +++ b/testing/integration/endpoint_security_test.go @@ -490,11 +490,10 @@ func installElasticDefendPackage(t *testing.T, info *define.Info, policyID strin // path other than default func TestEndpointSecurityNonDefaultBasePath(t *testing.T) { info := define.Require(t, define.Requirements{ - Group: "endpoint", - Stack: &define.Stack{}, - Local: false, // requires Agent installation - Isolate: false, - Sudo: true, // requires Agent installation + Group: "endpoint", + Stack: &define.Stack{}, + Local: false, // requires Agent installation + Sudo: true, // requires Agent installation }) ctx, cn := context.WithCancel(context.Background())