@@ -119,4 +119,78 @@ TEST_F(Describe, TEST_NAME(Location)) {
119119 }
120120}
121121
122+ TEST_F (Describe, TEST_NAME(MetricsLevel)) {
123+ TTopicClient client (MakeDriver ());
124+
125+ // const std::uint32_t MetricsLevelDisabled = 0;
126+ // const std::uint32_t MetricsLevelDatabase = 1;
127+ const std::uint32_t MetricsLevelObject = 2 ;
128+ const std::uint32_t MetricsLevelDetailed = 3 ;
129+
130+ auto createTopic = [&](std::string topic, EMetricsLevel metricsLevel) {
131+ auto res = client.CreateTopic (topic, TCreateTopicSettings ().MetricsLevel (metricsLevel)).GetValueSync ();
132+ ASSERT_TRUE (res.IsSuccess ());
133+ };
134+
135+ auto setMetricsLevel = [&](std::string topic, EMetricsLevel metricsLevel) {
136+ auto res = client.AlterTopic (topic, TAlterTopicSettings ().SetMetricsLevel (metricsLevel)).GetValueSync ();
137+ ASSERT_TRUE (res.IsSuccess ());
138+ };
139+
140+ auto resetMetricsLevel = [&](std::string topic) {
141+ auto res = client.AlterTopic (topic, TAlterTopicSettings ().ResetMetricsLevel ()).GetValueSync ();
142+ ASSERT_TRUE (res.IsSuccess ());
143+ };
144+
145+ auto checkFlag = [&](std::string topic, std::optional<EMetricsLevel> expectedMetricsLevel) {
146+ auto res = client.DescribeTopic (topic, {}).GetValueSync ();
147+ Y_ENSURE (res.IsSuccess ());
148+ return res.GetTopicDescription ().GetMetricsLevel () == expectedMetricsLevel;
149+ };
150+
151+ {
152+ const std::string topic (" topic-with-counters" );
153+ createTopic (topic, MetricsLevelDetailed);
154+ checkFlag (topic, MetricsLevelDetailed);
155+ setMetricsLevel (topic, MetricsLevelObject);
156+ Y_ENSURE (checkFlag (topic, MetricsLevelObject));
157+
158+ {
159+ // Empty alter should change nothing.
160+ auto res = client.AlterTopic (topic).GetValueSync ();
161+ ASSERT_TRUE (res.IsSuccess ());
162+ Y_ENSURE (checkFlag (topic, MetricsLevelObject));
163+ }
164+
165+ {
166+ resetMetricsLevel (topic);
167+ Y_ENSURE (checkFlag (topic, {}));
168+ }
169+ }
170+
171+ {
172+ const std::string topic (" topic-without-counters-by-default" );
173+ auto res = client.CreateTopic (topic).GetValueSync ();
174+ ASSERT_TRUE (res.IsSuccess ());
175+ Y_ENSURE (checkFlag (topic, {}));
176+ setMetricsLevel (topic, MetricsLevelDetailed);
177+ Y_ENSURE (checkFlag (topic, MetricsLevelDetailed));
178+
179+ {
180+ // Empty alter should change nothing.
181+ auto res = client.AlterTopic (topic).GetValueSync ();
182+ ASSERT_TRUE (res.IsSuccess ());
183+ Y_ENSURE (checkFlag (topic, MetricsLevelDetailed));
184+ }
185+ }
186+
187+ {
188+ const std::string topic (" topic-without-counters" );
189+ createTopic (topic, MetricsLevelObject);
190+ Y_ENSURE (checkFlag (topic, MetricsLevelObject));
191+ setMetricsLevel (topic, MetricsLevelDetailed);
192+ Y_ENSURE (checkFlag (topic, MetricsLevelDetailed));
193+ }
194+ }
195+
122196}
0 commit comments