Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 26 additions & 6 deletions docs/test-framework-dev-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,21 +64,41 @@ Go to https://docker-auth.elastic.co/ and authenticate with Okta to receive your

The test are run with mage using the `integration` namespace:

- `mage integration:test` to execute all tests under the `testing/integration`
#### ESS oriented tests

- `mage integration:test` to execute all tests under the `testing/integration/ess`
folder. All tests are executed on remote VMs, including those that set `Local: true`.

- `mage integration:local [testName|all]` to execute only those tests under the
`testing/integration` folder that set `Local: true`. It'll run all the tests if
`testing/integration/ess` folder that set `Local: true`. It'll run all the tests if
`all` is passed as argument, or it'll pass `[testName]` to `go test` as
`--run=[testName]`. These tests are executed on your local machine.

- `mage integration:single [testName]` to execute a single test under the `testing/integration` folder. Only the selected test will be executed on remote VMs.
- `mage integration:single [testName]` to execute a single test under the `testing/integration/ess` folder. Only the selected test will be executed on remote VMs.

- `mage integration:matrix` to run all tests under the `testing/integration/ess` folder on the complete matrix of supported operating systems and architectures of the Elastic Agent.

#### Kubernetes oriented tests

- `mage integration:testKubernetes` to run kubernetes tests under the `testing/integration/k8s` folder for the default image on the default version of kubernetes (all previous commands will not run any kubernetes tests).

- `mage integration:testKubernetesMatrix` to run a matrix of kubernetes tests under the `testing/integration/k8s` folder for all image types and supported versions of kubernetes.

- `mage integration:testKubernetesSingle [testName|all]` to execute a single test under the `testing/integration/k8s` folder. Only the selected test will be executed.

#### Serverless oriented tests

- `mage integration:testServerless` to execute all tests under the `testing/integration/serverless` folder. All tests are executed on remote VMs, including those that set `Local: true`.

- `mage integration:testServerlessSingle [testName|all]` to execute a single test under the `testing/integration/serverless` folder. Only the selected test will be executed on remote VMs.

#### Resource leaks tests

- `mage integration:matrix` to run all tests on the complete matrix of supported operating systems and architectures of the Elastic Agent.
- `mage integration:testForResourceLeaks` to execute all tests under the `testing/integration/leak` folder. All tests are executed on remote VMs.

- `mage integration:testKubernetes` to run kubernetes tests for the default image on the default version of kubernetes (all previous commands will not run any kubernetes tests).
- `mage integration:testForResourceLeaksSingle [testName|all]` to execute a single test under the `testing/integration/leak` folder. Only the selected test will be executed on remote VMs.

- `mage integration:testKubernetesMatrix` to run a matrix of kubernetes tests for all image types and supported versions of kubernetes.
You can list all available mage targets by running `mage -l`

#### Selecting specific platform

Expand Down
60 changes: 35 additions & 25 deletions magefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -2340,46 +2340,47 @@ func (Integration) Single(ctx context.Context, testName string) error {
}

// TestServerless runs the integration tests defined in testing/integration/serverless
func (Integration) TestServerless(ctx context.Context) error {
func (i Integration) TestServerless(ctx context.Context) error {
return i.testServerless(ctx, false, "")
}

// TestServerlessSingle runs a single integration test defined in testing/integration/serverless
func (i Integration) TestServerlessSingle(ctx context.Context, testName string) error {
return i.testServerless(ctx, false, testName)
}

func (i Integration) testServerless(ctx context.Context, matrix bool, testName string) error {
err := os.Setenv("STACK_PROVISIONER", "serverless")
if err != nil {
return fmt.Errorf("error setting serverless stack env var: %w", err)
}

return integRunner(ctx, "testing/integration/serverless", false, "")
return integRunner(ctx, "testing/integration/serverless", matrix, testName)
}

// TestKubernetes runs kubernetes integration tests
func (Integration) TestKubernetes(ctx context.Context) error {
mg.Deps(Integration.BuildKubernetesTestData)
// invoke integration tests
if err := os.Setenv("TEST_GROUPS", "kubernetes"); err != nil {
return err
}

return integRunner(ctx, "testing/integration/k8s", false, "")
// TestKubernetes runs the integration tests defined in testing/integration/k8s
func (i Integration) TestKubernetes(ctx context.Context) error {
return i.testKubernetes(ctx, false, "")
}

// TestKubernetesSingle runs single k8s integration test
func (Integration) TestKubernetesSingle(ctx context.Context, testName string) error {
mg.Deps(Integration.BuildKubernetesTestData)
// invoke integration tests
if err := os.Setenv("TEST_GROUPS", "kubernetes"); err != nil {
return err
}
// TestKubernetesSingle runs a single integration test defined in testing/integration/k8s
func (i Integration) TestKubernetesSingle(ctx context.Context, testName string) error {
return i.testKubernetes(ctx, false, testName)
}

return integRunner(ctx, "testing/integration/k8s", false, testName)
// TestKubernetesMatrix runs a matrix of integration tests defined in testing/integration/k8s
func (i Integration) TestKubernetesMatrix(ctx context.Context) error {
return i.testKubernetes(ctx, true, "")
}

// TestKubernetesMatrix runs a matrix of kubernetes integration tests
func (Integration) TestKubernetesMatrix(ctx context.Context) error {
func (i Integration) testKubernetes(ctx context.Context, matrix bool, testName string) error {
mg.Deps(Integration.BuildKubernetesTestData)
// invoke integration tests
if err := os.Setenv("TEST_GROUPS", "kubernetes"); err != nil {
return err
}

return integRunner(ctx, "testing/integration/k8s", true, "")
return integRunner(ctx, "testing/integration/k8s", matrix, testName)
}

// BuildKubernetesTestData builds the test data required to run k8s integration tests
Expand Down Expand Up @@ -2897,9 +2898,18 @@ func (Integration) TestBeatServerless(ctx context.Context, beatname string) erro
return integRunner(ctx, "testing/integration/beats/serverless", false, "TestBeatsServerless")
}

// TestForResourceLeaks runs tests that check for resource leaks
func (Integration) TestForResourceLeaks(ctx context.Context) error {
return integRunner(ctx, "testing/integration/leak", false, "TestLongRunningAgentForLeaks")
// TestForResourceLeaks runs the integration tests defined in testing/integration/leak
func (i Integration) TestForResourceLeaks(ctx context.Context) error {
return i.testForResourceLeaks(ctx, false, "")
}

// TestForResourceLeaksSingle runs a single integration test defined in testing/integration/leak
func (i Integration) TestForResourceLeaksSingle(ctx context.Context, testName string) error {
return i.testForResourceLeaks(ctx, false, testName)
}

func (i Integration) testForResourceLeaks(ctx context.Context, matrix bool, testName string) error {
return integRunner(ctx, "testing/integration/leak", matrix, testName)
}

// TestOnRemote shouldn't be called locally (called on remote host to perform testing)
Expand Down