Skip to content

Commit 82845cd

Browse files
jackye1995claude
andcommitted
fix: fix failing tests
- Fix Glue integration test tearDown NPE when credentials unavailable - Fix Makefile test patterns (!*IntegrationTest -> !*Integration) - Add Iceberg config unit tests - Remove warehouse from Python Iceberg test config 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent b140235 commit 82845cd

5 files changed

Lines changed: 112 additions & 14 deletions

File tree

java/Makefile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ build-hive2:
4242

4343
.PHONY: test-hive2
4444
test-hive2:
45-
./mvnw test -pl lance-namespace-hive2 -Dtest="!*IntegrationTest"
45+
./mvnw test -pl lance-namespace-hive2 -Dtest="!*Integration"
4646

4747
# ============================================================================
4848
# Hive3
@@ -59,7 +59,7 @@ build-hive3:
5959

6060
.PHONY: test-hive3
6161
test-hive3:
62-
./mvnw test -pl lance-namespace-hive3 -Dtest="!*IntegrationTest"
62+
./mvnw test -pl lance-namespace-hive3 -Dtest="!*Integration"
6363

6464
# ============================================================================
6565
# Iceberg
@@ -76,7 +76,7 @@ build-iceberg:
7676

7777
.PHONY: test-iceberg
7878
test-iceberg:
79-
./mvnw test -pl lance-namespace-iceberg -Dtest="!*IntegrationTest"
79+
./mvnw test -pl lance-namespace-iceberg -Dtest="!*Integration"
8080

8181
# ============================================================================
8282
# Polaris
@@ -93,7 +93,7 @@ build-polaris:
9393

9494
.PHONY: test-polaris
9595
test-polaris:
96-
./mvnw test -pl lance-namespace-polaris -Dtest="!*IntegrationTest"
96+
./mvnw test -pl lance-namespace-polaris -Dtest="!*Integration"
9797

9898
# ============================================================================
9999
# Unity
@@ -110,7 +110,7 @@ build-unity:
110110

111111
.PHONY: test-unity
112112
test-unity:
113-
./mvnw test -pl lance-namespace-unity -Dtest="!*IntegrationTest"
113+
./mvnw test -pl lance-namespace-unity -Dtest="!*Integration"
114114

115115
# ============================================================================
116116
# All

