Skip to content
This repository has been archived by the owner on Jun 27, 2024. It is now read-only.

feat: testcontainers extensions integrated #12

Merged
merged 1 commit into from
Jun 19, 2020
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
feat: testcontainers extensions integrated
  • Loading branch information
lholota committed Jun 19, 2020
commit 9c07bdf81130502e19916ed8bf0d8eb219a26f8d
5 changes: 4 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
* text=auto
*.sh eol=lf
*.yml eol=lf
**/run eol=lf
*/services.d/* eol=lf
**/finish eol=lf
**/services.d/** eol=lf
**/cont-init.d/** eol=lf
2 changes: 1 addition & 1 deletion .github/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ branches:
protection:
required_status_checks:
strict: true
contexts: [ ".github/workflows/ci.yml" ]
contexts: [ "build" ]
required_pull_request_reviews: null
enforce_admins: false
restrictions:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
run: docker build . -t ${{ env.IMAGE_NAME }}:${{ steps.vars.outputs.docker_tag }}

- name: Test Docker image
run: cd tests && sudo gradle test --info -Dimage_tag=${{ env.IMAGE_NAME }}:${{ steps.vars.outputs.docker_tag }}
run: cd tests && sudo gradle test --info -Ddocker_image_tag=${{ env.IMAGE_NAME }}:${{ steps.vars.outputs.docker_tag }}

- name: Scan with Phonito Security
uses: phonito/phonito-scanner-action@master
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci_cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:

- name: Test Docker image
if: env.RELEASE_VERSION != ''
run: cd tests && sudo gradle test -Dimage_tag=${{ env.IMAGE_NAME }}:${{ env.RELEASE_VERSION }}
run: cd tests && sudo gradle test -Ddocker_image_tag=${{ env.IMAGE_NAME }}:${{ env.RELEASE_VERSION }}

- name: Scan with Phonito Security
if: env.RELEASE_VERSION != ''
Expand Down
5 changes: 5 additions & 0 deletions tests/.idea/jarRepositories.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 7 additions & 2 deletions tests/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,22 @@ sourceCompatibility = 1.8

repositories {
mavenCentral()
maven {
url "https://dl.bintray.com/homecentr/maven"
}
}

dependencies {
testImplementation group: 'junit', name: 'junit', version: '4.13'
testImplementation "org.testcontainers:testcontainers:1.14.3"
testImplementation 'org.testcontainers:testcontainers:1.14.3'
testImplementation 'io.homecentr:testcontainers-extensions:1.3.2'
testImplementation group: 'org.slf4j', name: 'slf4j-api', version: '1.7.30'
testImplementation group: 'org.slf4j', name: 'slf4j-simple', version: '1.7.30'
}

test {
systemProperty 'image_tag', System.getProperty('image_tag')
systemProperty 'docker_image_tag', System.getProperty('docker_image_tag')

afterTest { desc, result ->
logger.quiet "Executing test ${desc.name} [${desc.className}] with result: ${result.resultType}"
}
Expand Down
38 changes: 38 additions & 0 deletions tests/src/test/java/ContainerShould.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testcontainers.DockerClientFactory;
import org.testcontainers.containers.output.Slf4jLogConsumer;
import org.testcontainers.utility.LogUtils;

import helpers.DockerImageTagResolver;

import io.homecentr.testcontainers.containers.GenericContainerEx;
import io.homecentr.testcontainers.containers.wait.strategy.WaitEx;

public abstract class ContainerShould {
private static final Logger logger = LoggerFactory.getLogger(ContainerShould.class);

private static GenericContainerEx _container;

@BeforeClass
public static void setUp() {
_container = new GenericContainerEx<>(new DockerImageTagResolver())
.waitingFor(WaitEx.forS6OverlayStart());

_container.start();
LogUtils.followOutput(DockerClientFactory.instance().client(), _container.getContainerId(), new Slf4jLogConsumer(logger));
}

@AfterClass
public static void cleanUp() {
_container.close();
}

@Test
public void doSomething() throws Exception {
throw new Exception("Implement the test");
}
}
36 changes: 0 additions & 36 deletions tests/src/test/java/ContainerTestBase.java

This file was deleted.

9 changes: 9 additions & 0 deletions tests/src/test/java/helpers/DockerImageTagResolver.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package helpers;

import io.homecentr.testcontainers.images.EnvironmentImageTagResolver;

public class DockerImageTagResolver extends EnvironmentImageTagResolver {
public DockerImageTagResolver() {
super("homecentr/$$IMAGE_NAME$$:local");
}
}