Skip to content

Commit 2238bdf

Browse files
authored
Merge ce6fe1c into 11ed7b0
2 parents 11ed7b0 + ce6fe1c commit 2238bdf

File tree

13 files changed

+124
-1
lines changed

13 files changed

+124
-1
lines changed

ydb/core/grpc_services/rpc_export_base.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ struct TExportConv {
5252
*operation.mutable_end_time() = exprt.GetEndTime();
5353
}
5454

55+
if (exprt.HasUserSID()) {
56+
operation.set_created_by(exprt.GetUserSID());
57+
}
58+
5559
using namespace Ydb::Export;
5660
switch (exprt.GetSettingsCase()) {
5761
case NKikimrExport::TExport::kExportToYtSettings:

ydb/core/grpc_services/rpc_import_base.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ struct TImportConv {
4949
*operation.mutable_end_time() = import.GetEndTime();
5050
}
5151

52+
if (import.HasUserSID()) {
53+
operation.set_created_by(import.GetUserSID());
54+
}
55+
5256
using namespace Ydb::Import;
5357
switch (import.GetSettingsCase()) {
5458
case NKikimrImport::TImport::kImportFromS3Settings:

ydb/core/protos/export.proto

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ message TExport {
2020
Ydb.Export.ExportToYtSettings ExportToYtSettings = 5;
2121
Ydb.Export.ExportToS3Settings ExportToS3Settings = 6;
2222
}
23+
optional string UserSID = 10;
2324
}
2425

2526
message TCreateExportRequest {

ydb/core/protos/import.proto

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ message TImport {
1919
oneof Settings {
2020
Ydb.Import.ImportFromS3Settings ImportFromS3Settings = 6;
2121
}
22+
optional string UserSID = 9;
2223
}
2324

2425
message TCreateImportRequest {

ydb/core/testlib/tablet_helpers.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -769,7 +769,7 @@ namespace NKikimr {
769769
TTabletTracer tabletTracer(activeZone, tabletIds);
770770
TTabletScheduledFilter scheduledFilter(tabletTracer);
771771
try {
772-
testFunc(INITIAL_TEST_DISPATCH_NAME, [&](TTestActorRuntimeBase& runtime) {
772+
testxFunc(INITIAL_TEST_DISPATCH_NAME, [&](TTestActorRuntimeBase& runtime) {
773773
runtime.SetObserverFunc([&](TAutoPtr<IEventHandle>& event) {
774774
tabletTracer.OnEvent(AsKikimrRuntime(runtime), event);
775775
return TTestActorRuntime::EEventAction::PROCESS;

ydb/core/tx/schemeshard/schemeshard_export.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,10 @@ void TSchemeShard::FromXxportInfo(NKikimrExport::TExport& exprt, const TExportIn
9191
*exprt.MutableEndTime() = SecondsToProtoTimeStamp(exportInfo->EndTime.Seconds());
9292
}
9393

94+
if (exportInfo->UserSID) {
95+
exprt.SetUserSID(*exportInfo->UserSID);
96+
}
97+
9498
switch (exportInfo->State) {
9599
case TExportInfo::EState::CreateExportDir:
96100
case TExportInfo::EState::CopyTables:

ydb/core/tx/schemeshard/schemeshard_import.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ void TSchemeShard::FromXxportInfo(NKikimrImport::TImport& import, const TImportI
5555
*import.MutableEndTime() = SecondsToProtoTimeStamp(importInfo->EndTime.Seconds());
5656
}
5757

58+
if (importInfo->UserSID) {
59+
import.SetUserSID(*importInfo->UserSID);
60+
}
61+
5862
switch (importInfo->State) {
5963
case TImportInfo::EState::Waiting:
6064
switch (GetMinState(importInfo)) {

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

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1817,5 +1817,42 @@ partitioning_settings {
18171817
min_partitions_count: 10
18181818
)"));
18191819
}
1820+
1821+
Y_UNIT_TEST(UserSID) {
1822+
TTestBasicRuntime runtime;
1823+
TTestEnv env(runtime);
1824+
ui64 txId = 100;
1825+
1826+
TestCreateTable(runtime, ++txId, "/MyRoot", R"(
1827+
Name: "Table"
1828+
Columns { Name: "key" Type: "Utf8" }
1829+
Columns { Name: "value" Type: "Utf8" }
1830+
KeyColumnNames: ["key"]
1831+
)");
1832+
env.TestWaitNotification(runtime, txId);
1833+
1834+
TPortManager portManager;
1835+
const ui16 port = portManager.GetPort();
1836+
1837+
TS3Mock s3Mock({}, TS3Mock::TSettings(port));
1838+
UNIT_ASSERT(s3Mock.Start());
18201839

1840+
const TString request = Sprintf(R"(
1841+
ExportToS3Settings {
1842+
endpoint: "localhost:%d"
1843+
scheme: HTTP
1844+
items {
1845+
source_path: "/MyRoot/Table"
1846+
destination_prefix: ""
1847+
}
1848+
}
1849+
)", port);
1850+
const TString userSID = "user@builtin";
1851+
TestExport(runtime, ++txId, "/MyRoot", request, userSID);
1852+
1853+
const auto desc = TestGetExport(runtime, txId, "/MyRoot");
1854+
const auto& entry = desc.GetResponse().GetEntry();
1855+
UNIT_ASSERT_VALUES_EQUAL(entry.GetProgress(), Ydb::Export::ExportProgress::PROGRESS_PREPARING);
1856+
UNIT_ASSERT_VALUES_EQUAL(entry.GetUserSID(), userSID);
1857+
}
18211858
}

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

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3429,6 +3429,48 @@ Y_UNIT_TEST_SUITE(TImportTests) {
34293429
UNIT_ASSERT(entry.HasEndTime());
34303430
UNIT_ASSERT_LT(entry.GetStartTime().seconds(), entry.GetEndTime().seconds());
34313431
}
3432+
3433+
Y_UNIT_TEST(UserSID) {
3434+
TTestBasicRuntime runtime;
3435+
TTestEnv env(runtime);
3436+
ui64 txId = 100;
3437+
3438+
const auto data = GenerateTestData(R"(
3439+
columns {
3440+
name: "key"
3441+
type { optional_type { item { type_id: UTF8 } } }
3442+
}
3443+
columns {
3444+
name: "value"
3445+
type { optional_type { item { type_id: UTF8 } } }
3446+
}
3447+
primary_key: "key"
3448+
)", {{"a", 1}});
3449+
3450+
TPortManager portManager;
3451+
const ui16 port = portManager.GetPort();
3452+
3453+
TS3Mock s3Mock(ConvertTestData(data), TS3Mock::TSettings(port));
3454+
UNIT_ASSERT(s3Mock.Start());
3455+
3456+
const TString request = Sprintf(R"(
3457+
ImportFromS3Settings {
3458+
endpoint: "localhost:%d"
3459+
scheme: HTTP
3460+
items {
3461+
source_prefix: ""
3462+
destination_path: "/MyRoot/Table"
3463+
}
3464+
}
3465+
)", port);
3466+
const TString userSID = "user@builtin";
3467+
TestImport(runtime, ++txId, "/MyRoot", request, userSID);
3468+
3469+
const auto desc = TestGetImport(runtime, txId, "/MyRoot");
3470+
const auto& entry = desc.GetResponse().GetEntry();
3471+
UNIT_ASSERT_VALUES_EQUAL(entry.GetProgress(), Ydb::Import::ImportProgress::PROGRESS_PREPARING);
3472+
UNIT_ASSERT_VALUES_EQUAL(entry.GetUserSID(), userSID);
3473+
}
34323474
}
34333475

34343476
Y_UNIT_TEST_SUITE(TImportWithRebootsTests) {

ydb/public/api/protos/ydb_operation.proto

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,4 +127,7 @@ message Operation {
127127

128128
// The time at which this operation was completed, doesn't matter successful or not (if supported).
129129
google.protobuf.Timestamp end_time = 9;
130+
131+
// User SID (Security ID) of the user who created this operation (if supported).
132+
string created_by = 10;
130133
}

0 commit comments

Comments
 (0)