Skip to content

Commit

Permalink
Merge pull request jgroups-extras#327 from rhusar/326
Browse files Browse the repository at this point in the history
Upgrade org.testcontainers to version compatible with podman and vers…
  • Loading branch information
rhusar authored Apr 16, 2024
2 parents 061e082 + 6c4b934 commit 5feccd2
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 6 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ mvn verify

If any of the required properties are not specified tests will be skipped (uses `org.junit.Assume`).

In case credentials are not provided and running on Linux, tests will be run against mock containerized S3 instance.
These require a functioning podman or Docker environment.

# Reporting Issues

Project JGroups AWS uses GitHub issues:
Expand Down
6 changes: 6 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,12 @@
<version>2.17.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers</artifactId>
<version>1.19.7</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ public abstract class AbstractS3_PINGDiscoveryTestCase {
// credentials (e.g. running JDK8 and JDK9 on the CI).
public static final String RANDOM_CLUSTER_NAME = UUID.randomUUID().toString();

static boolean isGenuineCredentialsAvailable() {
return System.getenv("AWS_ACCESS_KEY_ID") != null && System.getenv("AWS_SECRET_ACCESS_KEY") != null && System.getenv("S3_PING_BUCKET_NAME") != null;
}

@Test
public void testDiscovery() throws Exception {
discover(RANDOM_CLUSTER_NAME, S3_PING.class.getSimpleName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,14 @@
import org.junit.BeforeClass;

/**
* Tests against real S3 endpoint requiring credentials.
* Tests against genuine S3 endpoint requiring credentials.
*
* @author Radoslav Husar
*/
public class RealS3_PINGDiscoveryTestCase extends AbstractS3_PINGDiscoveryTestCase {
public class GenuineS3_PINGDiscoveryTestCase extends AbstractS3_PINGDiscoveryTestCase {

@BeforeClass
public static void assumeCredentials() {
Assume.assumeTrue("Credentials are not available, test is ignored!", System.getenv("AWS_ACCESS_KEY_ID") != null && System.getenv("AWS_SECRET_ACCESS_KEY") != null && System.getenv("S3_PING_BUCKET_NAME") != null);
Assume.assumeTrue("Credentials are not available, test will be ignored!", isGenuineCredentialsAvailable());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,16 @@
package org.jgroups.protocols.aws;

import com.adobe.testing.s3mock.testcontainers.S3MockContainer;
import org.jgroups.util.Util;
import org.junit.AfterClass;
import org.junit.Assume;
import org.junit.BeforeClass;
import org.testcontainers.DockerClientFactory;

import static org.junit.Assert.fail;

/**
* Tests against a mock S3 service.
* Tests against a containerized mock S3 service.
*
* @author Radoslav Husar
*/
Expand All @@ -33,7 +36,12 @@ public class MockS3_PINGDiscoveryTestCase extends AbstractS3_PINGDiscoveryTestCa

@BeforeClass
public static void setUp() {
Assume.assumeTrue("Docker environment is not available - skipping tests against S3 mock service.", isDockerAvailable());
// If credentials are available, we can conditionally skip Mock tests
if (isGenuineCredentialsAvailable() || (!isDockerAvailable() && !Util.checkForLinux())) {
Assume.assumeTrue("Podman/Docker environment is not available - skipping tests against S3 mock service.", isDockerAvailable());
} else if (!isDockerAvailable()) {
fail("Credentials are not provided, thus Podman/Docker on Linux is required to run tests against a mock service!");
}

// TODO Since 3.3.0 the obscure cluster name tests start to fail. Manage the version manually and keep on '3.2.0' for now.
s3Mock = new S3MockContainer("3.2.0");
Expand Down

0 comments on commit 5feccd2

Please sign in to comment.