Skip to content

Commit

Permalink
Merge pull request #6 from vlad-gogov/test_snapshot_too_old
Browse files Browse the repository at this point in the history
Add test
  • Loading branch information
ivanmorozov333 authored Nov 12, 2024
2 parents 1c1b35b + 51e1428 commit c1ec6b1
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions ydb/core/kqp/ut/olap/kqp_olap_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2964,6 +2964,33 @@ Y_UNIT_TEST_SUITE(KqpOlap) {
UNIT_ASSERT_C(result.IsSuccess(), result.GetIssues().ToString());
}
}

Y_UNIT_TEST(ScanFailedSnapshotTooOld) {
NKikimrConfig::TAppConfig appConfig;
appConfig.MutableTableServiceConfig()->SetEnableOlapSink(true);
appConfig.MutableColumnShardConfig()->SetMaxReadStaleness_ms(100);
auto settings = TKikimrSettings().SetAppConfig(appConfig).SetWithSampleTables(false);
TTestHelper testHelper(settings);

TTestHelper::TColumnTable cnt;
TVector<TTestHelper::TColumnSchema> schema = {
TTestHelper::TColumnSchema().SetName("key").SetType(NScheme::NTypeIds::Int32).SetNullable(false),
TTestHelper::TColumnSchema().SetName("c").SetType(NScheme::NTypeIds::Int32).SetNullable(true)
};
cnt.SetName("/Root/cnt").SetPrimaryKey({ "key" }).SetSchema(schema);
testHelper.CreateTable(cnt);

auto client = testHelper.GetKikimr().GetQueryClient();
auto result =
client
.ExecuteQuery(
TStringBuilder() << "$v = SELECT CAST(COUNT(*) AS INT32) FROM `/Root/cnt`; INSERT INTO `/Root/cnt` (key, c) values(1, $v);",
NYdb::NQuery::TTxControl::BeginTx().CommitTx())
.GetValueSync();
UNIT_ASSERT_VALUES_EQUAL(result.GetStatus(), EStatus::BAD_REQUEST);
UNIT_ASSERT_VALUES_EQUAL(result.GetIssues().Size(), 1);
UNIT_ASSERT_STRING_CONTAINS(result.GetIssues().ToString(), "scan failed, reason: cannot build metadata/Snapshot too old");
}
}

}

0 comments on commit c1ec6b1

Please sign in to comment.