Skip to content

Commit

Permalink
add negative tests
Browse files Browse the repository at this point in the history
  • Loading branch information
swalrus1 committed Nov 27, 2024
1 parent 93d6e8c commit 4b19a54
Showing 1 changed file with 60 additions and 10 deletions.
70 changes: 60 additions & 10 deletions ydb/core/tx/schemeshard/ut_ttl/ut_ttl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardTTLTests) {
ColumnName: "created_at"
}
}
)", {NKikimrScheme::StatusSchemeError});
)", {{NKikimrScheme::StatusSchemeError, "Cannot enable TTL on unknown column: 'created_at'"}});
}

Y_UNIT_TEST(CreateTableShouldFailOnWrongColumnType) {
Expand All @@ -127,7 +127,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardTTLTests) {
ColumnName: "modified_at"
}
}
)", {NKikimrScheme::StatusSchemeError});
)", {{NKikimrScheme::StatusSchemeError, "Unsupported column type"}});
}

void CreateTableShouldFailOnWrongUnit(const char* ttlColumnType, bool enableTablePgTypes, const char* unit) {
Expand All @@ -146,7 +146,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardTTLTests) {
ColumnUnit: %s
}
}
)", ttlColumnType, unit), {NKikimrScheme::StatusSchemeError});
)", ttlColumnType, unit), {{NKikimrScheme::StatusSchemeError, "To enable TTL on date type column 'DateTypeColumnModeSettings' should be specified"}});
}

Y_UNIT_TEST_FLAG(CreateTableShouldFailOnWrongUnit, EnableTablePgTypes) {
Expand Down Expand Up @@ -179,7 +179,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardTTLTests) {
KeyColumnNames: ["key"]
TTLSettings {
}
)", {NKikimrScheme::StatusSchemeError});
)", {{NKikimrScheme::StatusSchemeError, "TTL status must be specified"}});
}

Y_UNIT_TEST(CreateTableShouldFailOnBeforeEpochTTL) {
Expand All @@ -206,7 +206,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardTTLTests) {
}
}
}
)", {NKikimrScheme::StatusSchemeError});
)", {{NKikimrScheme::StatusSchemeError, "TTL should be less than 1732709274 seconds"}});
}

void CreateTableOnIndexedTable(NKikimrSchemeOp::EIndexType indexType) {
Expand Down Expand Up @@ -878,7 +878,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardTTLTests) {
}
}
}
)", {NKikimrScheme::StatusSchemeError});
)", {{NKikimrScheme::StatusSchemeError, "TTL run interval cannot be less than limit"}});
}

Y_UNIT_TEST(ShouldSkipDroppedColumn) {
Expand Down Expand Up @@ -1171,6 +1171,56 @@ Y_UNIT_TEST_SUITE(TSchemeShardTTLTests) {
WaitForStats(runtime, 2);
CheckPercentileCounter(runtime, "SchemeShard/NumShardsByTtlLag", {{"900", 2}, {"1800", 0}, {"inf", 0}});
}

Y_UNIT_TEST(TtlTiersValidation) {
TTestBasicRuntime runtime;
TTestEnv env(runtime);
ui64 txId = 100;

TestCreateTable(runtime, ++txId, "/MyRoot", Sprintf(R"(
Name: "TTLEnabledTable"
Columns { Name: "key" Type: "Uint64" }
Columns { Name: "modified_at" Type: "Timestamp" }
KeyColumnNames: ["key"]
)"));
env.TestWaitNotification(runtime, txId);

TestAlterTable(runtime, ++txId, "/MyRoot", R"(
Name: "TTLEnabledTable"
TTLSettings {
Enabled {
ColumnName: "modified_at"
Tiers {
Delete {}
ApplyAfterSeconds: 3600
}
Tiers {
Delete {}
ApplyAfterSeconds: 7200
}
}
}
)", {{NKikimrScheme::StatusInvalidParameter, "Only the last tier in TTL settings can have Delete action"}});

TestAlterTable(runtime, ++txId, "/MyRoot", R"(
Name: "TTLEnabledTable"
TTLSettings {
Enabled {
ColumnName: "modified_at"
Tiers {
EvictToExternalStorage {
StorageName: "/Root/abc"
}
ApplyAfterSeconds: 3600
}
Tiers {
Delete {}
ApplyAfterSeconds: 7200
}
}
}
)", {{NKikimrScheme::StatusInvalidParameter, "Only DELETE via TTL is allowed for row-oriented tables"}});
}
}

Y_UNIT_TEST_SUITE(TSchemeShardColumnTableTTL) {
Expand Down Expand Up @@ -1237,7 +1287,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardColumnTableTTL) {
}
}
}
)", ct), {NKikimrScheme::StatusSchemeError});
)", ct), {{NKikimrScheme::StatusSchemeError, "Unsupported column type"}});
}
}

Expand All @@ -1258,7 +1308,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardColumnTableTTL) {
ColumnName: "created_at"
}
}
)", {NKikimrScheme::StatusSchemeError});
)", {{NKikimrScheme::StatusSchemeError, "Incorrect ttl column - not found in scheme"}});
}

Y_UNIT_TEST(AlterColumnTable) {
Expand Down Expand Up @@ -1326,7 +1376,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardColumnTableTTL) {
AlterSchema {
AlterColumns {Name: "data" DefaultValue: "10"}
}
)", {NKikimrScheme::StatusSchemeError});
)", {{NKikimrScheme::StatusSchemeError, "sparsed columns are disabled"}});
env.TestWaitNotification(runtime, txId);
}

Expand Down Expand Up @@ -1367,7 +1417,7 @@ Y_UNIT_TEST_SUITE(TSchemeShardColumnTableTTL) {
}
}
}
)", {NKikimrScheme::StatusSchemeError});
)", {{NKikimrScheme::StatusSchemeError, "Unsupported column type"}});
}
}

Expand Down

0 comments on commit 4b19a54

Please sign in to comment.