Skip to content

feat: singleTest mage target for each integration test package #8691

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
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