Skip to content

Commit 1fdf57e

Browse files
committed
3
1 parent 962c65b commit 1fdf57e

File tree

4 files changed

+23
-153
lines changed

4 files changed

+23
-153
lines changed

src/iceberg/test/resources/docker-compose.yml renamed to src/iceberg/test/resources/iceberg-rest-fixture/docker-compose.yml

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,12 @@
1515
# specific language governing permissions and limitations
1616
# under the License.
1717

18-
networks:
19-
rest_bridge:
20-
2118
services:
2219
rest:
23-
image: apache/iceberg-rest-fixture:1.10.0
20+
image: apache/iceberg-rest-fixture:latest
2421
environment:
25-
- AWS_ACCESS_KEY_ID=admin
26-
- AWS_SECRET_ACCESS_KEY=password
27-
- AWS_REGION=us-east-1
2822
- CATALOG_CATALOG__IMPL=org.apache.iceberg.jdbc.JdbcCatalog
2923
- CATALOG_URI=jdbc:sqlite:file:/tmp/iceberg_rest_mode=memory
3024
- CATALOG_WAREHOUSE=file:///tmp/iceberg_warehouse
31-
networks:
32-
rest_bridge:
3325
ports:
3426
- "8181:8181"

src/iceberg/test/rest_catalog_test.cc

Lines changed: 13 additions & 135 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
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

4344
namespace 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

134132
TEST_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

src/iceberg/test/util/cmd_util.cc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ namespace iceberg {
3434

3535
Command::Command(std::string program) : program_(std::move(program)) {}
3636

37-
Command& Command::Arg(std::string a) {
38-
args_.push_back(std::move(a));
37+
Command& Command::Arg(std::string arg) {
38+
args_.push_back(std::move(arg));
3939
return *this;
4040
}
4141

42-
Command& Command::Args(const std::vector<std::string>& as) {
43-
args_.insert(args_.end(), as.begin(), as.end());
42+
Command& Command::Args(const std::vector<std::string>& args) {
43+
args_.insert(args_.end(), args.begin(), args.end());
4444
return *this;
4545
}
4646

@@ -55,7 +55,7 @@ Command& Command::Env(const std::string& key, const std::string& val) {
5555
}
5656

5757
void Command::RunCommand(const std::string& desc) const {
58-
std::println("[INFO] Starting to {}, command: {} {}", desc, program_, fmt_args());
58+
std::println("[INFO] Starting to {}, command: {} {}", desc, program_, FormatArgs());
5959

6060
std::cout.flush();
6161
std::cerr.flush();
@@ -122,7 +122,7 @@ void Command::RunCommand(const std::string& desc) const {
122122
}
123123
}
124124

125-
std::string Command::fmt_args() const {
125+
std::string Command::FormatArgs() const {
126126
std::string s;
127127
for (const auto& a : args_) {
128128
s += a + " ";

src/iceberg/test/util/cmd_util.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ class Command {
3535
explicit Command(std::string program);
3636

3737
/// \brief Add a single argument
38-
Command& Arg(std::string a);
38+
Command& Arg(std::string arg);
3939

4040
/// \brief Add multiple arguments at once
41-
Command& Args(const std::vector<std::string>& as);
41+
Command& Args(const std::vector<std::string>& args);
4242

4343
/// \brief Set the current working directory for the command
4444
Command& CurrentDir(const std::filesystem::path& path);
@@ -57,7 +57,7 @@ class Command {
5757
std::map<std::string, std::string> env_vars_;
5858

5959
/// \brief Format arguments for logging
60-
std::string fmt_args() const;
60+
std::string FormatArgs() const;
6161
};
6262

6363
} // namespace iceberg

0 commit comments

Comments
 (0)