Skip to content

Commit

Permalink
add maxConnections config & use fakes3
Browse files Browse the repository at this point in the history
Change-Id: I9b564b9449c6a5d6394d86212f5b324b0d811100
  • Loading branch information
xu-chaojie committed Feb 13, 2020
1 parent f884a2f commit b97d16a
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 29 deletions.
15 changes: 0 additions & 15 deletions conf/s3_test.conf

This file was deleted.

19 changes: 12 additions & 7 deletions src/common/s3_adapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,33 +18,38 @@ void S3Adapter::Init(const std::string &path) {
conf_.SetConfigPath(path);
LOG_IF(FATAL, !conf_.LoadConfig())
<< "Failed to open s3 config file: " << conf_.GetConfigPath();
options_ = new Aws::SDKOptions();
options_ = Aws::New<Aws::SDKOptions>("S3Adapter.SDKOptions");
options_->loggingOptions.logLevel =
Aws::Utils::Logging::LogLevel(conf_.GetIntValue("s3.loglevel"));
Aws::InitAPI(*options_);
s3Address_ = conf_.GetStringValue("s3.nos_address").c_str();
s3Ak_ = conf_.GetStringValue("s3.ak").c_str();
s3Sk_ = conf_.GetStringValue("s3.sk").c_str();
bucketName_ = conf_.GetStringValue("s3.snapshot_bucket_name").c_str();
clientCfg_ = new Aws::Client::ClientConfiguration();
clientCfg_ = Aws::New<Aws::Client::ClientConfiguration>(
"S3Adapter.ClientConfiguration");
clientCfg_->scheme = Aws::Http::Scheme(conf_.GetIntValue("s3.http_scheme"));
clientCfg_->verifySSL = conf_.GetBoolValue("s3.verify_SSL");
//clientCfg_->userAgent = conf_.GetStringValue("s3.user_agent_conf").c_str(); //NOLINT
clientCfg_->userAgent = "S3 Browser";
clientCfg_->maxConnections = conf_.GetIntValue("s3.max_connections");
clientCfg_->connectTimeoutMs = conf_.GetIntValue("s3.connect_timeout");
clientCfg_->requestTimeoutMs = conf_.GetIntValue("s3.request_timeout");
clientCfg_->endpointOverride = s3Address_;
s3Client_ = new Aws::S3::S3Client(
s3Client_ = Aws::New<Aws::S3::S3Client>("S3Adapter.S3Client",
Aws::Auth::AWSCredentials(s3Ak_, s3Sk_),
*clientCfg_);
*clientCfg_,
Aws::Client::AWSAuthV4Signer::PayloadSigningPolicy::Never,
false);
}

void S3Adapter::Deinit() {
Aws::ShutdownAPI(*options_);
delete options_;
delete clientCfg_;
delete s3Client_;
Aws::Delete<Aws::SDKOptions>(options_);
Aws::Delete<Aws::Client::ClientConfiguration>(clientCfg_);
Aws::Delete<Aws::S3::S3Client>(s3Client_);
}

int S3Adapter::CreateBucket() {
Aws::S3::Model::CreateBucketRequest request;
request.SetBucket(bucketName_);
Expand Down
1 change: 1 addition & 0 deletions src/common/s3_adapter.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#define SRC_COMMON_S3_ADAPTER_H_
#include <map>
#include <string>
#include <aws/core/utils/memory/AWSMemory.h> //NOLINT
#include <aws/core/Aws.h> //NOLINT
#include <aws/s3/S3Client.h> //NOLINT
#include <aws/core/client/ClientConfiguration.h> //NOLINT
Expand Down
2 changes: 1 addition & 1 deletion test/common/test_s3_adapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class TestS3Adapter : public ::testing::Test {

void SetUp() {
adapter_ = new S3Adapter();
adapter_->Init("./conf/s3_test.conf");
adapter_->Init("./conf/s3.conf");
adapter_->SetBucketName("curve-unit-test");
}
void TearDown() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,6 @@ namespace snapshotcloneserver {
class SnapshotCloneServerTest : public ::testing::Test {
public:
static void SetUpTestCase() {
// sleep 防止timewait造成端口失败
std::this_thread::sleep_for(std::chrono::seconds(60));

std::string mkLogDirCmd = std::string("mkdir -p ") + kLogPath;
system(mkLogDirCmd.c_str());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,6 @@ namespace snapshotcloneserver {
class SnapshotCloneServerTest : public ::testing::Test {
public:
static void SetUpTestCase() {
// sleep 防止timewait造成端口失败
std::this_thread::sleep_for(std::chrono::seconds(60));

std::string mkLogDirCmd = std::string("mkdir -p ") + kLogPath;
system(mkLogDirCmd.c_str());

Expand Down
1 change: 1 addition & 0 deletions test/resources.list
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ Used port list:
use port(lixiaocui) : 6879, 2221, 2222, 3333,2001~2004, 3333, 3500
2301~2312
snapshotcloneserver integration test: 10001~10030
fakes3 : 9999

# chunkserver

Expand Down
1 change: 1 addition & 0 deletions test/util/config_generator.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ struct S3ConfigGenerator : public ConfigGenerator {
explicit S3ConfigGenerator(const std::string &configPath) {
LoadTemplete(DEFAULT_S3_CONF);
SetConfigPath(configPath);
SetKV("s3.nos_address", "127.0.0.1:9999");
}
};

Expand Down

0 comments on commit b97d16a

Please sign in to comment.