aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorponasenko-rs <ponasenko-rs@yandex-team.com>2024-03-20 13:41:59 +0300
committerponasenko-rs <ponasenko-rs@yandex-team.com>2024-03-20 14:36:54 +0300
commita352a04f477457eb94fc8d4ab61a97e0993d8d37 (patch)
tree8b9f6c6b87d998f44c1ce5d7e13063ba1c0a0f30
parent74e58239b8cbb4b8e235693bfc2d12b7c9675c74 (diff)
downloadydb-a352a04f477457eb94fc8d4ab61a97e0993d8d37.tar.gz
YT-21146: Test chaos replica misconfiguration
b9b60f9a70f2cf90759a16b03e5fbfd886f21c01
-rw-r--r--yt/yt/client/chaos_client/helpers.cpp17
-rw-r--r--yt/yt/client/chaos_client/replication_card.cpp8
-rw-r--r--yt/yt/client/chaos_client/replication_card.h5
3 files changed, 30 insertions, 0 deletions
diff --git a/yt/yt/client/chaos_client/helpers.cpp b/yt/yt/client/chaos_client/helpers.cpp
index d6ddbb0c01..377011c913 100644
--- a/yt/yt/client/chaos_client/helpers.cpp
+++ b/yt/yt/client/chaos_client/helpers.cpp
@@ -60,6 +60,23 @@ TCellTag GetSiblingChaosCellTag(TCellTag cellTag)
return TCellTag(cellTag.Underlying() ^ 1);
}
+bool IsValidReplicationProgress(const TReplicationProgress& progress)
+{
+ const auto& segments = progress.Segments;
+
+ if (segments.empty()) {
+ return false;
+ }
+
+ for (int segmentIndex = 1; segmentIndex < std::ssize(segments); ++segmentIndex) {
+ if (segments[segmentIndex - 1].LowerKey >= segments[segmentIndex].LowerKey) {
+ return false;
+ }
+ }
+
+ return segments.back().LowerKey < progress.UpperKey;
+}
+
bool IsOrderedTabletReplicationProgress(const TReplicationProgress& progress)
{
const auto& segments = progress.Segments;
diff --git a/yt/yt/client/chaos_client/replication_card.cpp b/yt/yt/client/chaos_client/replication_card.cpp
index 3f58b6d74f..69076d4cf7 100644
--- a/yt/yt/client/chaos_client/replication_card.cpp
+++ b/yt/yt/client/chaos_client/replication_card.cpp
@@ -672,6 +672,14 @@ std::vector<TReplicationProgress> ScatterReplicationProgress(
return result;
}
+bool IsReplicaLocationValid(
+ const TReplicaInfo* replica,
+ const NYPath::TYPath& tablePath,
+ const TString& clusterName)
+{
+ return replica->ReplicaPath == tablePath && replica->ClusterName == clusterName;
+}
+
////////////////////////////////////////////////////////////////////////////////
} // namespace NYT::NChaosClient
diff --git a/yt/yt/client/chaos_client/replication_card.h b/yt/yt/client/chaos_client/replication_card.h
index 43f424567e..aba106b65f 100644
--- a/yt/yt/client/chaos_client/replication_card.h
+++ b/yt/yt/client/chaos_client/replication_card.h
@@ -179,6 +179,11 @@ std::vector<TReplicationProgress> ScatterReplicationProgress(
const std::vector<NTableClient::TUnversionedRow>& pivotKeys,
NTableClient::TUnversionedRow upperKey);
+bool IsReplicaLocationValid(
+ const TReplicaInfo* replica,
+ const NYPath::TYPath& tablePath,
+ const TString& clusterName);
+
////////////////////////////////////////////////////////////////////////////////
} // namespace NYT::NChaosClient