Skip to content

fix tests #8323

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions ydb/core/statistics/aggregator/ut/ut_traverse_columnshard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Y_UNIT_TEST_SUITE(TraverseColumnShard) {

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

UNIT_ASSERT(CheckCountMinSketch(countMin, 1000000));
UNIT_ASSERT(CheckCountMinSketch(countMin, ColumnTableRowsNumber));
}

Y_UNIT_TEST(TraverseColumnTableRebootSaTabletBeforeResolve) {
Expand All @@ -56,16 +56,16 @@ Y_UNIT_TEST_SUITE(TraverseColumnShard) {
runtime.WaitFor("2nd TEvResolveKeySetResult", [&]{ return block.size() >= 1; });
block.Unblock(1);
runtime.WaitFor("3rd TEvResolveKeySetResult", [&]{ return block.size() >= 1; });

RebootTablet(runtime, tableInfo.SaTabletId, sender);

block.Unblock();
block.Stop();
block.Stop();

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

auto countMin = ExtractCountMin(runtime, tableInfo.PathId);
UNIT_ASSERT(CheckCountMinSketch(countMin, 1000000));
UNIT_ASSERT(CheckCountMinSketch(countMin, ColumnTableRowsNumber));
}

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

auto countMin = ExtractCountMin(runtime, tableInfo.PathId);
UNIT_ASSERT(CheckCountMinSketch(countMin, 1000000));
UNIT_ASSERT(CheckCountMinSketch(countMin, ColumnTableRowsNumber));
}

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

auto countMin = ExtractCountMin(runtime, tableInfo.PathId);
UNIT_ASSERT(CheckCountMinSketch(countMin, 1000000));
UNIT_ASSERT(CheckCountMinSketch(countMin, ColumnTableRowsNumber));
}

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

auto countMin = ExtractCountMin(runtime, tableInfo.PathId);
UNIT_ASSERT(CheckCountMinSketch(countMin, 1000000));
UNIT_ASSERT(CheckCountMinSketch(countMin, ColumnTableRowsNumber));
}

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

auto countMin = ExtractCountMin(runtime, tableInfo.PathId);
UNIT_ASSERT(CheckCountMinSketch(countMin, 1000000));
UNIT_ASSERT(CheckCountMinSketch(countMin, ColumnTableRowsNumber));
}

Y_UNIT_TEST(TraverseColumnTableHiveDistributionZeroNodes) {
Expand Down Expand Up @@ -191,7 +191,7 @@ Y_UNIT_TEST_SUITE(TraverseColumnShard) {
runtime.SimulateSleep(TDuration::Seconds(30));

auto countMin = ExtractCountMin(runtime, tableInfo.PathId);
UNIT_ASSERT(CheckCountMinSketch(countMin, 1000000));
UNIT_ASSERT(CheckCountMinSketch(countMin, ColumnTableRowsNumber));
}

Y_UNIT_TEST(TraverseColumnTableHiveDistributionAbsentNodes) {
Expand Down Expand Up @@ -228,7 +228,7 @@ Y_UNIT_TEST_SUITE(TraverseColumnShard) {
runtime.SimulateSleep(TDuration::Seconds(30));

auto countMin = ExtractCountMin(runtime, tableInfo.PathId);
UNIT_ASSERT(CheckCountMinSketch(countMin, 1000000));
UNIT_ASSERT(CheckCountMinSketch(countMin, ColumnTableRowsNumber));
}

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

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

}
Expand Down
40 changes: 22 additions & 18 deletions ydb/core/statistics/ut_common/ut_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ NKikimrSubDomains::TSubDomainSettings GetSubDomainDefaultSettings(const TString
return subdomain;
}

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

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

CSController->SetOverridePeriodicWakeupActivationPeriod(TDuration::Seconds(1));
CSController->SetOverrideLagForCompactionBeforeTierings(TDuration::Seconds(1));
CSController->SetOverrideReduceMemoryIntervalLimit(1LLU << 30);

Server->GetRuntime()->SetLogPriority(NKikimrServices::STATISTICS, NActors::NLog::PRI_DEBUG);
}

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

