Skip to content
Draft
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
137 changes: 77 additions & 60 deletions integration-tests/invoke_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
_ "embed"
"flag"
"fmt"
"math/rand/v2"
"os"
"os/exec"
"path/filepath"
Expand All @@ -19,69 +20,85 @@

var workingDir = flag.String("workingDir", "", "run tests in the specified directory, relative to the root of the repository. Defaults to the root of the repository.")

func TestInvokes(t *testing.T) {
// Set working directory
rootPath, err := rootPath()
require.NoError(t, err)
if *workingDir == "" {
*workingDir = rootPath
func TestImFlaky(t *testing.T) {
fmt.Println("I'm not flaky anymore!")
fmt.Println(*workingDir)
if rand.Int32()%8 == 0 {
fmt.Println("I fail")
t.Fail()
} else {
fmt.Println("I dont fail")
}
if !filepath.IsAbs(*workingDir) {
*workingDir = filepath.Join(rootPath, *workingDir)
}
t.Logf("Running tests in %s", *workingDir)

// Arrange
t.Log("Creating temporary configuration file")
tmpConfigFile, err := createTemporaryConfigurationFile()
require.NoError(t, err, "Error writing temporary configuration")
t.Cleanup(func() {
t.Log("Cleaning up temporary configuration file")
os.Remove(tmpConfigFile)
})

t.Log("setup test infra")
err = setupTestInfra(tmpConfigFile)
require.NoError(t, err, "Error setting up test infra")

tmpConfig, err := LoadConfig(tmpConfigFile)
require.NoError(t, err)

require.NotEmpty(t, tmpConfig.ConfigParams.AWS.TeamTag)

// Subtests

t.Run("az.create-vm", func(t *testing.T) {
t.Parallel()
testAzureInvokeVM(t, tmpConfigFile, *workingDir)
})

t.Run("aws.create-vm", func(t *testing.T) {
t.Parallel()
testAwsInvokeVM(t, tmpConfigFile, *workingDir)
})

t.Run("gcp.create-vm", func(t *testing.T) {
t.Parallel()
testGcpInvokeVM(t, tmpConfigFile, *workingDir)
})

t.Run("aws.invoke-docker-vm", func(t *testing.T) {
t.Parallel()
testInvokeDockerVM(t, tmpConfigFile, *workingDir)
})

t.Run("aws.invoke-kind", func(t *testing.T) {
t.Parallel()
testInvokeKind(t, tmpConfigFile, *workingDir)
})

t.Run("invoke-kind-operator", func(t *testing.T) {
t.Parallel()
testInvokeKindOperator(t, tmpConfigFile, *workingDir)
})
}

func TestImOk(t *testing.T) {

Check failure on line 34 in integration-tests/invoke_test.go

View workflow job for this annotation

GitHub Actions / lint-go

unused-parameter: parameter 't' seems to be unused, consider removing or renaming it as _ (revive)
fmt.Println("OK")
}

// TODO
// func TestInvokes(t *testing.T) {
// // Set working directory
// rootPath, err := rootPath()
// require.NoError(t, err)
// if *workingDir == "" {
// *workingDir = rootPath
// }
// if !filepath.IsAbs(*workingDir) {
// *workingDir = filepath.Join(rootPath, *workingDir)
// }
// t.Logf("Running tests in %s", *workingDir)

// // Arrange
// t.Log("Creating temporary configuration file")
// tmpConfigFile, err := createTemporaryConfigurationFile()
// require.NoError(t, err, "Error writing temporary configuration")
// t.Cleanup(func() {
// t.Log("Cleaning up temporary configuration file")
// os.Remove(tmpConfigFile)
// })

// t.Log("setup test infra")
// err = setupTestInfra(tmpConfigFile)
// require.NoError(t, err, "Error setting up test infra")

// tmpConfig, err := LoadConfig(tmpConfigFile)
// require.NoError(t, err)

// require.NotEmpty(t, tmpConfig.ConfigParams.AWS.TeamTag)

// // Subtests

// t.Run("az.create-vm", func(t *testing.T) {
// t.Parallel()
// testAzureInvokeVM(t, tmpConfigFile, *workingDir)
// })

// t.Run("aws.create-vm", func(t *testing.T) {
// t.Parallel()
// testAwsInvokeVM(t, tmpConfigFile, *workingDir)
// })

// t.Run("gcp.create-vm", func(t *testing.T) {
// t.Parallel()
// testGcpInvokeVM(t, tmpConfigFile, *workingDir)
// })

// t.Run("aws.invoke-docker-vm", func(t *testing.T) {
// t.Parallel()
// testInvokeDockerVM(t, tmpConfigFile, *workingDir)
// })

// t.Run("aws.invoke-kind", func(t *testing.T) {
// t.Parallel()
// testInvokeKind(t, tmpConfigFile, *workingDir)
// })

// t.Run("invoke-kind-operator", func(t *testing.T) {
// t.Parallel()
// testInvokeKindOperator(t, tmpConfigFile, *workingDir)
// })
// }

func testAzureInvokeVM(t *testing.T, tmpConfigFile string, workingDirectory string) {
t.Helper()

Expand Down
Loading