Skip to content

Commit

Permalink
Merge fc8c8fa into 0f0f3bc
Browse files Browse the repository at this point in the history
  • Loading branch information
swalrus1 authored Aug 20, 2024
2 parents 0f0f3bc + fc8c8fa commit 08ea83c
Show file tree
Hide file tree
Showing 3 changed files with 99 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ydb/core/kqp/ut/common/columnshard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace NKqp {
}
SecretableSecretKey: {
Value: {
Data: "secretSecretKey"
Data: "fakeSecret"
}
}
}
Expand Down
97 changes: 97 additions & 0 deletions ydb/core/kqp/ut/olap/tiering_ut.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
#include "helpers/get_value.h"
#include "helpers/local.h"
#include "helpers/query_executor.h"
#include "helpers/typed_local.h"
#include "helpers/writer.h"

#include <ydb/core/kqp/ut/common/columnshard.h>
#include <ydb/core/tx/columnshard/engines/scheme/abstract/index_info.h>
#include <ydb/core/tx/columnshard/hooks/testing/controller.h>
#include <ydb/core/tx/columnshard/test_helper/controllers.h>
#include <ydb/core/wrappers/fake_storage.h>

namespace NKikimr::NKqp {

Y_UNIT_TEST_SUITE(KqpOlapTiering) {
Y_UNIT_TEST(Eviction) {
auto csController = NYDBTest::TControllers::RegisterCSControllerGuard<NOlap::TWaitCompactionController>();

TKikimrSettings runnerSettings;
runnerSettings.WithSampleTables = false;
TTestHelper testHelper(runnerSettings);
TLocalHelper localHelper(testHelper.GetKikimr());
NYdb::NTable::TTableClient tableClient = testHelper.GetKikimr().GetTableClient();
Tests::NCommon::TLoggerInit(testHelper.GetKikimr()).Initialize();
Singleton<NKikimr::NWrappers::NExternalStorage::TFakeExternalStorage>()->SetSecretKey("fakeSecret");

localHelper.CreateTestOlapTable();
testHelper.CreateTier("tier1");
const TString tieringRule = testHelper.CreateTieringRule("tier1", "timestamp");

for (ui64 i = 0; i < 100; ++i) {
WriteTestData(testHelper.GetKikimr(), "/Root/olapStore/olapTable", 0, i * 10000, 1000);
}

csController->WaitActualization(TDuration::Seconds(5));

ui64 columnRawBytes = 0;
{
auto selectQuery = TString(R"(
SELECT
TierName, SUM(ColumnRawBytes) As RawBytes
FROM `/Root/olapStore/olapTable/.sys/primary_index_portion_stats`
WHERE Activity == 1
GROUP BY TierName
)");

auto rows = ExecuteScanQuery(tableClient, selectQuery);
UNIT_ASSERT_VALUES_EQUAL(rows.size(), 1);
UNIT_ASSERT_VALUES_EQUAL(GetUtf8(rows[0].at("TierName")), "__DEFAULT");

columnRawBytes = GetUint64(rows[0].at("RawBytes"));
UNIT_ASSERT_GT(columnRawBytes, 0);
}

testHelper.SetTiering("/Root/olapStore/olapTable", tieringRule);
csController->WaitActualization(TDuration::Seconds(5));

{
auto selectQuery = TString(R"(
SELECT
TierName, SUM(ColumnRawBytes) As RawBytes
FROM `/Root/olapStore/olapTable/.sys/primary_index_portion_stats`
WHERE Activity == 1
GROUP BY TierName
)");

auto rows = ExecuteScanQuery(tableClient, selectQuery);
UNIT_ASSERT_VALUES_EQUAL(rows.size(), 1);
UNIT_ASSERT_VALUES_EQUAL(GetUtf8(rows[0].at("TierName")), "tier1");
UNIT_ASSERT_VALUES_EQUAL_C(GetUint64(rows[0].at("RawBytes")), columnRawBytes,
TStringBuilder() << "RawBytes changed after eviction: before=" << columnRawBytes
<< " after=" << GetUint64(rows[0].at("RawBytes")));
}

testHelper.ResetTiering("/Root/olapStore/olapTable");
csController->WaitCompactions(TDuration::Seconds(5));

{
auto selectQuery = TString(R"(
SELECT
TierName, SUM(ColumnRawBytes) As RawBytes
FROM `/Root/olapStore/olapTable/.sys/primary_index_portion_stats`
WHERE Activity == 1
GROUP BY TierName
)");

auto rows = ExecuteScanQuery(tableClient, selectQuery);
UNIT_ASSERT_VALUES_EQUAL(rows.size(), 1);
UNIT_ASSERT_VALUES_EQUAL(GetUtf8(rows[0].at("TierName")), "__DEFAULT");
UNIT_ASSERT_VALUES_EQUAL_C(GetUint64(rows[0].at("RawBytes")), columnRawBytes,
TStringBuilder() << "RawBytes changed after resetting tiering: before=" << columnRawBytes
<< " after=" << rows[0].at("RawBytes"));
}
}
}

} // namespace NKikimr::NKqp
1 change: 1 addition & 0 deletions ydb/core/kqp/ut/olap/ya.make
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ SRCS(
aggregations_ut.cpp
write_ut.cpp
sparsed_ut.cpp
tiering_ut.cpp
)

PEERDIR(
Expand Down

0 comments on commit 08ea83c

Please sign in to comment.