nifi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ab...@apache.org
Subject [nifi-minifi-cpp] branch main updated: MINIFICPP-1585 Rename enum values in ConsumeKafkaTests::PublishEvent
Date Mon, 07 Jun 2021 15:34:09 GMT
This is an automated email from the ASF dual-hosted git repository.

aboda pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/nifi-minifi-cpp.git


The following commit(s) were added to refs/heads/main by this push:
     new 4d12658  MINIFICPP-1585 Rename enum values in ConsumeKafkaTests::PublishEvent
4d12658 is described below

commit 4d12658952f553f1a8285ec5224698a72e708451
Author: Ferenc Gerlits <fgerlits@gmail.com>
AuthorDate: Mon Jun 7 10:03:05 2021 +0200

    MINIFICPP-1585 Rename enum values in ConsumeKafkaTests::PublishEvent
    
    TRANSACTION_COMMIT is defined in winnt.h as a macro, so the build fails
    on Windows.  I have renamed it, and a few other enum values for
    consistency.
    
    Also added /K to the VS2019 Windows CI job, to make sure bugs like this
    get caught in the CI stage in the future.
    
    Signed-off-by: Arpad Boda <aboda@apache.org>
    
    This closes #1102
---
 .github/workflows/ci.yml                          |  2 +-
 extensions/librdkafka/tests/ConsumeKafkaTests.cpp | 30 +++++++++++------------
 2 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 7cafa6f..c8399dc 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -154,7 +154,7 @@ jobs:
         run: |
           PATH %PATH%;C:\Program Files (x86)\Windows Kits\10\bin\10.0.19041.0\x64
           PATH %PATH%;C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\Roslyn
-          win_build_vs.bat build /2019 /64 /CI /S /A /PDH /L /R
+          win_build_vs.bat build /2019 /64 /CI /S /A /PDH /K /L /R
         shell: cmd
       - name: test
         run: cd build && ctest --timeout 300 --parallel 8 -C Release --output-on-failure
