3838#include " iceberg/result.h"
3939#include " iceberg/table_identifier.h"
4040#include " iceberg/test/matchers.h"
41+ #include " iceberg/test/test_resource.h"
4142#include " iceberg/test/util/docker_compose_util.h"
4243
4344namespace iceberg ::rest {
@@ -86,8 +87,7 @@ class RestCatalogIntegrationTest : public ::testing::Test {
8687 protected:
8788 static void SetUpTestSuite () {
8889 std::string project_name{kDockerProjectName };
89- std::filesystem::path resources_dir =
90- std::filesystem::path (__FILE__).parent_path () / " resources" ;
90+ std::filesystem::path resources_dir = GetResourcePath (" iceberg-rest-fixture" );
9191
9292 // Create and start DockerCompose
9393 docker_compose_ = std::make_unique<DockerCompose>(project_name, resources_dir);
@@ -106,29 +106,27 @@ class RestCatalogIntegrationTest : public ::testing::Test {
106106 kMaxRetries );
107107 std::this_thread::sleep_for (std::chrono::milliseconds (kRetryDelayMs ));
108108 }
109- throw RestError (" REST catalog failed to start within {} seconds" , kMaxRetries );
109+ throw std::runtime_error (" REST catalog failed to start within {} seconds" );
110110 }
111111
112112 static void TearDownTestSuite () { docker_compose_.reset (); }
113113
114- void SetUp () override {
115- config_ = RestCatalogProperties::default_properties ();
116- config_
117- ->Set (RestCatalogProperties::kUri ,
118- std::format (" {}:{}" , kLocalhostUri , kRestCatalogPort ))
119- .Set (RestCatalogProperties::kName , std::string (kCatalogName ))
120- .Set (RestCatalogProperties::kWarehouse , std::string (kWarehouseName ));
121- }
114+ void SetUp () override {}
122115
123116 void TearDown () override {}
124117
125- // / \brief Helper function to create a REST catalog instance
118+ // Helper function to create a REST catalog instance
126119 Result<std::unique_ptr<RestCatalog>> CreateCatalog () {
127- return RestCatalog::Make (*config_);
120+ auto config = RestCatalogProperties::default_properties ();
121+ config
122+ ->Set (RestCatalogProperties::kUri ,
123+ std::format (" {}:{}" , kLocalhostUri , kRestCatalogPort ))
124+ .Set (RestCatalogProperties::kName , std::string (kCatalogName ))
125+ .Set (RestCatalogProperties::kWarehouse , std::string (kWarehouseName ));
126+ return RestCatalog::Make (*config);
128127 }
129128
130129 static inline std::unique_ptr<DockerCompose> docker_compose_;
131- std::unique_ptr<RestCatalogProperties> config_;
132130};
133131
134132TEST_F (RestCatalogIntegrationTest, MakeCatalogSuccess) {
@@ -147,127 +145,7 @@ TEST_F(RestCatalogIntegrationTest, ListNamespaces) {
147145 Namespace root{.levels = {}};
148146 auto result = catalog->ListNamespaces (root);
149147 EXPECT_THAT (result, IsOk ());
150- }
151-
152- TEST_F (RestCatalogIntegrationTest, DISABLED_GetNonExistentNamespace) {
153- auto catalog_result = CreateCatalog ();
154- ASSERT_THAT (catalog_result, IsOk ());
155- auto & catalog = catalog_result.value ();
156-
157- Namespace ns{.levels = {" test_get_non_existent_namespace" }};
158- auto result = catalog->GetNamespaceProperties (ns);
159-
160- EXPECT_THAT (result, HasErrorMessage (" does not exist" ));
161- }
162-
163- TEST_F (RestCatalogIntegrationTest, DISABLED_CreateAndDropNamespace) {
164- auto catalog_result = CreateCatalog ();
165- ASSERT_THAT (catalog_result, IsOk ());
166- auto catalog = std::move (catalog_result.value ());
167-
168- // Create a namespace
169- Namespace test_ns{.levels = {" test_create_drop_ns" }};
170- std::unordered_map<std::string, std::string> props = {{" owner" , " test_user" }};
171-
172- auto create_result = catalog->CreateNamespace (test_ns, props);
173- ASSERT_THAT (create_result, IsOk ());
174-
175- // Verify it exists
176- auto exists_result = catalog->NamespaceExists (test_ns);
177- EXPECT_THAT (exists_result, HasValue (::testing::Eq (true )));
178-
179- // Drop it
180- auto drop_result = catalog->DropNamespace (test_ns);
181- EXPECT_THAT (drop_result, IsOk ());
182-
183- // Verify it no longer exists
184- auto exists_result2 = catalog->NamespaceExists (test_ns);
185- EXPECT_THAT (exists_result2, HasValue (::testing::Eq (false )));
186- }
187-
188- TEST_F (RestCatalogIntegrationTest, DISABLED_UpdateNamespaceProperties) {
189- auto catalog_result = CreateCatalog ();
190- ASSERT_THAT (catalog_result, IsOk ());
191- auto catalog = std::move (catalog_result.value ());
192-
193- // Create a namespace
194- Namespace test_ns{.levels = {" test_update_props_ns" }};
195- std::unordered_map<std::string, std::string> initial_props = {{" owner" , " alice" },
196- {" team" , " data_eng" }};
197-
198- auto create_result = catalog->CreateNamespace (test_ns, initial_props);
199- ASSERT_THAT (create_result, IsOk ());
200-
201- // Update properties
202- std::unordered_map<std::string, std::string> updates = {
203- {" owner" , " bob" }, {" description" , " test namespace" }};
204- std::unordered_set<std::string> removals = {" team" };
205-
206- auto update_result = catalog->UpdateNamespaceProperties (test_ns, updates, removals);
207- EXPECT_THAT (update_result, IsOk ());
208-
209- // Verify updated properties
210- auto props_result = catalog->GetNamespaceProperties (test_ns);
211- ASSERT_THAT (props_result, IsOk ());
212- EXPECT_EQ ((*props_result)[" owner" ], " bob" );
213- EXPECT_EQ ((*props_result)[" description" ], " test namespace" );
214- EXPECT_EQ (props_result->count (" team" ), 0 ); // Should be removed
215-
216- // Cleanup
217- catalog->DropNamespace (test_ns);
218- }
219-
220- TEST_F (RestCatalogIntegrationTest, DISABLED_FullNamespaceWorkflow) {
221- auto catalog_result = CreateCatalog ();
222- ASSERT_THAT (catalog_result, IsOk ());
223- auto catalog = std::move (catalog_result.value ());
224-
225- // 1. List initial namespaces
226- Namespace root{.levels = {}};
227- auto list_result1 = catalog->ListNamespaces (root);
228- ASSERT_THAT (list_result1, IsOk ());
229- size_t initial_count = list_result1->size ();
230-
231- // 2. Create a new namespace
232- Namespace test_ns{.levels = {" integration_test_workflow" }};
233- std::unordered_map<std::string, std::string> props = {
234- {" owner" , " test" }, {" created_by" , " rest_catalog_integration_test" }};
235- auto create_result = catalog->CreateNamespace (test_ns, props);
236- ASSERT_THAT (create_result, IsOk ());
237-
238- // 3. Verify namespace exists
239- auto exists_result = catalog->NamespaceExists (test_ns);
240- EXPECT_THAT (exists_result, HasValue (::testing::Eq (true )));
241-
242- // 4. List namespaces again (should have one more)
243- auto list_result2 = catalog->ListNamespaces (root);
244- ASSERT_THAT (list_result2, IsOk ());
245- EXPECT_EQ (list_result2->size (), initial_count + 1 );
246-
247- // 5. Get namespace properties
248- auto props_result = catalog->GetNamespaceProperties (test_ns);
249- ASSERT_THAT (props_result, IsOk ());
250- EXPECT_EQ ((*props_result)[" owner" ], " test" );
251-
252- // 6. Update properties
253- std::unordered_map<std::string, std::string> updates = {
254- {" description" , " integration test namespace" }};
255- std::unordered_set<std::string> removals = {};
256- auto update_result = catalog->UpdateNamespaceProperties (test_ns, updates, removals);
257- EXPECT_THAT (update_result, IsOk ());
258-
259- // 7. Verify updated properties
260- auto props_result2 = catalog->GetNamespaceProperties (test_ns);
261- ASSERT_THAT (props_result2, IsOk ());
262- EXPECT_EQ ((*props_result2)[" description" ], " integration test namespace" );
263-
264- // 8. Drop the namespace (cleanup)
265- auto drop_result = catalog->DropNamespace (test_ns);
266- EXPECT_THAT (drop_result, IsOk ());
267-
268- // 9. Verify namespace no longer exists
269- auto exists_result2 = catalog->NamespaceExists (test_ns);
270- EXPECT_THAT (exists_result2, HasValue (::testing::Eq (false )));
148+ EXPECT_TRUE (result->empty ());
271149}
272150
273151} // namespace iceberg::rest
0 commit comments