Skip to content

Commit

Permalink
fix tests (ydb-platform#1653)
Browse files Browse the repository at this point in the history
* fix tests

* fix build
  • Loading branch information
ivanmorozov333 committed Apr 16, 2024
1 parent d5dc6cf commit 7566c9b
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 16 deletions.
11 changes: 11 additions & 0 deletions ydb/core/tx/columnshard/engines/ut/helper.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#include "helper.h"

namespace NKikimr::NOlap::NEngines::NTest {

NKikimrTxColumnShard::TLogicalMetadata TLocalHelper::GetMetaProto() {
NKikimrTxColumnShard::TLogicalMetadata result;
result.SetDirtyWriteTimeSeconds(TInstant::Now().Seconds());
return result;
}

}
11 changes: 11 additions & 0 deletions ydb/core/tx/columnshard/engines/ut/helper.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#pragma once
#include <ydb/core/tx/columnshard/engines/insert_table/meta.h>

namespace NKikimr::NOlap::NEngines::NTest {

class TLocalHelper {
public:
static NKikimrTxColumnShard::TLogicalMetadata GetMetaProto();
};

};
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "db_wrapper.h"
#include "insert_table/insert_table.h"
#include "helper.h"
#include <ydb/core/tx/columnshard/engines/db_wrapper.h>
#include <ydb/core/tx/columnshard/engines/insert_table/insert_table.h>

#include <ydb/core/tx/columnshard/columnshard_schema.h>

Expand All @@ -9,6 +10,7 @@
namespace NKikimr {

using namespace NOlap;
using namespace NKikimr::NOlap::NEngines::NTest;

namespace {

Expand Down Expand Up @@ -40,7 +42,6 @@ class TTestInsertTableDB: public IDbWrapper {

}


Y_UNIT_TEST_SUITE(TColumnEngineTestInsertTable) {
Y_UNIT_TEST(TestInsertCommit) {
ui64 writeId = 0;
Expand All @@ -53,16 +54,16 @@ Y_UNIT_TEST_SUITE(TColumnEngineTestInsertTable) {
ui64 indexSnapshot = 0;

// insert, not commited
bool ok = insertTable.Insert(dbTable, TInsertedData(writeId, tableId, dedupId, blobId1, {}, indexSnapshot, {}));
bool ok = insertTable.Insert(dbTable, TInsertedData(writeId, tableId, dedupId, blobId1, TLocalHelper::GetMetaProto(), indexSnapshot, {}));
UNIT_ASSERT(ok);

// insert the same blobId1 again
ok = insertTable.Insert(dbTable, TInsertedData(writeId, tableId, dedupId, blobId1, {}, indexSnapshot, {}));
ok = insertTable.Insert(dbTable, TInsertedData(writeId, tableId, dedupId, blobId1, TLocalHelper::GetMetaProto(), indexSnapshot, {}));
UNIT_ASSERT(!ok);

// insert different blodId with the same writeId and dedupId
TUnifiedBlobId blobId2(2222, 1, 2, 100, 1);
ok = insertTable.Insert(dbTable, TInsertedData(writeId, tableId, dedupId, blobId2, {}, indexSnapshot, {}));
ok = insertTable.Insert(dbTable, TInsertedData(writeId, tableId, dedupId, blobId2, TLocalHelper::GetMetaProto(), indexSnapshot, {}));
UNIT_ASSERT(!ok);

// read nothing
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#include "helper.h"
#include <library/cpp/testing/unittest/registar.h>
#include "column_engine_logs.h"
#include "predicate/predicate.h"
#include "changes/cleanup.h"
#include <ydb/core/tx/columnshard/engines/column_engine_logs.h>
#include <ydb/core/tx/columnshard/engines/predicate/predicate.h>
#include <ydb/core/tx/columnshard/engines/changes/cleanup.h>

#include <ydb/core/tx/columnshard/columnshard_ut_common.h>
#include <ydb/core/tx/columnshard/engines/changes/compaction.h>
Expand All @@ -16,6 +17,7 @@ namespace NTypeIds = NScheme::NTypeIds;
using TTypeId = NScheme::TTypeId;
using TTypeInfo = NScheme::TTypeInfo;
using TDefaultTestsController = NKikimr::NYDBTest::NColumnShard::TController;
using namespace NKikimr::NOlap::NEngines::NTest;

namespace {

Expand Down Expand Up @@ -411,8 +413,8 @@ Y_UNIT_TEST_SUITE(TColumnEngineTestLogs) {
engine.Load(db);

std::vector<TInsertedData> dataToIndex = {
TInsertedData(2, paths[0], "", blobRanges[0].BlobId, {}, 0, {}),
TInsertedData(1, paths[0], "", blobRanges[1].BlobId, {}, 0, {})
TInsertedData(2, paths[0], "", blobRanges[0].BlobId, TLocalHelper::GetMetaProto(), 0, {}),
TInsertedData(1, paths[0], "", blobRanges[1].BlobId, TLocalHelper::GetMetaProto(), 0, {})
};

// write
Expand Down Expand Up @@ -507,7 +509,7 @@ Y_UNIT_TEST_SUITE(TColumnEngineTestLogs) {
// PlanStep, TxId, PathId, DedupId, BlobId, Data, [Metadata]
std::vector<TInsertedData> dataToIndex;
dataToIndex.push_back(
TInsertedData(txId, pathId, "", blobRange.BlobId, {}, 0, {}));
TInsertedData(txId, pathId, "", blobRange.BlobId, TLocalHelper::GetMetaProto(), 0, {}));

bool ok = Insert(engine, db, TSnapshot(planStep, txId), std::move(dataToIndex), blobs, step);
UNIT_ASSERT(ok);
Expand Down Expand Up @@ -605,7 +607,7 @@ Y_UNIT_TEST_SUITE(TColumnEngineTestLogs) {
// PlanStep, TxId, PathId, DedupId, BlobId, Data, [Metadata]
std::vector<TInsertedData> dataToIndex;
dataToIndex.push_back(
TInsertedData(txId, pathId, "", blobRange.BlobId, {}, 0, {}));
TInsertedData(txId, pathId, "", blobRange.BlobId, TLocalHelper::GetMetaProto(), 0, {}));

bool ok = Insert(engine, db, TSnapshot(planStep, txId), std::move(dataToIndex), blobs, step);
for (auto&& i : blobs) {
Expand Down Expand Up @@ -639,7 +641,7 @@ Y_UNIT_TEST_SUITE(TColumnEngineTestLogs) {
// PlanStep, TxId, PathId, DedupId, BlobId, Data, [Metadata]
std::vector<TInsertedData> dataToIndex;
dataToIndex.push_back(
TInsertedData(txId, pathId, "", blobRange.BlobId, {}, 0, {}));
TInsertedData(txId, pathId, "", blobRange.BlobId, TLocalHelper::GetMetaProto(), 0, {}));

bool ok = Insert(engine, db, TSnapshot(planStep, txId), std::move(dataToIndex), blobs, step);
UNIT_ASSERT(ok);
Expand Down Expand Up @@ -680,7 +682,7 @@ Y_UNIT_TEST_SUITE(TColumnEngineTestLogs) {
// PlanStep, TxId, PathId, DedupId, BlobId, Data, [Metadata]
std::vector<TInsertedData> dataToIndex;
dataToIndex.push_back(
TInsertedData(txId, pathId, "", blobRange.BlobId, {}, 0, {}));
TInsertedData(txId, pathId, "", blobRange.BlobId, TLocalHelper::GetMetaProto(), 0, {}));

bool ok = Insert(engine, db, TSnapshot(planStep, txId), std::move(dataToIndex), blobs, step);
UNIT_ASSERT(ok);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "index_info.h"
#include <ydb/core/tx/columnshard/engines/index_info.h>

#include <ydb/core/tx/columnshard/columnshard__index_scan.h>
#include <ydb/core/tx/columnshard/columnshard_ut_common.h>
Expand Down
1 change: 1 addition & 0 deletions ydb/core/tx/columnshard/engines/ut/ya.make
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ SRCS(
ut_insert_table.cpp
ut_logs_engine.cpp
ut_program.cpp
helper.cpp
ydb/core/tx/columnshard/columnshard_ut_common.cpp
)

Expand Down

0 comments on commit 7566c9b

Please sign in to comment.