diff --git a/extensions/librdkafka/tests/ConsumeKafkaTests.cpp b/extensions/librdkafka/tests/ConsumeKafkaTests.cpp
index c1d50f4..b011ea1 100644
--- a/extensions/librdkafka/tests/ConsumeKafkaTests.cpp
+++ b/extensions/librdkafka/tests/ConsumeKafkaTests.cpp
@@ -43,9 +43,9 @@ class KafkaTestProducer {
  public:
   enum class PublishEvent {
     PUBLISH,
-    TRANSACTION_START,
-    TRANSACTION_COMMIT,
-    CANCEL
+    BEGIN_TRANSACTION,
+    END_TRANSACTION,
+    CANCEL_TRANSACTION
   };
   KafkaTestProducer(const std::string& kafka_brokers, const std::string& topic, const
bool transactional) :
       logger_(logging::LoggerFactory<KafkaTestProducer>::getLogger()) {
@@ -88,15 +88,15 @@ class KafkaTestProducer {
           publish_message(*next_message, message_key, message_headers);
           std::advance(next_message, 1);
           break;
-        case PublishEvent::TRANSACTION_START:
+        case PublishEvent::BEGIN_TRANSACTION:
           logger_->log_debug("Starting new transaction...");
           rd_kafka_begin_transaction(producer_.get());
           break;
-        case PublishEvent::TRANSACTION_COMMIT:
+        case PublishEvent::END_TRANSACTION:
           logger_->log_debug("Committing transaction...");
           rd_kafka_commit_transaction(producer_.get(), TRANSACTIONS_TIMEOUT_MS.count());
           break;
-        case PublishEvent::CANCEL:
+        case PublishEvent::CANCEL_TRANSACTION:
           logger_->log_debug("Cancelling transaction...");
           rd_kafka_abort_transaction(producer_.get(), TRANSACTIONS_TIMEOUT_MS.count());
       }
@@ -147,15 +147,15 @@ class ConsumeKafkaTest {
   using ExtractText = org::apache::nifi::minifi::processors::ExtractText;
 
   const KafkaTestProducer::PublishEvent PUBLISH            = KafkaTestProducer::PublishEvent::PUBLISH;
-  const KafkaTestProducer::PublishEvent TRANSACTION_START  = KafkaTestProducer::PublishEvent::TRANSACTION_START;
-  const KafkaTestProducer::PublishEvent TRANSACTION_COMMIT = KafkaTestProducer::PublishEvent::TRANSACTION_COMMIT;
-  const KafkaTestProducer::PublishEvent CANCEL             = KafkaTestProducer::PublishEvent::CANCEL;
+  const KafkaTestProducer::PublishEvent BEGIN_TRANSACTION  = KafkaTestProducer::PublishEvent::BEGIN_TRANSACTION;
+  const KafkaTestProducer::PublishEvent END_TRANSACTION    = KafkaTestProducer::PublishEvent::END_TRANSACTION;
+  const KafkaTestProducer::PublishEvent CANCEL_TRANSACTION = KafkaTestProducer::PublishEvent::CANCEL_TRANSACTION;
 
   const std::vector<KafkaTestProducer::PublishEvent> NON_TRANSACTIONAL_MESSAGES   {
PUBLISH, PUBLISH };
-  const std::vector<KafkaTestProducer::PublishEvent> SINGLE_COMMITTED_TRANSACTION {
TRANSACTION_START, PUBLISH, PUBLISH, TRANSACTION_COMMIT };
-  const std::vector<KafkaTestProducer::PublishEvent> TWO_SEPARATE_TRANSACTIONS    {
TRANSACTION_START, PUBLISH, TRANSACTION_COMMIT, TRANSACTION_START, PUBLISH, TRANSACTION_COMMIT
};
-  const std::vector<KafkaTestProducer::PublishEvent> NON_COMMITTED_TRANSACTION    {
TRANSACTION_START, PUBLISH, PUBLISH };
-  const std::vector<KafkaTestProducer::PublishEvent> CANCELLED_TRANSACTION        {
TRANSACTION_START, PUBLISH, CANCEL };
+  const std::vector<KafkaTestProducer::PublishEvent> SINGLE_COMMITTED_TRANSACTION {
BEGIN_TRANSACTION, PUBLISH, PUBLISH, END_TRANSACTION };
+  const std::vector<KafkaTestProducer::PublishEvent> TWO_SEPARATE_TRANSACTIONS    {
BEGIN_TRANSACTION, PUBLISH, END_TRANSACTION, BEGIN_TRANSACTION, PUBLISH, END_TRANSACTION };
+  const std::vector<KafkaTestProducer::PublishEvent> NON_COMMITTED_TRANSACTION    {
BEGIN_TRANSACTION, PUBLISH, PUBLISH };
+  const std::vector<KafkaTestProducer::PublishEvent> CANCELLED_TRANSACTION        {
BEGIN_TRANSACTION, PUBLISH, CANCEL_TRANSACTION };
 
   const std::string KEEP_FIRST            = ConsumeKafka::MSG_HEADER_KEEP_FIRST;
   const std::string KEEP_LATEST           = ConsumeKafka::MSG_HEADER_KEEP_LATEST;
@@ -301,8 +301,8 @@ class ConsumeKafkaPropertiesTest : public ConsumeKafkaTest {
     std::unique_ptr<rd_kafka_conf_t, utils::rd_kafka_conf_deleter> conf_;
     std::unique_ptr<rd_kafka_t, utils::rd_kafka_consumer_deleter> consumer_;
 
-    const bool is_transactional = std::count(transaction_events.cbegin(), transaction_events.cend(),
KafkaTestProducer::PublishEvent::TRANSACTION_START);
-    const bool transactions_committed = transaction_events.back() == KafkaTestProducer::PublishEvent::TRANSACTION_COMMIT;
+    const bool is_transactional = std::count(transaction_events.cbegin(), transaction_events.cend(),
KafkaTestProducer::PublishEvent::BEGIN_TRANSACTION) != 0;
+    const bool transactions_committed = transaction_events.back() == KafkaTestProducer::PublishEvent::END_TRANSACTION;
 
     KafkaTestProducer producer(kafka_brokers, PRODUCER_TOPIC, is_transactional);
     producer.publish_messages_to_topic(messages_on_topic, TEST_MESSAGE_KEY, transaction_events,
message_headers);

Mime
View raw message