41 std::string metricString;
45 metricString =
"[METRIC] data_relayer/1,0 1 1789372894 hostname=test.cern.chbar";
46 result = DeviceMetricsHelper::parseMetric(metricString,
match);
48 REQUIRE(strncmp(
match.beginKey,
"data_relayer/1", strlen(
"data_relayer/1")) == 0);
49 REQUIRE(
match.endKey -
match.beginKey == strlen(
"data_relayer/1"));
50 REQUIRE(
match.timestamp == 1789372894);
51 REQUIRE(
match.type == MetricType::Enum);
52 REQUIRE(
match.intValue == 1);
53 REQUIRE(
match.uint64Value == 1);
57 std::string metricString;
61 metricString =
"[METRIC] data_relayer/h,0 3 1662377068602 hostname=stillwater.dyndns.cern.ch,dataprocessor_id=D,dataprocessor_name=D,dpl_instance=0";
62 result = DeviceMetricsHelper::parseMetric(metricString,
match);
64 REQUIRE(strncmp(
match.beginKey,
"data_relayer/h", strlen(
"data_relayer/h")) == 0);
65 REQUIRE(
match.endKey -
match.beginKey == strlen(
"data_relayer/h"));
66 REQUIRE(
match.timestamp == 1662377068602);
67 REQUIRE(
match.type == MetricType::Int);
68 REQUIRE(
match.intValue == 3);
69 REQUIRE(
match.uint64Value == 3);
73 std::string metricString;
77 metricString =
"[14:00:44][INFO] metric-feedback[0]: in: 0 (0 MB) out: 0 (0";
78 result = DeviceMetricsHelper::parseMetric(metricString,
match);
86 std::string metricString;
92 metricString =
"foo[METRIC] bkey,0 12 1789372894 hostname=test.cern.chbar";
93 std::string_view metric{metricString.data() + 3, metricString.size() - 6};
94 REQUIRE(metric == std::string_view(
"[METRIC] bkey,0 12 1789372894 hostname=test.cern.ch"));
95 result = DeviceMetricsHelper::parseMetric(metric,
match);
97 REQUIRE(strncmp(
match.beginKey,
"bkey", 4) == 0);
98 REQUIRE(
match.timestamp == 1789372894);
99 REQUIRE(
match.type == MetricType::Int);
100 REQUIRE(
match.intValue == 12);
102 result = DeviceMetricsHelper::processMetric(
match, info);
106 REQUIRE(strncmp(info.
metricLabels[0].label,
"bkey", 4) == 0);
115 REQUIRE(info.
metrics.size() == 1);
116 REQUIRE(info.
metrics[0].type == MetricType::Int);
117 REQUIRE(info.
metrics[0].storeIdx == 0);
118 REQUIRE(info.
metrics[0].pos == 1);
125 metric =
"[METRIC] bkey,0 13 1789372894 hostname=test.cern.ch";
126 result = DeviceMetricsHelper::parseMetric(metric,
match);
128 REQUIRE(
match.intValue == 13);
129 result = DeviceMetricsHelper::processMetric(
match, info);
142 REQUIRE(info.
metrics[0].pos == 2);
145 metric =
"[METRIC] akey,0 14 1789372894 hostname=test.cern.ch";
146 result = DeviceMetricsHelper::parseMetric(metric,
match);
148 result = DeviceMetricsHelper::processMetric(
match, info);
165 REQUIRE(info.
metrics.size() == 2);
166 REQUIRE(info.
metrics[1].type == MetricType::Int);
167 REQUIRE(info.
metrics[1].storeIdx == 1);
168 REQUIRE(info.
metrics[1].pos == 1);
171 metric =
"[METRIC] key3,2 16.0 1789372894 hostname=test.cern.ch";
172 result = DeviceMetricsHelper::parseMetric(metric,
match);
174 result = DeviceMetricsHelper::processMetric(
match, info);
191 REQUIRE(info.
metrics.size() == 3);
194 REQUIRE(info.
metrics[2].type == MetricType::Float);
195 REQUIRE(info.
metrics[2].storeIdx == 0);
196 REQUIRE(info.
metrics[2].pos == 1);
199 metric =
"[METRIC] key3,2 17.0 1789372895 hostname=test.cern.ch";
200 result = DeviceMetricsHelper::parseMetric(metric,
match);
202 result = DeviceMetricsHelper::processMetric(
match, info);
215 REQUIRE(info.
metrics.size() == 3);
219 REQUIRE(info.
metrics[2].type == MetricType::Float);
220 REQUIRE(info.
metrics[2].storeIdx == 0);
221 REQUIRE(info.
metrics[2].pos == 2);
223 REQUIRE(DeviceMetricsHelper::metricIdxByName(
"akey", info) == 1);
224 REQUIRE(DeviceMetricsHelper::metricIdxByName(
"bkey", info) == 0);
225 REQUIRE(DeviceMetricsHelper::metricIdxByName(
"key3", info) == 2);
226 REQUIRE(DeviceMetricsHelper::metricIdxByName(
"foo", info) == 3);
229 metric =
"[METRIC] key4,1 some_string 1789372895 hostname=test.cern.ch";
230 result = DeviceMetricsHelper::parseMetric(metric,
match);
232 result = DeviceMetricsHelper::processMetric(
match, info);
248 REQUIRE(info.
metrics.size() == 4);
250 REQUIRE(info.
metrics[3].type == MetricType::String);
251 REQUIRE(info.
metrics[3].storeIdx == 0);
252 REQUIRE(info.
metrics[3].pos == 1);
256 metric =
"[METRIC] alien-file-name,1 alien:///alice/data/2015/LHC15o/000244918/pass5_lowIR/PWGZZ/Run3_Conversion/96_20201013-1346_child_1/0028/AO2D.root:/,631838549,ALICE::CERN::EOS 1789372895 hostname=test.cern.ch";
257 result = DeviceMetricsHelper::parseMetric(metric,
match);
259 result = DeviceMetricsHelper::processMetric(
match, info);
276 REQUIRE(info.
metrics.size() == 5);
278 REQUIRE(info.
metrics[4].type == MetricType::String);
279 REQUIRE(info.
metrics[4].storeIdx == 1);
280 REQUIRE(info.
metrics[4].pos == 1);
281 REQUIRE(std::string(info.
stringMetrics[1][0].data) == std::string(
"alien:///alice/data/2015/LHC15o/000244918/pass5_lowIR/PWGZZ/Run3_Conversion/96_20201013-1346_child_1/0028/AO2D.root:/,631838549,ALICE::CERN::EOS"));
285 metric =
"[METRIC] array/w,0 2 1789372895 hostname=test.cern.ch";
286 result = DeviceMetricsHelper::parseMetric(metric,
match);
288 result = DeviceMetricsHelper::processMetric(
match, info);
308 REQUIRE(info.
metrics.size() == 6);
312 metric =
"[METRIC] array/h,0 3 1789372895 hostname=test.cern.ch";
313 result = DeviceMetricsHelper::parseMetric(metric,
match);
315 result = DeviceMetricsHelper::processMetric(
match, info);
320 REQUIRE(info.
metrics.size() == 7);
324 metric =
"[METRIC] array/0,0 0 1789372895 hostname=test.cern.ch";
325 result = DeviceMetricsHelper::parseMetric(metric,
match);
327 result = DeviceMetricsHelper::processMetric(
match, info);
333 metric =
"[METRIC] array/1,0 1 1789372895 hostname=test.cern.ch";
334 result = DeviceMetricsHelper::parseMetric(metric,
match);
336 result = DeviceMetricsHelper::processMetric(
match, info);
342 metric =
"[METRIC] array/2,0 2 1789372895 hostname=test.cern.ch";
343 result = DeviceMetricsHelper::parseMetric(metric,
match);
345 result = DeviceMetricsHelper::processMetric(
match, info);
373 metric =
"[METRIC] array/2,0 2 1789372895 hostname=test.cern.ch";
374 result = DeviceMetricsHelper::parseMetric(metric,
match);
376 result = DeviceMetricsHelper::processMetric(
match, info);
381 auto array3 = DeviceMetricsHelper::createNumericMetric<int>(info,
"array/3");
409 metric =
"[METRIC] data_relayer/w,0 1 1789372895 hostname=test.cern.ch";
410 result = DeviceMetricsHelper::parseMetric(metric,
match);
412 REQUIRE(
match.type == MetricType::Int);
415 metric =
"[METRIC] data_relayer/h,0 1 1789372895 hostname=test.cern.ch";
416 result = DeviceMetricsHelper::parseMetric(metric,
match);
418 REQUIRE(
match.type == MetricType::Int);
421 metric =
"[METRIC] data_relayer/1,0 8 1789372895 hostname=test.cern.ch";
422 result = DeviceMetricsHelper::parseMetric(metric,
match);
424 REQUIRE(
match.type == MetricType::Enum);
431 auto bkey = DeviceMetricsHelper::createNumericMetric<int>(info,
"bkey");
434 auto akey = DeviceMetricsHelper::createNumericMetric<float>(info,
"akey");
437 auto ckey = DeviceMetricsHelper::createNumericMetric<uint64_t>(info,
"ckey");
440 REQUIRE(DeviceMetricsHelper::metricIdxByName(
"akey", info) == 1);
441 REQUIRE(DeviceMetricsHelper::metricIdxByName(
"bkey", info) == 0);
442 REQUIRE(DeviceMetricsHelper::metricIdxByName(
"ckey", info) == 2);
443 REQUIRE(info.
changed.size() == 3);
444 REQUIRE(info.
changed.at(0) ==
false);
452 REQUIRE(info.
metrics[0].filledMetrics == 6);
453 REQUIRE(info.
metrics[1].filledMetrics == 0);
454 REQUIRE(info.
metrics[2].filledMetrics == 0);
455 REQUIRE(info.
changed[0] ==
true);
462 REQUIRE(info.
changed[1] ==
false);
465 REQUIRE(info.
changed[0] ==
true);
466 REQUIRE(info.
changed[1] ==
false);
471 REQUIRE(info.
changed[0] ==
true);
472 REQUIRE(info.
changed[1] ==
true);
473 REQUIRE(info.
changed[2] ==
false);
474 REQUIRE(info.
metrics[0].filledMetrics == 7);
475 REQUIRE(info.
metrics[1].filledMetrics == 4);
476 REQUIRE(info.
metrics[2].filledMetrics == 0);
495 REQUIRE(info.
changed.size() == 3);
496 for (
int i = 0;
i < 1026; ++
i) {
502 REQUIRE(info.
metrics[0].filledMetrics == 7);
503 REQUIRE(info.
metrics[1].filledMetrics == 4);
504 REQUIRE(info.
metrics[2].filledMetrics == 1026);