diff --git a/code/test/components/jomjol-flowcontroll/test_flow_postrocess_helper.cpp b/code/test/components/jomjol-flowcontroll/test_flow_postrocess_helper.cpp index 07f2eedaa..2b31bfe27 100644 --- a/code/test/components/jomjol-flowcontroll/test_flow_postrocess_helper.cpp +++ b/code/test/components/jomjol-flowcontroll/test_flow_postrocess_helper.cpp @@ -3,7 +3,7 @@ #include "esp_log.h" -static const char *TAG = "POSTPROC_TEST"; +static const char *TAG_PPTEST = "POSTPROC_TEST"; UnderTestPost* setUpClassFlowPostprocessing(t_CNNType digType, t_CNNType anaType) @@ -30,7 +30,7 @@ UnderTestPost* setUpClassFlowPostprocessing(t_CNNType digType, t_CNNType anaType std::string process_doFlow(UnderTestPost* _underTestPost) { - std::string time; + std::string time; // run test TEST_ASSERT_TRUE(_underTestPost->doFlow(time)); @@ -44,7 +44,7 @@ std::string process_doFlow(std::vector analog, std::vector digits, { // setup the classundertest UnderTestPost* _undertestPost = init_do_flow(analog, digits, digType, checkConsistency, extendedResolution, decimal_shift); - ESP_LOGD(TAG, "SetupClassFlowPostprocessing completed."); + ESP_LOGD(TAG_PPTEST, "SetupClassFlowPostprocessing completed."); std::string time; // run test @@ -94,7 +94,7 @@ UnderTestPost* init_do_flow(std::vector analog, std::vector digits } else { _undertestPost->flowAnalog = NULL; } - ESP_LOGD(TAG, "Setting up of ROIs completed."); + ESP_LOGD(TAG_PPTEST, "Setting up of ROIs completed."); _undertestPost->InitNUMBERS(); @@ -111,7 +111,7 @@ UnderTestPost* init_do_flow(std::vector analog, std::vector digits void SetFallbackValue(UnderTestPost* _underTestPost, double _fallbackValue) { if (_fallbackValue > 0) { - ESP_LOGD(TAG, "fallbackValue=%f", _fallbackValue); + ESP_LOGD(TAG_PPTEST, "fallbackValue=%f", _fallbackValue); std::vector* NUMBERS = _underTestPost->GetNumbers(); for (int _n = 0; _n < (*NUMBERS).size(); ++_n) { (*NUMBERS)[_n]->fallbackValue = _fallbackValue; @@ -124,7 +124,7 @@ void SetFallbackValue(UnderTestPost* _underTestPost, double _fallbackValue) void setAllowNegatives(UnderTestPost* _underTestPost, bool _allowNegatives) { - ESP_LOGD(TAG, "checkConsistency=true"); + ESP_LOGD(TAG_PPTEST, "checkConsistency=true"); std::vector* NUMBERS = _underTestPost->GetNumbers(); for (int _n = 0; _n < (*NUMBERS).size(); ++_n) { (*NUMBERS)[_n]->allowNegativeRates = _allowNegatives; @@ -136,7 +136,7 @@ void setAllowNegatives(UnderTestPost* _underTestPost, bool _allowNegatives) void setConsitencyCheck(UnderTestPost* _underTestPost, bool _checkConsistency) { if (_checkConsistency) { - ESP_LOGD(TAG, "checkConsistency=true"); + ESP_LOGD(TAG_PPTEST, "checkConsistency=true"); std::vector* NUMBERS = _underTestPost->GetNumbers(); for (int _n = 0; _n < (*NUMBERS).size(); ++_n) { (*NUMBERS)[_n]->checkDigitIncreaseConsistency = true; @@ -161,7 +161,7 @@ void setDecimalShift(UnderTestPost* _underTestPost, int _decimal_shift) if (_decimal_shift!=0) { std::vector* NUMBERS = _underTestPost->GetNumbers(); for (int _n = 0; _n < (*NUMBERS).size(); ++_n) { - ESP_LOGD(TAG, "Setting decimal shift on number: %d to %d", _n, _decimal_shift); + ESP_LOGD(TAG_PPTEST, "Setting decimal shift on number: %d to %d", _n, _decimal_shift); (*NUMBERS)[_n]->decimalShift = _decimal_shift; } } @@ -173,7 +173,7 @@ void setAnalogdigitTransistionStart(UnderTestPost* _underTestPost, float _analog if (_analogdigitTransistionStart!=0) { std::vector* NUMBERS = _underTestPost->GetNumbers(); for (int _n = 0; _n < (*NUMBERS).size(); ++_n) { - ESP_LOGD(TAG, "Setting decimal shift on number: %d to %f", _n, _analogdigitTransistionStart); + ESP_LOGD(TAG_PPTEST, "Setting decimal shift on number: %d to %f", _n, _analogdigitTransistionStart); (*NUMBERS)[_n]->analogDigitalTransitionStart = _analogdigitTransistionStart; } } diff --git a/code/test/components/openmetrics/test_openmetrics.cpp b/code/test/components/openmetrics/test_openmetrics.cpp index 259a71161..e43c7ab40 100644 --- a/code/test/components/openmetrics/test_openmetrics.cpp +++ b/code/test/components/openmetrics/test_openmetrics.cpp @@ -1,12 +1,12 @@ #include -#include "openmetrics.h" +#include "openmetrics.cpp" void test_createMetric() { // simple happy path - const char *expected = "# HELP metric_name short description\n# TYPE metric_name gauge\nmetric_name 123.456\n"; - std::string result = createMetric("metric_name", "short description", "gauge", "123.456"); + const char *expected = "# TYPE metric_name gauge\n# HELP metric_name short description\nmetric_name 123.456\n"; + std::string result = createMetric("metric_name", "gauge", "short description", "123.456"); TEST_ASSERT_EQUAL_STRING(expected, result.c_str()); } @@ -40,23 +40,33 @@ void test_createSequenceMetrics() NumberPost *number_1 = new NumberPost; number_1->name = "main"; number_1->sActualValue = "123.456"; + number_1->sRatePerMin = "0.001"; sequences.push_back(number_1); - const std::string metricNamePrefix = "ai_on_the_edge_device"; - const std::string metricName = metricNamePrefix + "_flow_value"; + const std::string metricNamePrefix = "ai_on_the_edge_device_"; - std::string expected1 = "# HELP " + metricName + " current value of meter readout\n# TYPE " + metricName + " gauge\n" + - metricName + "{sequence=\"" + number_1->name + "\"} " + number_1->sActualValue + "\n"; + std::string expected1 = "# TYPE " + metricNamePrefix + "actual_value gauge\n# HELP " + metricNamePrefix + + "actual_value Actual value of meter\n" + metricNamePrefix + "actual_value{sequence=\"" + + number_1->name + "\"} " + number_1->sActualValue + "\n" + + "# TYPE " + metricNamePrefix + "rate_per_minute gauge\n# HELP " + metricNamePrefix + + "rate_per_minute Rate per minute of meter\n" + metricNamePrefix + "rate_per_minute{sequence=\"" + + number_1->name + "\"} " + number_1->sRatePerMin + "\n"; TEST_ASSERT_EQUAL_STRING(expected1.c_str(), createSequenceMetrics(metricNamePrefix, sequences).c_str()); NumberPost *number_2 = new NumberPost; number_2->name = "secondary"; number_2->sActualValue = "1.0"; + number_2->sRatePerMin = "0.0"; sequences.push_back(number_2); - std::string expected2 = "# HELP " + metricName + " current value of meter readout\n# TYPE " + metricName + " gauge\n" + - metricName + "{sequence=\"" + number_1->name + "\"} " + number_1->sActualValue + "\n" + - metricName + "{sequence=\"" + number_2->name + "\"} " + number_2->sActualValue + "\n"; + std::string expected2 = "# TYPE " + metricNamePrefix + "actual_value gauge\n# HELP " + metricNamePrefix + + "actual_value Actual value of meter\n" + metricNamePrefix + "actual_value{sequence=\"" + + number_1->name + "\"} " + number_1->sActualValue + "\n" + metricNamePrefix + "actual_value{sequence=\"" + + number_2->name + "\"} " + number_2->sActualValue + "\n" + + "# TYPE " + metricNamePrefix + "rate_per_minute gauge\n# HELP " + metricNamePrefix + + "rate_per_minute Rate per minute of meter\n" + metricNamePrefix + "rate_per_minute{sequence=\"" + + number_1->name + "\"} " + number_1->sRatePerMin + "\n" + metricNamePrefix + "rate_per_minute{sequence=\"" + + number_2->name + "\"} " + number_2->sRatePerMin + "\n"; TEST_ASSERT_EQUAL_STRING(expected2.c_str(), createSequenceMetrics(metricNamePrefix, sequences).c_str()); }