Skip to content

Commit 8785ddc

Browse files
authored
Merge e8fd738 into 13c2d99
2 parents 13c2d99 + e8fd738 commit 8785ddc

26 files changed

+751
-373
lines changed

ydb/core/driver_lib/run/kikimr_services_initializers.cpp

+36
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,29 @@
243243

244244
#include <util/system/hostname.h>
245245

246+
#ifndef KIKIMR_DISABLE_S3_OPS
247+
#include <aws/core/Aws.h>
248+
#endif
249+
250+
namespace {
251+
252+
#ifndef KIKIMR_DISABLE_S3_OPS
253+
struct TAwsApiGuard {
254+
TAwsApiGuard() {
255+
Aws::InitAPI(Options);
256+
}
257+
258+
~TAwsApiGuard() {
259+
Aws::ShutdownAPI(Options);
260+
}
261+
262+
private:
263+
Aws::SDKOptions Options;
264+
};
265+
#endif
266+
267+
}
268+
246269
namespace NKikimr {
247270

248271
namespace NKikimrServicesInitializers {
@@ -2816,5 +2839,18 @@ void TGraphServiceInitializer::InitializeServices(NActors::TActorSystemSetup* se
28162839
TActorSetupCmd(NGraph::CreateGraphService(appData->TenantName), TMailboxType::HTSwap, appData->UserPoolId));
28172840
}
28182841

2842+
#ifndef KIKIMR_DISABLE_S3_OPS
2843+
TAwsApiInitializer::TAwsApiInitializer(IGlobalObjectStorage& globalObjects)
2844+
: GlobalObjects(globalObjects)
2845+
{
2846+
}
2847+
2848+
void TAwsApiInitializer::InitializeServices(NActors::TActorSystemSetup* setup, const NKikimr::TAppData* appData) {
2849+
Y_UNUSED(setup);
2850+
Y_UNUSED(appData);
2851+
GlobalObjects.AddGlobalObject(std::make_shared<TAwsApiGuard>());
2852+
}
2853+
#endif
2854+
28192855
} // namespace NKikimrServicesInitializers
28202856
} // namespace NKikimr

ydb/core/driver_lib/run/kikimr_services_initializers.h

+11
Original file line numberDiff line numberDiff line change
@@ -618,5 +618,16 @@ class TGraphServiceInitializer : public IKikimrServicesInitializer {
618618
void InitializeServices(NActors::TActorSystemSetup* setup, const NKikimr::TAppData* appData) override;
619619
};
620620

621+
#ifndef KIKIMR_DISABLE_S3_OPS
622+
class TAwsApiInitializer : public IServiceInitializer {
623+
IGlobalObjectStorage& GlobalObjects;
624+
625+
public:
626+
TAwsApiInitializer(IGlobalObjectStorage& globalObjects);
627+
628+
void InitializeServices(NActors::TActorSystemSetup* setup, const NKikimr::TAppData* appData) override;
629+
};
630+
#endif
631+
621632
} // namespace NKikimrServicesInitializers
622633
} // namespace NKikimr

ydb/core/driver_lib/run/run.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -1655,6 +1655,12 @@ TIntrusivePtr<TServiceInitializersList> TKikimrRunner::CreateServiceInitializers
16551655
sil->AddServiceInitializer(new TGraphServiceInitializer(runConfig));
16561656
}
16571657

1658+
#ifndef KIKIMR_DISABLE_S3_OPS
1659+
if (serviceMask.EnableAwsService) {
1660+
sil->AddServiceInitializer(new TAwsApiInitializer(*this));
1661+
}
1662+
#endif
1663+
16581664
return sil;
16591665
}
16601666

ydb/core/driver_lib/run/service_mask.h

+1
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ union TBasicKikimrServicesMask {
7979
bool EnableGraphService:1;
8080
bool EnableCompDiskLimiter:1;
8181
bool EnableGroupedMemoryLimiter:1;
82+
bool EnableAwsService:1;
8283
};
8384

