Mercurial > hg > orthanc
comparison OrthancFramework/UnitTestsSources/FrameworkTests.cpp @ 5336:dd9795dc380d
renamed MetricsType as MetricsUpdate to clarify
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 27 Jun 2023 15:56:04 +0200 |
parents | 5b2a5cc64cb1 |
children | b376abae664a |
comparison
equal
deleted
inserted
replaced
5335:c103b0e70d75 | 5336:dd9795dc380d |
---|---|
1319 ASSERT_TRUE(s.empty()); | 1319 ASSERT_TRUE(s.empty()); |
1320 } | 1320 } |
1321 | 1321 |
1322 { | 1322 { |
1323 MetricsRegistry m; | 1323 MetricsRegistry m; |
1324 m.Register("hello.world", MetricsType_Default); | 1324 m.Register("hello.world", MetricsUpdate_Directly); |
1325 | 1325 |
1326 std::string s; | 1326 std::string s; |
1327 m.ExportPrometheusText(s); | 1327 m.ExportPrometheusText(s); |
1328 ASSERT_TRUE(s.empty()); | 1328 ASSERT_TRUE(s.empty()); |
1329 } | 1329 } |
1330 | 1330 |
1331 { | 1331 { |
1332 MetricsRegistry m; | 1332 MetricsRegistry m; |
1333 m.SetValue("hello.world", -42); | 1333 m.SetValue("hello.world", -42); |
1334 ASSERT_EQ(MetricsType_Default, m.GetMetricsType("hello.world")); | 1334 ASSERT_EQ(MetricsUpdate_Directly, m.GetMetricsUpdate("hello.world")); |
1335 ASSERT_THROW(m.GetMetricsType("nope"), OrthancException); | 1335 ASSERT_THROW(m.GetMetricsUpdate("nope"), OrthancException); |
1336 | 1336 |
1337 std::string s; | 1337 std::string s; |
1338 m.ExportPrometheusText(s); | 1338 m.ExportPrometheusText(s); |
1339 | 1339 |
1340 std::vector<std::string> t; | 1340 std::vector<std::string> t; |
1344 ASSERT_TRUE(t[1].empty()); | 1344 ASSERT_TRUE(t[1].empty()); |
1345 } | 1345 } |
1346 | 1346 |
1347 { | 1347 { |
1348 MetricsRegistry m; | 1348 MetricsRegistry m; |
1349 m.Register("hello.max", MetricsType_MaxOver10Seconds); | 1349 m.Register("hello.max", MetricsUpdate_MaxOver10Seconds); |
1350 m.SetValue("hello.max", 10); | 1350 m.SetValue("hello.max", 10); |
1351 m.SetValue("hello.max", 20); | 1351 m.SetValue("hello.max", 20); |
1352 m.SetValue("hello.max", -10); | 1352 m.SetValue("hello.max", -10); |
1353 m.SetValue("hello.max", 5); | 1353 m.SetValue("hello.max", 5); |
1354 | 1354 |
1355 m.Register("hello.min", MetricsType_MinOver10Seconds); | 1355 m.Register("hello.min", MetricsUpdate_MinOver10Seconds); |
1356 m.SetValue("hello.min", 10); | 1356 m.SetValue("hello.min", 10); |
1357 m.SetValue("hello.min", 20); | 1357 m.SetValue("hello.min", 20); |
1358 m.SetValue("hello.min", -10); | 1358 m.SetValue("hello.min", -10); |
1359 m.SetValue("hello.min", 5); | 1359 m.SetValue("hello.min", 5); |
1360 | 1360 |
1361 m.Register("hello.default", MetricsType_Default); | 1361 m.Register("hello.directly", MetricsUpdate_Directly); |
1362 m.SetValue("hello.default", 10); | 1362 m.SetValue("hello.directly", 10); |
1363 m.SetValue("hello.default", 20); | 1363 m.SetValue("hello.directly", 20); |
1364 m.SetValue("hello.default", -10); | 1364 m.SetValue("hello.directly", -10); |
1365 m.SetValue("hello.default", 5); | 1365 m.SetValue("hello.directly", 5); |
1366 | 1366 |
1367 ASSERT_EQ(MetricsType_MaxOver10Seconds, m.GetMetricsType("hello.max")); | 1367 ASSERT_EQ(MetricsUpdate_MaxOver10Seconds, m.GetMetricsUpdate("hello.max")); |
1368 ASSERT_EQ(MetricsType_MinOver10Seconds, m.GetMetricsType("hello.min")); | 1368 ASSERT_EQ(MetricsUpdate_MinOver10Seconds, m.GetMetricsUpdate("hello.min")); |
1369 ASSERT_EQ(MetricsType_Default, m.GetMetricsType("hello.default")); | 1369 ASSERT_EQ(MetricsUpdate_Directly, m.GetMetricsUpdate("hello.directly")); |
1370 | 1370 |
1371 std::string s; | 1371 std::string s; |
1372 m.ExportPrometheusText(s); | 1372 m.ExportPrometheusText(s); |
1373 | 1373 |
1374 std::vector<std::string> t; | 1374 std::vector<std::string> t; |
1384 u[v[0]] = v[1]; | 1384 u[v[0]] = v[1]; |
1385 } | 1385 } |
1386 | 1386 |
1387 ASSERT_EQ("20", u["hello.max"]); | 1387 ASSERT_EQ("20", u["hello.max"]); |
1388 ASSERT_EQ("-10", u["hello.min"]); | 1388 ASSERT_EQ("-10", u["hello.min"]); |
1389 ASSERT_EQ("5", u["hello.default"]); | 1389 ASSERT_EQ("5", u["hello.directly"]); |
1390 } | 1390 } |
1391 | 1391 |
1392 { | 1392 { |
1393 MetricsRegistry m; | 1393 MetricsRegistry m; |
1394 | 1394 |
1395 m.SetValue("a", 10); | 1395 m.SetValue("a", 10); |
1396 m.SetValue("b", 10, MetricsType_MinOver10Seconds); | 1396 m.SetValue("b", 10, MetricsUpdate_MinOver10Seconds); |
1397 | 1397 |
1398 m.Register("c", MetricsType_MaxOver10Seconds); | 1398 m.Register("c", MetricsUpdate_MaxOver10Seconds); |
1399 m.SetValue("c", 10, MetricsType_MinOver10Seconds); | 1399 m.SetValue("c", 10, MetricsUpdate_MinOver10Seconds); |
1400 | 1400 |
1401 m.Register("d", MetricsType_MaxOver10Seconds); | 1401 m.Register("d", MetricsUpdate_MaxOver10Seconds); |
1402 m.Register("d", MetricsType_Default); | 1402 m.Register("d", MetricsUpdate_Directly); |
1403 | 1403 |
1404 ASSERT_EQ(MetricsType_Default, m.GetMetricsType("a")); | 1404 ASSERT_EQ(MetricsUpdate_Directly, m.GetMetricsUpdate("a")); |
1405 ASSERT_EQ(MetricsType_MinOver10Seconds, m.GetMetricsType("b")); | 1405 ASSERT_EQ(MetricsUpdate_MinOver10Seconds, m.GetMetricsUpdate("b")); |
1406 ASSERT_EQ(MetricsType_MaxOver10Seconds, m.GetMetricsType("c")); | 1406 ASSERT_EQ(MetricsUpdate_MaxOver10Seconds, m.GetMetricsUpdate("c")); |
1407 ASSERT_EQ(MetricsType_Default, m.GetMetricsType("d")); | 1407 ASSERT_EQ(MetricsUpdate_Directly, m.GetMetricsUpdate("d")); |
1408 } | 1408 } |
1409 | 1409 |
1410 { | 1410 { |
1411 MetricsRegistry m; | 1411 MetricsRegistry m; |
1412 | 1412 |
1413 { | 1413 { |
1414 MetricsRegistry::Timer t1(m, "a"); | 1414 MetricsRegistry::Timer t1(m, "a"); |
1415 MetricsRegistry::Timer t2(m, "b", MetricsType_MinOver10Seconds); | 1415 MetricsRegistry::Timer t2(m, "b", MetricsUpdate_MinOver10Seconds); |
1416 } | 1416 } |
1417 | 1417 |
1418 ASSERT_EQ(MetricsType_MaxOver10Seconds, m.GetMetricsType("a")); | 1418 ASSERT_EQ(MetricsUpdate_MaxOver10Seconds, m.GetMetricsUpdate("a")); |
1419 ASSERT_EQ(MetricsType_MinOver10Seconds, m.GetMetricsType("b")); | 1419 ASSERT_EQ(MetricsUpdate_MinOver10Seconds, m.GetMetricsUpdate("b")); |
1420 } | 1420 } |
1421 } | 1421 } |
1422 #endif | 1422 #endif |
1423 | 1423 |
1424 | 1424 |