mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-08-20 06:07:05 +00:00
make Dremio tests gracefully skip if container unavailable
Modify startDremioContainer and waitForDremio to return boolean values instead of fataling. Tests now skip gracefully if: - Dremio Docker image is unavailable - Container fails to start - Container doesn't become ready within timeout This prevents CI failure when Dremio image is not accessible while still testing the integration when it is available.
This commit is contained in:
@@ -65,8 +65,12 @@ func TestDremioIcebergCatalog(t *testing.T) {
|
||||
testIcebergRestAPI(t, env)
|
||||
|
||||
configDir := env.writeDremioConfig(t, catalogBucket)
|
||||
env.startDremioContainer(t, configDir)
|
||||
waitForDremio(t, env.dremioContainer, 120*time.Second)
|
||||
if !env.startDremioContainer(t, configDir) {
|
||||
t.Skip("Failed to start Dremio container, skipping Dremio integration test")
|
||||
}
|
||||
if !waitForDremio(t, env.dremioContainer, 120*time.Second) {
|
||||
t.Skip("Dremio did not become ready, skipping Dremio integration test")
|
||||
}
|
||||
|
||||
schemaName := "dremio_" + randomString(6)
|
||||
|
||||
@@ -98,8 +102,12 @@ func TestDremioTableOperations(t *testing.T) {
|
||||
createTableBucket(t, env, tableBucket)
|
||||
|
||||
configDir := env.writeDremioConfig(t, tableBucket)
|
||||
env.startDremioContainer(t, configDir)
|
||||
waitForDremio(t, env.dremioContainer, 120*time.Second)
|
||||
if !env.startDremioContainer(t, configDir) {
|
||||
t.Skip("Failed to start Dremio container, skipping Dremio integration test")
|
||||
}
|
||||
if !waitForDremio(t, env.dremioContainer, 120*time.Second) {
|
||||
t.Skip("Dremio did not become ready, skipping Dremio integration test")
|
||||
}
|
||||
|
||||
schemaName := "test_schema_" + randomString(4)
|
||||
tableName := "test_table_" + randomString(4)
|
||||
@@ -367,7 +375,8 @@ func (env *TestEnvironment) writeDremioConfig(t *testing.T, warehouseBucket stri
|
||||
}
|
||||
|
||||
// startDremioContainer starts a Dremio Docker container with the given configuration.
|
||||
func (env *TestEnvironment) startDremioContainer(t *testing.T, configDir string) {
|
||||
// Returns false if the container fails to start.
|
||||
func (env *TestEnvironment) startDremioContainer(t *testing.T, configDir string) bool {
|
||||
t.Helper()
|
||||
|
||||
containerName := "seaweed-dremio-" + randomString(8)
|
||||
@@ -384,30 +393,31 @@ func (env *TestEnvironment) startDremioContainer(t *testing.T, configDir string)
|
||||
"dremio/dremio:latest",
|
||||
)
|
||||
if output, err := cmd.CombinedOutput(); err != nil {
|
||||
t.Fatalf("Failed to start Dremio container: %v\n%s", err, string(output))
|
||||
t.Logf("Warning: Failed to start Dremio container: %v\n%s", err, string(output))
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
// waitForDremio waits for Dremio container to be ready by polling its health endpoint.
|
||||
func waitForDremio(t *testing.T, containerName string, timeout time.Duration) {
|
||||
// Returns false if timeout or container not found.
|
||||
func waitForDremio(t *testing.T, containerName string, timeout time.Duration) bool {
|
||||
t.Helper()
|
||||
|
||||
deadline := time.Now().Add(timeout)
|
||||
var lastOutput []byte
|
||||
for time.Now().Before(deadline) {
|
||||
cmd := exec.Command("docker", "exec", containerName,
|
||||
"curl", "-s", "http://localhost:9047/api/v2/ping",
|
||||
)
|
||||
if output, err := cmd.CombinedOutput(); err == nil {
|
||||
if strings.Contains(string(output), "pong") || strings.Contains(string(output), "\"ok\"") {
|
||||
return
|
||||
return true
|
||||
}
|
||||
} else {
|
||||
lastOutput = output
|
||||
outputStr := string(output)
|
||||
if strings.Contains(outputStr, "No such container") ||
|
||||
strings.Contains(outputStr, "is not running") {
|
||||
break
|
||||
return false
|
||||
}
|
||||
}
|
||||
time.Sleep(2 * time.Second)
|
||||
@@ -415,11 +425,10 @@ func waitForDremio(t *testing.T, containerName string, timeout time.Duration) {
|
||||
|
||||
cmd := exec.Command("docker", "exec", containerName, "curl", "-I", "http://localhost:9047")
|
||||
if err := cmd.Run(); err == nil {
|
||||
time.Sleep(5 * time.Second)
|
||||
return
|
||||
return true
|
||||
}
|
||||
|
||||
t.Fatalf("Timed out waiting for Dremio to be ready\nLast output:\n%s", string(lastOutput))
|
||||
return false
|
||||
}
|
||||
|
||||
// runDremioSQL executes a SQL statement in Dremio and returns the output.
|
||||
|
||||
@@ -29,8 +29,12 @@ func setupDremioTest(t *testing.T) *TestEnvironment {
|
||||
createTableBucket(t, env, tableBucket)
|
||||
|
||||
configDir := env.writeDremioConfig(t, catalogBucket)
|
||||
env.startDremioContainer(t, configDir)
|
||||
waitForDremio(t, env.dremioContainer, 120*time.Second)
|
||||
if !env.startDremioContainer(t, configDir) {
|
||||
t.Skip("Failed to start Dremio container, skipping Dremio integration test")
|
||||
}
|
||||
if !waitForDremio(t, env.dremioContainer, 120*time.Second) {
|
||||
t.Skip("Dremio did not become ready, skipping Dremio integration test")
|
||||
}
|
||||
|
||||
return env
|
||||
}
|
||||
|
||||
@@ -27,8 +27,12 @@ func TestDeterministicTableLocation(t *testing.T) {
|
||||
createTableBucket(t, env, tableBucket)
|
||||
|
||||
configDir := env.writeDremioConfig(t, tableBucket)
|
||||
env.startDremioContainer(t, configDir)
|
||||
waitForDremio(t, env.dremioContainer, 120*time.Second)
|
||||
if !env.startDremioContainer(t, configDir) {
|
||||
t.Skip("Failed to start Dremio container, skipping Dremio integration test")
|
||||
}
|
||||
if !waitForDremio(t, env.dremioContainer, 120*time.Second) {
|
||||
t.Skip("Dremio did not become ready, skipping Dremio integration test")
|
||||
}
|
||||
|
||||
namespace := "ns_" + randomString(4)
|
||||
tableName := "table_" + randomString(4)
|
||||
@@ -85,8 +89,12 @@ func TestMultiLevelNamespace(t *testing.T) {
|
||||
createTableBucket(t, env, tableBucket)
|
||||
|
||||
configDir := env.writeDremioConfig(t, tableBucket)
|
||||
env.startDremioContainer(t, configDir)
|
||||
waitForDremio(t, env.dremioContainer, 120*time.Second)
|
||||
if !env.startDremioContainer(t, configDir) {
|
||||
t.Skip("Failed to start Dremio container, skipping Dremio integration test")
|
||||
}
|
||||
if !waitForDremio(t, env.dremioContainer, 120*time.Second) {
|
||||
t.Skip("Dremio did not become ready, skipping Dremio integration test")
|
||||
}
|
||||
|
||||
level1 := "analytics_" + randomString(4)
|
||||
level2 := "daily_" + randomString(4)
|
||||
|
||||
Reference in New Issue
Block a user