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

chore: removing it profile #63

Merged
merged 17 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ jobs:
fi
if [ true == '${{matrix.it}}' ]; then
${PRE_CMD}
KALIX_TESTKIT_DEBUG=true mvn verify -Pit --no-transfer-progress
KALIX_TESTKIT_DEBUG=true mvn verify --no-transfer-progress
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can change this to AKKA_TESTKIT_DEBUG, but later.

franciscolopezsancho marked this conversation as resolved.
Show resolved Hide resolved
fi

- name: ${{ matrix.sample }} rm & test-compile
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
</includes>
</fileSet>
<fileSet filtered="true">
<directory>src/it/java</directory>
<directory>src/test/java</directory>
<includes>
<include>**/*</include>
</includes>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* It interacts with the components of the application using a componentClient
* (already configured and provided automatically through injection).
*/
public class IntegrationTest extends TestKitSupport {
public class HelloWorldIT extends TestKitSupport {
Copy link
Member

@octonato octonato Dec 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can keep this as IntegrationTest because IntegrationTest is excluded from the mvn test. Also, HelloWorldIT is completely unrelated with the archetype.

IMO, we should prefer suffixing the test with IntegrationTest instead of IT in all cases because it makes it more obvious.

I understand that the folks from the fail failsafe plugin had to choose for IT, because they don't know where it will be used. So they needed to step out of *IntegrationTest to avoid conflicts with the more general *Test.

But our parent pom configures the failsafe plugin and the surefire plugin. So we don't need to favor IT.

Then we have:

