Skip to content

Commit 98eddf2

Browse files
committed
Fix broken unit tests
1 parent 5a85760 commit 98eddf2

File tree

5 files changed

+42
-113
lines changed

5 files changed

+42
-113
lines changed

ydb/core/kqp/ut/indexes/kqp_indexes_multishard_ut.cpp

Lines changed: 11 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1605,29 +1605,7 @@ Y_UNIT_TEST_SUITE(KqpMultishardIndex) {
16051605

16061606
FillTable(session);
16071607

1608-
kikimr.GetTestServer().GetRuntime()->GetAppData().AdministrationAllowedSIDs.push_back("root@builtin");
1609-
1610-
{ // without token request is forbidded
1611-
Tests::TClient& client = kikimr.GetTestClient();
1612-
const TString scheme = R"(
1613-
Name: "indexImplTable"
1614-
PartitionConfig {
1615-
PartitioningPolicy {
1616-
MinPartitionsCount: 1
1617-
SizeToSplit: 100500
1618-
FastSplitSettings {
1619-
SizeThreshold: 100500
1620-
RowCountThreshold: 100500
1621-
}
1622-
}
1623-
}
1624-
)";
1625-
auto result = client.AlterTable("/Root/MultiShardIndexed/index", scheme, "user@builtin");
1626-
UNIT_ASSERT_VALUES_EQUAL_C(result->Record.GetStatus(), NMsgBusProxy::MSTATUS_ERROR, "User must not be able to alter index impl table");
1627-
UNIT_ASSERT_VALUES_EQUAL(result->Record.GetErrorReason(), "Administrative access denied");
1628-
}
1629-
1630-
{ // with root token request is accepted
1608+
{ // regular users should be able to alter indexImplTable's PartitionConfig
16311609
Tests::TClient& client = kikimr.GetTestClient();
16321610
const TString scheme = R"(
16331611
Name: "indexImplTable"
@@ -1642,53 +1620,24 @@ Y_UNIT_TEST_SUITE(KqpMultishardIndex) {
16421620
}
16431621
}
16441622
)";
1645-
auto result = client.AlterTable("/Root/MultiShardIndexed/index", scheme, "root@builtin");
1646-
UNIT_ASSERT_VALUES_EQUAL_C(result->Record.GetStatus(), NMsgBusProxy::MSTATUS_OK, "Super user must be able to alter partition config");
1623+
auto result = client.AlterTable("/Root/MultiShardIndexed/index", scheme, {});
1624+
UNIT_ASSERT_VALUES_EQUAL_C(result->Record.GetStatus(), NMsgBusProxy::MSTATUS_OK,
1625+
result->Record.ShortDebugString()
1626+
);
16471627
}
16481628

