Skip to content

Commit 14d8e1b

Browse files
fix tests (#8323)
1 parent 4b2a95c commit 14d8e1b

File tree

4 files changed

+48
-35
lines changed

4 files changed

+48
-35
lines changed

ydb/core/statistics/aggregator/ut/ut_traverse_columnshard.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ Y_UNIT_TEST_SUITE(TraverseColumnShard) {
4040

4141
auto countMin = ExtractCountMin(runtime, tableInfo.PathId);
4242

43-
UNIT_ASSERT(CheckCountMinSketch(countMin, 1000000));
43+
UNIT_ASSERT(CheckCountMinSketch(countMin, ColumnTableRowsNumber));
4444
}
4545

4646
Y_UNIT_TEST(TraverseColumnTableRebootSaTabletBeforeResolve) {
@@ -56,16 +56,16 @@ Y_UNIT_TEST_SUITE(TraverseColumnShard) {
5656
runtime.WaitFor("2nd TEvResolveKeySetResult", [&]{ return block.size() >= 1; });
5757
block.Unblock(1);
5858
runtime.WaitFor("3rd TEvResolveKeySetResult", [&]{ return block.size() >= 1; });
59-
59+
6060
RebootTablet(runtime, tableInfo.SaTabletId, sender);
61-
61+
6262
block.Unblock();
63-
block.Stop();
63+
block.Stop();
6464

6565
runtime.SimulateSleep(TDuration::Seconds(10));
6666

6767
auto countMin = ExtractCountMin(runtime, tableInfo.PathId);
68-
UNIT_ASSERT(CheckCountMinSketch(countMin, 1000000));
68+
UNIT_ASSERT(CheckCountMinSketch(countMin, ColumnTableRowsNumber));
6969
}
7070

7171
Y_UNIT_TEST(TraverseColumnTableRebootSaTabletBeforeReqDistribution) {
@@ -85,7 +85,7 @@ Y_UNIT_TEST_SUITE(TraverseColumnShard) {
8585
RebootTablet(runtime, tableInfo.SaTabletId, sender);
8686

8787
auto countMin = ExtractCountMin(runtime, tableInfo.PathId);
88-
UNIT_ASSERT(CheckCountMinSketch(countMin, 1000000));
88+
UNIT_ASSERT(CheckCountMinSketch(countMin, ColumnTableRowsNumber));
8989
}
9090

9191
Y_UNIT_TEST(TraverseColumnTableRebootSaTabletBeforeAggregate) {
@@ -105,7 +105,7 @@ Y_UNIT_TEST_SUITE(TraverseColumnShard) {
105105
RebootTablet(runtime, tableInfo.SaTabletId, sender);
106106

107107
auto countMin = ExtractCountMin(runtime, tableInfo.PathId);
108-
UNIT_ASSERT(CheckCountMinSketch(countMin, 1000000));
108+
UNIT_ASSERT(CheckCountMinSketch(countMin, ColumnTableRowsNumber));
109109
}
110110

111111
Y_UNIT_TEST(TraverseColumnTableRebootSaTabletBeforeSave) {
@@ -125,7 +125,7 @@ Y_UNIT_TEST_SUITE(TraverseColumnShard) {
125125
RebootTablet(runtime, tableInfo.SaTabletId, sender);
126126

127127
auto countMin = ExtractCountMin(runtime, tableInfo.PathId);
128-
UNIT_ASSERT(CheckCountMinSketch(countMin, 1000000));
128+
UNIT_ASSERT(CheckCountMinSketch(countMin, ColumnTableRowsNumber));
129129
}
130130

131131
Y_UNIT_TEST(TraverseColumnTableRebootSaTabletInAggregate) {
@@ -146,7 +146,7 @@ Y_UNIT_TEST_SUITE(TraverseColumnShard) {
146146
RebootTablet(runtime, tableInfo.SaTabletId, sender);
147147

148148
auto countMin = ExtractCountMin(runtime, tableInfo.PathId);
149-
UNIT_ASSERT(CheckCountMinSketch(countMin, 1000000));
149+
UNIT_ASSERT(CheckCountMinSketch(countMin, ColumnTableRowsNumber));
150150
}
151151

152152
Y_UNIT_TEST(TraverseColumnTableHiveDistributionZeroNodes) {
@@ -191,7 +191,7 @@ Y_UNIT_TEST_SUITE(TraverseColumnShard) {
191191
runtime.SimulateSleep(TDuration::Seconds(30));
192192

193193
auto countMin = ExtractCountMin(runtime, tableInfo.PathId);
194-
UNIT_ASSERT(CheckCountMinSketch(countMin, 1000000));
194+
UNIT_ASSERT(CheckCountMinSketch(countMin, ColumnTableRowsNumber));
195195
}
196196

197197
Y_UNIT_TEST(TraverseColumnTableHiveDistributionAbsentNodes) {
@@ -228,7 +228,7 @@ Y_UNIT_TEST_SUITE(TraverseColumnShard) {
228228
runtime.SimulateSleep(TDuration::Seconds(30));
229229

230230
auto countMin = ExtractCountMin(runtime, tableInfo.PathId);
231-
UNIT_ASSERT(CheckCountMinSketch(countMin, 1000000));
231+
UNIT_ASSERT(CheckCountMinSketch(countMin, ColumnTableRowsNumber));
232232
}
233233

234234
Y_UNIT_TEST(TraverseColumnTableAggrStatUnavailableNode) {
@@ -265,7 +265,7 @@ Y_UNIT_TEST_SUITE(TraverseColumnShard) {
265265
auto probe = countMin->Probe((const char *)&value, sizeof(value));
266266
Cerr << "probe = " << probe << Endl;
267267
const double eps = 1. / countMin->GetWidth();
268-
UNIT_ASSERT(probe <= 1 + eps * 1100000); // 10 for first round, 1 for second
268+
UNIT_ASSERT(probe <= 1 + eps * ColumnTableRowsNumber * 1.1); // 10 for first round, 1 for second
269269
}
270270

271271
Y_UNIT_TEST(TraverseColumnTableAggrStatNonLocalTablet) {
@@ -302,7 +302,7 @@ Y_UNIT_TEST_SUITE(TraverseColumnShard) {
302302
auto probe = countMin->Probe((const char *)&value, sizeof(value));
303303
Cerr << "probe = " << probe << Endl;
304304
const double eps = 1. / countMin->GetWidth();
305-
UNIT_ASSERT(probe <= 1 + eps * 1100000); // 10 for first round, 1 for second
305+
UNIT_ASSERT(probe <= 1 + eps * ColumnTableRowsNumber * 1.1); // 10 for first round, 1 for second
306306
}
307307

308308
}

ydb/core/statistics/ut_common/ut_common.cpp

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ NKikimrSubDomains::TSubDomainSettings GetSubDomainDefaultSettings(const TString
4343
return subdomain;
4444
}
4545

46-
TTestEnv::TTestEnv(ui32 staticNodes, ui32 dynamicNodes, ui32 storagePools, bool useRealThreads) {
46+
TTestEnv::TTestEnv(ui32 staticNodes, ui32 dynamicNodes, ui32 storagePools, bool useRealThreads)
47+
: CSController(NYDBTest::TControllers::RegisterCSControllerGuard<NYDBTest::NColumnShard::TController>()) {
4748
auto mbusPort = PortManager.GetPort();
4849
auto grpcPort = PortManager.GetPort();
4950

@@ -77,6 +78,10 @@ TTestEnv::TTestEnv(ui32 staticNodes, ui32 dynamicNodes, ui32 storagePools, bool
7778
DriverConfig = NYdb::TDriverConfig().SetEndpoint(Endpoint);
7879
Driver = MakeHolder<NYdb::TDriver>(DriverConfig);
7980

81+
CSController->SetOverridePeriodicWakeupActivationPeriod(TDuration::Seconds(1));
82+
CSController->SetOverrideLagForCompactionBeforeTierings(TDuration::Seconds(1));
83+
CSController->SetOverrideReduceMemoryIntervalLimit(1LLU << 30);
84+
8085
Server->GetRuntime()->SetLogPriority(NKikimrServices::STATISTICS, NActors::NLog::PRI_DEBUG);
8186
}
8287

@@ -250,23 +255,22 @@ void CreateColumnStoreTable(TTestEnv& env, const TString& databaseName, const TS
250255
)", fullTableName.c_str())).GetValueSync();
251256
UNIT_ASSERT_C(result.IsSuccess(), result.GetIssues().ToString());
252257

253-
for (size_t bulk = 0; bulk < 5; ++bulk) {
254-
NYdb::TValueBuilder rows;
255-
rows.BeginList();
256-
for (size_t i = 0; i < 1000000; ++i) {
257-
auto key = TValueBuilder().Uint64(i).Build();
258-
auto value = TValueBuilder().OptionalUint64(i).Build();
259-
rows.AddListItem();
260-
rows.BeginStruct();
261-
rows.AddMember("Key", key);
262-
rows.AddMember("Value", value);
263-
rows.EndStruct();
264-
}
265-
rows.EndList();
266-
267-
result = client.BulkUpsert(fullTableName, rows.Build()).GetValueSync();
268-
UNIT_ASSERT_C(result.IsSuccess(), result.GetIssues().ToString());
258+
NYdb::TValueBuilder rows;
259+
rows.BeginList();
260+
for (size_t i = 0; i < ColumnTableRowsNumber; ++i) {
261+
auto key = TValueBuilder().Uint64(i).Build();
262+
auto value = TValueBuilder().OptionalUint64(i).Build();
263+
rows.AddListItem();
264+
rows.BeginStruct();
265+
rows.AddMember("Key", key);
266+
rows.AddMember("Value", value);
267+
rows.EndStruct();
269268
}
269+
rows.EndList();
270+
result = client.BulkUpsert(fullTableName, rows.Build()).GetValueSync();
271+
UNIT_ASSERT_C(result.IsSuccess(), result.GetIssues().ToString());
272+
273+
env.GetController()->WaitActualization(TDuration::Seconds(1));
270274
}
271275

272276
std::vector<TTableInfo> CreateDatabaseColumnTables(TTestEnv& env, ui8 tableCount, ui8 shardCount) {
@@ -281,7 +285,7 @@ std::vector<TTableInfo> CreateDatabaseColumnTables(TTestEnv& env, ui8 tableCount
281285
auto& runtime = *env.GetServer().GetRuntime();
282286
auto sender = runtime.AllocateEdgeActor();
283287

284-
runtime.SimulateSleep(TDuration::Seconds(30));
288+
runtime.SimulateSleep(TDuration::Seconds(10));
285289
initThread.join();
286290

287291
std::vector<TTableInfo> ret;

ydb/core/statistics/ut_common/ut_common.h

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
#include <ydb/core/statistics/events.h>
44

5+
#include <ydb/core/tx/columnshard/hooks/testing/controller.h>
6+
57
#include <ydb/core/testlib/test_client.h>
68
#include <library/cpp/testing/unittest/registar.h>
79

@@ -12,12 +14,14 @@ namespace NKikimrStat {
1214
namespace NKikimr {
1315
namespace NStat {
1416

17+
static constexpr ui32 ColumnTableRowsNumber = 1000;
18+
1519
NKikimrSubDomains::TSubDomainSettings GetSubDomainDeclareSettings(
1620
const TString &name, const TStoragePools &pools = {});
1721

1822
NKikimrSubDomains::TSubDomainSettings GetSubDomainDefaultSettings(
1923
const TString &name, const TStoragePools &pools = {});
20-
24+
2125
class TTestEnv {
2226
public:
2327
TTestEnv(ui32 staticNodes = 1, ui32 dynamicNodes = 1, ui32 storagePools = 1, bool useRealThreads = false);
@@ -49,6 +53,10 @@ class TTestEnv {
4953

5054
TStoragePools GetPools() const;
5155

56+
auto& GetController() {
57+
return CSController;
58+
}
59+
5260
private:
5361
TPortManager PortManager;
5462

@@ -60,6 +68,7 @@ class TTestEnv {
6068
TString Endpoint;
6169
NYdb::TDriverConfig DriverConfig;
6270
THolder<NYdb::TDriver> Driver;
71+
NYDBTest::TControllers::TGuard<NYDBTest::NColumnShard::TController> CSController;
6372
};
6473

6574
void CreateDatabase(TTestEnv& env, const TString& databaseName, size_t nodeCount = 1);
@@ -68,7 +77,7 @@ void CreateServerlessDatabase(TTestEnv& env, const TString& databaseName, TPathI
6877

6978
struct TTableInfo {
7079
std::vector<ui64> ShardIds;
71-
ui64 SaTabletId;
80+
ui64 SaTabletId;
7281
TPathId DomainKey;
7382
TPathId PathId;
7483
};
@@ -93,7 +102,7 @@ void ValidateCountMinDatashardAbsense(TTestActorRuntime& runtime, TPathId pathId
93102
struct TAnalyzedTable {
94103
TPathId PathId;
95104
std::vector<ui32> ColumnTags;
96-
105+
97106
TAnalyzedTable(const TPathId& pathId);
98107
TAnalyzedTable(const TPathId& pathId, const std::vector<ui32>& columnTags);
99108
void ToProto(NKikimrStat::TTable& tableProto) const;

ydb/core/statistics/ut_common/ya.make

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ SRCS(
66
)
77

88
PEERDIR(
9+
ydb/core/tx/columnshard/hooks/testing
910
ydb/core/testlib
1011
)
1112

1213
YQL_LAST_ABI_VERSION()
1314

1415
END()
15-

0 commit comments

Comments
 (0)