Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[plugin-kafka] Remove Kafka deprecated steps #4237

Merged
merged 1 commit into from
Aug 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 0 additions & 29 deletions docs/modules/plugins/pages/plugin-kafka.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.

Expand All @@ -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].
Expand All @@ -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].
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -178,40 +177,6 @@ public void startKafkaListener(String consumerKey, Set<String> 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:
* <ul>
* <li>less than (&lt;)</li>
* <li>less than or equal to (&lt;=)</li>
* <li>greater than (&gt;)</li>
* <li>greater than or equal to (&gt;=)</li>
* <li>equal to (=)</li>
* <li>not equal to (!=)</li>
* </ul>
* @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<Integer> 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.
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -140,27 +140,6 @@ static Stream<Arguments> kafkaOperations()
}));
}

@ParameterizedTest
@MethodSource("kafkaOperations")
void shouldProduceMessagesToAndConsumeMessagesFromKafka(BiConsumer<KafkaSteps, VariableContext> 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<KafkaSteps, VariableContext> test)
Expand Down
22 changes: 0 additions & 22 deletions vividus-tests/src/main/resources/story/system/Kafka.story
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Loading