1649-
{ // after alter yql works fine
1650-
const TString query(R"(
1629+
{ // yql works fine after alter
1630+
const TString query = R"(
16511631
SELECT * FROM `/Root/MultiShardIndexed` VIEW index ORDER BY fk DESC LIMIT 1;
1652-
)");
1632+
)";
16531633

16541634
auto result = session.ExecuteDataQuery(
1655-
query,
1656-
TTxControl::BeginTx(TTxSettings::SerializableRW()).CommitTx())
1657-
.ExtractValueSync();
1635+
query,
1636+
TTxControl::BeginTx(TTxSettings::SerializableRW()).CommitTx()
1637+
).ExtractValueSync();
16581638
UNIT_ASSERT_C(result.IsSuccess(), result.GetIssues().ToString());
16591639
UNIT_ASSERT_VALUES_EQUAL(NYdb::FormatResultSetYson(result.GetResultSet(0)), "[[[4294967295u];[4u];[\"v4\"]]]");
16601640
}
1661-
1662-
FillTable(session);
1663-
1664-
{ // just for sure, public api got error when alter index
1665-
auto settings = NYdb::NTable::TAlterTableSettings()
1666-
.BeginAlterPartitioningSettings()
1667-
.SetPartitionSizeMb(50)
1668-
.SetMinPartitionsCount(4)
1669-
.SetMaxPartitionsCount(5)
1670-
.EndAlterPartitioningSettings();
1671-
1672-
auto result = session.AlterTable("/Root/MultiShardIndexed/index/indexImplTable", settings).ExtractValueSync();
1673-
UNIT_ASSERT_VALUES_EQUAL_C(result.GetStatus(), EStatus::SCHEME_ERROR, result.GetIssues().ToString());
1674-
}
1675-
1676-
{ // however public api is able to perform alter index if user has AlterSchema right and user is a member of the list AdministrationAllowedSIDs
1677-
auto clSettings = NYdb::NTable::TClientSettings().AuthToken("root@builtin").UseQueryCache(false);
1678-
auto client = NYdb::NTable::TTableClient(kikimr.GetDriver(), clSettings);
1679-
auto session = client.CreateSession().GetValueSync().GetSession();
1680-
1681-
auto settings = NYdb::NTable::TAlterTableSettings()
1682-
.BeginAlterPartitioningSettings()
1683-
.SetPartitionSizeMb(50)
1684-
.SetMinPartitionsCount(4)
1685-
.SetMaxPartitionsCount(5)
1686-
.EndAlterPartitioningSettings();
1687-
1688-
auto result = session.AlterTable("/Root/MultiShardIndexed/index/indexImplTable", settings).ExtractValueSync();
1689-
UNIT_ASSERT_VALUES_EQUAL_C(result.GetStatus(), EStatus::SUCCESS, result.GetIssues().ToString());
1690-
}
1691-
16921641
}
16931642

16941643
Y_UNIT_TEST_TWIN(DataColumnUpsertMixedSemantic, StreamLookup) {

ydb/core/tx/schemeshard/ut_base/ut_base.cpp

Lines changed: 19 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -10477,45 +10477,27 @@ Y_UNIT_TEST_SUITE(TSchemeShardTest) {
1047710477
NLs::NoMaxPartitionsCount
1047810478
});
1047910479

10480-
// request without token
10480+
// request direct alter of forbidden fields of indexImplTable
1048110481
TestAlterTable(runtime, ++txId, "/MyRoot/table/indexByValue/", R"(
10482-
Name: "indexImplTable"
10483-
PartitionConfig {
10484-
PartitioningPolicy {
10485-
MinPartitionsCount: 1
10486-
SizeToSplit: 100502
10487-
FastSplitSettings {
10488-
SizeThreshold: 100502
10489-
RowCountThreshold: 100502
10490-
}
10491-
}
10492-
}
10493-
)", {NKikimrScheme::StatusNameConflict});
10494-
10495-
{ // request with not a super user token
10496-
auto request = AlterTableRequest(++txId, "/MyRoot/table/indexByValue/", R"(
10497-
Name: "indexImplTable"
10498-
PartitionConfig {
10499-
PartitioningPolicy {
10500-
MinPartitionsCount: 1
10501-
SizeToSplit: 100501
10502-
FastSplitSettings {
10503-
SizeThreshold: 100501
10504-
RowCountThreshold: 100501
10505-
}
10506-
}
10482+
Name: "indexImplTable"
10483+
KeyColumnNames: ["key", "value"]
10484+
PartitionConfig {
10485+
PartitioningPolicy {
10486+
MinPartitionsCount: 1
10487+
SizeToSplit: 100502
10488+
FastSplitSettings {
10489+
SizeThreshold: 100502
10490+
RowCountThreshold: 100502
1050710491
}
10508-
)");
10509-
10510-
auto wellCookedToken = NACLib::TUserToken(TVector<TString>{"not-a-root@builtin"});
10511-
request->Record.SetUserToken(wellCookedToken.SerializeAsString());
10512-
TActorId sender = runtime.AllocateEdgeActor();
10513-
ForwardToTablet(runtime, TTestTxConfig::SchemeShard, sender, request);
10514-
TestModificationResults(runtime, txId, {TEvSchemeShard::EStatus::StatusNameConflict});
10515-
}
10492+
}
10493+
}
10494+
)",
10495+
{TEvSchemeShard::EStatus::StatusNameConflict}
10496+
);
10497+
env.TestWaitNotification(runtime, txId);
1051610498

