Skip to content
Closed
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
4 changes: 0 additions & 4 deletions dhis-2/dhis-support/dhis-support-test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,6 @@
<groupId>org.testcontainers</groupId>
<artifactId>postgresql</artifactId>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>minio</artifactId>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,16 @@
import org.springframework.context.annotation.Configuration;

/**
* Use this configuration for tests relying on MinIO storage running in a Docker container. e.g. add
* to test class like `@ContextConfiguration(classes = {MinIODhisConfiguration.class})`
* Use this configuration for tests relying on S3 storage running in a Docker container. e.g. add to
* test class like `@ContextConfiguration(classes = {S3Configuration.class})`
*
* @author david mackessy
*/
@Configuration
public class MinIOConfiguration {
public class S3Configuration {
@Bean
public DhisConfigurationProvider dhisConfigurationProvider() {
return new MinIOConfigurationProvider(
return new S3ConfigurationProvider(
new TestContainerPostgresConfig().dhisConfigurationProvider().getProperties());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,44 +28,54 @@
package org.hisp.dhis.config;

import java.util.Properties;
import org.testcontainers.containers.MinIOContainer;
import org.testcontainers.utility.DockerImageName;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.containers.wait.strategy.Wait;

/**
* Config provider for MinIO store usage. It extends the Postgres config to make use of that setup.
* Config provider for S3 store usage, backed by a <a
* href="https://github.com/seaweedfs/seaweedfs">SeaweedFS</a> container with only its S3 gateway
* enabled. It extends the Postgres config to make use of that setup.
*
* @author david mackessy
*/
public class MinIOConfigurationProvider extends PostgresDhisConfigurationProvider {
public class S3ConfigurationProvider extends PostgresDhisConfigurationProvider {
private static final String S3_ACCESS_KEY = "testuser";
private static final String S3_SECRET_KEY = "testpassword";
private static final int S3_PORT = 8333;

private static final String S3_URL;
private static final String MINIO_USER = "testuser";
private static final String MINIO_PASSWORD = "testpassword";
private static final MinIOContainer MIN_IO_CONTAINER;
private static final GenericContainer<?> S3_CONTAINER;

static {
// Docker Hub no longer serves minio/minio (404 / pull access denied). Official
// community images remain on quay.io; Testcontainers requires a compatible substitute.
MIN_IO_CONTAINER =
new MinIOContainer(
DockerImageName.parse("quay.io/minio/minio:RELEASE.2024-07-16T23-46-41Z")
.asCompatibleSubstituteFor("minio/minio"))
.withUserName(MINIO_USER)
.withPassword(MINIO_PASSWORD);
MIN_IO_CONTAINER.start();
S3_URL = MIN_IO_CONTAINER.getS3URL();
S3_CONTAINER =
new GenericContainer<>("chrislusf/seaweedfs:4.47")
.withCommand(
"server",
"-dir=/data",
"-s3",
"-s3.port.iceberg=0",
"-s3.port.lance=0",
"-master.telemetry=false")
// SeaweedFS registers these as the admin S3 identity.
.withEnv("AWS_ACCESS_KEY_ID", S3_ACCESS_KEY)
.withEnv("AWS_SECRET_ACCESS_KEY", S3_SECRET_KEY)
.withExposedPorts(S3_PORT)
.waitingFor(Wait.forHttp("/healthz").forPort(S3_PORT));
S3_CONTAINER.start();
S3_URL = "http://" + S3_CONTAINER.getHost() + ":" + S3_CONTAINER.getMappedPort(S3_PORT);
}

public MinIOConfigurationProvider(Properties dhisConfig) {
setMinIOProperties(dhisConfig);
public S3ConfigurationProvider(Properties dhisConfig) {
setS3Properties(dhisConfig);
}

public void setMinIOProperties(Properties properties) {
public void setS3Properties(Properties properties) {
properties.put("filestore.provider", "s3");
properties.put("filestore.container", "dhis2");
properties.put("filestore.location", "eu-west-1");
properties.put("filestore.endpoint", S3_URL);
properties.put("filestore.identity", MINIO_USER);
properties.put("filestore.secret", MINIO_PASSWORD);
properties.put("filestore.identity", S3_ACCESS_KEY);
properties.put("filestore.secret", S3_SECRET_KEY);
this.properties = properties;
}
}
2 changes: 1 addition & 1 deletion dhis-2/dhis-test-e2e/config/dhis2_home/dhis.conf
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ redis.host = redis
filestore.provider = s3
filestore.container = dhis2
filestore.location = eu-west-1
filestore.endpoint = http://minio:9000
filestore.endpoint = http://s3:8333
filestore.identity = root
filestore.secret = dhisdhis

Expand Down
18 changes: 9 additions & 9 deletions dhis-2/dhis-test-e2e/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ services:
condition: service_healthy
redis:
condition: service_started
minio:
s3:
condition: service_healthy

db:
Expand All @@ -43,20 +43,20 @@ services:
ports:
- "6379"

minio:
image: quay.io/minio/minio
command: server /data --console-address ":9090"
s3:
image: chrislusf/seaweedfs:4.47
command: server -dir=/data -s3 -s3.port.iceberg=0 -s3.port.lance=0 -master.telemetry=false
ports:
- "9000" # minio API
- "9090" # minio UI
- "8333" # S3 API
healthcheck:
test: [ "CMD", "mc", "ready", "local" ]
test: [ "CMD", "wget", "--quiet", "--spider", "http://127.0.0.1:8333/healthz" ]
interval: 5s
timeout: 5s
retries: 5
environment:
MINIO_ROOT_USER: root
MINIO_ROOT_PASSWORD: dhisdhis
# SeaweedFS registers these as the admin S3 identity
AWS_ACCESS_KEY_ID: root
AWS_SECRET_ACCESS_KEY: dhisdhis

selenium:
image: "selenium/standalone-chrome:latest"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
import org.hisp.dhis.appmanager.ResourceResult.Redirect;
import org.hisp.dhis.appmanager.ResourceResult.ResourceFound;
import org.hisp.dhis.appmanager.ResourceResult.ResourceNotFound;
import org.hisp.dhis.config.MinIOConfiguration;
import org.hisp.dhis.config.S3Configuration;
import org.hisp.dhis.test.integration.IntegrationTestBase;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
Expand All @@ -56,17 +56,17 @@
import org.springframework.test.context.ContextConfiguration;

/**
* Test class configured for use cases when DHIS2 is configured to use MinIO storage. The default
* Test class configured for use cases when DHIS2 is configured to use S3 storage. The default
* storage is the local filesystem.
*/
@ContextConfiguration(classes = {MinIOConfiguration.class})
class AppManagerMinIOTest extends IntegrationTestBase {
@ContextConfiguration(classes = {S3Configuration.class})
class AppManagerS3Test extends IntegrationTestBase {

@Autowired AppManager appManager;

@Test
@DisplayName("Can install and then update an App using MinIO storage")
void canUpdateAppUsingMinIOStorageTest() throws IOException {
@DisplayName("Can install and then update an App using S3 storage")
void canUpdateAppUsingS3StorageTest() throws IOException {
// install an app for the 1st time (version 1)
AppStatus appStatus =
appManager.installApp(
Expand Down
9 changes: 3 additions & 6 deletions dhis-2/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,9 @@
<javax.persistence-api.version>2.2</javax.persistence-api.version>

<!-- Maven plugin versions -->
<maven-surefire-plugin.version>3.6.0</maven-surefire-plugin.version>
<!-- Surefire 3.6.0 treats groups/excludedGroups as JUnit 4 categories (not JUnit Platform tags)
when junit:junit is on the test classpath, which breaks the unit/integration test profiles -->
<maven-surefire-plugin.version>3.5.6</maven-surefire-plugin.version>
<maven-compiler-plugin.version>3.15.0</maven-compiler-plugin.version>
<maven-exec-plugin.version>3.6.4</maven-exec-plugin.version>
<maven-resources-plugin.version>3.5.0</maven-resources-plugin.version>
Expand Down Expand Up @@ -1756,11 +1758,6 @@
<artifactId>jdbc</artifactId>
<version>${testcontainers.version}</version>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>minio</artifactId>
<version>${testcontainers.version}</version>
</dependency>

<!-- Monitoring -->
<dependency>
Expand Down
Loading