You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by "lordgamez (via GitHub)" <gi...@apache.org> on 2023/09/27 07:17:59 UTC
[GitHub] [nifi-minifi-cpp] lordgamez opened a new pull request, #1668: MINIFICPP-2226 Remove flakiness from LoggerTests
lordgamez opened a new pull request, #1668:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1668
Randomization is removed from the testcase to remove flakiness. We only check if multiple segments are present in the compressed logs.
https://issues.apache.org/jira/browse/MINIFICPP-2226
------------------
Thank you for submitting a contribution to Apache NiFi - MiNiFi C++.
In order to streamline the review of the contribution we ask you
to ensure the following steps have been taken:
### For all changes:
- [ ] Is there a JIRA ticket associated with this PR? Is it referenced
in the commit message?
- [ ] Does your PR title start with MINIFICPP-XXXX where XXXX is the JIRA number you are trying to resolve? Pay particular attention to the hyphen "-" character.
- [ ] Has your PR been rebased against the latest commit within the target branch (typically main)?
- [ ] Is your initial contribution a single, squashed commit?
### For code changes:
- [ ] If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under [ASF 2.0](http://www.apache.org/legal/resolved.html#category-a)?
- [ ] If applicable, have you updated the LICENSE file?
- [ ] If applicable, have you updated the NOTICE file?
### For documentation related changes:
- [ ] Have you ensured that format looks appropriate for the output in which it is rendered?
### Note:
Please ensure that once the PR is submitted, you check GitHub Actions CI results for build issues and submit an update to your PR as soon as possible.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nifi-minifi-cpp] fgerlits commented on a diff in pull request #1668: MINIFICPP-2226 Remove flakiness from LoggerTests
Posted by "fgerlits (via GitHub)" <gi...@apache.org>.
fgerlits commented on code in PR #1668:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1668#discussion_r1338519909
##########
libminifi/test/unit/LoggerTests.cpp:
##########
@@ -364,24 +363,14 @@ TEST_CASE("Test sending multiple segments at once", "[ttl16]") {
log_config.initialize(properties);
auto logger = log_config.getLogger("CompressionTestMultiSegment");
- std::random_device rd;
- std::mt19937 eng(rd());
- constexpr const char * TEXT_CHARS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
- const int index_of_last_char = gsl::narrow<int>(strlen(TEXT_CHARS)) - 1;
- std::uniform_int_distribution<> distr(0, index_of_last_char);
- std::vector<char> data(100);
- std::string log_str;
- const size_t SEGMENT_COUNT = 5;
- for (size_t idx = 0; idx < SEGMENT_COUNT; ++idx) {
- std::generate_n(data.begin(), data.size(), [&] { return TEXT_CHARS[static_cast<uint8_t>(distr(eng))]; });
- log_str = std::string{data.begin(), data.end()} + "." + std::to_string(idx);
+ std::string log_str = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
+ for (size_t i = 0; i < 100; ++i) {
logger->log_error(log_str.c_str());
}
LoggerTestAccessor::runCompression(log_config);
-
auto compressed_logs = logging::LoggerConfiguration::getCompressedLogs();
- REQUIRE(compressed_logs.size() == SEGMENT_COUNT);
- auto logs = decompress(compressed_logs[SEGMENT_COUNT - 1]);
+ REQUIRE(compressed_logs.size() > 1);
Review Comment:
I like the idea of logging 5 different messages instead of the same message 5 times, but I don't insist on randomization. Appending a number to the message would be fine, too. Although testing the compression with different strings, not just 5 hard-coded ones, does have value.
On the other hand, I have done some experiments, and now I don't think the test is flaky: it looks like `getCompressedLogs()` itself returns non-deterministic results. Out of the [0, 1, 2, 3, 4] log lines sent, I have seen cases where we receive [0, 2, 3, 4] or [0, 1, 3, 4] or [0, 2, 3, 4, 1].
I would prefer to keep the test as it was (removing the randomness if you don't like it), and to fix the code itself.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nifi-minifi-cpp] lordgamez commented on a diff in pull request #1668: MINIFICPP-2226 Remove flakiness from LoggerTests
Posted by "lordgamez (via GitHub)" <gi...@apache.org>.
lordgamez commented on code in PR #1668:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1668#discussion_r1338438770
##########
libminifi/test/unit/LoggerTests.cpp:
##########
@@ -364,24 +363,14 @@ TEST_CASE("Test sending multiple segments at once", "[ttl16]") {
log_config.initialize(properties);
auto logger = log_config.getLogger("CompressionTestMultiSegment");
- std::random_device rd;
- std::mt19937 eng(rd());
- constexpr const char * TEXT_CHARS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
- const int index_of_last_char = gsl::narrow<int>(strlen(TEXT_CHARS)) - 1;
- std::uniform_int_distribution<> distr(0, index_of_last_char);
- std::vector<char> data(100);
- std::string log_str;
- const size_t SEGMENT_COUNT = 5;
- for (size_t idx = 0; idx < SEGMENT_COUNT; ++idx) {
- std::generate_n(data.begin(), data.size(), [&] { return TEXT_CHARS[static_cast<uint8_t>(distr(eng))]; });
- log_str = std::string{data.begin(), data.end()} + "." + std::to_string(idx);
+ std::string log_str = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
+ for (size_t i = 0; i < 100; ++i) {
logger->log_error(log_str.c_str());
}
LoggerTestAccessor::runCompression(log_config);
-
auto compressed_logs = logging::LoggerConfiguration::getCompressedLogs();
- REQUIRE(compressed_logs.size() == SEGMENT_COUNT);
- auto logs = decompress(compressed_logs[SEGMENT_COUNT - 1]);
+ REQUIRE(compressed_logs.size() > 1);
Review Comment:
The point of this test case was to see if multiple segments are sent if the compressed logs are segmented due to their size. If it can be achieved by using fix input log entries, it should be enough to test this use case, and the result should be more consistent. Why do you think the randomization in this test should be kept?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nifi-minifi-cpp] fgerlits commented on a diff in pull request #1668: MINIFICPP-2226 Remove flakiness from LoggerTests
Posted by "fgerlits (via GitHub)" <gi...@apache.org>.
fgerlits commented on code in PR #1668:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1668#discussion_r1338259169
##########
libminifi/test/unit/LoggerTests.cpp:
##########
@@ -364,24 +363,14 @@ TEST_CASE("Test sending multiple segments at once", "[ttl16]") {
log_config.initialize(properties);
auto logger = log_config.getLogger("CompressionTestMultiSegment");
- std::random_device rd;
- std::mt19937 eng(rd());
- constexpr const char * TEXT_CHARS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
- const int index_of_last_char = gsl::narrow<int>(strlen(TEXT_CHARS)) - 1;
- std::uniform_int_distribution<> distr(0, index_of_last_char);
- std::vector<char> data(100);
- std::string log_str;
- const size_t SEGMENT_COUNT = 5;
- for (size_t idx = 0; idx < SEGMENT_COUNT; ++idx) {
- std::generate_n(data.begin(), data.size(), [&] { return TEXT_CHARS[static_cast<uint8_t>(distr(eng))]; });
- log_str = std::string{data.begin(), data.end()} + "." + std::to_string(idx);
+ std::string log_str = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
+ for (size_t i = 0; i < 100; ++i) {
logger->log_error(log_str.c_str());
}
LoggerTestAccessor::runCompression(log_config);
-
auto compressed_logs = logging::LoggerConfiguration::getCompressedLogs();
- REQUIRE(compressed_logs.size() == SEGMENT_COUNT);
- auto logs = decompress(compressed_logs[SEGMENT_COUNT - 1]);
+ REQUIRE(compressed_logs.size() > 1);
Review Comment:
I would prefer to keep the randomization and retry the check until it succeeds. For example:
```c++
CHECK(utils::verifyEventHappenedInPollTime(10s, [&] {
auto compressed_logs = logging::LoggerConfiguration::getCompressedLogs();
if (compressed_logs.size() != SEGMENT_COUNT) {
return false;
}
auto logs = decompress(compressed_logs.back());
return logs.find(log_str) != std::string::npos;
}));
```
EDIT: no, this can still fail sometimes. If it is OK to get 4 segments instead of 5, then I think the test needs to make it clearer why. As it is after this change, the test looks weak.
Also, I would keep the randomization, because I don't think that causes the flakiness, and it makes the test more realistic.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nifi-minifi-cpp] fgerlits commented on a diff in pull request #1668: MINIFICPP-2226 Remove flakiness from LoggerTests
Posted by "fgerlits (via GitHub)" <gi...@apache.org>.
fgerlits commented on code in PR #1668:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1668#discussion_r1338519909
##########
libminifi/test/unit/LoggerTests.cpp:
##########
@@ -364,24 +363,14 @@ TEST_CASE("Test sending multiple segments at once", "[ttl16]") {
log_config.initialize(properties);
auto logger = log_config.getLogger("CompressionTestMultiSegment");
- std::random_device rd;
- std::mt19937 eng(rd());
- constexpr const char * TEXT_CHARS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
- const int index_of_last_char = gsl::narrow<int>(strlen(TEXT_CHARS)) - 1;
- std::uniform_int_distribution<> distr(0, index_of_last_char);
- std::vector<char> data(100);
- std::string log_str;
- const size_t SEGMENT_COUNT = 5;
- for (size_t idx = 0; idx < SEGMENT_COUNT; ++idx) {
- std::generate_n(data.begin(), data.size(), [&] { return TEXT_CHARS[static_cast<uint8_t>(distr(eng))]; });
- log_str = std::string{data.begin(), data.end()} + "." + std::to_string(idx);
+ std::string log_str = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
+ for (size_t i = 0; i < 100; ++i) {
logger->log_error(log_str.c_str());
}
LoggerTestAccessor::runCompression(log_config);
-
auto compressed_logs = logging::LoggerConfiguration::getCompressedLogs();
- REQUIRE(compressed_logs.size() == SEGMENT_COUNT);
- auto logs = decompress(compressed_logs[SEGMENT_COUNT - 1]);
+ REQUIRE(compressed_logs.size() > 1);
Review Comment:
I like the idea of logging 5 different messages instead of the same message 5 times, but I don't insist on randomization. Appending a number to the message would be fine, too.
On the other hand, I have done some experiments, and now I don't think the test is flaky: it looks like `getCompressedLogs()` itself returns non-deterministic results. Out of the [0, 1, 2, 3, 4] log lines sent, I have seen cases where we receive [0, 2, 3, 4] or [0, 1, 3, 4] or [0, 2, 3, 4, 1].
I would prefer to keep the test as it was (removing the randomness if you don't like it), and to fix the code itself.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] MINIFICPP-2226 Remove flakiness from LoggerTests [nifi-minifi-cpp]
Posted by "lordgamez (via GitHub)" <gi...@apache.org>.
lordgamez commented on PR #1668:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1668#issuecomment-1755677105
@fgerlits took over the investigation of this ticket as it seems to be a bug not a flaky test case issue
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nifi-minifi-cpp] fgerlits commented on a diff in pull request #1668: MINIFICPP-2226 Remove flakiness from LoggerTests
Posted by "fgerlits (via GitHub)" <gi...@apache.org>.
fgerlits commented on code in PR #1668:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1668#discussion_r1338259169
##########
libminifi/test/unit/LoggerTests.cpp:
##########
@@ -364,24 +363,14 @@ TEST_CASE("Test sending multiple segments at once", "[ttl16]") {
log_config.initialize(properties);
auto logger = log_config.getLogger("CompressionTestMultiSegment");
- std::random_device rd;
- std::mt19937 eng(rd());
- constexpr const char * TEXT_CHARS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
- const int index_of_last_char = gsl::narrow<int>(strlen(TEXT_CHARS)) - 1;
- std::uniform_int_distribution<> distr(0, index_of_last_char);
- std::vector<char> data(100);
- std::string log_str;
- const size_t SEGMENT_COUNT = 5;
- for (size_t idx = 0; idx < SEGMENT_COUNT; ++idx) {
- std::generate_n(data.begin(), data.size(), [&] { return TEXT_CHARS[static_cast<uint8_t>(distr(eng))]; });
- log_str = std::string{data.begin(), data.end()} + "." + std::to_string(idx);
+ std::string log_str = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
+ for (size_t i = 0; i < 100; ++i) {
logger->log_error(log_str.c_str());
}
LoggerTestAccessor::runCompression(log_config);
-
auto compressed_logs = logging::LoggerConfiguration::getCompressedLogs();
- REQUIRE(compressed_logs.size() == SEGMENT_COUNT);
- auto logs = decompress(compressed_logs[SEGMENT_COUNT - 1]);
+ REQUIRE(compressed_logs.size() > 1);
Review Comment:
I would prefer to keep the randomization and retry the check until it succeeds. For example:
```c++
CHECK(utils::verifyEventHappenedInPollTime(10s, [&] {
auto compressed_logs = logging::LoggerConfiguration::getCompressedLogs();
if (compressed_logs.size() != SEGMENT_COUNT) {
return false;
}
auto logs = decompress(compressed_logs.back());
return logs.find(log_str) != std::string::npos;
}));
```
EDIT: no, this can still fail sometimes. If it is OK to get 4 segments instead of 5, then I think the test needs to make it clearer why. As it is after this change, the test looks weak.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nifi-minifi-cpp] fgerlits commented on a diff in pull request #1668: MINIFICPP-2226 Remove flakiness from LoggerTests
Posted by "fgerlits (via GitHub)" <gi...@apache.org>.
fgerlits commented on code in PR #1668:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1668#discussion_r1338259169
##########
libminifi/test/unit/LoggerTests.cpp:
##########
@@ -364,24 +363,14 @@ TEST_CASE("Test sending multiple segments at once", "[ttl16]") {
log_config.initialize(properties);
auto logger = log_config.getLogger("CompressionTestMultiSegment");
- std::random_device rd;
- std::mt19937 eng(rd());
- constexpr const char * TEXT_CHARS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
- const int index_of_last_char = gsl::narrow<int>(strlen(TEXT_CHARS)) - 1;
- std::uniform_int_distribution<> distr(0, index_of_last_char);
- std::vector<char> data(100);
- std::string log_str;
- const size_t SEGMENT_COUNT = 5;
- for (size_t idx = 0; idx < SEGMENT_COUNT; ++idx) {
- std::generate_n(data.begin(), data.size(), [&] { return TEXT_CHARS[static_cast<uint8_t>(distr(eng))]; });
- log_str = std::string{data.begin(), data.end()} + "." + std::to_string(idx);
+ std::string log_str = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
+ for (size_t i = 0; i < 100; ++i) {
logger->log_error(log_str.c_str());
}
LoggerTestAccessor::runCompression(log_config);
-
auto compressed_logs = logging::LoggerConfiguration::getCompressedLogs();
- REQUIRE(compressed_logs.size() == SEGMENT_COUNT);
- auto logs = decompress(compressed_logs[SEGMENT_COUNT - 1]);
+ REQUIRE(compressed_logs.size() > 1);
Review Comment:
I would prefer to keep the randomization and retry the check until it succeeds. For example:
```c++
CHECK(utils::verifyEventHappenedInPollTime(10s, [&] {
auto compressed_logs = logging::LoggerConfiguration::getCompressedLogs();
if (compressed_logs.size() != SEGMENT_COUNT) {
return false;
}
auto logs = decompress(compressed_logs.back());
return logs.find(log_str) != std::string::npos;
}));
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nifi-minifi-cpp] fgerlits commented on a diff in pull request #1668: MINIFICPP-2226 Remove flakiness from LoggerTests
Posted by "fgerlits (via GitHub)" <gi...@apache.org>.
fgerlits commented on code in PR #1668:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1668#discussion_r1338259169
##########
libminifi/test/unit/LoggerTests.cpp:
##########
@@ -364,24 +363,14 @@ TEST_CASE("Test sending multiple segments at once", "[ttl16]") {
log_config.initialize(properties);
auto logger = log_config.getLogger("CompressionTestMultiSegment");
- std::random_device rd;
- std::mt19937 eng(rd());
- constexpr const char * TEXT_CHARS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
- const int index_of_last_char = gsl::narrow<int>(strlen(TEXT_CHARS)) - 1;
- std::uniform_int_distribution<> distr(0, index_of_last_char);
- std::vector<char> data(100);
- std::string log_str;
- const size_t SEGMENT_COUNT = 5;
- for (size_t idx = 0; idx < SEGMENT_COUNT; ++idx) {
- std::generate_n(data.begin(), data.size(), [&] { return TEXT_CHARS[static_cast<uint8_t>(distr(eng))]; });
- log_str = std::string{data.begin(), data.end()} + "." + std::to_string(idx);
+ std::string log_str = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
+ for (size_t i = 0; i < 100; ++i) {
logger->log_error(log_str.c_str());
}
LoggerTestAccessor::runCompression(log_config);
-
auto compressed_logs = logging::LoggerConfiguration::getCompressedLogs();
- REQUIRE(compressed_logs.size() == SEGMENT_COUNT);
- auto logs = decompress(compressed_logs[SEGMENT_COUNT - 1]);
+ REQUIRE(compressed_logs.size() > 1);
Review Comment:
I would prefer to keep the randomization and retry the check until it succeeds. For example:
```c++
utils::verifyEventHappenedInPollTime(10s, [&] {
auto compressed_logs = logging::LoggerConfiguration::getCompressedLogs(10s);
if (compressed_logs.size() != SEGMENT_COUNT) {
return false;
}
auto logs = decompress(compressed_logs.back());
return logs.find(log_str) != std::string::npos;
});
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nifi-minifi-cpp] fgerlits commented on a diff in pull request #1668: MINIFICPP-2226 Remove flakiness from LoggerTests
Posted by "fgerlits (via GitHub)" <gi...@apache.org>.
fgerlits commented on code in PR #1668:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1668#discussion_r1338259169
##########
libminifi/test/unit/LoggerTests.cpp:
##########
@@ -364,24 +363,14 @@ TEST_CASE("Test sending multiple segments at once", "[ttl16]") {
log_config.initialize(properties);
auto logger = log_config.getLogger("CompressionTestMultiSegment");
- std::random_device rd;
- std::mt19937 eng(rd());
- constexpr const char * TEXT_CHARS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
- const int index_of_last_char = gsl::narrow<int>(strlen(TEXT_CHARS)) - 1;
- std::uniform_int_distribution<> distr(0, index_of_last_char);
- std::vector<char> data(100);
- std::string log_str;
- const size_t SEGMENT_COUNT = 5;
- for (size_t idx = 0; idx < SEGMENT_COUNT; ++idx) {
- std::generate_n(data.begin(), data.size(), [&] { return TEXT_CHARS[static_cast<uint8_t>(distr(eng))]; });
- log_str = std::string{data.begin(), data.end()} + "." + std::to_string(idx);
+ std::string log_str = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
+ for (size_t i = 0; i < 100; ++i) {
logger->log_error(log_str.c_str());
}
LoggerTestAccessor::runCompression(log_config);
-
auto compressed_logs = logging::LoggerConfiguration::getCompressedLogs();
- REQUIRE(compressed_logs.size() == SEGMENT_COUNT);
- auto logs = decompress(compressed_logs[SEGMENT_COUNT - 1]);
+ REQUIRE(compressed_logs.size() > 1);
Review Comment:
Was randomization of the content of the log lines really a problem? Do we understand why the number of segments is sometimes 4 instead of 5?
It seems to me that the change in this one line: "number of segments > 1" instead of "number of segments == 5" fixes the flakiness, but it makes the test much weaker.
I would prefer to track down the underlying reason why the segment count returned by `getCompressedLogs()` is not always 5, and fix that. (E.g. is there any multi-threading going on? can we add a timeout, or (better) some way to query if all pending tasks have finished?)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] MINIFICPP-2226 Remove flakiness from LoggerTests [nifi-minifi-cpp]
Posted by "lordgamez (via GitHub)" <gi...@apache.org>.
lordgamez closed pull request #1668: MINIFICPP-2226 Remove flakiness from LoggerTests
URL: https://github.com/apache/nifi-minifi-cpp/pull/1668
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nifi-minifi-cpp] lordgamez commented on a diff in pull request #1668: MINIFICPP-2226 Remove flakiness from LoggerTests
Posted by "lordgamez (via GitHub)" <gi...@apache.org>.
lordgamez commented on code in PR #1668:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1668#discussion_r1338932369
##########
libminifi/test/unit/LoggerTests.cpp:
##########
@@ -364,24 +363,14 @@ TEST_CASE("Test sending multiple segments at once", "[ttl16]") {
log_config.initialize(properties);
auto logger = log_config.getLogger("CompressionTestMultiSegment");
- std::random_device rd;
- std::mt19937 eng(rd());
- constexpr const char * TEXT_CHARS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
- const int index_of_last_char = gsl::narrow<int>(strlen(TEXT_CHARS)) - 1;
- std::uniform_int_distribution<> distr(0, index_of_last_char);
- std::vector<char> data(100);
- std::string log_str;
- const size_t SEGMENT_COUNT = 5;
- for (size_t idx = 0; idx < SEGMENT_COUNT; ++idx) {
- std::generate_n(data.begin(), data.size(), [&] { return TEXT_CHARS[static_cast<uint8_t>(distr(eng))]; });
- log_str = std::string{data.begin(), data.end()} + "." + std::to_string(idx);
+ std::string log_str = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
+ for (size_t i = 0; i < 100; ++i) {
logger->log_error(log_str.c_str());
}
LoggerTestAccessor::runCompression(log_config);
-
auto compressed_logs = logging::LoggerConfiguration::getCompressedLogs();
- REQUIRE(compressed_logs.size() == SEGMENT_COUNT);
- auto logs = decompress(compressed_logs[SEGMENT_COUNT - 1]);
+ REQUIRE(compressed_logs.size() > 1);
Review Comment:
I think the inconsistency comes from the `LogCompressorSink` that creates a separate thread for processing and compressing the incoming logs in parallel. I will have to check it how the test can be changed to make the results more consistent.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nifi-minifi-cpp] lordgamez commented on a diff in pull request #1668: MINIFICPP-2226 Remove flakiness from LoggerTests
Posted by "lordgamez (via GitHub)" <gi...@apache.org>.
lordgamez commented on code in PR #1668:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1668#discussion_r1338932369
##########
libminifi/test/unit/LoggerTests.cpp:
##########
@@ -364,24 +363,14 @@ TEST_CASE("Test sending multiple segments at once", "[ttl16]") {
log_config.initialize(properties);
auto logger = log_config.getLogger("CompressionTestMultiSegment");
- std::random_device rd;
- std::mt19937 eng(rd());
- constexpr const char * TEXT_CHARS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
- const int index_of_last_char = gsl::narrow<int>(strlen(TEXT_CHARS)) - 1;
- std::uniform_int_distribution<> distr(0, index_of_last_char);
- std::vector<char> data(100);
- std::string log_str;
- const size_t SEGMENT_COUNT = 5;
- for (size_t idx = 0; idx < SEGMENT_COUNT; ++idx) {
- std::generate_n(data.begin(), data.size(), [&] { return TEXT_CHARS[static_cast<uint8_t>(distr(eng))]; });
- log_str = std::string{data.begin(), data.end()} + "." + std::to_string(idx);
+ std::string log_str = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
+ for (size_t i = 0; i < 100; ++i) {
logger->log_error(log_str.c_str());
}
LoggerTestAccessor::runCompression(log_config);
-
auto compressed_logs = logging::LoggerConfiguration::getCompressedLogs();
- REQUIRE(compressed_logs.size() == SEGMENT_COUNT);
- auto logs = decompress(compressed_logs[SEGMENT_COUNT - 1]);
+ REQUIRE(compressed_logs.size() > 1);
Review Comment:
I think the inconsistency comes from the `LogCompressorSink` that creates a separate thread for processing and compressing the incoming logs in parallel. I will have to check it how the test can be changed to make the results more consistent.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nifi-minifi-cpp] fgerlits commented on a diff in pull request #1668: MINIFICPP-2226 Remove flakiness from LoggerTests
Posted by "fgerlits (via GitHub)" <gi...@apache.org>.
fgerlits commented on code in PR #1668:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1668#discussion_r1338259169
##########
libminifi/test/unit/LoggerTests.cpp:
##########
@@ -364,24 +363,14 @@ TEST_CASE("Test sending multiple segments at once", "[ttl16]") {
log_config.initialize(properties);
auto logger = log_config.getLogger("CompressionTestMultiSegment");
- std::random_device rd;
- std::mt19937 eng(rd());
- constexpr const char * TEXT_CHARS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
- const int index_of_last_char = gsl::narrow<int>(strlen(TEXT_CHARS)) - 1;
- std::uniform_int_distribution<> distr(0, index_of_last_char);
- std::vector<char> data(100);
- std::string log_str;
- const size_t SEGMENT_COUNT = 5;
- for (size_t idx = 0; idx < SEGMENT_COUNT; ++idx) {
- std::generate_n(data.begin(), data.size(), [&] { return TEXT_CHARS[static_cast<uint8_t>(distr(eng))]; });
- log_str = std::string{data.begin(), data.end()} + "." + std::to_string(idx);
+ std::string log_str = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
+ for (size_t i = 0; i < 100; ++i) {
logger->log_error(log_str.c_str());
}
LoggerTestAccessor::runCompression(log_config);
-
auto compressed_logs = logging::LoggerConfiguration::getCompressedLogs();
- REQUIRE(compressed_logs.size() == SEGMENT_COUNT);
- auto logs = decompress(compressed_logs[SEGMENT_COUNT - 1]);
+ REQUIRE(compressed_logs.size() > 1);
Review Comment:
I would prefer to keep the randomization and retry the check until it succeeds. For example:
```c++
utils::verifyEventHappenedInPollTime(10s, [&] {
auto compressed_logs = logging::LoggerConfiguration::getCompressedLogs();
if (compressed_logs.size() != SEGMENT_COUNT) {
return false;
}
auto logs = decompress(compressed_logs.back());
return logs.find(log_str) != std::string::npos;
});
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org