Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade org.testcontainers to version compatible with podman and vers… #327

Merged
merged 2 commits into from
Apr 16, 2024
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
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
Loading