aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorabcdef <akotov@ydb.tech>2023-07-25 13:33:32 +0300
committerroot <root@qavm-2ed34686.qemu>2023-07-25 13:33:32 +0300
commit977eb634af1ea835560d2bb2c6ae6f28410a9f90 (patch)
tree63afbb295fee4a7bfdfdeadd66e204e15b86664a
parentcaf4520026f5517ea48ecde3467e195dc7981b7c (diff)
downloadydb-977eb634af1ea835560d2bb2c6ae6f28410a9f90.tar.gz
В методе `CreateTopicNoLegacy` используется такой же набор кодеков что и в методе `CreateTopic`
https://a.yandex-team.ru/arcadia/ydb/core/testlib/test_pq_client.h?rev=users%2Fabcdef%2FLOGBROKER-8499#L144
-rw-r--r--ydb/core/testlib/test_pq_client.h92
1 files changed, 59 insertions, 33 deletions
diff --git a/ydb/core/testlib/test_pq_client.h b/ydb/core/testlib/test_pq_client.h
index db5cf358af8..6c44df0c416 100644
--- a/ydb/core/testlib/test_pq_client.h
+++ b/ydb/core/testlib/test_pq_client.h
@@ -880,39 +880,18 @@ public:
void CreateTopicNoLegacy(const TString& name, ui32 partsCount, bool doWait = true, bool canWrite = true,
const TMaybe<TString>& dc = Nothing(), TVector<TString> rr = {"user"},
- const TMaybe<TString>& account = Nothing(), bool expectFail = false
- ) {
- Cerr << "CreateTopicNoLegacy: " << name << Endl;
-
- TString path = name;
- if (UseConfigTables && !path.StartsWith("/Root") && !account.Defined()) {
- path = TStringBuilder() << "/Root/PQ/" << name;
- }
-
- auto pqClient = NYdb::NPersQueue::TPersQueueClient(*Driver);
- auto settings = NYdb::NPersQueue::TCreateTopicSettings().PartitionsCount(partsCount).ClientWriteDisabled(!canWrite);
- settings.FederationAccount(account);
- TVector<NYdb::NPersQueue::TReadRuleSettings> rrSettings;
- for (auto &user : rr) {
- rrSettings.push_back({NYdb::NPersQueue::TReadRuleSettings{}.ConsumerName(user)});
- }
- settings.ReadRules(rrSettings);
-
- Cerr << "Create topic: " << path << Endl;
- auto res = pqClient.CreateTopic(path, settings);
- //ToDo - hack, cannot avoid legacy compat yet as PQv1 still uses RequestProcessor from core/client/server
- if (UseConfigTables && !expectFail) {
- AddTopic(name, dc);
- }
- if (expectFail) {
- res.Wait();
- UNIT_ASSERT(!res.GetValue().IsSuccess());
- } else {
- Y_UNUSED(doWait);
- res.Wait();
- Cerr << "Create topic result: " << res.GetValue().IsSuccess() << " " << res.GetValue().GetIssues().ToString() << "\n";
- UNIT_ASSERT(res.GetValue().IsSuccess());
- }
+ const TMaybe<TString>& account = Nothing(), bool expectFail = false)
+ {
+ CreateTopicNoLegacy({
+ .Name = name,
+ .PartsCount = partsCount,
+ .DoWait = doWait,
+ .CanWrite = canWrite,
+ .Dc = dc,
+ .ReadRules = rr,
+ .Account = account,
+ .ExpectFail = expectFail
+ });
}
void WaitTopicInit(const TString& topic) {
@@ -1399,6 +1378,53 @@ public:
query << "DECLARE $version as Int64; " << GetAlterTopicsVersionQuery();
RunYqlDataQueryWithParams(query, params);
}
+
+ struct CreateTopicNoLegacyParams {
+ TString Name;
+ ui32 PartsCount;
+ bool DoWait = true;
+ bool CanWrite = true;
+ TMaybe<TString> Dc = Nothing();
+ TVector<TString> ReadRules = {"user"};
+ TMaybe<TString> Account = Nothing();
+ bool ExpectFail = false;
+ TVector<NYdb::NPersQueue::ECodec> Codecs = NYdb::NPersQueue::GetDefaultCodecs();
+ };
+
+ void CreateTopicNoLegacy(const CreateTopicNoLegacyParams& params)
+ {
+ Cerr << "CreateTopicNoLegacy: " << params.Name << Endl;
+
+ TString path = params.Name;
+ if (UseConfigTables && !path.StartsWith("/Root") && !params.Account.Defined()) {
+ path = TStringBuilder() << "/Root/PQ/" << params.Name;
+ }
+
+ auto pqClient = NYdb::NPersQueue::TPersQueueClient(*Driver);
+ auto settings = NYdb::NPersQueue::TCreateTopicSettings().PartitionsCount(params.PartsCount).ClientWriteDisabled(!params.CanWrite);
+ settings.FederationAccount(params.Account);
+ settings.SupportedCodecs(params.Codecs);
+ TVector<NYdb::NPersQueue::TReadRuleSettings> rrSettings;
+ for (auto &user : params.ReadRules) {
+ rrSettings.push_back({NYdb::NPersQueue::TReadRuleSettings{}.ConsumerName(user)});
+ }
+ settings.ReadRules(rrSettings);
+
+ Cerr << "Create topic: " << path << Endl;
+ auto res = pqClient.CreateTopic(path, settings);
+ //ToDo - hack, cannot avoid legacy compat yet as PQv1 still uses RequestProcessor from core/client/server
+ if (UseConfigTables && !params.ExpectFail) {
+ AddTopic(params.Name, params.Dc);
+ }
+ if (params.ExpectFail) {
+ res.Wait();
+ UNIT_ASSERT(!res.GetValue().IsSuccess());
+ } else {
+ res.Wait();
+ Cerr << "Create topic result: " << res.GetValue().IsSuccess() << " " << res.GetValue().GetIssues().ToString() << "\n";
+ UNIT_ASSERT(res.GetValue().IsSuccess());
+ }
+ }
};
} // namespace NPersQueueTests