-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* host ports turn of/off * fix(uploadTmpTar): complicating code for predictable result * feat(uploadTmpTar): сopy as base64 encoded string * feat(uploadTmpTar): wait until the websocket message queue is empty * feat(reusing): different ways of reuse pods: session limited or global * dependency(lombok): update to 1.18.30 * feat(pod-name-generator): uses the docker image name as a suffix in a pod name. * feat: migrates to testcontainers:1.19.7
- Loading branch information
Showing
55 changed files
with
1,901 additions
and
1,275 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
name: Build | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
- dev | ||
- "releases/**" | ||
- "feature/**" | ||
- "bugfix/**" | ||
pull_request: | ||
branches: | ||
- main | ||
- dev | ||
- "releases/**" | ||
- "feature/**" | ||
- "bugfix/**" | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Create k8s Kind Cluster | ||
uses: helm/kind-action@v1 | ||
- uses: actions/setup-java@v4 | ||
with: | ||
distribution: temurin | ||
java-version: 17 | ||
- name: Setup Gradle | ||
uses: gradle/actions/setup-gradle@v3 | ||
- name: config kube namespace | ||
run: kubectl config set-context --current --namespace=default | ||
- name: Execute Gradle build | ||
run: ./gradlew clean :test:build -Pno-pandoc | ||
- name: Publish Test Report | ||
uses: mikepenz/action-junit-report@v4 | ||
if: success() || failure() # always run even if the previous step fails | ||
with: | ||
report_paths: '**/build/test-results/test/TEST-*.xml' |
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 |
---|---|---|
@@ -1,42 +1,6 @@ | ||
.gradle | ||
build/ | ||
!gradle/wrapper/gradle-wrapper.jar | ||
!**/src/main/**/build/ | ||
!**/src/test/**/build/ | ||
|
||
### IntelliJ IDEA ### | ||
.idea/modules.xml | ||
.idea/jarRepositories.xml | ||
.idea/compiler.xml | ||
.idea/libraries/ | ||
*.iws | ||
*.iml | ||
*.ipr | ||
out/ | ||
!**/src/main/**/out/ | ||
!**/src/test/**/out/ | ||
|
||
### Eclipse ### | ||
.apt_generated | ||
.classpath | ||
.factorypath | ||
.project | ||
.settings | ||
.springBeans | ||
.sts4-cache | ||
bin/ | ||
!**/src/main/**/bin/ | ||
!**/src/test/**/bin/ | ||
|
||
### NetBeans ### | ||
/nbproject/private/ | ||
/nbbuild/ | ||
/dist/ | ||
/nbdist/ | ||
/.nb-gradle/ | ||
|
||
### VS Code ### | ||
.vscode/ | ||
|
||
### Mac OS ### | ||
.DS_Store | ||
.idea/ | ||
test/build/ | ||
test/logs* | ||
gradle.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 |
---|---|---|
@@ -1,22 +1,103 @@ | ||
# Testcontainers on kubernetes (under construction) | ||
# Testcontainers on Kubernetes (under construction) | ||
|
||
A tool to run testcontainers tests in a kubernetes environment. | ||
|
||
Goal is Postgresql and Redis support. | ||
Requires Java 17 or higher. | ||
|
||
- to build run `./gradlew publishToMavenLocal` | ||
- add next code in your `gradle.kts` script: | ||
```gradle | ||
repositories { | ||
mavenLocal() | ||
Compatibility with Testcontainers 1.19.7. | ||
|
||
## Implementations | ||
|
||
- [PostgresqlPod](./src/main/java/io/github/m4gshm/testcontainers/PostgresqlPod.java) | ||
|
||
- [MongoDBPod](./src/main/java/io/github/m4gshm/testcontainers/MongoDBPod.java) | ||
|
||
- [GenericPod](./src/main/java/io/github/m4gshm/testcontainers/GenericPod.java) | ||
|
||
## Install | ||
|
||
### Gradle (Kotlin syntax) | ||
|
||
Add the code below to your `build.gradle.kts` | ||
|
||
``` kotlin | ||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
testImplementation("io.github.m4gshm:kubetestcontainers:0.0.1-rc1") | ||
testImplementation("org.testcontainers:postgresql:1.19.7") | ||
} | ||
``` | ||
|
||
## Usage example | ||
|
||
To run locally, it is highly recommended to use | ||
[Minikube](https://minikube.sigs.k8s.io) or | ||
[Kind](https://kind.sigs.k8s.io). | ||
|
||
``` java | ||
package example; | ||
|
||
import io.github.m4gshm.testcontainers.PostgresqlPod; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.BeforeAll; | ||
import org.junit.jupiter.api.Test; | ||
import org.testcontainers.containers.JdbcDatabaseContainer; | ||
import org.testcontainers.containers.PostgreSQLContainer; | ||
|
||
import java.sql.SQLException; | ||
|
||
import static java.sql.DriverManager.getConnection; | ||
|
||
public class JdbcTest { | ||
|
||
private final static JdbcDatabaseContainer<?> postgres = useKubernetes() | ||
? new PostgresqlPod() : new PostgreSQLContainer<>(); | ||
|
||
private static boolean useKubernetes() { | ||
return "kuber".equals(System.getProperty("testcontainers-engine", "kuber")); | ||
} | ||
dependencies { | ||
testImplementation("com.github.m4gshm:kubetestcontainers:0.1-SNAPSHOT") | ||
testImplementation("org.testcontainers:postgresql:1.19.0") | ||
|
||
@BeforeAll | ||
static void beforeAll() { | ||
postgres.start(); | ||
} | ||
``` | ||
- start experimenting. | ||
|
||
See tests as an example [here](./tests/src/test/java/com/github/m4gshm/testcontainers). | ||
@Test | ||
public void jdbcInsertSelectTest() throws SQLException { | ||
var url = postgres.getJdbcUrl(); | ||
var username = postgres.getUsername(); | ||
var password = postgres.getPassword(); | ||
try (var connection = getConnection(url, username, password)) { | ||
try (var statement = connection.prepareStatement(""" | ||
create table participant ( | ||
id integer, | ||
name text | ||
); | ||
""" | ||
)) { | ||
statement.execute(); | ||
} | ||
|
||
And don't forget to install [Minikube](https://kubernetes.io/ru/docs/tasks/tools/install-minikube/). | ||
try (var statement = connection.prepareStatement( | ||
"insert into participant(id, name) values(?,?)")) { | ||
statement.setInt(1, 1); | ||
statement.setString(2, "Alice"); | ||
statement.execute(); | ||
} | ||
|
||
try (var statement = connection.prepareStatement( | ||
"select name from participant where id=?")) { | ||
statement.setInt(1, 1); | ||
try (var resultSet = statement.executeQuery()) { | ||
Assertions.assertTrue(resultSet.next()); | ||
var name = resultSet.getString(1); | ||
Assertions.assertEquals("Alice", name); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
``` |
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
#Sat Aug 26 10:32:41 MSK 2023 | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
rootProject.name = "kubetestcontainers" | ||
|
||
include(":tests") | ||
include(":test") |
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,38 @@ | ||
= Kubetestcontainers | ||
|
||
== Testcontainers on Kubernetes (under construction) | ||
|
||
A tool to run testcontainers tests in a kubernetes environment. | ||
|
||
Requires Java 17 or higher. | ||
|
||
Compatibility with Testcontainers 1.19.7. | ||
|
||
=== Implementations | ||
- link:./src/main/java/io/github/m4gshm/testcontainers/PostgresqlPod.java[PostgresqlPod] | ||
- link:./src/main/java/io/github/m4gshm/testcontainers/MongoDBPod.java[MongoDBPod] | ||
- link:./src/main/java/io/github/m4gshm/testcontainers/GenericPod.java[GenericPod] | ||
|
||
=== Install | ||
==== Gradle (Kotlin syntax) | ||
Add the code below to your `build.gradle.kts` | ||
[source,kotlin] | ||
---- | ||
repositories { | ||
mavenCentral() | ||
} | ||
dependencies { | ||
testImplementation("io.github.m4gshm:kubetestcontainers:0.0.1-rc1") | ||
testImplementation("org.testcontainers:postgresql:1.19.7") | ||
} | ||
---- | ||
|
||
=== Usage example | ||
|
||
To run locally, it is highly recommended to use link:https://minikube.sigs.k8s.io[Minikube] or link:https://kind.sigs.k8s.io[Kind]. | ||
|
||
[source,java] | ||
---- | ||
include::../../../test/src/test/java/example/JdbcTest.java[] | ||
---- |
25 changes: 0 additions & 25 deletions
25
src/main/java/com/github/m4gshm/testcontainers/DefaultPodNameGenerator.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.