Skip to content

Commit c8bb861

Browse files
committed
simplify cs_helper a bit (#18981)
1 parent aea00ee commit c8bb861

File tree

6 files changed

+35
-48
lines changed

6 files changed

+35
-48
lines changed

ydb/core/kqp/ut/olap/clickbench_ut.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,7 @@ Y_UNIT_TEST_SUITE(KqpOlapClickbench) {
2020
{}
2121

2222
void CreateClickBenchTable(TString tableName = "benchTable", ui32 shardsCount = 4) {
23-
TActorId sender = Server.GetRuntime()->AllocateEdgeActor();
24-
25-
TBase::CreateTestOlapTable(sender, "", Sprintf(R"(
23+
TBase::CreateTestOlapTable( "", Sprintf(R"(
2624
Name: "%s"
2725
ColumnShardCount: %d
2826
Schema {

ydb/core/kqp/ut/olap/helpers/local.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33
namespace NKikimr::NKqp {
44

55
void TTableWithNullsHelper::CreateTableWithNulls(TString tableName /*= "tableWithNulls"*/, ui32 shardsCount /*= 4*/) {
6-
TActorId sender = Server.GetRuntime()->AllocateEdgeActor();
7-
8-
TBase::CreateTestOlapTable(sender, "", Sprintf(R"(
6+
TBase::CreateTestOlapTable("", Sprintf(R"(
97
Name: "%s"
108
ColumnShardCount: %d
119
Schema {

ydb/core/testlib/cs_helper.cpp

Lines changed: 22 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,11 @@
1717

1818
namespace NKikimr::Tests::NCS {
1919

20-
void THelperSchemaless::CreateTestOlapStore(TActorId sender, TString scheme) {
21-
NKikimrSchemeOp::TColumnStoreDescription store;
22-
UNIT_ASSERT(::google::protobuf::TextFormat::ParseFromString(scheme, &store));
23-
20+
void THelperSchemaless::ExecuteModifyScheme(NKikimrSchemeOp::TModifyScheme& modifyScheme) {
2421
auto request = std::make_unique<TEvTxUserProxy::TEvProposeTransaction>();
2522
request->Record.SetExecTimeoutPeriod(Max<ui64>());
26-
auto* op = request->Record.MutableTransaction()->MutableModifyScheme();
27-
op->SetOperationType(NKikimrSchemeOp::EOperationType::ESchemeOpCreateColumnStore);
28-
op->SetWorkingDir(ROOT_PATH);
29-
op->MutableCreateColumnStore()->CopyFrom(store);
30-
23+
*request->Record.MutableTransaction()->MutableModifyScheme() = modifyScheme;
24+
TActorId sender = Server.GetRuntime()->AllocateEdgeActor();
3125
Server.GetRuntime()->Send(new IEventHandle(MakeTxProxyID(), sender, request.release()));
3226
auto ev = Server.GetRuntime()->GrabEdgeEventRethrow<TEvTxUserProxy::TEvProposeTransactionStatus>(sender);
3327
Cerr << ev->Get()->Record.DebugString() << Endl;
@@ -37,29 +31,29 @@ void THelperSchemaless::CreateTestOlapStore(TActorId sender, TString scheme) {
3731
WaitForSchemeOperation(sender, txId);
3832
}
3933

40-
void THelperSchemaless::CreateTestOlapTable(TActorId sender, TString storeOrDirName, TString scheme) {
34+
void THelperSchemaless::CreateTestOlapStore(TString scheme) {
35+
NKikimrSchemeOp::TColumnStoreDescription store;
36+
UNIT_ASSERT(::google::protobuf::TextFormat::ParseFromString(scheme, &store));
37+
NKikimrSchemeOp::TModifyScheme op;
38+
op.SetOperationType(NKikimrSchemeOp::EOperationType::ESchemeOpCreateColumnStore);
39+
op.SetWorkingDir(ROOT_PATH);
40+
op.MutableCreateColumnStore()->CopyFrom(store);
41+
ExecuteModifyScheme(op);
42+
}
43+
44+
void THelperSchemaless::CreateTestOlapTable(TString storeOrDirName, TString scheme) {
4145
NKikimrSchemeOp::TColumnTableDescription table;
4246
UNIT_ASSERT(::google::protobuf::TextFormat::ParseFromString(scheme, &table));
43-
auto request = std::make_unique<TEvTxUserProxy::TEvProposeTransaction>();
44-
request->Record.SetExecTimeoutPeriod(Max<ui64>());
45-
4647
TString workingDir = ROOT_PATH;
4748
if (!storeOrDirName.empty()) {
4849
workingDir += "/" + storeOrDirName;
4950
}
5051

51-
auto* op = request->Record.MutableTransaction()->MutableModifyScheme();
52-
op->SetOperationType(NKikimrSchemeOp::EOperationType::ESchemeOpCreateColumnTable);
53-
op->SetWorkingDir(workingDir);
54-
op->MutableCreateColumnTable()->CopyFrom(table);
55-
56-
Server.GetRuntime()->Send(new IEventHandle(MakeTxProxyID(), sender, request.release()));
57-
auto ev = Server.GetRuntime()->GrabEdgeEventRethrow<TEvTxUserProxy::TEvProposeTransactionStatus>(sender);
58-
ui64 txId = ev->Get()->Record.GetTxId();
59-
auto status = ev->Get()->Record.GetStatus();
60-
Cerr << ev->Get()->Record.DebugString() << Endl;
61-
UNIT_ASSERT(status != TEvTxUserProxy::TEvProposeTransactionStatus::EStatus::ExecError);
62-
WaitForSchemeOperation(sender, txId);
52+
NKikimrSchemeOp::TModifyScheme op;
53+
op.SetOperationType(NKikimrSchemeOp::EOperationType::ESchemeOpCreateColumnTable);
54+
op.SetWorkingDir(workingDir);
55+
op.MutableCreateColumnTable()->CopyFrom(table);
56+
ExecuteModifyScheme(op);
6357
}
6458

6559
void THelperSchemaless::SendDataViaActorSystem(TString testTable, std::shared_ptr<arrow::RecordBatch> batch, const Ydb::StatusIds_StatusCode& expectedStatus) const {
@@ -200,8 +194,7 @@ TString THelper::GetTestTableSchema() const {
200194
}
201195

202196
void THelper::CreateSchemaOlapTablesWithStore(const TString tableSchema, TVector<TString> tableNames /*= "olapTable"*/, TString storeName /*= "olapStore"*/, ui32 storeShardsCount /*= 4*/, ui32 tableShardsCount /*= 3*/) {
203-
TActorId sender = Server.GetRuntime()->AllocateEdgeActor();
204-
CreateTestOlapStore(sender, Sprintf(R"(
197+
CreateTestOlapStore(Sprintf(R"(
205198
Name: "%s"
206199
ColumnShardCount: %d
207200
SchemaPresets {
@@ -215,7 +208,7 @@ void THelper::CreateSchemaOlapTablesWithStore(const TString tableSchema, TVector
215208
const TString shardingColumns = "[\"" + JoinSeq("\",\"", GetShardingColumns()) + "\"]";
216209

217210
for (const TString& tableName : tableNames) {
218-
TBase::CreateTestOlapTable(sender, storeName, Sprintf(R"(
211+
TBase::CreateTestOlapTable(storeName, Sprintf(R"(
219212
Name: "%s"
220213
ColumnShardCount: %d
221214
Sharding {
@@ -232,12 +225,10 @@ void THelper::CreateOlapTablesWithStore(TVector<TString> tableNames /*= {"olapTa
232225
}
233226

234227
void THelper::CreateSchemaOlapTables(const TString tableSchema, TVector<TString> tableNames, ui32 tableShardsCount) {
235-
TActorId sender = Server.GetRuntime()->AllocateEdgeActor();
236-
237228
const TString shardingColumns = "[\"" + JoinSeq("\",\"", GetShardingColumns()) + "\"]";
238229

239230
for (const TString& tableName : tableNames) {
240-
TBase::CreateTestOlapTable(sender, "", Sprintf(R"(
231+
TBase::CreateTestOlapTable("", Sprintf(R"(
241232
Name: "%s"
242233
ColumnShardCount: %d
243234
Sharding {

ydb/core/testlib/cs_helper.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,15 @@ namespace NKikimr::Tests::NCS {
88
class THelperSchemaless : public NCommon::THelper {
99
private:
1010
using TBase = NCommon::THelper;
11+
protected:
12+
void ExecuteModifyScheme(NKikimrSchemeOp::TModifyScheme& modifyScheme);
13+
1114
public:
1215
static constexpr const char * ROOT_PATH = "/Root";
1316

1417
using TBase::TBase;
15-
void CreateTestOlapStore(TActorId sender, TString scheme);
16-
void CreateTestOlapTable(TActorId sender, TString storeOrDirName, TString scheme);
18+
void CreateTestOlapStore(TString scheme);
19+
void CreateTestOlapTable(TString storeOrDirName, TString scheme);
1720
void SendDataViaActorSystem(TString testTable, ui64 pathIdBegin, ui64 tsBegin, size_t rowCount, const ui32 tsStepUs = 1) const;
1821
void SendDataViaActorSystem(TString testTable, std::shared_ptr<arrow::RecordBatch> batch, const Ydb::StatusIds_StatusCode& expectedStatus = Ydb::StatusIds::SUCCESS) const;
1922

ydb/core/tx/tiering/ut/ut_tiers.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,7 @@ class TLocalHelper: public Tests::NCS::THelper {
5555
void CreateTestOlapTable(TString tableName = "olapTable", ui32 tableShardsCount = 3,
5656
TString storeName = "olapStore", ui32 storeShardsCount = 4,
5757
TString shardingFunction = "HASH_FUNCTION_CONSISTENCY_64") {
58-
TActorId sender = Server.GetRuntime()->AllocateEdgeActor();
59-
CreateTestOlapStore(sender, Sprintf(R"(
58+
CreateTestOlapStore(Sprintf(R"(
6059
Name: "%s"
6160
ColumnShardCount: %d
6261
SchemaPresets {
@@ -72,7 +71,7 @@ class TLocalHelper: public Tests::NCS::THelper {
7271
shardingColumns = "[\"uid\"]";
7372
}
7473

75-
TBase::CreateTestOlapTable(sender, storeName, Sprintf(R"(
74+
TBase::CreateTestOlapTable(storeName, Sprintf(R"(
7675
Name: "%s"
7776
ColumnShardCount: %d
7877
Sharding {
@@ -88,8 +87,7 @@ class TLocalHelper: public Tests::NCS::THelper {
8887
TString storeName = "olapStore", ui32 storeShardsCount = 4,
8988
TString shardingFunction = "HASH_FUNCTION_CONSISTENCY_64") {
9089

91-
TActorId sender = Server.GetRuntime()->AllocateEdgeActor();
92-
CreateTestOlapStore(sender, Sprintf(R"(
90+
CreateTestOlapStore(Sprintf(R"(
9391
Name: "%s"
9492
ColumnShardCount: %d
9593
SchemaPresets {
@@ -105,7 +103,7 @@ class TLocalHelper: public Tests::NCS::THelper {
105103
shardingColumns = "[\"uid\"]";
106104
}
107105

108-
TBase::CreateTestOlapTable(sender, storeName, Sprintf(R"(
106+
TBase::CreateTestOlapTable(storeName, Sprintf(R"(
109107
Name: "%s"
110108
ColumnShardCount: %d
111109
TtlSettings: {

ydb/services/ext_index/ut/ut_ext_index.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ class TLocalHelper: public Tests::NCS::THelper {
3232
void CreateTestOlapTable(TString tableName = "olapTable", ui32 tableShardsCount = 3,
3333
TString storeName = "olapStore", ui32 storeShardsCount = 4,
3434
TString shardingFunction = "HASH_FUNCTION_CLOUD_LOGS") {
35-
TActorId sender = Server.GetRuntime()->AllocateEdgeActor();
36-
CreateTestOlapStore(sender, Sprintf(R"(
35+
CreateTestOlapStore(Sprintf(R"(
3736
Name: "%s"
3837
ColumnShardCount: %d
3938
SchemaPresets {
@@ -49,7 +48,7 @@ class TLocalHelper: public Tests::NCS::THelper {
4948
shardingColumns = "[\"uid\"]";
5049
}
5150

52-
TBase::CreateTestOlapTable(sender, storeName, Sprintf(R"(
51+
TBase::CreateTestOlapTable(storeName, Sprintf(R"(
5352
Name: "%s"
5453
ColumnShardCount: %d
5554
TtlSettings: {

0 commit comments

Comments
 (0)