Skip to content

Commit f613d86

Browse files
committed
Next pass at fixing tests on Windows
- Fix the ObjectPath to always be set to unix-style directory - Use RocksDB DestroyDir rather than custom implementation - Change the CopyToFromS3 test to append smaller blocks. Windows barfs when appending large blocks to files (RocksDB, not Cloud issue?)
1 parent 2e3b2da commit f613d86

File tree

2 files changed

+24
-26
lines changed

2 files changed

+24
-26
lines changed

cloud/cloud_env.cc

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,13 @@ void BucketOptions::TEST_Initialize(const std::string& bucket,
106106
prefix_ = prefix;
107107
}
108108
name_ = prefix_ + bucket_;
109-
if (!CloudEnvOptions::GetNameFromEnvironment("ROCKSDB_CLOUD_TEST_OBECT_PATH",
110-
"ROCKSDB_CLOUD_OBJECT_PATH",
111-
&object_)) {
112-
object_ = object;
109+
std::string value;
110+
if (CloudEnvOptions::GetNameFromEnvironment("ROCKSDB_CLOUD_TEST_OBECT_PATH",
111+
"ROCKSDB_CLOUD_OBJECT_PATH",
112+
&value)) {
113+
SetObjectPath(value);
114+
} else {
115+
SetObjectPath(object);
113116
}
114117
if (!CloudEnvOptions::GetNameFromEnvironment(
115118
"ROCKSDB_CLOUD_TEST_REGION", "ROCKSDB_CLOUD_REGION", &region_)) {

cloud/db_cloud_test.cc

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "cloud/db_cloud_impl.h"
1616
#include "cloud/filename.h"
1717
#include "cloud/manifest_reader.h"
18+
#include "file/file_util.h"
1819
#include "file/filename.h"
1920
#include "logging/logging.h"
2021
#include "rocksdb/cloud/cloud_storage_provider.h"
@@ -47,7 +48,7 @@ class CloudTest : public testing::Test {
4748
persistent_cache_size_gb_ = 0;
4849
db_ = nullptr;
4950

50-
DestroyDir(dbname_);
51+
DestroyDir(base_env_, dbname_);
5152
base_env_->CreateDirIfMissing(dbname_);
5253
base_env_->NewLogger(test::TmpDir(base_env_) + "/rocksdb-cloud.log",
5354
&options_.info_log);
@@ -75,7 +76,7 @@ class CloudTest : public testing::Test {
7576
ASSERT_TRUE(st.ok() || st.IsNotFound());
7677
aenv_.reset();
7778

78-
DestroyDir(clone_dir_);
79+
DestroyDir(base_env_, clone_dir_);
7980
ASSERT_OK(base_env_->CreateDir(clone_dir_));
8081
}
8182

@@ -96,12 +97,6 @@ class CloudTest : public testing::Test {
9697
return GetSSTFiles(cname);
9798
}
9899

99-
void DestroyDir(const std::string& dir) {
100-
std::string cmd = "rm -rf " + dir;
101-
int rc = system(cmd.c_str());
102-
ASSERT_EQ(rc, 0);
103-
}
104-
105100
virtual ~CloudTest() {
106101
// Cleanup the cloud bucket
107102
if (!cloud_env_options_.src_bucket.GetBucketName().empty()) {
@@ -323,7 +318,7 @@ TEST_F(CloudTest, GetChildrenTest) {
323318
ASSERT_OK(db_->Flush(FlushOptions()));
324319

325320
CloseDB();
326-
DestroyDir(dbname_);
321+
DestroyDir(base_env_, dbname_);
327322
OpenDB();
328323

329324
std::vector<std::string> children;
@@ -567,7 +562,7 @@ TEST_F(CloudTest, KeepLocalFiles) {
567562
ASSERT_OK(db_->Flush(FlushOptions()));
568563

569564
CloseDB();
570-
DestroyDir(dbname_);
565+
DestroyDir(base_env_, dbname_);
571566
OpenDB();
572567

573568
std::vector<std::string> files;
@@ -598,14 +593,14 @@ TEST_F(CloudTest, CopyToFromS3) {
598593
cloud_env_options_.use_aws_transfer_manager = iter == 1;
599594
CreateAwsEnv();
600595
((CloudEnvImpl*)aenv_.get())->TEST_InitEmptyCloudManifest();
601-
char buffer[1 * 1024 * 1024];
596+
char buffer[10 * 1024];
602597

603598
// create a 10 MB file and upload it to cloud
604599
{
605600
std::unique_ptr<WritableFile> writer;
606601
ASSERT_OK(aenv_->NewWritableFile(fname, &writer, EnvOptions()));
607602

608-
for (int i = 0; i < 10; i++) {
603+
for (int i = 0; i < 1024; i++) {
609604
ASSERT_OK(writer->Append(Slice(buffer, sizeof(buffer))));
610605
}
611606
// sync and close file
@@ -620,7 +615,7 @@ TEST_F(CloudTest, CopyToFromS3) {
620615
ASSERT_OK(aenv_->NewRandomAccessFile(fname, &reader, EnvOptions()));
621616

622617
uint64_t offset = 0;
623-
for (int i = 0; i < 10; i++) {
618+
for (int i = 0; i < 1024; i++) {
624619
Slice result;
625620
char* scratch = &buffer[0];
626621
ASSERT_OK(reader->Read(offset, sizeof(buffer), &result, scratch));
@@ -815,8 +810,8 @@ TEST_F(CloudTest, KeepLocalLogKafka) {
815810
delete db_;
816811
db_ = nullptr;
817812
aenv_.reset();
818-
DestroyDir(dbname_);
819-
DestroyDir("/tmp/ROCKSET");
813+
DestroyDir(base_env_, dbname_);
814+
DestroyDir(base_env_, "/tmp/ROCKSET");
820815

821816
// Create new env.
822817
CreateAwsEnv();
@@ -853,8 +848,8 @@ TEST_F(CloudTest, DISABLED_KeepLocalLogKinesis) {
853848
delete db_;
854849
db_ = nullptr;
855850
aenv_.reset();
856-
DestroyDir(dbname_);
857-
DestroyDir("/tmp/ROCKSET");
851+
DestroyDir(base_env_, dbname_);
852+
DestroyDir(base_env_, "/tmp/ROCKSET");
858853

859854
// Create new env.
860855
CreateAwsEnv();
@@ -1000,7 +995,7 @@ TEST_F(CloudTest, TwoConcurrentWriters) {
1000995
for (int i = 0; i < 5; ++i) {
1001996
closeDB1();
1002997
if (i == 2) {
1003-
DestroyDir(firstDB);
998+
DestroyDir(base_env_, firstDB);
1004999
}
10051000
// opening the database makes me a master (i.e. CLOUDMANIFEST points to my
10061001
// manifest), my writes are applied to the shared space!
@@ -1012,7 +1007,7 @@ TEST_F(CloudTest, TwoConcurrentWriters) {
10121007
}
10131008
closeDB2();
10141009
if (i == 2) {
1015-
DestroyDir(secondDB);
1010+
DestroyDir(base_env_, secondDB);
10161011
}
10171012
// opening the database makes me a master (i.e. CLOUDMANIFEST points to my
10181013
// manifest), my writes are applied to the shared space!
@@ -1089,7 +1084,7 @@ TEST_F(CloudTest, MigrateFromPureRocksDB) {
10891084
// Tests that we can open cloud DB without destination and source bucket set.
10901085
// This is useful for tests.
10911086
TEST_F(CloudTest, NoDestOrSrc) {
1092-
DestroyDir(dbname_);
1087+
DestroyDir(base_env_, dbname_);
10931088
cloud_env_options_.keep_local_sst_files = true;
10941089
cloud_env_options_.src_bucket.SetBucketName("");
10951090
cloud_env_options_.src_bucket.SetObjectPath("");
@@ -1109,7 +1104,7 @@ TEST_F(CloudTest, NoDestOrSrc) {
11091104
}
11101105

11111106
TEST_F(CloudTest, PreloadCloudManifest) {
1112-
DestroyDir(dbname_);
1107+
DestroyDir(base_env_, dbname_);
11131108
// Put one key-value
11141109
OpenDB();
11151110
std::string value;
@@ -1408,7 +1403,7 @@ TEST_F(CloudTest, CheckpointToCloud) {
14081403
ASSERT_EQ(2, GetSSTFiles(dbname_).size());
14091404
CloseDB();
14101405

1411-
DestroyDir(dbname_);
1406+
DestroyDir(base_env_, dbname_);
14121407

14131408
cloud_env_options_.src_bucket = checkpoint_bucket;
14141409

0 commit comments

Comments
 (0)