Skip to content

Commit d1e2a22

Browse files
committed
fix(S3): Keys in s3store tests
1 parent e19416f commit d1e2a22

File tree

4 files changed

+26
-15
lines changed

4 files changed

+26
-15
lines changed

src/fdb5/database/Key.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ Key::Key(const TypesRegistry* reg) :
3232

3333
Key::Key(const TypesRegistry& reg) : Key(&reg) {}
3434

35+
Key::Key(const std::string& s, const TypesRegistry& reg) : Key(parseString(s,reg)) {}
36+
3537
Key::Key(const std::string &s, const Rule *rule) :
3638
keys_(),
3739
registry_(rule ? &rule->registry() : nullptr) {

src/fdb5/database/Key.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ class Key {
4848
explicit Key(const TypesRegistry* reg=nullptr);
4949
explicit Key(const TypesRegistry& reg);
5050

51+
explicit Key(const std::string& s, const TypesRegistry& reg);
52+
5153
explicit Key(eckit::Stream &, const TypesRegistry* reg=nullptr);
5254
explicit Key(eckit::Stream &, const TypesRegistry& reg);
5355
/// @todo remove ?? explicit Key(const std::string &request, const TypesRegistry* reg=nullptr);

src/fdb5/s3/S3Common.cc

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@
1414
#include "eckit/io/s3/S3Credential.h"
1515
#include "eckit/io/s3/S3Session.h"
1616

17+
#include "metkit/mars/MarsRequest.h"
18+
19+
#include "fdb5/config/Config.h"
20+
#include "fdb5/rules/Schema.h"
1721
#include "fdb5/s3/S3Common.h"
1822

1923
// #include "eckit/exception/Exceptions.h"
@@ -30,8 +34,9 @@ S3Common::S3Common(const fdb5::Config& config, const std::string& component, con
3034

3135

3236
/// @note: code for bucket per DB
33-
34-
std::string keyStr = key.valuesToString();
37+
Key keyInternal(key);
38+
keyInternal.registry(config.schema().registry());
39+
std::string keyStr = keyInternal.valuesToString();
3540
std::replace(keyStr.begin(), keyStr.end(), ':', '-');
3641
db_bucket_ = prefix_ + keyStr;
3742

tests/fdb/s3/test_s3_store.cc

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -187,9 +187,9 @@ CASE("S3Store tests") {
187187

188188
fdb5::Schema schema{schema_file()};
189189

190-
fdb5::Key request_key{"a=1,b=2,c=3,d=4,e=5,f=6"};
191-
fdb5::Key db_key{"a=1,b=2"};
192-
fdb5::Key index_key{"c=3,d=4"};
190+
fdb5::Key request_key{"a=1,b=2,c=3,d=4,e=5,f=6",schema.registry()};
191+
fdb5::Key db_key{"a=1,b=2",schema.registry()};
192+
fdb5::Key index_key{"c=3,d=4",schema.registry()};
193193

194194
char data[] = "test";
195195

@@ -250,10 +250,10 @@ CASE("S3Store tests") {
250250

251251
// request
252252

253-
fdb5::Key request_key{"a=1,b=2,c=3,d=4,e=5,f=6"};
254-
fdb5::Key db_key{"a=1,b=2"};
255-
fdb5::Key index_key{"c=3,d=4"};
256-
fdb5::Key field_key{"e=5,f=6"};
253+
fdb5::Key request_key{"a=1,b=2,c=3,d=4,e=5,f=6",schema.registry()};
254+
fdb5::Key db_key{"a=1,b=2",schema.registry()};
255+
fdb5::Key index_key{"c=3,d=4",schema.registry()};
256+
fdb5::Key field_key{"e=5,f=6",schema.registry()};
257257

258258
// store data
259259

@@ -347,9 +347,9 @@ CASE("S3Store tests") {
347347

348348
// request
349349

350-
fdb5::Key request_key{"a=1,b=2,c=3,d=4,e=5,f=6"};
351-
fdb5::Key index_key{"a=1,b=2,c=3,d=4"};
352-
fdb5::Key db_key{"a=1,b=2"};
350+
fdb5::Key request_key{"a=1,b=2,c=3,d=4,e=5,f=6",config.schema().registry()};
351+
fdb5::Key index_key{"a=1,b=2,c=3,d=4",config.schema().registry()};
352+
fdb5::Key db_key{"a=1,b=2",config.schema().registry()};
353353

354354
fdb5::FDBToolRequest full_req{
355355
request_key.request("retrieve"),
@@ -467,6 +467,8 @@ CASE("S3Store tests") {
467467

468468
std::string prefix{"test4-"};
469469

470+
ensureClean(prefix);
471+
470472
// FDB configuration
471473

472474
std::string config_str{
@@ -484,9 +486,9 @@ CASE("S3Store tests") {
484486

485487
// request
486488

487-
fdb5::Key request_key{"a=1,b=2,c=3,d=4,e=5,f=6"};
488-
fdb5::Key index_key{"a=1,b=2,c=3,d=4"};
489-
fdb5::Key db_key{"a=1,b=2"};
489+
fdb5::Key request_key{"a=1,b=2,c=3,d=4,e=5,f=6",config.schema().registry()};
490+
fdb5::Key index_key{"a=1,b=2,c=3,d=4",config.schema().registry()};
491+
fdb5::Key db_key{"a=1,b=2",config.schema().registry()};
490492

491493
fdb5::FDBToolRequest full_req{
492494
request_key.request("retrieve"),

0 commit comments

Comments
 (0)