Skip to content

Commit

Permalink
added check to test flush data.
Browse files Browse the repository at this point in the history
  • Loading branch information
hariharan-devarajan committed Jan 14, 2021
1 parent 8d7212b commit 0f4b97b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/api/vbucket.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class VBucket {
hermes_(h) {
LOG(INFO) << "Create VBucket " << initial_name << std::endl;
(void)ctx;
if (IsBucketNameTooLong(name_)) {
if (IsVBucketNameTooLong(name_)) {
id_.as_int = 0;
} else {
id_ = GetOrCreateVBucketId(&hermes_->context_, &hermes_->rpc_, name_);
Expand Down
4 changes: 2 additions & 2 deletions src/metadata_management.cc
Original file line number Diff line number Diff line change
Expand Up @@ -341,10 +341,10 @@ VBucketID GetOrCreateVBucketId(SharedMemoryContext *context, RpcContext *rpc,
VBucketID result = GetVBucketIdByName(context, rpc, name.c_str());

if (result.as_int != 0) {
LOG(INFO) << "Opening Bucket '" << name << "'" << std::endl;
LOG(INFO) << "Opening VBucket '" << name << "'" << std::endl;
IncrementRefcount(context, rpc, result);
} else {
LOG(INFO) << "Creating Bucket '" << name << "'" << std::endl;
LOG(INFO) << "Creating VBucket '" << name << "'" << std::endl;
result = GetNextFreeVBucketId(context, rpc, name);
}
EndTicketMutex(&mdm->vbucket_mutex);
Expand Down
16 changes: 15 additions & 1 deletion test/trait_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ TEST_CASE("CustomTrait",
file_bucket.Put(std::to_string(i), info.write_blob, ctx);
blob_names.insert(std::to_string(i));
}
for (const auto &blob_name : blob_names) {
for (const auto& blob_name : blob_names) {
file_vbucket.Link(blob_name, args.filename, ctx);
offset_map.emplace(blob_name, std::stol(blob_name) * info.FILE_PAGE);
}
Expand All @@ -86,6 +86,20 @@ TEST_CASE("CustomTrait",
file_vbucket.Attach(&trait, ctx);
file_vbucket.Delete(ctx);
file_bucket.Destroy(ctx);
REQUIRE(fs::exists(fullpath_str));
REQUIRE(fs::file_size(fullpath_str) == args.iterations * args.request_size);
info.write_blob =
hermes::api::Blob(args.iterations * args.request_size, '1');
auto read_blob =
hermes::api::Blob(args.iterations * args.request_size, '0');
FILE* fh = fopen(fullpath_str.c_str(), "r+");
REQUIRE(fh != nullptr);
auto read_size =
fread(read_blob.data(), args.iterations * args.request_size, 1, fh);
REQUIRE(read_size == 1);
REQUIRE(read_blob == info.write_blob);
auto status = fclose(fh);
REQUIRE(status == 0);
}
hermes_app->Finalize(true);
posttest();
Expand Down

0 comments on commit 0f4b97b

Please sign in to comment.