Skip to content

Commit ceb784a

Browse files
tanmayrauthclaude
andcommitted
fix(test): use unique namespace names per integration test
TearDownTest cannot remove root-owned Spark directories, so tests that share namespace names collide when a later test tries to create a namespace that already exists from a prior test. Give each test its own namespace to avoid ordering dependencies. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 21e4367 commit ceb784a

1 file changed

Lines changed: 13 additions & 13 deletions

File tree

catalog/hadoop/hadoop_integration_test.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -89,19 +89,19 @@ func (s *HadoopIntegrationSuite) sparkSQL(sql string) string {
8989
func (s *HadoopIntegrationSuite) TestGoCreateSparkDescribe() {
9090
// Create namespace from Go so the directory is owned by the runner
9191
// process and Go can create table subdirectories inside it.
92-
err := s.cat.CreateNamespace(s.ctx, []string{"integration_ns"}, nil)
92+
err := s.cat.CreateNamespace(s.ctx, []string{"describe_ns"}, nil)
9393
s.Require().NoError(err)
9494

9595
schema := iceberg.NewSchema(1,
9696
iceberg.NestedField{ID: 1, Name: "id", Type: iceberg.PrimitiveTypes.Int64, Required: true},
9797
iceberg.NestedField{ID: 2, Name: "name", Type: iceberg.PrimitiveTypes.String, Required: false},
9898
)
9999

100-
tbl, err := s.cat.CreateTable(s.ctx, []string{"integration_ns", "go_created_table"}, schema)
100+
tbl, err := s.cat.CreateTable(s.ctx, []string{"describe_ns", "go_created_table"}, schema)
101101
s.Require().NoError(err)
102102
s.NotNil(tbl)
103103

104-
output := s.sparkSQL("DESCRIBE TABLE hadoop_test.integration_ns.go_created_table")
104+
output := s.sparkSQL("DESCRIBE TABLE hadoop_test.describe_ns.go_created_table")
105105
s.Contains(output, "id")
106106
s.Contains(output, "name")
107107
}
@@ -110,10 +110,10 @@ func (s *HadoopIntegrationSuite) TestGoCreateSparkDescribe() {
110110
// Go and verifies schema and metadata are consistent.
111111
func (s *HadoopIntegrationSuite) TestSparkCreateGoLoad() {
112112
// Spark creates both namespace and table — Go only reads here.
113-
s.sparkSQL("CREATE NAMESPACE IF NOT EXISTS hadoop_test.integration_ns")
114-
s.sparkSQL("CREATE TABLE hadoop_test.integration_ns.spark_created_table (age INT, city STRING) USING iceberg")
113+
s.sparkSQL("CREATE NAMESPACE IF NOT EXISTS hadoop_test.load_ns")
114+
s.sparkSQL("CREATE TABLE hadoop_test.load_ns.spark_created_table (age INT, city STRING) USING iceberg")
115115

116-
tbl, err := s.cat.LoadTable(s.ctx, []string{"integration_ns", "spark_created_table"})
116+
tbl, err := s.cat.LoadTable(s.ctx, []string{"load_ns", "spark_created_table"})
117117
s.Require().NoError(err)
118118
s.NotNil(tbl)
119119

@@ -130,32 +130,32 @@ func (s *HadoopIntegrationSuite) TestSparkCreateGoLoad() {
130130
// TestGoCreateSparkSelect creates a table from Go, then runs a SELECT
131131
// from Spark to confirm the table is queryable (should return empty).
132132
func (s *HadoopIntegrationSuite) TestGoCreateSparkSelect() {
133-
err := s.cat.CreateNamespace(s.ctx, []string{"integration_ns"}, nil)
133+
err := s.cat.CreateNamespace(s.ctx, []string{"select_ns"}, nil)
134134
s.Require().NoError(err)
135135

136136
schema := iceberg.NewSchema(1,
137137
iceberg.NestedField{ID: 1, Name: "value", Type: iceberg.PrimitiveTypes.Int32, Required: true},
138138
)
139139

140-
_, err = s.cat.CreateTable(s.ctx, []string{"integration_ns", "go_select_table"}, schema)
140+
_, err = s.cat.CreateTable(s.ctx, []string{"select_ns", "go_select_table"}, schema)
141141
s.Require().NoError(err)
142142

143-
output := s.sparkSQL("SELECT * FROM hadoop_test.integration_ns.go_select_table")
143+
output := s.sparkSQL("SELECT * FROM hadoop_test.select_ns.go_select_table")
144144
s.Contains(output, "value")
145145
}
146146

147147
// TestGoCheckTableExistsForSparkTable verifies that CheckTableExists
148148
// returns true for a table created by Spark.
149149
func (s *HadoopIntegrationSuite) TestGoCheckTableExistsForSparkTable() {
150150
// Spark creates both namespace and table — Go only checks existence.
151-
s.sparkSQL("CREATE NAMESPACE IF NOT EXISTS hadoop_test.integration_ns")
152-
s.sparkSQL("CREATE TABLE hadoop_test.integration_ns.spark_exists_table (x INT) USING iceberg")
151+
s.sparkSQL("CREATE NAMESPACE IF NOT EXISTS hadoop_test.exists_ns")
152+
s.sparkSQL("CREATE TABLE hadoop_test.exists_ns.spark_exists_table (x INT) USING iceberg")
153153

154-
exists, err := s.cat.CheckTableExists(s.ctx, []string{"integration_ns", "spark_exists_table"})
154+
exists, err := s.cat.CheckTableExists(s.ctx, []string{"exists_ns", "spark_exists_table"})
155155
s.Require().NoError(err)
156156
s.True(exists)
157157

158-
exists, err = s.cat.CheckTableExists(s.ctx, []string{"integration_ns", "no_such_table"})
158+
exists, err = s.cat.CheckTableExists(s.ctx, []string{"exists_ns", "no_such_table"})
159159
s.Require().NoError(err)
160160
s.False(exists)
161161
}

0 commit comments

Comments
 (0)