java/lance-namespace-glue/src/test/java/org/lance/namespace/glue/TestGlueNamespaceIntegration.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,11 +137,13 @@ public void setUp() {
137137
@AfterEach
138138
public void tearDown() {
139139
// Clean up test resources
140-
for (String dbName : createdDatabases) {
141-
try {
142-
cleanupDatabase(dbName);
143-
} catch (Exception e) {
144-
// Ignore cleanup errors
140+
if (createdDatabases != null) {
141+
for (String dbName : createdDatabases) {
142+
try {
143+
cleanupDatabase(dbName);
144+
} catch (Exception e) {
145+
// Ignore cleanup errors
146+
}
145147
}
146148
}
147149

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
/*
2+
* Licensed under the Apache License, Version 2.0 (the "License");
3+
* you may not use this file except in compliance with the License.
4+
* You may obtain a copy of the License at
5+
*
6+
* http://www.apache.org/licenses/LICENSE-2.0
7+
*
8+
* Unless required by applicable law or agreed to in writing, software
9+
* distributed under the License is distributed on an "AS IS" BASIS,
10+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
* See the License for the specific language governing permissions and
12+
* limitations under the License.
13+
*/
14+
package org.lance.namespace.iceberg;
15+
16+
import org.junit.jupiter.api.Test;
17+
18+
import java.util.HashMap;
19+
import java.util.Map;
20+
21+
import static org.junit.jupiter.api.Assertions.assertEquals;
22+
import static org.junit.jupiter.api.Assertions.assertNull;
23+
import static org.junit.jupiter.api.Assertions.assertThrows;
24+
25+
public class TestIcebergNamespaceConfig {
26+
27+
@Test
28+
public void testConfigWithEndpoint() {
29+
Map<String, String> properties = new HashMap<>();
30+
properties.put("endpoint", "http://localhost:8181");
31+
32+
IcebergNamespaceConfig config = new IcebergNamespaceConfig(properties);
33+
34+
assertEquals("http://localhost:8181", config.getEndpoint());
35+
assertEquals(System.getProperty("user.dir"), config.getRoot());
36+
assertNull(config.getAuthToken());
37+
assertNull(config.getCredential());
38+
assertEquals(10000, config.getConnectTimeout());
39+
assertEquals(30000, config.getReadTimeout());
40+
assertEquals(3, config.getMaxRetries());
41+
}
42+
43+
@Test
44+
public void testConfigWithAllProperties() {
45+
Map<String, String> properties = new HashMap<>();
46+
properties.put("endpoint", "https://iceberg.example.com");
47+
properties.put("auth_token", "test_token");
48+
properties.put("credential", "client_id:client_secret");
49+
properties.put("connect_timeout", "5000");
50+
properties.put("read_timeout", "60000");
51+
properties.put("max_retries", "5");
52+
properties.put("root", "/data/lance");
53+
54+
IcebergNamespaceConfig config = new IcebergNamespaceConfig(properties);
55+
56+
assertEquals("https://iceberg.example.com", config.getEndpoint());
57+
assertEquals("test_token", config.getAuthToken());
58+
assertEquals("client_id:client_secret", config.getCredential());
59+
assertEquals(5000, config.getConnectTimeout());
60+
assertEquals(60000, config.getReadTimeout());
61+
assertEquals(5, config.getMaxRetries());
62+
assertEquals("/data/lance", config.getRoot());
63+
}
64+
65+
@Test
66+
public void testMissingEndpointThrowsException() {
67+
Map<String, String> properties = new HashMap<>();
68+
69+
assertThrows(IllegalArgumentException.class, () -> new IcebergNamespaceConfig(properties));
70+
}
71+
72+
@Test
73+
public void testEmptyEndpointThrowsException() {
74+
Map<String, String> properties = new HashMap<>();
75+
properties.put("endpoint", "");
76+
77+
assertThrows(IllegalArgumentException.class, () -> new IcebergNamespaceConfig(properties));
78+
}
79+
80+
@Test
81+
public void testGetBaseApiUrlStripsTrailingSlash() {
82+
Map<String, String> properties = new HashMap<>();
83+
properties.put("endpoint", "http://localhost:8181/");
84+
85+
IcebergNamespaceConfig config = new IcebergNamespaceConfig(properties);
86+
87+
assertEquals("http://localhost:8181", config.getBaseApiUrl());
88+
}
89+
90+
@Test
91+
public void testGetBaseApiUrlWithoutTrailingSlash() {
92+
Map<String, String> properties = new HashMap<>();
93+
properties.put("endpoint", "http://localhost:8181");
94+
95+
IcebergNamespaceConfig config = new IcebergNamespaceConfig(properties);
96+
97+
assertEquals("http://localhost:8181", config.getBaseApiUrl());
98+
}
99+
}

python/tests/test_iceberg.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,13 @@ def test_config_initialization(self):
3939
"endpoint": "https://iceberg.example.com",
4040
"root": "/data/lance",
4141
"auth_token": "test_token",
42-
"warehouse": "test_warehouse",
4342
}
4443

4544
config = IcebergNamespaceConfig(properties)
4645

4746
self.assertEqual(config.endpoint, "https://iceberg.example.com")
4847
self.assertEqual(config.root, "/data/lance")
4948
self.assertEqual(config.auth_token, "test_token")
50-
self.assertEqual(config.warehouse, "test_warehouse")
5149

5250
def test_config_defaults(self):
5351
"""Test configuration with default values."""
@@ -59,7 +57,6 @@ def test_config_defaults(self):
5957

6058
self.assertEqual(config.root, os.getcwd())
6159
self.assertIsNone(config.auth_token)
62-
self.assertIsNone(config.warehouse)
6360
self.assertEqual(config.connect_timeout, 10000)
6461
self.assertEqual(config.read_timeout, 30000)
6562
self.assertEqual(config.max_retries, 3)

python/uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)