Skip to content

Commit

Permalink
[#25423] docdb: Fix Unit Tests with Inconsistent Table ID and Table N…
Browse files Browse the repository at this point in the history
…ame in Metric Attributes

Summary:
A new DCHECK, introduced as part of D39667(pending work), checks pre-aggregated metric's attributes to ensures that all metrics sharing the same table_id have the same table_name. However, during testing, this DCHECK revealed several inconsistencies in existing unit tests where mismatches between table_id and table_name were found. These are test only issue and need to be corrected by assigning proper table_id and table_name values.
Jira: DB-14655

Test Plan: Jenkins

Reviewers: amitanand, xCluster, hsunder

Reviewed By: amitanand

Subscribers: ybase, rthallam

Differential Revision: https://phorge.dev.yugabyte.com/D40875
  • Loading branch information
yusong-yan committed Dec 26, 2024
1 parent 77f4fab commit 45496e4
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
2 changes: 2 additions & 0 deletions src/yb/client/client-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2425,6 +2425,7 @@ TEST_F(ClientTest, TestCreateTableWithRangePartition) {
std::unique_ptr<YBTableCreator> table_creator(client_->NewTableCreator());
const std::string kPgsqlTableName = "pgsqlrangepartitionedtable";
const std::string kPgsqlTableId = "pgsqlrangepartitionedtableid";
const std::string kYqlTableId = "yqlrangepartitionedtableid";
const size_t kColIdx = 1;
const int64_t kKeyValue = 48238;
auto yql_table_name = YBTableName(YQL_DATABASE_CQL, kKeyspaceName, "yqlrangepartitionedtable");
Expand Down Expand Up @@ -2472,6 +2473,7 @@ TEST_F(ClientTest, TestCreateTableWithRangePartition) {

// Create a YQL table using range partition.
s = table_creator->table_name(yql_table_name)
.table_id(kYqlTableId)
.schema(&schema)
.set_range_partition_columns({"key"})
.table_type(YBTableType::YQL_TABLE_TYPE)
Expand Down
2 changes: 1 addition & 1 deletion src/yb/integration-tests/create-table-itest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1027,7 +1027,7 @@ TEST_F(CreateTableITest, OnlyMajorityReplicasWithPlacement) {
// Try creating a table. It should succeed.
YBTableName table_name5(kNamespaceType, kNamespaceName, kTableName5);
std::unique_ptr<client::YBTableCreator> table_creator5(client_->NewTableCreator());
ASSERT_OK(table_creator1->table_name(table_name5)
ASSERT_OK(table_creator5->table_name(table_name5)
.schema(&client_schema)
.num_tablets(kNumTablets)
.wait(true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,8 @@ class XClusterConsistencyTest : public XClusterYsqlTestBase {

for (const auto& stream_id : stream_ids_) {
for (const auto& tablet_id : producer_tablet_ids_) {
auto metrics = GetXClusterTabletMetrics(*cdc_service, tablet_id, stream_id);
auto metrics = GetXClusterTabletMetrics(
*cdc_service, tablet_id, stream_id, cdc::CreateMetricsEntityIfNotFound::kFalse);

if (metrics && metrics.get()->last_read_hybridtime->value()) {
producer_tablet_read_time_[tablet_id] = metrics.get()->last_read_hybridtime->value();
Expand All @@ -191,7 +192,8 @@ class XClusterConsistencyTest : public XClusterYsqlTestBase {

for (const auto& stream_id : stream_ids_) {
for (const auto& tablet_id : producer_tablet_ids_) {
auto metrics = GetXClusterTabletMetrics(*cdc_service, tablet_id, stream_id);
auto metrics = GetXClusterTabletMetrics(
*cdc_service, tablet_id, stream_id, cdc::CreateMetricsEntityIfNotFound::kFalse);

if (metrics &&
metrics.get()->last_read_hybridtime->value() >
Expand Down
4 changes: 3 additions & 1 deletion src/yb/tserver/ts_tablet_manager-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,9 @@ class TsTabletManagerTest : public YBTest {
auto partition = tablet::CreateDefaultPartition(full_schema);

auto table_info = std::make_shared<tablet::TableInfo>(
"TEST: ", tablet::Primary::kTrue, table_id, tablet_id, tablet_id,
"TEST: ", tablet::Primary::kTrue, /*table_id=*/table_id,
/*namespace_name=*/table_id + "_namespace",
/*table_name=*/table_id + "_table_name",
TableType::DEFAULT_TABLE_TYPE, full_schema, qlexpr::IndexMap(),
std::nullopt /* index_info */, 0 /* schema_version */, partition.first,
"" /* pg_table_id */, tablet::SkipTableTombstoneCheck::kFalse);
Expand Down

0 comments on commit 45496e4

Please sign in to comment.