Skip to content

Commit 3b87a8e

Browse files
authored
Tablets test (#1989)
1 parent 64999d4 commit 3b87a8e

File tree

5 files changed

+50
-0
lines changed

5 files changed

+50
-0
lines changed

ydb/core/kqp/ut/common/columnshard.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,11 @@ namespace NKqp {
8282
UNIT_ASSERT_VALUES_EQUAL_C(result.GetStatus(), EStatus::SUCCESS, result.GetIssues().ToString());
8383
}
8484

85+
void TTestHelper::DropTable(const TString& tableName) {
86+
auto result = Session.DropTable(tableName).GetValueSync();
87+
UNIT_ASSERT_VALUES_EQUAL_C(result.GetStatus(), EStatus::SUCCESS, result.GetIssues().ToString());
88+
}
89+
8590
void TTestHelper::BulkUpsert(const TColumnTable& table, TTestHelper::TUpdatesBuilder& updates, const Ydb::StatusIds_StatusCode& opStatus /*= Ydb::StatusIds::SUCCESS*/) {
8691
Y_UNUSED(opStatus);
8792
NKikimr::Tests::NCS::THelper helper(Kikimr.GetTestServer());

ydb/core/kqp/ut/common/columnshard.h

+1
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ namespace NKqp {
7171
TTestActorRuntime& GetRuntime();
7272
NYdb::NTable::TSession& GetSession();
7373
void CreateTable(const TColumnTableBase& table, const NYdb::EStatus expectedStatus = NYdb::EStatus::SUCCESS);
74+
void DropTable(const TString& tableName);
7475
void CreateTier(const TString& tierName);
7576
TString CreateTieringRule(const TString& tierName, const TString& columnName);
7677
void SetTiering(const TString& tableName, const TString& ruleName);

ydb/core/kqp/ut/common/kqp_ut_common.cpp

+12
Original file line numberDiff line numberDiff line change
@@ -1310,6 +1310,18 @@ TVector<ui64> GetTableShards(Tests::TServer* server,
13101310
return shards;
13111311
}
13121312

1313+
TVector<ui64> GetColumnTableShards(Tests::TServer* server,
1314+
TActorId sender,
1315+
const TString &path)
1316+
{
1317+
TVector<ui64> shards;
1318+
auto lsResult = DescribeTable(server, sender, path);
1319+
for (auto &part : lsResult.GetPathDescription().GetColumnTableDescription().GetSharding().GetColumnShards())
1320+
shards.push_back(part);
1321+
1322+
return shards;
1323+
}
1324+
13131325
TVector<ui64> GetTableShards(Tests::TServer::TPtr server,
13141326
TActorId sender,
13151327
const TString &path) {

ydb/core/kqp/ut/common/kqp_ut_common.h

+1
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,7 @@ NKikimrScheme::TEvDescribeSchemeResult DescribeTable(Tests::TServer* server, TAc
329329
TVector<ui64> GetTableShards(Tests::TServer* server, TActorId sender, const TString &path);
330330

331331
TVector<ui64> GetTableShards(Tests::TServer::TPtr server, TActorId sender, const TString &path);
332+
TVector<ui64> GetColumnTableShards(Tests::TServer* server, TActorId sender, const TString &path);
332333

333334
void WaitForZeroSessions(const NKqp::TKqpCounters& counters);
334335

ydb/core/kqp/ut/scheme/kqp_scheme_ut.cpp

+31
Original file line numberDiff line numberDiff line change
@@ -5178,6 +5178,37 @@ Y_UNIT_TEST_SUITE(KqpScheme) {
51785178

51795179
Y_UNIT_TEST_SUITE(KqpOlapScheme) {
51805180

5181+
Y_UNIT_TEST(DropTable) {
5182+
TKikimrSettings runnerSettings;
5183+
runnerSettings.WithSampleTables = false;
5184+
TTestHelper testHelper(runnerSettings);
5185+
5186+
TVector<TTestHelper::TColumnSchema> schema = {
5187+
TTestHelper::TColumnSchema().SetName("id").SetType(NScheme::NTypeIds::Int32).SetNullable(false),
5188+
TTestHelper::TColumnSchema().SetName("id_second").SetType(NScheme::NTypeIds::Int32).SetNullable(false),
5189+
TTestHelper::TColumnSchema().SetName("level").SetType(NScheme::NTypeIds::Int32),
5190+
TTestHelper::TColumnSchema().SetName("created_at").SetType(NScheme::NTypeIds::Timestamp).SetNullable(false)
5191+
};
5192+
5193+
TTestHelper::TColumnTable testTable;
5194+
testTable
5195+
.SetName("/Root/ColumnTableTest")
5196+
.SetPrimaryKey({ "id", "id_second" })
5197+
.SetSharding({ "id" })
5198+
.SetMinPartitionsCount(16)
5199+
.SetSchema(schema);
5200+
testHelper.CreateTable(testTable);
5201+
auto sender = testHelper.GetRuntime().AllocateEdgeActor();
5202+
auto tabletIds = GetColumnTableShards(&testHelper.GetKikimr().GetTestServer(), sender, "/Root/ColumnTableTest");
5203+
for (auto tablet: tabletIds) {
5204+
UNIT_ASSERT_C(testHelper.GetKikimr().GetTestClient().TabletExistsInHive(&testHelper.GetRuntime(), tablet), ToString(tablet) + " not alive");
5205+
}
5206+
testHelper.DropTable("/Root/ColumnTableTest");
5207+
for (auto tablet: tabletIds) {
5208+
UNIT_ASSERT_C(!testHelper.GetKikimr().GetTestClient().TabletExistsInHive(&testHelper.GetRuntime(), tablet), ToString(tablet) + " is alive");
5209+
}
5210+
}
5211+
51815212
Y_UNIT_TEST(AddColumnLongPk) {
51825213
TKikimrSettings runnerSettings;
51835214
runnerSettings.WithSampleTables = false;

0 commit comments

Comments
 (0)