From 01330c8458b213aa38e823699aeab50ee839d7fe Mon Sep 17 00:00:00 2001 From: Uladzislau Arlouski Date: Wed, 16 Aug 2023 10:55:28 +0300 Subject: [PATCH] [plugin-kafka] Remove Kafka deprecated steps --- docs/modules/plugins/pages/plugin-kafka.adoc | 29 --------------- .../org/vividus/steps/kafka/KafkaSteps.java | 35 ------------------- .../resources/steps/defaults/deprecated.steps | 18 ---------- .../kafka/KafkaStepsIntegrationTests.java | 21 ----------- .../main/resources/story/system/Kafka.story | 22 ------------ 5 files changed, 125 deletions(-) delete mode 100644 vividus-plugin-kafka/src/main/resources/steps/defaults/deprecated.steps diff --git a/docs/modules/plugins/pages/plugin-kafka.adoc b/docs/modules/plugins/pages/plugin-kafka.adoc index ed8ba5b4b1..140de02d87 100644 --- a/docs/modules/plugins/pages/plugin-kafka.adoc +++ b/docs/modules/plugins/pages/plugin-kafka.adoc @@ -38,11 +38,6 @@ Sends the event with the value to the provided topic with no key or partition. When I send event with value `$value` to `$producerKey` Kafka topic `$topic` ---- -_Deprecated syntax (will be removed in VIVIDUS 0.6.0)_: -[source,gherkin] ----- -When I send data `$data` to `$producerKey` Kafka topic `$topic` ----- * `$value` - The event value. * `$producerKey` - The key of Kafka producer configuration. * `$topic` - The topic name. @@ -115,12 +110,6 @@ Starts the Kafka consumer with the provided configuration to listen the specifie When I start consuming events from `$consumerKey` Kafka topics `$topics` ---- -_Deprecated syntax (will be removed in VIVIDUS 0.6.0)_: -[source,gherkin] ----- -When I start consuming messages from `$consumerKey` Kafka topics `$topics` ----- - * `$consumerKey` - The key of the Kafka consumer configuration. * `$topics` - The comma-separated set of topics to listen. @@ -133,12 +122,6 @@ Drains/Peeks the consumed events to the specified variable. If the consumer is n When I $queueOperation consumed `$consumerKey` Kafka events to $scopes variable `$variableName` ---- -_Deprecated syntax (will be removed in VIVIDUS 0.6.0)_: -[source,gherkin] ----- -When I $queueOperation consumed `$consumerKey` Kafka messages to $scopes variable `$variableName` ----- - * `$queueOperation` - `DRAIN` - saves the events consumed since the last drain or from the consumption start and moves the consumer cursor to the position after the last consumed event, `PEEK` - saves the events consumed since the last drain or from the consumption start and doesn't change the consumer cursor position * `$consumerKey` - The key of the Kafka consumer configuration. * `$scopes` - xref:commons:variables.adoc#_scopes[The comma-separated set of the variables scopes]. @@ -153,12 +136,6 @@ Waits until the count of the consumed events (from the consumer start or after t When I wait with `$timeout` timeout until count of consumed `$consumerKey` Kafka events is $comparisonRule `$expectedCount` ---- -_Deprecated syntax (will be removed in VIVIDUS 0.6.0)_: -[source,gherkin] ----- -When I wait with `$timeout` timeout until count of consumed `$consumerKey` Kafka messages is $comparisonRule `$expectedCount` ----- - * `$timeout` - The maximum time to wait for the events in {durations-format-link} format. * `$consumerKey` - The key of the Kafka consumer configuration. * `$comparisonRule` - xref:parameters:comparison-rule.adoc[The comparison rule]. @@ -173,12 +150,6 @@ Stops the Kafka consumer started by the corresponding step before. All recorded When I stop consuming events from `$consumerKey` Kafka ---- -_Deprecated syntax (will be removed in VIVIDUS 0.6.0)_: -[source,gherkin] ----- -When I stop consuming messages from `$consumerKey` Kafka ----- - * `$consumerKey` - The key of the Kafka consumer configuration. === Examples diff --git a/vividus-plugin-kafka/src/main/java/org/vividus/steps/kafka/KafkaSteps.java b/vividus-plugin-kafka/src/main/java/org/vividus/steps/kafka/KafkaSteps.java index 0393b61e9e..e398804eea 100644 --- a/vividus-plugin-kafka/src/main/java/org/vividus/steps/kafka/KafkaSteps.java +++ b/vividus-plugin-kafka/src/main/java/org/vividus/steps/kafka/KafkaSteps.java @@ -54,7 +54,6 @@ import org.springframework.kafka.listener.GenericMessageListenerContainer; import org.springframework.kafka.listener.KafkaMessageListenerContainer; import org.springframework.kafka.listener.MessageListener; -import org.vividus.annotation.Replacement; import org.vividus.context.VariableContext; import org.vividus.softassert.ISoftAssert; import org.vividus.steps.ComparisonRule; @@ -178,40 +177,6 @@ public void startKafkaListener(String consumerKey, Set topics) LOGGER.info("Kafka event listener is started"); } - /** - * Waits until the count of the consumed messages (from the consumer start or after the last draining operation) - * matches to the rule or until the timeout is exceeded. - * - * @param timeout The maximum time to wait for the messages in ISO-8601 format - * @param consumerKey The key of the producer configuration - * @param comparisonRule The rule to match the quantity of messages. The supported rules: - * - * @param expectedCount The expected count of the messages to be matched by the rule - * @deprecated Use step: "When I wait with `$timeout` timeout until count of consumed `$consumerKey` Kafka events is - * $comparisonRule `$expectedCount`" - */ - @Deprecated(since = "0.5.6", forRemoval = true) - @Replacement(versionToRemoveStep = "0.6.0", replacementFormatPattern = - "When I wait with `%1$s` timeout until count of consumed `%2$s` Kafka events is %3$s `%4$s`") - @When("I wait with `$timeout` timeout until count of consumed `$consumerKey` Kafka messages is $comparisonRule" - + " `$expectedCount`") - public void waitForKafkaMessages(Duration timeout, String consumerKey, ComparisonRule comparisonRule, - int expectedCount) - { - Matcher countMatcher = comparisonRule.getComparisonRule(expectedCount); - Integer result = new DurationBasedWaiter(timeout, Duration.ofSeconds(1)).wait( - () -> getEventsBy(consumerKey).size(), - countMatcher::matches); - softAssert.assertThat("Total count of consumed Kafka messages", result, countMatcher); - } - /** * Waits until the count of the consumed events (from the consumer start or after the last draining operation) * matches to the rule or until the timeout is exceeded. diff --git a/vividus-plugin-kafka/src/main/resources/steps/defaults/deprecated.steps b/vividus-plugin-kafka/src/main/resources/steps/defaults/deprecated.steps deleted file mode 100644 index 6ab46c97cb..0000000000 --- a/vividus-plugin-kafka/src/main/resources/steps/defaults/deprecated.steps +++ /dev/null @@ -1,18 +0,0 @@ -Composite: When I send data `$data` to `$producerKey` Kafka topic `$topic` -!-- DEPRECATED: 0.6.0, When I send event with value `%1$s` to `%2$s` Kafka topic `%3$s` -When I send event with value `` to `` Kafka topic `` - - -Composite: When I start consuming messages from `$consumerKey` Kafka topics `$topics` -!-- DEPRECATED: 0.6.0, When I start consuming events from `%1$s` Kafka topics `%2$s` -When I start consuming events from `` Kafka topics `` - - -Composite: When I stop consuming messages from `$consumerKey` Kafka -!-- DEPRECATED: 0.6.0, When I stop consuming events from `%1$s` Kafka -When I stop consuming events from `` Kafka - - -Composite: When I $queueOperation consumed `$consumerKey` Kafka messages to $scopes variable `$variableName` -!-- DEPRECATED: 0.6.0, When I %1$s consumed `%2$s` Kafka events to %3$s variable `%4$s` -When I consumed `` Kafka events to variable `` diff --git a/vividus-plugin-kafka/src/test/java/org/vividus/steps/kafka/KafkaStepsIntegrationTests.java b/vividus-plugin-kafka/src/test/java/org/vividus/steps/kafka/KafkaStepsIntegrationTests.java index d6502add41..0207ffee3b 100644 --- a/vividus-plugin-kafka/src/test/java/org/vividus/steps/kafka/KafkaStepsIntegrationTests.java +++ b/vividus-plugin-kafka/src/test/java/org/vividus/steps/kafka/KafkaStepsIntegrationTests.java @@ -140,27 +140,6 @@ static Stream kafkaOperations() })); } - @ParameterizedTest - @MethodSource("kafkaOperations") - void shouldProduceMessagesToAndConsumeMessagesFromKafka(BiConsumer test) - throws InterruptedException, ExecutionException, TimeoutException - { - kafkaSteps.startKafkaListener(CONSUMER, Set.of(TOPIC)); - - kafkaSteps.sendEvent(ANY_DATA, PRODUCER, TOPIC); - - ComparisonRule comparisonRule = ComparisonRule.EQUAL_TO; - kafkaSteps.waitForKafkaMessages(Duration.ofSeconds(10), CONSUMER, comparisonRule, 1); - verify(softAssert).assertThat(eq("Total count of consumed Kafka messages"), eq(1), - argThat(matcher -> EQUAL_TO_ONE_MATCHER.equals(matcher.toString()))); - - kafkaSteps.stopKafkaListener(CONSUMER); - - assertThat(logger.getLoggingEvents(), is(List.of(info(LISTENER_STARTED), info(LISTENER_STOPPED)))); - - test.accept(kafkaSteps, variableContext); - } - @ParameterizedTest @MethodSource("kafkaOperations") void shouldProduceEventsToAndConsumeEventsFromKafka(BiConsumer test) diff --git a/vividus-tests/src/main/resources/story/system/Kafka.story b/vividus-tests/src/main/resources/story/system/Kafka.story index 36cb4feea3..da0e665dda 100644 --- a/vividus-tests/src/main/resources/story/system/Kafka.story +++ b/vividus-tests/src/main/resources/story/system/Kafka.story @@ -5,28 +5,6 @@ Meta: Scenario: Init Given I initialize story variable `topic` with value `hnzzmrpq-default` -Scenario: [DEPRECATED] Produce/consume data to/from Kafka -Given I initialize scenario variable `message` with value `{"message-from-system-vividus-test": "#{generate(regexify '[a-z]{8}')}"}` -When I start consuming messages from `vividus` Kafka topics `${topic}` -When I send data `${message}` to `vividus` Kafka topic `${topic}` -When I wait with `PT60S` timeout until count of consumed `vividus` Kafka messages is equal to `1` -When I stop consuming messages from `vividus` Kafka -When I drain consumed `vividus` Kafka messages to scenario variable `consumed-messages` -Then `${consumed-messages[0]}` is equal to `${message}` - - -Scenario: [DEPRECATED] Wait until expected message appears in the Kafka topic -When I start consuming messages from `vividus` Kafka topics `${topic}` -When I send data `{"key" : "failed"}` to `vividus` Kafka topic `${topic}` -When I send data `{"key" : "passed"}` to `vividus` Kafka topic `${topic}` -When I execute steps with delay `PT5S` at most 12 times while variable `messageCount` is = `0`: -|step | -|When I peek consumed `vividus` Kafka messages to scenario variable `messages` | -|When I save number of elements from `${messages}` found by JSON path `$..[?(@.key == "failed")]` to scenario variable `messageCount`| -When I drain consumed `vividus` Kafka messages to scenario variable `consumed-messages` -Then JSON element from `${consumed-messages}` by JSON path `$` is equal to `[{"key" : "failed"}, {"key" : "passed"}]` ignoring array order -When I stop consuming messages from `vividus` Kafka - Scenario: Produce/consume events to/from Kafka Meta: