Skip to content

Commit

Permalink
WIP basic tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Enjection committed Oct 11, 2024
1 parent 862f106 commit dc81d18
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,7 @@ class TDropBackupCollection : public TSubOperation {
public:
using TSubOperation::TSubOperation;

THolder<TProposeResponse> Propose(const TString& owner, TOperationContext& context) override {
Y_UNUSED(owner);

THolder<TProposeResponse> Propose(const TString&, TOperationContext& context) override {
const TString& parentPathStr = Transaction.GetWorkingDir();
const auto& dropDescription = Transaction.GetDropBackupCollection();
const TString& name = dropDescription.GetName();
Expand All @@ -166,19 +164,23 @@ class TDropBackupCollection : public TSubOperation {
static_cast<ui64>(OperationId.GetTxId()),
static_cast<ui64>(context.SS->SelfTabletId()));

const TPath& dstPath = TPath::Resolve(parentPathStr, context.SS).Dive(name);
const TPath& dstPath = TPath::Resolve(parentPathStr, context.SS).Child(name);

RETURN_RESULT_UNLESS(IsDestinationPathValid(result, context, dstPath));
// RETURN_RESULT_UNLESS(NBackupCollection::IsApplyIfChecksPassed(Transaction, result, context));
TString errStr;
if (!context.SS->CheckApplyIf(Transaction, errStr)) {
result->SetError(NKikimrScheme::StatusPreconditionFailed, errStr);
return result;
}

result->SetPathId(dstPath.Base()->PathId.LocalPathId);

auto guard = context.DbGuard();
PersistDropBackupCollection(context, dstPath);
// TTxState& txState = context.SS->CreateTx(
// OperationId,
// TTxState::TxDropBackupCollection,
// dstPath.Base()->PathId);
context.SS->CreateTx(
OperationId,
TTxState::TxDropBackupCollection,
dstPath.Base()->PathId);

DropBackupCollectionPathElement(dstPath);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ Y_UNIT_TEST_SUITE(TBackupCollectionTests) {
env.TestWaitNotification(runtime, txId);
}

Y_UNIT_TEST(ParallelCreateBackupCollection) {
Y_UNIT_TEST(ParallelCreate) {
TTestBasicRuntime runtime;
TTestEnv env(runtime, TTestEnvOptions().EnableBackupService(true));
ui64 txId = 100;
Expand All @@ -203,4 +203,22 @@ Y_UNIT_TEST_SUITE(TBackupCollectionTests) {
TestDescribeResult(DescribePath(runtime, "/MyRoot/.backups/collections/" DEFAULT_NAME_2),
{NLs::PathVersionEqual(1)});
}

Y_UNIT_TEST(Drop) {
TTestBasicRuntime runtime;
TTestEnv env(runtime, TTestEnvOptions().EnableBackupService(true));
ui64 txId = 100;

PrepareDirs(runtime, env, txId);

TestCreateBackupCollection(runtime, ++txId, "/MyRoot/.backups/collections", DefaultCollectionSettings());
env.TestWaitNotification(runtime, txId);

TestLs(runtime, "/MyRoot/.backups/collections/" DEFAULT_NAME_1, false, NLs::PathExist);

TestDropBackupCollection(runtime, ++txId, "/MyRoot/.backups/collections", "Name: \"" DEFAULT_NAME_1 "\"");
env.TestWaitNotification(runtime, txId);

TestLs(runtime, "/MyRoot/.backups/collections/" DEFAULT_NAME_1, false, NLs::PathNotExist);
}
} // TBackupCollectionTests
4 changes: 2 additions & 2 deletions ydb/core/tx/schemeshard/ut_helpers/helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -919,9 +919,9 @@ namespace NSchemeShardUT_Private {
GENERIC_HELPERS(DropResourcePool, NKikimrSchemeOp::EOperationType::ESchemeOpDropResourcePool, &NKikimrSchemeOp::TModifyScheme::MutableDrop)
DROP_BY_PATH_ID_HELPERS(DropResourcePool, NKikimrSchemeOp::EOperationType::ESchemeOpDropResourcePool)

// resource pool
// backup collection
GENERIC_HELPERS(CreateBackupCollection, NKikimrSchemeOp::EOperationType::ESchemeOpCreateBackupCollection, &NKikimrSchemeOp::TModifyScheme::MutableCreateBackupCollection)
GENERIC_HELPERS(DropBackupCollection, NKikimrSchemeOp::EOperationType::ESchemeOpDropBackupCollection, &NKikimrSchemeOp::TModifyScheme::MutableDrop)
GENERIC_HELPERS(DropBackupCollection, NKikimrSchemeOp::EOperationType::ESchemeOpDropBackupCollection, &NKikimrSchemeOp::TModifyScheme::MutableDropBackupCollection)
DROP_BY_PATH_ID_HELPERS(DropBackupCollection, NKikimrSchemeOp::EOperationType::ESchemeOpDropBackupCollection)

#undef DROP_BY_PATH_ID_HELPERS
Expand Down

0 comments on commit dc81d18

Please sign in to comment.