1051710499
{
10518-
auto request = AlterTableRequest(++txId, "/MyRoot/table/indexByValue/", R"(
10500+
TestAlterTable(runtime, ++txId, "/MyRoot/table/indexByValue/", R"(
1051910501
Name: "indexImplTable"
1052010502
PartitionConfig {
1052110503
PartitioningPolicy {
@@ -10527,13 +10509,8 @@ Y_UNIT_TEST_SUITE(TSchemeShardTest) {
1052710509
}
1052810510
}
1052910511
}
10530-
)");
10531-
auto wellCookedToken = NACLib::TUserToken(TVector<TString>{"true-root@builtin"});
10532-
request->Record.SetUserToken(wellCookedToken.SerializeAsString());
10533-
TActorId sender = runtime.AllocateEdgeActor();
10534-
ForwardToTablet(runtime, TTestTxConfig::SchemeShard, sender, request);
10535-
TestModificationResults(runtime, txId, {TEvSchemeShard::EStatus::StatusAccepted});
10536-
10512+
)"
10513+
);
1053710514
env.TestWaitNotification(runtime, txId);
1053810515
}
1053910516

ydb/library/yql/core/expr_nodes/yql_expr_nodes.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
{"Index": 1, "Name": "Type", "Type": "TCoAtom"},
4444
{"Index": 2, "Name": "Columns", "Type": "TCoAtomList"},
4545
{"Index": 3, "Name": "DataColumns", "Type": "TCoAtomList"},
46-
{"Index": 4, "Name": "TableSettings", "Type": "TCoNameValueTupleList"}
46+
{"Index": 4, "Name": "TableSettings", "Type": "TCoNameValueTupleList", "Optional": true}
4747
]
4848
},
4949
{

ydb/library/yql/sql/v1/query.cpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -281,17 +281,20 @@ static INode::TPtr CreateIndexDesc(const TIndexDescription& index, ETableSetting
281281
}
282282
const auto& indexType = node.Y(node.Q("indexType"), CreateIndexType(index.Type, node));
283283
const auto& indexName = node.Y(node.Q("indexName"), BuildQuotedAtom(index.Name.Pos, index.Name.Name));
284-
const auto& tableSettings = node.Y(
285-
node.Q("tableSettings"),
286-
node.Q(CreateTableSettings(index.TableSettings, parsingMode, node))
287-
);
288-
return node.Y(
284+
auto indexNode = node.Y(
289285
node.Q(indexName),
290286
node.Q(indexType),
291287
node.Q(node.Y(node.Q("indexColumns"), node.Q(indexColumns))),
292-
node.Q(node.Y(node.Q("dataColumns"), node.Q(dataColumns))),
293-
node.Q(tableSettings)
288+
node.Q(node.Y(node.Q("dataColumns"), node.Q(dataColumns)))
294289
);
290+
if (index.TableSettings.IsSet()) {
291+
const auto& tableSettings = node.Y(
292+
node.Q("tableSettings"),
293+
node.Q(CreateTableSettings(index.TableSettings, parsingMode, node))
294+
);
295+
indexNode = node.L(indexNode, tableSettings);
296+
}
297+
return indexNode;
295298
}
296299

297300
static INode::TPtr CreateAlterIndex(const TIndexDescription& index, const INode& node) {

ydb/library/yql/sql/v1/sql_ut.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2494,7 +2494,7 @@ Y_UNIT_TEST_SUITE(SqlParsingOnly) {
24942494

24952495
Y_UNIT_TEST(AlterTableAddIndexWithIsNotSupported) {
24962496
ExpectFailWithError("USE plato; ALTER TABLE table ADD INDEX idx LOCAL WITH (a=b, c=d, e=f) ON (col)",
2497-
"<main>:1:40: Error: local: alternative is not implemented yet: 720:7: local_index\n");
2497+
"<main>:1:40: Error: local: alternative is not implemented yet: 722:7: local_index\n");
24982498
}
24992499

25002500
Y_UNIT_TEST(OptionalAliases) {

0 commit comments

Comments
 (0)