for (size_t bulk = 0; bulk < 5; ++bulk) {
NYdb::TValueBuilder rows;
rows.BeginList();
for (size_t i = 0; i < 1000000; ++i) {
auto key = TValueBuilder().Uint64(i).Build();
auto value = TValueBuilder().OptionalUint64(i).Build();
rows.AddListItem();
rows.BeginStruct();
rows.AddMember("Key", key);
rows.AddMember("Value", value);
rows.EndStruct();
}
rows.EndList();

result = client.BulkUpsert(fullTableName, rows.Build()).GetValueSync();
UNIT_ASSERT_C(result.IsSuccess(), result.GetIssues().ToString());
NYdb::TValueBuilder rows;
rows.BeginList();
for (size_t i = 0; i < ColumnTableRowsNumber; ++i) {
auto key = TValueBuilder().Uint64(i).Build();
auto value = TValueBuilder().OptionalUint64(i).Build();
rows.AddListItem();
rows.BeginStruct();
rows.AddMember("Key", key);
rows.AddMember("Value", value);
rows.EndStruct();
}
rows.EndList();
result = client.BulkUpsert(fullTableName, rows.Build()).GetValueSync();
UNIT_ASSERT_C(result.IsSuccess(), result.GetIssues().ToString());

env.GetController()->WaitActualization(TDuration::Seconds(1));
}

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

runtime.SimulateSleep(TDuration::Seconds(30));
runtime.SimulateSleep(TDuration::Seconds(10));
initThread.join();

std::vector<TTableInfo> ret;
Expand Down
15 changes: 12 additions & 3 deletions ydb/core/statistics/ut_common/ut_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

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

#include <ydb/core/tx/columnshard/hooks/testing/controller.h>

#include <ydb/core/testlib/test_client.h>
#include <library/cpp/testing/unittest/registar.h>

Expand All @@ -12,12 +14,14 @@ namespace NKikimrStat {
namespace NKikimr {
namespace NStat {

static constexpr ui32 ColumnTableRowsNumber = 1000;

NKikimrSubDomains::TSubDomainSettings GetSubDomainDeclareSettings(
const TString &name, const TStoragePools &pools = {});

NKikimrSubDomains::TSubDomainSettings GetSubDomainDefaultSettings(
const TString &name, const TStoragePools &pools = {});

class TTestEnv {
public:
TTestEnv(ui32 staticNodes = 1, ui32 dynamicNodes = 1, ui32 storagePools = 1, bool useRealThreads = false);
Expand Down Expand Up @@ -49,6 +53,10 @@ class TTestEnv {

TStoragePools GetPools() const;

auto& GetController() {
return CSController;
}

private:
TPortManager PortManager;

Expand All @@ -60,6 +68,7 @@ class TTestEnv {
TString Endpoint;
NYdb::TDriverConfig DriverConfig;
THolder<NYdb::TDriver> Driver;
NYDBTest::TControllers::TGuard<NYDBTest::NColumnShard::TController> CSController;
};

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

struct TTableInfo {
std::vector<ui64> ShardIds;
ui64 SaTabletId;
ui64 SaTabletId;
TPathId DomainKey;
TPathId PathId;
};
Expand All @@ -93,7 +102,7 @@ void ValidateCountMinDatashardAbsense(TTestActorRuntime& runtime, TPathId pathId
struct TAnalyzedTable {
TPathId PathId;
std::vector<ui32> ColumnTags;

TAnalyzedTable(const TPathId& pathId);
TAnalyzedTable(const TPathId& pathId, const std::vector<ui32>& columnTags);
void ToProto(NKikimrStat::TTable& tableProto) const;
Expand Down
2 changes: 1 addition & 1 deletion ydb/core/statistics/ut_common/ya.make
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ SRCS(
)

PEERDIR(
ydb/core/tx/columnshard/hooks/testing
ydb/core/testlib
)

YQL_LAST_ABI_VERSION()

END()