8485
struct {

ydb/core/driver_lib/run/ya.make

+10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
LIBRARY(run)
22

3+
IF (OS_WINDOWS)
4+
CFLAGS(
5+
-DKIKIMR_DISABLE_S3_OPS
6+
)
7+
ELSE()
8+
PEERDIR(
9+
contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core
10+
)
11+
ENDIF()
12+
313
SRCS(
414
auto_config_initializer.cpp
515
config.cpp

ydb/core/tx/columnshard/ut_schema/ut_columnshard_schema.cpp

+13
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717

1818
#include <util/system/hostname.h>
1919
#include <library/cpp/deprecated/atomic/atomic.h>
20+
#include <library/cpp/testing/hook/hook.h>
21+
22+
#include <aws/core/Aws.h>
2023

2124
namespace NKikimr {
2225

@@ -32,6 +35,16 @@ enum class EInitialEviction {
3235

3336
namespace {
3437

38+
Aws::SDKOptions Options;
39+
40+
Y_TEST_HOOK_BEFORE_RUN(InitAwsAPI) {
41+
Aws::InitAPI(Options);
42+
}
43+
44+
Y_TEST_HOOK_AFTER_RUN(ShutdownAwsAPI) {
45+
Aws::ShutdownAPI(Options);
46+
}
47+
3548
static const std::vector<NArrow::NTest::TTestColumn> testYdbSchema = TTestSchema::YdbSchema();
3649
static const std::vector<NArrow::NTest::TTestColumn> testYdbPk = TTestSchema::YdbPkSchema();
3750

ydb/core/tx/columnshard/ut_schema/ya.make

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ PEERDIR(
1818
library/cpp/getopt
1919
library/cpp/regex/pcre
2020
library/cpp/svnversion
21+
contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core
2122
ydb/core/testlib/default
2223
ydb/core/tx/columnshard/hooks/abstract
2324
ydb/core/tx/columnshard/hooks/testing

ydb/core/tx/datashard/import_s3.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <ydb/core/tablet/resource_broker.h>
1515
#include <ydb/core/wrappers/s3_wrapper.h>
1616
#include <ydb/core/wrappers/s3_storage.h>
17+
#include <ydb/core/wrappers/s3_storage_config.h>
1718
#include <ydb/core/io_formats/ydb_dump/csv_ydb_dump.h>
1819
#include <ydb/public/lib/scheme_types/scheme_type_id.h>
1920

ydb/core/tx/schemeshard/ut_backup/ut_backup.cpp

+18
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,27 @@
77
#include <util/string/cast.h>
88
#include <util/string/printf.h>
99

10+
#include <library/cpp/testing/hook/hook.h>
11+
12+
#include <aws/core/Aws.h>
13+
1014
using namespace NSchemeShardUT_Private;
1115
using namespace NKikimr::NWrappers::NTestHelpers;
1216

17+
namespace {
18+
19+
Aws::SDKOptions Options;
20+
21+
Y_TEST_HOOK_BEFORE_RUN(InitAwsAPI) {
22+
Aws::InitAPI(Options);
23+
}
24+
25+
Y_TEST_HOOK_AFTER_RUN(ShutdownAwsAPI) {
26+
Aws::ShutdownAPI(Options);
27+
}
28+
29+
}
30+
1331
Y_UNIT_TEST_SUITE(TBackupTests) {
1432
using TFillFn = std::function<void(TTestBasicRuntime&)>;
1533

ydb/core/tx/schemeshard/ut_backup/ya.make

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ IF (NOT OS_WINDOWS)
2020
library/cpp/getopt
2121
library/cpp/regex/pcre
2222
library/cpp/svnversion
23+
contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core
2324
ydb/core/testlib/default
2425
ydb/core/tx
2526
ydb/core/tx/schemeshard/ut_helpers

ydb/core/tx/schemeshard/ut_export/ut_export.cpp

+16-2
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,25 @@
1313
#include <util/string/printf.h>
1414
#include <util/system/env.h>
1515

16+
#include <library/cpp/testing/hook/hook.h>
17+
18+
#include <aws/core/Aws.h>
19+
1620
using namespace NSchemeShardUT_Private;
1721
using namespace NKikimr::NWrappers::NTestHelpers;
1822

1923
namespace {
2024

25+
Aws::SDKOptions Options;
26+
27+
Y_TEST_HOOK_BEFORE_RUN(InitAwsAPI) {
28+
Aws::InitAPI(Options);
29+
}
30+
31+
Y_TEST_HOOK_AFTER_RUN(ShutdownAwsAPI) {
32+
Aws::ShutdownAPI(Options);
33+
}
34+
2135
void Run(TTestBasicRuntime& runtime, TTestEnv& env, const TVector<TString>& tables, const TString& request,
2236
Ydb::StatusIds::StatusCode expectedStatus = Ydb::StatusIds::SUCCESS,
2337
const TString& dbName = "/MyRoot", bool serverless = false, const TString& userSID = "", const TString& peerName = "") {
@@ -1687,7 +1701,7 @@ partitioning_settings {
16871701
return ev->Get<TEvSchemeShard::TEvModifySchemeTransaction>()->Record
16881702
.GetTransaction(0).GetOperationType() == NKikimrSchemeOp::ESchemeOpBackup;
16891703
};
1690-
1704+
16911705
THolder<IEventHandle> delayed;
16921706
auto prevObserver = runtime.SetObserverFunc([&](TAutoPtr<IEventHandle>& ev) {
16931707
if (delayFunc(ev)) {
@@ -2083,7 +2097,7 @@ partitioning_settings {
20832097
min_partitions_count: 10
20842098
)"));
20852099
}
2086-
2100+
20872101
Y_UNIT_TEST(UserSID) {
20882102
TTestBasicRuntime runtime;
20892103
TTestEnv env(runtime);

ydb/core/tx/schemeshard/ut_export/ya.make

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ IF (NOT OS_WINDOWS)
2020
library/cpp/getopt
2121
library/cpp/regex/pcre
2222
library/cpp/svnversion
23+
contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core
2324
ydb/core/testlib/default
2425
ydb/core/tx
2526
ydb/core/tx/schemeshard/ut_helpers

ydb/core/tx/schemeshard/ut_export_reboots_s3/ut_export_reboots_s3.cpp

+18
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,28 @@
44

55
#include <util/string/printf.h>
66

7+
#include <library/cpp/testing/hook/hook.h>
8+
9+
#include <aws/core/Aws.h>
10+
711
using namespace NSchemeShardUT_Private;
812
using namespace NSchemeShardUT_Private::NExportReboots;
913
using namespace NKikimr::NWrappers::NTestHelpers;
1014

15+
namespace {
16+
17+
Aws::SDKOptions Options;
18+
19+
Y_TEST_HOOK_BEFORE_RUN(InitAwsAPI) {
20+
Aws::InitAPI(Options);
21+
}
22+
23+
Y_TEST_HOOK_AFTER_RUN(ShutdownAwsAPI) {
24+
Aws::ShutdownAPI(Options);
25+
}
26+
27+
}
28+
1129
Y_UNIT_TEST_SUITE(TExportToS3WithRebootsTests) {
1230
using TUnderlying = std::function<void(const TVector<TString>&, const TString&, TTestWithReboots&)>;
1331

ydb/core/tx/schemeshard/ut_export_reboots_s3/ya.make

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ PEERDIR(
1919
library/cpp/getopt
2020
library/cpp/regex/pcre
2121
library/cpp/svnversion
22+
contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core
2223
ydb/core/testlib/default
2324
ydb/core/tx
2425
ydb/core/tx/schemeshard/ut_helpers

ydb/core/tx/schemeshard/ut_restore/ut_restore.cpp

+12-1
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@
2121

2222
#include <ydb/public/api/protos/ydb_import.pb.h>
2323

24+
#include <aws/core/Aws.h>
2425
#include <contrib/libs/zstd/include/zstd.h>
2526
#include <library/cpp/string_utils/quote/quote.h>
27+
#include <library/cpp/testing/hook/hook.h>
2628

2729
#include <util/datetime/base.h>
2830
#include <util/generic/size_literals.h>
@@ -38,6 +40,16 @@ using namespace NKikimr::NWrappers::NTestHelpers;
3840

3941
namespace {
4042

43+
Aws::SDKOptions Options;
44+
45+
Y_TEST_HOOK_BEFORE_RUN(InitAwsAPI) {
46+
Aws::InitAPI(Options);
47+
}
48+
49+
Y_TEST_HOOK_AFTER_RUN(ShutdownAwsAPI) {
50+
Aws::ShutdownAPI(Options);
51+
}
52+
4153
const TString EmptyYsonStr = R"([[[[];%false]]])";
4254

4355
TString GenerateScheme(const NKikimrSchemeOp::TPathDescription& pathDesc) {
@@ -317,7 +329,6 @@ namespace {
317329
runtime.SetObserverFunc(prevObserver);
318330
}
319331

320-
321332
} // anonymous
322333

323334
Y_UNIT_TEST_SUITE(TRestoreTests) {

ydb/core/tx/schemeshard/ut_restore/ya.make

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ ELSE()
1414
ENDIF()
1515

1616
PEERDIR(
17+
contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core
1718
contrib/libs/double-conversion
1819
library/cpp/string_utils/quote
1920
ydb/core/kqp/ut/common

ydb/core/wrappers/s3_storage.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
#ifndef KIKIMR_DISABLE_S3_OPS
44

55
#include "abstract.h"
6-
#include "s3_storage_config.h"
76

87
#include <ydb/core/protos/flat_scheme_op.pb.h>
98
#include <ydb/core/wrappers/events/common.h>
@@ -32,7 +31,7 @@
3231

3332
namespace NKikimr::NWrappers::NExternalStorage {
3433

35-
class TS3ExternalStorage: public IExternalStorageOperator, TS3User {
34+
class TS3ExternalStorage: public IExternalStorageOperator {
3635
private:
3736
THolder<Aws::S3::S3Client> Client;
3837
const Aws::Client::ClientConfiguration Config;

0 commit comments

Comments
 (0)