  • *Test for unit tests, picked by surefire. *IntegratrionTest are excluded.
  • *IntegratrionTest and all the variants with IT (as originally define by failsafe plugin). Those will be picked by failsafe plugin.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, my idea was to follow the convention but I think you make a valid point. It's for sure clearer.



@Test
Expand Down
58 changes: 36 additions & 22 deletions akka-javasdk-maven/akka-javasdk-parent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,6 @@


<build>
<resources>
<resource>
<directory>${basedir}/src/main/resources</directory>
</resource>
</resources>

<extensions>
<extension>
<groupId>kr.motd.maven</groupId>
Expand Down Expand Up @@ -284,7 +278,28 @@
</systemPropertyVariables>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>${maven-failsafe-plugin.version}</version>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
franciscolopezsancho marked this conversation as resolved.
Show resolved Hide resolved
</goals>
<configuration>
<includes>
<include>**/*IntegrationTest.java</include>
<include>**/*IT.java</include>
<include>**/IT*.java</include>
<include>**/*ITCase.java</include>
</includes>
<argLine>-Dlogback.configurationFile=${logback.configurationFile} -Dakka.javasdk.dev-mode.project-artifact-id=${project.artifactId}</argLine>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
Expand Down Expand Up @@ -334,6 +349,11 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand All @@ -359,36 +379,30 @@
<profiles>

<profile>
<!-- run Integration Tests in src/it/java with `mvn verify -Pit`-->
<id>it</id>
<build>
<plugins>
<plugin>
<!-- run *IntegrationTest with failsafe -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>${maven-failsafe-plugin.version}</version>
<groupId>org.codehaus.gmaven</groupId>
<artifactId>groovy-maven-plugin</artifactId>
<version>2.1.1</version>
<executions>
<execution>
<phase>integration-test</phase>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
<goal>execute</goal>
</goals>
<configuration>
<includes>
<include>**/*IntegrationTest</include>
</includes>
<argLine>-Dlogback.configurationFile=${logback.configurationFile} -Dakka.javasdk.dev-mode.project-artifact-id=${project.artifactId}</argLine>
<source>
log.warn('This profile is deprecated. It will be removed in future versions. Integration tests only need `mvn verify` to run.')
franciscolopezsancho marked this conversation as resolved.
Show resolved Hide resolved
</source>
</configuration>
</execution>
</executions>
<configuration>
<classesDirectory>${project.build.outputDirectory}</classesDirectory>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profile>

<profile>
<id>clean-on-missing-descriptor</id>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
import static org.assertj.core.api.Assertions.assertThat;

@ExtendWith(Junit5LogCapturing.class)
public class SdkIntegrationTest extends TestKitSupport {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's revert them all back to *IntegrationTest as per other comment.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright.

public class SdkIT extends TestKitSupport {

@Override
protected TestKit.Settings testKitSettings() {
Expand Down
4 changes: 2 additions & 2 deletions docs/src/modules/java/pages/access-control.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -225,9 +225,9 @@ ACL rules will be applied whenever a call is made using testkit's `HttpClient`.
originating from the internet. You can disable the ACL checks by overriding the `testKitSettings()` method.

[source, java, indent=0]
.{sample-base-url}/doc-snippets/src/it/java/com/example/acl/UserEndpointIntegrationTest.java[UserEndpointIntegrationTest.java]
.{sample-base-url}/doc-snippets/src/test/java/com/example/acl/UserEndpointIT.java[UserEndpointIT.java]
----
include::example$doc-snippets/src/it/java/com/example/acl/UserEndpointIntegrationTest.java[tag=disable-acl-in-it]
include::example$doc-snippets/src/test/java/com/example/acl/UserEndpointIT.java[tag=disable-acl-in-it]
----

Calls made through the `ComponentClient` are internal to the service and therefore no ACL rule is applied.
4 changes: 2 additions & 2 deletions docs/src/modules/java/pages/auth-with-jwts.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,9 @@ When running locally, by default, a dev key with id `dev` is configured for use.
When running integration tests, JWTs will still be enforced but its signature will not be validated, similarly to what is described above for when running locally. Thus, when making calls in the context of integration testing, make sure to inject a proper token with the required claims, as shown below:

[source, java, indent=0]
.{sample-base-url}/endpoint-jwt/src/it/java/hellojwt/api/HelloJwtIntegrationTest.java[HelloJwtIntegrationTest.java]
.{sample-base-url}/endpoint-jwt/src/test/java/hellojwt/api/HelloJwtIT.java[HelloJwtIT.java]
----
include::example$endpoint-jwt/src/it/java/hellojwt/api/HelloJwtIntegrationTest.java[tag=bearer-token-claims-test]
include::example$endpoint-jwt/src/test/java/hellojwt/api/HelloJwtIT.java[tag=bearer-token-claims-test]
----
<1> Use a helper method to create a JWT token with 2 claims: issuer and subject.
<2> Inject the bearer token as header with the key `Authorization`.
Expand Down
20 changes: 10 additions & 10 deletions docs/src/modules/java/pages/consuming-producing.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -234,9 +234,9 @@ In this example:
To test this flow, we will take advantage of the TestKit to be able to push commands into the `event-commands` topic and check what messages are produced to topic `counter-events`.

[source,java]
.{sample-base-url}/event-sourced-counter-brokers/src/it/java/counter/application/CounterIntegrationTest.java[CounterIntegrationTest.java]
.{sample-base-url}/event-sourced-counter-brokers/src/test/java/counter/application/CounterIT.java[CounterIT.java]
----
include::example$event-sourced-counter-brokers/src/it/java/counter/application/CounterIntegrationTest.java[tags=class;test-topic]
include::example$event-sourced-counter-brokers/src/test/java/counter/application/CounterIT.java[tags=class;test-topic]
----
<1> Use the TestKitSupport class.
<2> Get a `IncomingMessages` for topic named `counter-commands` and `OutgoingMessages` for `counter-events` from the TestKit.
Expand All @@ -251,9 +251,9 @@ TIP: In the example above we take advantage of the TestKit to serialize / deseri
Before running your test, make sure to configure the TestKit correctly.

[source, java]
.{sample-base-url}/event-sourced-counter-brokers/src/it/java/counter/application/CounterIntegrationTest.java[CounterIntegrationTest.java]
.{sample-base-url}/event-sourced-counter-brokers/src/test/java/counter/application/CounterIT.java[CounterIT.java]
----
include::example$event-sourced-counter-brokers/src/it/java/counter/application/CounterIntegrationTest.java[tags=eventing-config]
include::example$event-sourced-counter-brokers/src/test/java/counter/application/CounterIT.java[tags=eventing-config]
----
<1> Mock incoming messages from the `counter-commands` topic.
<2> Mock outgoing messages from the `counter-events` topic.
Expand All @@ -263,9 +263,9 @@ include::example$event-sourced-counter-brokers/src/it/java/counter/application/C
Typically, messages are published with associated metadata. If you want to construct your own `Metadata` to be consumed by a service or make sure the messages published out of your service have specific metadata attached, you can do so using the TestKit, as shown below.

[source,java,indent=0]
.{sample-base-url}/event-sourced-counter-brokers/src/it/java/counter/application/CounterIntegrationTest.java[CounterIntegrationTest.java]
.{sample-base-url}/event-sourced-counter-brokers/src/test/java/counter/application/CounterIT.java[CounterIT.java]
----
include::example$event-sourced-counter-brokers/src/it/java/counter/application/CounterIntegrationTest.java[tags=test-topic-metadata]
include::example$event-sourced-counter-brokers/src/test/java/counter/application/CounterIT.java[tags=test-topic-metadata]
----
<1> Build a `CloudEvent` object with the 3 required attributes, respectively: `id`, `source` and `type`.
<2> Add the subject to which the message is related, that is the `counterId`.
Expand All @@ -286,9 +286,9 @@ As an alternative, you can consider using different test suites which will use i


[source,java,indent=0]
.{sample-base-url}/event-sourced-counter-brokers/src/it/java/counter/application/CounterIntegrationTest.java[CounterIntegrationTest.java]
.{sample-base-url}/event-sourced-counter-brokers/src/test/java/counter/application/CounterIT.java[CounterIT.java]
----
include::example$event-sourced-counter-brokers/src/it/java/counter/application/CounterIntegrationTest.java[tags=clear-topics]
include::example$event-sourced-counter-brokers/src/test/java/counter/application/CounterIT.java[tags=clear-topics]
----
<1> Run this before each test.
<2> Clear the topic ignoring any unread messages.
Expand All @@ -300,9 +300,9 @@ NOTE: Despite the example, you are neither forced to clear all topics nor to do
To run an integration test against a real instance of Google PubSub (or its Emulator) or Kafka, use the TestKit settings to override the default eventing support, as shown below:

[source,java]
.{sample-base-url}/event-sourced-counter-brokers/src/it/java/counter/application/CounterWithRealKafkaIntegrationTest.java[CounterWithRealKafkaIntegrationTest.java]
.{sample-base-url}/event-sourced-counter-brokers/src/test/java/counter/application/CounterWithRealKafkaIT.java[CounterWithRealKafkaIT.java]
----
include::example$event-sourced-counter-brokers/src/it/java/counter/application/CounterWithRealKafkaIntegrationTest.java[tags=kafka]
include::example$event-sourced-counter-brokers/src/test/java/counter/application/CounterWithRealKafkaIT.java[tags=kafka]
----

== Multi-region replication
Expand Down
7 changes: 3 additions & 4 deletions docs/src/modules/java/pages/event-sourced-entities.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -229,9 +229,9 @@ For the above example, this class provides access to all the command handlers of
The skeleton of an Integration Test is generated for you if you use the archetype to start your Akka service. Let's see what it could look like to test our `ShoppingCartEntity`:

[source,java]
.{sample-base-url}/shopping-cart-quickstart/src/it/java/shoppingcart/IntegrationTest.java[IntegrationTest.java]
.{sample-base-url}/shopping-cart-quickstart/src/test/java/shoppingcart/ShoppingCartIT.java[ShoppingCartIT.java]
----
include::example$shopping-cart-quickstart/src/it/java/shoppingcart/IntegrationTest.java[tag=sample-it]
include::example$shopping-cart-quickstart/src/test/java/shoppingcart/ShoppingCartIT.java[tag=sample-it]
----
<1> Note the test class must extend `TestKitSupport`.
<2> A built-in component client is provided to interact with the components.
Expand All @@ -240,8 +240,7 @@ include::example$shopping-cart-quickstart/src/it/java/shoppingcart/IntegrationTe
<5> Request to retrieve current status of the shopping cart.
<6> Assert there should only be one item.

NOTE: The integration tests in samples are under a specific project profile `it` and can be run using `mvn verify -Pit`.

NOTE: The integration tests in samples can be run using `mvn verify`.
franciscolopezsancho marked this conversation as resolved.
Show resolved Hide resolved
== Exposing entities directly

include::partial$component-endpoint.adoc[]
Expand Down
6 changes: 3 additions & 3 deletions docs/src/modules/java/pages/key-value-entities.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -150,17 +150,17 @@ NOTE: The `KeyValueEntityTestKit` is stateful, and it holds the state of a singl
The skeleton of an Integration Test is generated for you if you use the archetype to start your Akka service. Let's see what it could look like to test our Counter Entity:

[source,java,indent=0]
.{sample-base-url}/key-value-counter/src/it/java/com/example/CounterIntegrationTest.java[CounterIntegrationTest.java]
.{sample-base-url}/key-value-counter/src/test/java/com/example/CounterIT.java[CounterIT.java]
----
include::example$key-value-counter/src/it/java/com/example/CounterIntegrationTest.java[tags=sample-it]
include::example$key-value-counter/src/test/java/com/example/CounterIT.java[tags=sample-it]
----
<1> Note the test class must extend `TestKitSupport`.
<2> A built-in component client is provided to interact with the components.
<3> Get the current value of the counter named `bar`. Initial value of counter is expected to be `0`.
<4> Request to increase the value of counter `bar`. Response should have value `1`.
<5> Explicitly request current value of `bar`. It should be `1`.

NOTE: The integration tests in samples are under a specific project profile `it` and can be run using `mvn verify -Pit`.
NOTE: The integration tests in samples can be run using `mvn verify`.
franciscolopezsancho marked this conversation as resolved.
Show resolved Hide resolved

== Exposing entities directly

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,9 @@ The TestKit allows providing a custom `DependencyProvider` through `TestKit.Sett
that mock instances of dependencies can be used in tests.

[source,java]
.{sample-base-url}/doc-snippets/src/it/java/com/example/MyIntegrationTest.java[MyIntegrationTest.java]
.{sample-base-url}/doc-snippets/src/test/java/com/example/MyIT.java[MyIT.java]
----
include::example$doc-snippets/src/it/java/com/example/MyIntegrationTest.java[tag=test-di-provider]
include::example$doc-snippets/src/test/java/com/example/MyIT.java[tag=test-di-provider]
----
<1> Implement a test specific `DependencyProvider`.
<2> Configure the TestKit to use it.
Expand Down
4 changes: 2 additions & 2 deletions docs/src/modules/java/pages/views.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -304,9 +304,9 @@ include::example$key-value-customer-registry/src/main/java/customer/application/
An integration test can be implemented as below.

[source,java,indent=0]
.{sample-base-url}/key-value-customer-registry/src/it/java/customer/application/CustomersByCityIntegrationTest.java[CustomersByCityIntegrationTest.java]
.{sample-base-url}/key-value-customer-registry/src/test/java/customer/application/CustomersByCityIT.java[CustomersByCityIT.java]
----
include::example$key-value-customer-registry/src/it/java/customer/application/CustomersByCityIntegrationTest.java[tag=view-test]
include::example$key-value-customer-registry/src/test/java/customer/application/CustomersByCityIT.java[tag=view-test]
----
<1> Mocks incoming messages from the `customer` Key Value Entity.
<2> Gets an `IncomingMessages` from the `customer` Key Value Entity.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

import static org.assertj.core.api.Assertions.assertThat;

public class UserCreationIntegrationTest extends TestKitSupport {
public class UserCreationIT extends TestKitSupport {

private final Duration timeout = Duration.ofSeconds(6);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import static org.junit.jupiter.api.Assertions.assertSame;

// tag::test-di-provider[]
public class MyIntegrationTest extends TestKitSupport {
public class MyIT extends TestKitSupport {

private static final DependencyProvider mockDependencyProvider = new DependencyProvider() { // <1>
@SuppressWarnings("unchecked")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@


// tag::disable-acl-in-it[]
public class UserEndpointIntegrationTest extends TestKitSupport {
public class UserEndpointIT extends TestKitSupport {

@Override
protected TestKit.Settings testKitSettings() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import static org.assertj.core.api.Assertions.assertThat;


public class JwtIntegrationTest extends TestKitSupport {
public class JwtIT extends TestKitSupport {

// tag::bearer-token-claims-test[]
private String bearerTokenWith(Map<String, String> claims) throws JsonProcessingException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

import static org.assertj.core.api.Assertions.assertThat;

public class HelloJwtIntegrationTest extends TestKitSupport {
public class HelloJwtIT extends TestKitSupport {

// tag::bearer-token-claims-test[]
@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import static org.junit.jupiter.api.Assertions.assertEquals;

// tag::class[]
public class CounterIntegrationTest extends TestKitSupport { // <1>
public class CounterIT extends TestKitSupport { // <1>

// end::class[]

Expand Down Expand Up @@ -140,7 +140,7 @@ public void verifyCounterCommandsAndPublishWithMetadata() {

var metadata = CloudEvent.of( // <1>
"cmd1",
URI.create("CounterTopicIntegrationTest"),
URI.create("CounterTopicIT"),
increaseCmd.getClass().getName())
.withSubject(counterId) // <2>
.asMetadata()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import org.apache.kafka.common.serialization.ByteArrayDeserializer;
import org.apache.kafka.common.serialization.StringDeserializer;
import org.awaitility.Awaitility;
import org.jetbrains.annotations.NotNull;
import org.junit.jupiter.api.Test;

import java.nio.charset.StandardCharsets;
Expand All @@ -22,10 +21,10 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

public class CounterWithRealKafkaIntegrationTest extends TestKitSupport { // <1>
public class CounterWithRealKafkaIT extends TestKitSupport { // <1>

// logger
private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(CounterWithRealKafkaIntegrationTest.class);
private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(CounterWithRealKafkaIT.class);

// tag::kafka[]
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import akka.http.javadsl.model.ContentTypes;
import akka.http.javadsl.model.StatusCodes;
import akka.javasdk.http.HttpClient;
import akka.javasdk.testkit.TestKitSupport;
import akka.javasdk.testkit.TestKit;
import org.awaitility.Awaitility;
Expand All @@ -17,7 +16,7 @@

import static org.junit.jupiter.api.Assertions.assertEquals;

public class CounterWithRealPubSubIntegrationTest extends TestKitSupport { // <1>
public class CounterWithRealPubSubIT extends TestKitSupport { // <1>

// tag::pubsub[]
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* The subscriber service will first create a customer on customer-registry service. The customer will be streamed back
* to the subscriber service and update its view.
*/
public class CustomerIntegrationTest extends CustomerRegistryIntegrationTest {
public class CustomerIT extends CustomerRegistryIT {


// this test relies on a source Akka event-sourced-customer-registry service to which it subscribes.
Expand Down
Loading
Loading