Skip to content

Commit

Permalink
[BACKPORT 2024.1][#13358] YSQL: YBDdlAtomicityBackupTest::RunDdlAtomi…
Browse files Browse the repository at this point in the history
…cityTest test change

Summary:
The way the test YBDdlAtomicityBackupTest::RunDdlAtomicityTest is written, all
the DDLs will be inflight during the backup - so backup will fail. It's better
to test the case where backup fails if any single DDL is inflight. This diff
changes the test to randomly pick one DDL to be inflight and verify the backup
fails.
Jira: DB-2996

Original commit: 5ebfef8 / D35140

Test Plan: ./yb_build.sh release --cxx-test yb-backup-cross-feature-test --gtest_filter YBDdlAtomicityBackupTest.DdlRollbackAtomicityTest  -n 20

Reviewers: fizaa

Reviewed By: fizaa

Subscribers: yql, ybase

Tags: #jenkins-ready

Differential Revision: https://phorge.dev.yugabyte.com/D35150
  • Loading branch information
myang2021 committed May 17, 2024
1 parent a154522 commit ca8873c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/yb/tools/yb-backup/yb-backup-cross-feature-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1739,12 +1739,13 @@ Status YBDdlAtomicityBackupTest::RunDdlAtomicityTest(pgwrapper::DdlErrorInjectio

auto client = VERIFY_RESULT(cluster_->CreateClient());

// Run all DDLs after pausing DDL rollback.
RETURN_NOT_OK(cluster_->SetFlagOnMasters("TEST_pause_ddl_rollback", "true"));

if (inject_error) {
RETURN_NOT_OK(RunAllDdlsWithErrorInjection(&conn));
// Run one failed DDL after pausing DDL rollback.
RETURN_NOT_OK(RunOneDdlWithErrorInjection(&conn));
} else {
// Run all DDLs after pausing DDL rollback.
RETURN_NOT_OK(RunAllDdls(&conn));
}

Expand Down
9 changes: 9 additions & 0 deletions src/yb/yql/pgwrapper/pg_ddl_atomicity_test_base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,15 @@ Status PgDdlAtomicityTestBase::RunAllDdlsWithErrorInjection(PGConn* conn) {
return Status::OK();
}

Status PgDdlAtomicityTestBase::RunOneDdlWithErrorInjection(PGConn* conn) {
const auto& ddls = GetAllDDLs();
const auto selected = RandomUniformInt(0UL, ddls.size() - 1);
const auto& ddl = ddls[selected];
LOG(INFO) << "selected ddl to fail: " << ddl;
RETURN_NOT_OK(conn->TestFailDdl(ddl));
return Status::OK();
}

Status PgDdlAtomicityTestBase::VerifyAllSuccessfulDdls(PGConn *conn,
client::YBClient* client,
const string& database) {
Expand Down
4 changes: 4 additions & 0 deletions src/yb/yql/pgwrapper/pg_ddl_atomicity_test_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,10 @@ class PgDdlAtomicityTestBase : public LibPqTestBase {
// initiate rollback on the YB-Master.
Status RunAllDdlsWithErrorInjection(PGConn* conn);

// From all possible DDLs supported by this test, randomly select one DDL and run with
// error injection. The selected DDL will fail and initiate rollback on the YB-Master.
Status RunOneDdlWithErrorInjection(PGConn* conn);

// API that can be used after 'RunAllDdls' above to wait for all the DDL verification to
// complete.
Status WaitForDdlVerificationAfterSuccessfulDdl(
Expand Down

0 comments on commit ca8873c

Please sign in to comment.