Skip to content

Commit

Permalink
Update tests to always run at least one of the variants against genui…
Browse files Browse the repository at this point in the history
…ne or mock service.

Rename the alternative test to MockS3.. to GenuineS3..
Update readme file accordingly.
  • Loading branch information
rhusar committed Apr 16, 2024
1 parent 38cf08f commit f9757de
Show file tree
Hide file tree
Showing 4 changed files with 19 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, 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
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 @@ -22,8 +22,10 @@
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 +35,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()) {
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 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 f9757de

Please sign in to comment.