Skip to content

Commit

Permalink
Merge branch 'master' into presto
Browse files Browse the repository at this point in the history
  • Loading branch information
rnorth committed Feb 7, 2020
2 parents bafe997 + 1425584 commit 8e5999b
Show file tree
Hide file tree
Showing 32 changed files with 456 additions and 77 deletions.
22 changes: 0 additions & 22 deletions .github/workflows/gradle-release.yml

This file was deleted.

24 changes: 24 additions & 0 deletions .travis.yml
@@ -0,0 +1,24 @@
if: tag is present

language: java
jdk:
- openjdk8

sudo: required
services:
- docker

jobs:
include:

- stage: deploy
sudo: false
services: []
install: skip
script: skip
deploy:
provider: script
script: ./gradlew -Pversion=$TRAVIS_TAG release --scan --no-daemon -i
on:
tags: true
branch: master
4 changes: 2 additions & 2 deletions core/build.gradle
Expand Up @@ -108,14 +108,14 @@ dependencies {
testCompile 'org.apache.httpcomponents:httpclient:4.5.9'
testCompile 'redis.clients:jedis:3.2.0'
testCompile 'com.rabbitmq:amqp-client:5.8.0'
testCompile 'org.mongodb:mongo-java-driver:3.12.0'
testCompile 'org.mongodb:mongo-java-driver:3.12.1'
testCompile ('org.mockito:mockito-core:3.2.4') {
exclude(module: 'hamcrest-core')
}
// Synthetic JAR used for MountableFileTest and DirectoryTarResourceTest
testCompile files('testlib/repo/fakejar/fakejar/0/fakejar-0.jar')

testCompile 'org.assertj:assertj-core:3.14.0'
testCompile 'org.assertj:assertj-core:3.15.0'
testCompile project(':test-support')

jarFileTestCompileOnly "org.projectlombok:lombok:${lombok.version}"
Expand Down
62 changes: 35 additions & 27 deletions core/src/main/java/org/testcontainers/utility/ResourceReaper.java
Expand Up @@ -15,10 +15,11 @@

import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.rnorth.ducttape.ratelimits.RateLimiter;
import org.rnorth.ducttape.ratelimits.RateLimiterBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testcontainers.DockerClientFactory;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
Expand Down Expand Up @@ -49,6 +50,11 @@ public final class ResourceReaper {
private static final Logger LOGGER = LoggerFactory.getLogger(ResourceReaper.class);

private static final List<List<Map.Entry<String, String>>> DEATH_NOTE = new ArrayList<>();
private static final RateLimiter RYUK_ACK_RATE_LIMITER = RateLimiterBuilder
.newBuilder()
.withRate(4, TimeUnit.SECONDS)
.withConstantThroughput()
.build();

private static ResourceReaper instance;
private final DockerClient dockerClient;
Expand Down Expand Up @@ -110,34 +116,36 @@ public static String start(String hostIpAddress, DockerClient client) {
DockerClientFactory.TESTCONTAINERS_THREAD_GROUP,
() -> {
while (true) {
int index = 0;
try(Socket clientSocket = new Socket(hostIpAddress, ryukPort)) {
FilterRegistry registry = new FilterRegistry(clientSocket.getInputStream(), clientSocket.getOutputStream());

synchronized (DEATH_NOTE) {
while (true) {
if (DEATH_NOTE.size() <= index) {
try {
DEATH_NOTE.wait(1_000);
continue;
} catch (InterruptedException e) {
throw new RuntimeException(e);
RYUK_ACK_RATE_LIMITER.doWhenReady(() -> {
int index = 0;
try(Socket clientSocket = new Socket(hostIpAddress, ryukPort)) {
FilterRegistry registry = new FilterRegistry(clientSocket.getInputStream(), clientSocket.getOutputStream());

synchronized (DEATH_NOTE) {
while (true) {
if (DEATH_NOTE.size() <= index) {
try {
DEATH_NOTE.wait(1_000);
continue;
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
List<Map.Entry<String, String>> filters = DEATH_NOTE.get(index);
boolean isAcknowledged = registry.register(filters);
if (isAcknowledged) {
log.debug("Received 'ACK' from Ryuk");
ryukScheduledLatch.countDown();
index++;
} else {
log.debug("Didn't receive 'ACK' from Ryuk. Will retry to send filters.");
}
}
List<Map.Entry<String, String>> filters = DEATH_NOTE.get(index);
boolean isAcknowledged = registry.register(filters);
if (isAcknowledged) {
log.debug("Received 'ACK' from Ryuk");
ryukScheduledLatch.countDown();
index++;
} else {
log.debug("Didn't receive 'ACK' from Ryuk. Will retry to send filters.");
}
}
} catch (IOException e) {
log.warn("Can not connect to Ryuk at {}:{}", hostIpAddress, ryukPort, e);
}
} catch (IOException e) {
log.warn("Can not connect to Ryuk at {}:{}", hostIpAddress, ryukPort, e);
}
});
}
},
"testcontainers-ryuk"
Expand Down Expand Up @@ -341,12 +349,12 @@ public void unregisterNetwork(String identifier) {
public void unregisterContainer(String identifier) {
registeredContainers.remove(identifier);
}

public void registerImageForCleanup(String dockerImageName) {
setHook();
registeredImages.add(dockerImageName);
}

private void removeImage(String dockerImageName) {
LOGGER.trace("Removing image tagged {}", dockerImageName);
try {
Expand Down
2 changes: 1 addition & 1 deletion core/src/test/resources/compose-build-test/Dockerfile
@@ -1,3 +1,3 @@
FROM redis
FROM redis:2.6.17

CMD ["redis-server"]
Expand Up @@ -3,4 +3,4 @@ services:
customredis:
build: .
normalredis:
image: redis:latest
image: redis:2.6.17
2 changes: 1 addition & 1 deletion docs/modules/databases/index.md
Expand Up @@ -45,7 +45,7 @@ As long as you have Testcontainers and the appropriate JDBC driver on your class
_N.B:_

* _TC needs to be on your application's classpath at runtime for this to work_
* _For Spring Boot you need to specify the driver manually `spring.datasource.driver-class-name=org.testcontainers.jdbc.ContainerDatabaseDriver`_
* _For Spring Boot (Before version `2.3.0`) you need to specify the driver manually `spring.datasource.driver-class-name=org.testcontainers.jdbc.ContainerDatabaseDriver`_

**Original URL**: `jdbc:mysql:5.7.22://localhost:3306/databasename`

Expand Down
78 changes: 78 additions & 0 deletions docs/modules/databases/orientdb.md
@@ -0,0 +1,78 @@
# OrientDB Module

!!! note
This module is INCUBATING. While it is ready for use and operational in the current version of Testcontainers, it is possible that it may receive breaking changes in the future. See [our contributing guidelines](/contributing/#incubating-modules) for more information on our incubating modules policy.


This module helps running [OrientDB](https://orientdb.org/download) using Testcontainers.

Note that it's based on the [official Docker image](https://hub.docker.com/_/orientdb/) provided by OrientDB.

## Usage example

Declare your Testcontainer as a `@ClassRule` or `@Rule` in a JUnit 4 test or as static or member attribute of a JUnit 5 test annotated with `@Container` as you would with other Testcontainers.
You can call `getDbUrl()` OrientDB container and build the `ODatabaseSession` by your own, but a more useful `getSession()` method is provided.
On the JVM you would most likely use the [Java driver](https://github.com/).

The following example uses the JUnit 5 extension `@Testcontainers` and demonstrates both the usage of the Java Client:

```java tab="JUnit 5 example"
@Testcontainers
public class ExampleTest {

@Container
private static OrientDBContainer container = new OrientDBContainer();

@Test
void testDbCreation() {

final ODatabaseSession session = container.getSession();

session.command("CREATE CLASS Person EXTENDS V");
session.command("INSERT INTO Person set name='john'");
session.command("INSERT INTO Person set name='jane'");

assertThat(session.query("SELECT FROM Person").stream()).hasSize(2);
}

}
```

You are not limited to Unit tests and can of course use an instance of the OrientDB Testcontainer in vanilla Java code as well.


## Adding this module to your project dependencies

Add the following dependency to your `pom.xml`/`build.gradle` file:

```groovy tab='Gradle'
testCompile "org.testcontainers:orientdb:{{latest_version}}"
```

```xml tab='Maven'
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>orientdb</artifactId>
<version>{{latest_version}}</version>
<scope>test</scope>
</dependency>
```

!!! hint
Add the OrientDB Java client if you plan to access the Testcontainer:

```groovy tab='Gradle'
compile "com.orientechnologies:orientdb-client:3.0.24"
```

```xml tab='Maven'
<dependency>
<groupId>com.orientechnologies</groupId>
<artifactId>orientdb-client</artifactId>
<version>3.0.24</version>
</dependency>
```




1 change: 1 addition & 0 deletions docs/quickstart/junit_5_quickstart.md
Expand Up @@ -27,6 +27,7 @@ testCompile "org.junit.jupiter:junit-jupiter-api:$junitJupiterVersion"
testCompile "org.junit.jupiter:junit-jupiter-params:$junitJupiterVersion"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junitJupiterVersion"
testCompile "org.testcontainers:testcontainers:{{latest_version}}"
testCompile "org.testcontainers:junit-jupiter:{{latest_version}}"
```

```xml tab='Maven'
Expand Down
2 changes: 1 addition & 1 deletion examples/linked-container/build.gradle
Expand Up @@ -7,7 +7,7 @@ repositories {
}
dependencies {
compileOnly 'org.slf4j:slf4j-api:1.7.30'
implementation 'com.squareup.okhttp3:okhttp:3.14.5'
implementation 'com.squareup.okhttp3:okhttp:3.14.6'
implementation 'org.json:json:20180813'
testImplementation 'org.postgresql:postgresql:42.2.9'
testImplementation 'ch.qos.logback:logback-classic:1.2.3'
Expand Down
2 changes: 1 addition & 1 deletion examples/selenium-container/build.gradle
@@ -1,6 +1,6 @@
plugins {
id 'java'
id 'org.springframework.boot' version '2.2.2.RELEASE'
id 'org.springframework.boot' version '2.2.4.RELEASE'
}
apply plugin: 'io.spring.dependency-management'

Expand Down
2 changes: 1 addition & 1 deletion examples/spring-boot/build.gradle
@@ -1,6 +1,6 @@
plugins {
id 'java'
id 'org.springframework.boot' version '2.2.2.RELEASE'
id 'org.springframework.boot' version '2.2.4.RELEASE'
}
apply plugin: 'io.spring.dependency-management'

Expand Down
2 changes: 1 addition & 1 deletion mkdocs.yml
Expand Up @@ -85,4 +85,4 @@ nav:
- contributing.md
- contributing_docs.md
extra:
latest_version: 1.12.3
latest_version: 1.12.5
2 changes: 1 addition & 1 deletion modules/couchbase/build.gradle
Expand Up @@ -2,7 +2,7 @@ description = "Testcontainers :: Couchbase"

dependencies {
compile project(':testcontainers')
compile 'com.couchbase.client:java-client:2.7.11'
compile 'com.couchbase.client:java-client:2.7.12'

testCompile project(':test-support')
}
2 changes: 1 addition & 1 deletion modules/database-commons/build.gradle
Expand Up @@ -3,5 +3,5 @@ description = "Testcontainers :: Database-Commons"
dependencies {
compile project(':testcontainers')

testCompile 'org.assertj:assertj-core:3.14.0'
testCompile 'org.assertj:assertj-core:3.15.0'
}
2 changes: 1 addition & 1 deletion modules/elasticsearch/build.gradle
Expand Up @@ -2,6 +2,6 @@ description = "TestContainers :: elasticsearch"

dependencies {
compile project(':testcontainers')
testCompile "org.elasticsearch.client:elasticsearch-rest-client:7.5.1"
testCompile "org.elasticsearch.client:elasticsearch-rest-client:7.5.2"
testCompile "org.elasticsearch.client:transport:6.7.1"
}
6 changes: 3 additions & 3 deletions modules/junit-jupiter/build.gradle
Expand Up @@ -2,20 +2,20 @@ description = "Testcontainers :: JUnit Jupiter Extension"

dependencies {
compile project(':testcontainers')
compile 'org.junit.jupiter:junit-jupiter-api:5.5.2'
compile 'org.junit.jupiter:junit-jupiter-api:5.6.0'

testCompile project(':mysql')
testCompile project(':postgresql')
testCompile 'com.zaxxer:HikariCP:3.4.2'
testCompile 'redis.clients:jedis:3.2.0'
testCompile 'org.apache.httpcomponents:httpclient:4.5.10'
testCompile 'org.apache.httpcomponents:httpclient:4.5.11'
testCompile ('org.mockito:mockito-core:3.2.4') {
exclude(module: 'hamcrest-core')
}

testRuntime 'org.postgresql:postgresql:42.2.9'
testRuntime 'mysql:mysql-connector-java:8.0.19'
testRuntime 'org.junit.jupiter:junit-jupiter-engine:5.5.2'
testRuntime 'org.junit.jupiter:junit-jupiter-engine:5.6.0'
}

test {
Expand Down
2 changes: 1 addition & 1 deletion modules/kafka/build.gradle
Expand Up @@ -4,6 +4,6 @@ dependencies {
compile project(':testcontainers')

testCompile 'org.apache.kafka:kafka-clients:2.4.0'
testCompile 'org.assertj:assertj-core:3.14.0'
testCompile 'org.assertj:assertj-core:3.15.0'
testCompile 'com.google.guava:guava:23.0'
}
1 change: 1 addition & 0 deletions modules/localstack/build.gradle
Expand Up @@ -6,4 +6,5 @@ dependencies {
compileOnly 'com.amazonaws:aws-java-sdk-s3:1.11.683'
testCompile 'com.amazonaws:aws-java-sdk-s3:1.11.683'
testCompile 'com.amazonaws:aws-java-sdk-sqs:1.11.636'
testCompile 'com.amazonaws:aws-java-sdk-logs:1.11.636'
}
Expand Up @@ -154,7 +154,7 @@ public enum Service {
SSM("ssm", 4583),
SECRETSMANAGER("secretsmanager", 4584),
STEPFUNCTIONS("stepfunctions", 4585),
CLOUDWATCHLOGS("cloudwatchlogs", 4586),
CLOUDWATCHLOGS("logs", 4586),
STS("sts", 4592),
IAM("iam", 4593);

Expand Down

0 comments on commit 8e5999b

Please sign in to comment.