-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17133 from NetoDevel/feature/netodevel-adds-redis…
…-devservices-it
- Loading branch information
Showing
10 changed files
with
251 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
<?xml version="1.0"?> | ||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-integration-tests-parent</artifactId> | ||
<version>999-SNAPSHOT</version> | ||
<relativePath>../pom.xml</relativePath> | ||
</parent> | ||
<artifactId>quarkus-integration-test-redis-devservices</artifactId> | ||
<name>Quarkus - Integration Tests - Redis DevService</name> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-redis-client</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-arc</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-junit5</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<!-- Minimal test dependencies to *-deployment artifacts for consistent build order --> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-redis-client-deployment</artifactId> | ||
<version>${project.version}</version> | ||
<type>pom</type> | ||
<scope>test</scope> | ||
<exclusions> | ||
<exclusion> | ||
<groupId>*</groupId> | ||
<artifactId>*</artifactId> | ||
</exclusion> | ||
</exclusions> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-arc-deployment</artifactId> | ||
<version>${project.version}</version> | ||
<type>pom</type> | ||
<scope>test</scope> | ||
<exclusions> | ||
<exclusion> | ||
<groupId>*</groupId> | ||
<artifactId>*</artifactId> | ||
</exclusion> | ||
</exclusions> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<resources> | ||
<resource> | ||
<directory>src/main/resources</directory> | ||
<filtering>true</filtering> | ||
</resource> | ||
</resources> | ||
<plugins> | ||
<plugin> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<configuration> | ||
<skip>true</skip> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-failsafe-plugin</artifactId> | ||
<configuration> | ||
<skip>true</skip> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-maven-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>build</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
5 changes: 5 additions & 0 deletions
5
integration-tests/redis-devservices/src/main/resources/application.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#quarkus.redis.hosts=redis://localhost:6379 | ||
quarkus.redis.health.enabled=true | ||
#quarkus.redis.devservices.image-name=redis:6.0-alpine | ||
#quarkus.redis.devservices.port=6377 | ||
#quarkus.redis.devservices.enabled=true |
22 changes: 22 additions & 0 deletions
22
...rvices/src/test/java/io/quarkus/redis/devservices/it/DevServicesRedisCustomPortITest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package io.quarkus.redis.devservices.it; | ||
|
||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import io.quarkus.redis.devservices.it.profiles.DevServicesCustomPortProfile; | ||
import io.quarkus.redis.devservices.it.utils.SocketKit; | ||
import io.quarkus.test.junit.QuarkusTest; | ||
import io.quarkus.test.junit.TestProfile; | ||
|
||
@QuarkusTest | ||
@TestProfile(DevServicesCustomPortProfile.class) | ||
public class DevServicesRedisCustomPortITest { | ||
|
||
@Test | ||
@DisplayName("should start redis container with the given custom port") | ||
public void shouldStartRedisContainer() { | ||
Assertions.assertTrue(SocketKit.isPortAlreadyUsed(6371)); | ||
} | ||
|
||
} |
22 changes: 22 additions & 0 deletions
22
...services/src/test/java/io/quarkus/redis/devservices/it/DevServicesRedisDisabledITest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package io.quarkus.redis.devservices.it; | ||
|
||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import io.quarkus.redis.devservices.it.profiles.DevServicesDisabledProfile; | ||
import io.quarkus.redis.devservices.it.utils.SocketKit; | ||
import io.quarkus.test.junit.QuarkusTest; | ||
import io.quarkus.test.junit.TestProfile; | ||
|
||
@QuarkusTest | ||
@TestProfile(DevServicesDisabledProfile.class) | ||
public class DevServicesRedisDisabledITest { | ||
|
||
@Test | ||
@DisplayName("should not start the redis container when devservices is disabled") | ||
public void shouldStartRedisContainer() { | ||
Assertions.assertFalse(SocketKit.isPortAlreadyUsed(6379)); | ||
} | ||
|
||
} |
42 changes: 42 additions & 0 deletions
42
...edis-devservices/src/test/java/io/quarkus/redis/devservices/it/DevServicesRedisITest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package io.quarkus.redis.devservices.it; | ||
|
||
import java.util.Arrays; | ||
|
||
import javax.inject.Inject; | ||
|
||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import io.quarkus.redis.client.RedisClient; | ||
import io.quarkus.redis.devservices.it.profiles.DevServiceRedis; | ||
import io.quarkus.redis.devservices.it.utils.SocketKit; | ||
import io.quarkus.test.junit.QuarkusTest; | ||
import io.quarkus.test.junit.TestProfile; | ||
|
||
@QuarkusTest | ||
@TestProfile(DevServiceRedis.class) | ||
public class DevServicesRedisITest { | ||
|
||
@Inject | ||
RedisClient redisClient; | ||
|
||
@BeforeEach | ||
public void setUp() { | ||
redisClient.set(Arrays.asList("anykey", "anyvalue")); | ||
} | ||
|
||
@Test | ||
@DisplayName("given quarkus.redis.hosts disabled should start redis testcontainer") | ||
public void shouldStartRedisContainer() { | ||
Assertions.assertTrue(SocketKit.isPortAlreadyUsed(6379)); | ||
} | ||
|
||
@Test | ||
@DisplayName("given redis container must communicate with it and return value by key") | ||
public void shouldReturnAllKeys() { | ||
Assertions.assertEquals("anyvalue", redisClient.get("anykey").toString()); | ||
} | ||
|
||
} |
14 changes: 14 additions & 0 deletions
14
...s-devservices/src/test/java/io/quarkus/redis/devservices/it/profiles/DevServiceRedis.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package io.quarkus.redis.devservices.it.profiles; | ||
|
||
import java.util.Collections; | ||
import java.util.Map; | ||
|
||
import io.quarkus.test.junit.QuarkusTestProfile; | ||
|
||
public class DevServiceRedis implements QuarkusTestProfile { | ||
|
||
@Override | ||
public Map<String, String> getConfigOverrides() { | ||
return Collections.singletonMap("quarkus.redis.devservices.port", "6379"); | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
.../src/test/java/io/quarkus/redis/devservices/it/profiles/DevServicesCustomPortProfile.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package io.quarkus.redis.devservices.it.profiles; | ||
|
||
import java.util.Collections; | ||
import java.util.Map; | ||
|
||
import io.quarkus.test.junit.QuarkusTestProfile; | ||
|
||
public class DevServicesCustomPortProfile implements QuarkusTestProfile { | ||
|
||
@Override | ||
public Map<String, String> getConfigOverrides() { | ||
return Collections.singletonMap("quarkus.redis.devservices.port", "6371"); | ||
} | ||
|
||
@Override | ||
public String getConfigProfile() { | ||
return "test"; | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
...es/src/test/java/io/quarkus/redis/devservices/it/profiles/DevServicesDisabledProfile.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package io.quarkus.redis.devservices.it.profiles; | ||
|
||
import java.util.Collections; | ||
import java.util.Map; | ||
|
||
import io.quarkus.test.junit.QuarkusTestProfile; | ||
|
||
public class DevServicesDisabledProfile implements QuarkusTestProfile { | ||
|
||
@Override | ||
public Map<String, String> getConfigOverrides() { | ||
return Collections.singletonMap("quarkus.redis.devservices.enabled", "false"); | ||
} | ||
|
||
@Override | ||
public String getConfigProfile() { | ||
return "test"; | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
...ests/redis-devservices/src/test/java/io/quarkus/redis/devservices/it/utils/SocketKit.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package io.quarkus.redis.devservices.it.utils; | ||
|
||
import java.io.IOException; | ||
import java.net.Socket; | ||
|
||
public class SocketKit { | ||
|
||
public static boolean isPortAlreadyUsed(Integer port) { | ||
try (Socket ignored = new Socket("localhost", port)) { | ||
ignored.close(); | ||
return true; | ||
} catch (IOException ignored) { | ||
return false; | ||
} | ||
} | ||
} |