Skip to content

Commit

Permalink
Test for Read Only Snapshots (#11574)
Browse files Browse the repository at this point in the history
  • Loading branch information
nikvas0 authored and zverevgeny committed Jan 11, 2025
1 parent 46bf12b commit fa2e3d6
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions ydb/core/kqp/ut/tx/kqp_mvcc_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,51 @@ using namespace NYdb;
using namespace NYdb::NTable;

Y_UNIT_TEST_SUITE(KqpSnapshotRead) {

Y_UNIT_TEST_TWIN(TestReadOnly, withSink) {
NKikimrConfig::TAppConfig appConfig;
appConfig.MutableTableServiceConfig()->SetEnableOltpSink(withSink);
auto settings = TKikimrSettings()
.SetKeepSnapshotTimeout(TDuration::Seconds(1))
.SetAppConfig(appConfig);

TKikimrRunner kikimr(settings);

auto db = kikimr.GetTableClient();
auto session1 = db.CreateSession().GetValueSync().GetSession();
auto session2 = db.CreateSession().GetValueSync().GetSession();

auto result = session1.ExecuteDataQuery(Q_(R"(
SELECT * FROM `/Root/EightShard` WHERE Key = 101u OR Key = 801u ORDER BY Key;
)"), TTxControl::BeginTx(TTxSettings::SerializableRW())).ExtractValueSync();
UNIT_ASSERT_VALUES_EQUAL_C(result.GetStatus(), EStatus::SUCCESS, result.GetIssues().ToString());
CompareYson(R"([
[[1];[101u];["Value1"]];
[[2];[801u];["Value1"]]
])", FormatResultSetYson(result.GetResultSet(0)));

auto tx = result.GetTransaction();

result = session2.ExecuteDataQuery(Q_(R"(
UPSERT INTO `/Root/EightShard` (Key, Text) VALUES (101u, "Changed"), (801u, "Changed");
UPSERT INTO `/Root/TwoShard` (Key, Value1, Value2) VALUES (1u, "Changed", 1), (4000000001u, "Changed", 2);
)"), TTxControl::BeginTx(TTxSettings::SerializableRW()).CommitTx()).ExtractValueSync();
UNIT_ASSERT_VALUES_EQUAL_C(result.GetStatus(), EStatus::SUCCESS, result.GetIssues().ToString());

result = session1.ExecuteDataQuery(Q_(R"(
SELECT * FROM `/Root/TwoShard` WHERE Key = 1u OR Key = 4000000001u ORDER BY Key;
)"), TTxControl::Tx(*tx)).ExtractValueSync();
UNIT_ASSERT_VALUES_EQUAL_C(result.GetStatus(), EStatus::SUCCESS, result.GetIssues().ToString());
CompareYson(R"([
[[1u];["One"];[-1]];
[[4000000001u];["BigOne"];[-1]]
])", FormatResultSetYson(result.GetResultSet(0)));

auto commitResult = tx->Commit().GetValueSync();
UNIT_ASSERT_VALUES_EQUAL_C(commitResult.GetStatus(), EStatus::SUCCESS, result.GetIssues().ToString());
}


Y_UNIT_TEST_TWIN(TestSnapshotExpiration, withSink) {
NKikimrConfig::TAppConfig appConfig;
appConfig.MutableTableServiceConfig()->SetEnableOltpSink(withSink);
Expand Down

0 comments on commit fa2e3d6

Please sign in to comment.