Skip to content

Commit

Permalink
Merge branch 'main' into feature/disable-ssl-checks
Browse files Browse the repository at this point in the history
  • Loading branch information
jarlah authored Oct 10, 2023
2 parents b7f6f3a + ed74e7d commit 8522b4e
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 13 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>io.github.jarlah</groupId>
<artifactId>testcontainers-ceph</artifactId>
<version>1.1.2-SNAPSHOT</version>
<version>1.1.3-SNAPSHOT</version>
<packaging>jar</packaging>
<name>${project.groupId}:${project.artifactId}</name>
<description>Testcontainers Ceph</description>
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/org/testcontainers/containers/CephContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,19 @@ public class CephContainer extends GenericContainer<CephContainer> {

private static final String DEFAULT_IMAGE_TAG = "latest-quincy";

private static final String CEPH_RGW_DEFAULT_ACCESS_KEY = "accessKey";
private static final String CEPH_RGW_DEFAULT_ACCESS_KEY = "demo";

private static final String CEPH_RGW_DEFAULT_SECRET_KEY = "secretKey";
private static final String CEPH_RGW_DEFAULT_SECRET_KEY = "demo";

private static final Integer CEPH_MON_DEFAULT_PORT = 3300;

private static final Integer CEPH_RGW_DEFAULT_PORT = 8080;

private static final String CEPH_DEMO_UID = "admin";
private static final String CEPH_DEMO_UID = "demo";

private static final String CEPH_DEMO_BUCKET = "test-bucket";
private static final String CEPH_DEMO_BUCKET = "demo";

private static final String CEPH_END_START = ".*/opt/ceph-container/bin/demo: SUCCESS.*";
private static final String CEPH_END_START_REGEX_FORMAT = ".*Bucket 's3://%s/' created\n.*";

private String cephAccessKey;

Expand Down Expand Up @@ -87,7 +87,7 @@ public void configure() {
// This is important because without it, we cant access ceph from http://localhost:<PORT>
addEnv("RGW_NAME", "localhost");

setWaitStrategy(Wait.forLogMessage(CEPH_END_START, 1)
setWaitStrategy(Wait.forLogMessage(String.format(CEPH_END_START_REGEX_FORMAT, this.cephBucket), 1)
.withStartupTimeout(Duration.ofMinutes(5)));
}

Expand Down
36 changes: 30 additions & 6 deletions src/test/java/org/testcontainers/containers/CephContainerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import com.amazonaws.services.s3.AmazonS3ClientBuilder;
import com.amazonaws.services.s3.model.S3ObjectSummary;
import org.junit.Test;
import org.testcontainers.utility.DockerImageName;

import java.io.IOException;
import java.net.URISyntaxException;
Expand All @@ -34,19 +35,19 @@ public void testBasicUsage() throws Exception {
"rgw verify ssl = false\n" +
"rgw crypt require ssl = false"
);
assertThat(container.getCephAccessKey()).isEqualTo("accessKey");
assertThat(container.getCephSecretKey()).isEqualTo("secretKey");
assertThat(container.getCephBucket()).isEqualTo("test-bucket");
assertThat(container.getCephAccessKey()).isEqualTo("demo");
assertThat(container.getCephSecretKey()).isEqualTo("demo");
assertThat(container.getCephBucket()).isEqualTo("demo");

AmazonS3 s3client = getS3client(container);

assertThat(s3client.doesBucketExistV2(container.getCephBucket())).isTrue();
assertThat(s3client.doesBucketExistV2("demo")).isTrue();

URL file = this.getClass().getResource("/object_to_upload.txt");
assertThat(file).isNotNull();
s3client.putObject(container.getCephBucket(), "my-objectname", file.getFile());
s3client.putObject("demo", "my-objectname", file.getFile());

List<S3ObjectSummary> objets = s3client.listObjectsV2(container.getCephBucket()).getObjectSummaries();
List<S3ObjectSummary> objets = s3client.listObjectsV2("demo").getObjectSummaries();
assertThat(objets.size()).isEqualTo(1);
assertThat(objets.get(0).getKey()).isEqualTo("my-objectname");
}
Expand Down Expand Up @@ -78,6 +79,29 @@ public void testOverrides() throws Exception {
}
}

@Test
public void testSpecificDaemonImage() throws URISyntaxException {
DockerImageName daemonImage =
DockerImageName.parse("quay.io/ceph/daemon:v7.0.3-stable-7.0-quincy-centos-stream8-x86_64")
.asCompatibleSubstituteFor("quay.io/ceph/demo");
try (
// cephOverrides {
CephContainer container = new CephContainer(daemonImage)
.withCephAccessKey("testuser123")
.withCephSecretKey("testpassword123")
.withCephBucket("testbucket123")
.withCommand("demo")
// }
) {
container.start();
assertThat(container.getCephAccessKey()).isEqualTo("testuser123");
assertThat(container.getCephSecretKey()).isEqualTo("testpassword123");
assertThat(container.getCephBucket()).isEqualTo("testbucket123");
AmazonS3 s3client = getS3client(container);
assertThat(s3client.doesBucketExistV2("testbucket123")).isTrue();
}
}

// configuringClient {

private static AmazonS3 getS3client(CephContainer container) throws URISyntaxException {
Expand Down

0 comments on commit 8522b4e

Please sign in to comment.