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
46 changes: 34 additions & 12 deletions acceptance/acceptance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated, but tailing the output can be the default behaviour for all tests.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it's needed, since we already record it and show a diff, it's only useful to monitor and review timestamps of long running tests.

}
}

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)
}
}

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions acceptance/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Loading