From 992425e8abf2b6d9638dce881788d1cb0e1a43b3 Mon Sep 17 00:00:00 2001 From: Denis Bilenko Date: Tue, 11 Mar 2025 16:48:08 +0100 Subject: [PATCH] acc: Add CloudSlow config setting (#2470) ## Changes New bool config setting CloudSlow in acceptance tests. If set, it enables this test on Cloud but skips it in -short setting there. It does not affect local runs, "Slow" is only applied to Cloud. The reason is that we won't need to wait for cluster with mocked testserver. Additionally, this setting enables -tail if -v is already enabled. ## Why Certain tests that use "bundle run" are too long due to starting a cluster. ## Tests Using this option in #2471 --- acceptance/acceptance_test.go | 46 ++++++++++++++++++++++++++--------- acceptance/config_test.go | 4 +++ 2 files changed, 38 insertions(+), 12 deletions(-) diff --git a/acceptance/acceptance_test.go b/acceptance/acceptance_test.go index f0feb7b39..6c97aca4c 100644 --- a/acceptance/acceptance_test.go +++ b/acceptance/acceptance_test.go @@ -220,17 +220,39 @@ func runTest(t *testing.T, dir, coverDir string, repls testdiff.ReplacementsCont } cloudEnv := os.Getenv("CLOUD_ENV") - if !isTruePtr(config.Local) && cloudEnv == "" { - t.Skipf("Disabled via Local setting in %s (CLOUD_ENV=%s)", configPath, cloudEnv) - } + isRunningOnCloud := cloudEnv != "" + tailOutput := Tail - if !isTruePtr(config.Cloud) && cloudEnv != "" { - t.Skipf("Disabled via Cloud setting in %s (CLOUD_ENV=%s)", configPath, cloudEnv) - } + if isRunningOnCloud { + if isTruePtr(config.CloudSlow) { + if testing.Short() { + t.Skipf("Disabled via CloudSlow setting in %s (CLOUD_ENV=%s, Short=%v)", configPath, cloudEnv, testing.Short()) + } + + if testing.Verbose() { + // Combination of CloudSlow and -v auto-enables -tail + tailOutput = true + } + } + + isCloudEnabled := isTruePtr(config.Cloud) || isTruePtr(config.CloudSlow) + if !isCloudEnabled { + t.Skipf("Disabled via Cloud/CloudSlow setting in %s (CLOUD_ENV=%s, Cloud=%v, CloudSlow=%v)", + configPath, + cloudEnv, + isTruePtr(config.Cloud), + isTruePtr(config.CloudSlow), + ) + } - if cloudEnv != "" { if isTruePtr(config.RequiresUnityCatalog) && os.Getenv("TEST_METASTORE_ID") == "" { - t.Skipf("Skipping on non-UC workspaces") + t.Skipf("Disabled via RequiresUnityCatalog setting in %s (TEST_METASTORE_ID=%s)", configPath, os.Getenv("TEST_METASTORE_ID")) + } + + } else { + // Local run + if !isTruePtr(config.Local) { + t.Skipf("Disabled via Local setting in %s (CLOUD_ENV=%s)", configPath, cloudEnv) } } @@ -267,7 +289,7 @@ func runTest(t *testing.T, dir, coverDir string, repls testdiff.ReplacementsCont // specifies a custom server stubs. var server *testserver.Server - if cloudEnv == "" { + if !isRunningOnCloud { // Start a new server for this test if either: // 1. A custom server spec is defined in the test configuration. // 2. The test is configured to record requests and assert on them. We need @@ -374,7 +396,7 @@ func runTest(t *testing.T, dir, coverDir string, repls testdiff.ReplacementsCont require.NoError(t, err) defer out.Close() - err = runWithLog(t, cmd, out) + err = runWithLog(t, cmd, out, tailOutput) // Include exit code in output (if non-zero) formatOutput(out, err) @@ -725,7 +747,7 @@ func isTruePtr(value *bool) bool { return value != nil && *value } -func runWithLog(t *testing.T, cmd *exec.Cmd, out *os.File) error { +func runWithLog(t *testing.T, cmd *exec.Cmd, out *os.File, tail bool) error { r, w := io.Pipe() cmd.Stdout = w cmd.Stderr = w @@ -743,7 +765,7 @@ func runWithLog(t *testing.T, cmd *exec.Cmd, out *os.File) error { reader := bufio.NewReader(r) for { line, err := reader.ReadString('\n') - if Tail { + if tail { msg := strings.TrimRight(line, "\n") if len(msg) > 0 { d := time.Since(start) diff --git a/acceptance/config_test.go b/acceptance/config_test.go index fa236275b..e61d91ad3 100644 --- a/acceptance/config_test.go +++ b/acceptance/config_test.go @@ -31,6 +31,10 @@ type TestConfig struct { // If true, run this test when running with cloud env configured Cloud *bool + // If true, run this test when running with cloud env configured and -short is not passed + // This also sets -tail when -v is passed. + CloudSlow *bool + // If true and Cloud=true, run this test only if unity catalog is available in the cloud environment RequiresUnityCatalog *bool