Skip to content

Commit 7e317ad

Browse files
committed
Upload storage profile in hub workflow test as well.
Take hostname from env to overwrite storage profile in resources folder. Add hybrid MinIO STS setup. Add hybrid MinIO static setup. Upload storage profiles in tests instead of docker compose --profile local. Create access_key/secret_key for LOCAL_MINIO_STATIC instead of using root user. Cleanup setup, prepare MinIO HYBRID. Duplicate storage profiles to have full set for local and hybrid. Separate storage profiles for hybrid and local setups. # Conflicts: # hub/src/test/java/cloud/katta/client/model/ObjectMapperTest.java Separate storage profiles for hybrid and local setups. # Conflicts: # hub/src/test/java/cloud/katta/testsetup/AbstractHubTest.java # hub/src/test/resources/docker-compose-minio-localhost-hub.yml
1 parent b742825 commit 7e317ad

36 files changed

+535
-88
lines changed

hub/src/test/java/cloud/katta/client/model/ObjectMapperTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public void testAWSStatic() throws IOException {
2424
final ObjectMapper mapper = new ObjectMapper();
2525
mapper.registerModule(new JsonNullableModule());
2626

27-
final StorageProfileS3Dto awsStaticProfile = mapper.readValue(this.getClass().getResourceAsStream("/setup/aws_static/aws_static_profile.json"), StorageProfileS3Dto.class);
27+
final StorageProfileS3Dto awsStaticProfile = mapper.readValue(this.getClass().getResourceAsStream("/setup/hybrid/aws_static/aws_static_profile.json"), StorageProfileS3Dto.class);
2828
assertEquals(Protocol.S3, awsStaticProfile.getProtocol());
2929
assertEquals("https", awsStaticProfile.getScheme());
3030
assertNull(awsStaticProfile.getHostname());
@@ -41,7 +41,7 @@ public void testAWSSTS() throws IOException {
4141
mapper.registerModule(new JsonNullableModule());
4242

4343

44-
final StorageProfileS3STSDto awsSTSProfile = mapper.readValue(this.getClass().getResourceAsStream("/setup/aws_sts/aws_sts_profile.json"), StorageProfileS3STSDto.class);
44+
final StorageProfileS3STSDto awsSTSProfile = mapper.readValue(this.getClass().getResourceAsStream("/setup/hybrid/aws_sts/aws_sts_profile.json"), StorageProfileS3STSDto.class);
4545
assertEquals("katta-test-", awsSTSProfile.getBucketPrefix());
4646
assertEquals("eu-west-1", awsSTSProfile.getRegion());
4747
assertEquals(Arrays.asList("eu-west-1", "eu-west-2", "eu-west-3"), awsSTSProfile.getRegions());
@@ -64,7 +64,7 @@ public void testMinioStatic() throws IOException {
6464
final ObjectMapper mapper = new ObjectMapper();
6565
mapper.registerModule(new JsonNullableModule());
6666

67-
final StorageProfileS3Dto minioStaticProfile = mapper.readValue(this.getClass().getResourceAsStream("/setup/minio_static/minio_static_profile.json"), StorageProfileS3Dto.class);
67+
final StorageProfileS3Dto minioStaticProfile = mapper.readValue(this.getClass().getResourceAsStream("/setup/local/minio_static/minio_static_profile.json"), StorageProfileS3Dto.class);
6868
assertEquals(Protocol.S3, minioStaticProfile.getProtocol());
6969
assertEquals("http", minioStaticProfile.getScheme());
7070
assertEquals("minio", minioStaticProfile.getHostname());
@@ -79,7 +79,7 @@ public void testMinioStatic() throws IOException {
7979
public void testMinioSTS() throws IOException {
8080
final ObjectMapper mapper = new ObjectMapper();
8181
mapper.registerModule(new JsonNullableModule());
82-
final StorageProfileS3STSDto minioSTSProfile = mapper.readValue(this.getClass().getResourceAsStream("/setup/minio_sts/minio_sts_profile.json"), StorageProfileS3STSDto.class);
82+
final StorageProfileS3STSDto minioSTSProfile = mapper.readValue(this.getClass().getResourceAsStream("/setup/local/minio_sts/minio_sts_profile.json"), StorageProfileS3STSDto.class);
8383
assertEquals("katta-test-", minioSTSProfile.getBucketPrefix());
8484
assertEquals("eu-central-1", minioSTSProfile.getRegion());
8585
assertEquals(Arrays.asList("eu-west-1", "eu-west-2", "eu-west-3", "eu-north-1", "eu-south-1", "eu-south-2", "eu-central-1", "eu-central-2"), minioSTSProfile.getRegions());

hub/src/test/java/cloud/katta/core/AbstractHubSynchronizeTest.java

Lines changed: 40 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,11 @@
5353
import java.util.Arrays;
5454
import java.util.Collections;
5555
import java.util.EnumSet;
56+
import java.util.HashMap;
5657
import java.util.List;
58+
import java.util.Properties;
5759
import java.util.UUID;
60+
import java.util.stream.Collectors;
5861

5962
import cloud.katta.client.ApiClient;
6063
import cloud.katta.client.ApiException;
@@ -94,6 +97,15 @@ public abstract class AbstractHubSynchronizeTest extends AbstractHubTest {
9497
@MethodIgnorableSource(value = "arguments")
9598
public void test01Bootstrapping(final HubTestConfig hubTestConfig) throws Exception {
9699
log.info("M01 {}", hubTestConfig);
100+
final String profile = hubTestConfig.setup.dockerConfig.profile;
101+
final Properties props = new Properties();
102+
props.load(this.getClass().getResourceAsStream(hubTestConfig.setup.dockerConfig.envFile));
103+
final HashMap<String, String> env = props.entrySet().stream().collect(
104+
Collectors.toMap(
105+
e -> String.valueOf(e.getKey()),
106+
e -> String.valueOf(e.getValue()),
107+
(prev, next) -> next, HashMap::new
108+
));
97109

98110
final HubSession hubSession = setupConnection(hubTestConfig.setup);
99111
try {
@@ -105,7 +117,9 @@ public void test01Bootstrapping(final HubTestConfig hubTestConfig) throws Except
105117
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
106118
mapper.registerModule(new JsonNullableModule());
107119
try {
108-
adminStorageProfileApi.apiStorageprofileS3Put(mapper.readValue(AbstractHubSynchronizeTest.class.getResourceAsStream("/setup/aws_static/aws_static_profile.json"), StorageProfileS3Dto.class).storageClass(S3STORAGECLASSES.STANDARD));
120+
adminStorageProfileApi.apiStorageprofileS3Put(mapper.readValue(AbstractHubSynchronizeTest.class.getResourceAsStream(String.format("/setup/%s/aws_static/aws_static_profile.json", profile)), StorageProfileS3Dto.class)
121+
.storageClass(S3STORAGECLASSES.STANDARD)
122+
);
109123
}
110124
catch(ApiException e) {
111125
if(e.getCode() == 409) {
@@ -116,7 +130,7 @@ public void test01Bootstrapping(final HubTestConfig hubTestConfig) throws Except
116130
}
117131
}
118132
try {
119-
adminStorageProfileApi.apiStorageprofileS3stsPut(mapper.readValue(AbstractHubSynchronizeTest.class.getResourceAsStream("/setup/aws_sts/aws_sts_profile.json"), StorageProfileS3STSDto.class)
133+
adminStorageProfileApi.apiStorageprofileS3stsPut(mapper.readValue(AbstractHubSynchronizeTest.class.getResourceAsStream(String.format("/setup/%s/aws_sts/aws_sts_profile.json", profile)), StorageProfileS3STSDto.class)
120134
.storageClass(S3STORAGECLASSES.STANDARD).bucketEncryption(S3SERVERSIDEENCRYPTION.NONE));
121135
}
122136
catch(ApiException e) {
@@ -128,7 +142,17 @@ public void test01Bootstrapping(final HubTestConfig hubTestConfig) throws Except
128142
}
129143
}
130144
try {
131-
adminStorageProfileApi.apiStorageprofileS3Put(mapper.readValue(AbstractHubSynchronizeTest.class.getResourceAsStream("/setup/minio_static/minio_static_profile.json"), StorageProfileS3Dto.class).storageClass(S3STORAGECLASSES.STANDARD));
145+
final StorageProfileS3Dto storageProfile = mapper.readValue(AbstractHubSynchronizeTest.class.getResourceAsStream(String.format("/setup/%s/minio_static/minio_static_profile.json", profile)), StorageProfileS3Dto.class)
146+
.storageClass(S3STORAGECLASSES.STANDARD);
147+
final String minioPort = props.getProperty("MINIO_PORT");
148+
if(minioPort != null) {
149+
storageProfile.setPort(Integer.valueOf(minioPort));
150+
}
151+
final String minioHostname = props.getProperty("MINIO_HOSTNAME");
152+
if(minioHostname != null) {
153+
storageProfile.setHostname(minioHostname);
154+
}
155+
adminStorageProfileApi.apiStorageprofileS3Put(storageProfile);
132156
}
133157
catch(ApiException e) {
134158
if(e.getCode() == 409) {
@@ -139,8 +163,19 @@ public void test01Bootstrapping(final HubTestConfig hubTestConfig) throws Except
139163
}
140164
}
141165
try {
142-
final StorageProfileS3STSDto storageProfile = mapper.readValue(AbstractHubSynchronizeTest.class.getResourceAsStream("/setup/minio_sts/minio_sts_profile.json"), StorageProfileS3STSDto.class)
143-
.storageClass(S3STORAGECLASSES.STANDARD).bucketEncryption(S3SERVERSIDEENCRYPTION.NONE);
166+
final StorageProfileS3STSDto storageProfile = mapper.readValue(AbstractHubSynchronizeTest.class.getResourceAsStream(String.format("/setup/%s/minio_sts/minio_sts_profile.json", profile)), StorageProfileS3STSDto.class)
167+
.storageClass(S3STORAGECLASSES.STANDARD)
168+
.bucketEncryption(S3SERVERSIDEENCRYPTION.NONE);
169+
final String minioPort = props.getProperty("MINIO_PORT");
170+
if(minioPort != null) {
171+
storageProfile.setPort(Integer.valueOf(minioPort));
172+
storageProfile.setStsEndpoint(storageProfile.getStsEndpoint().replace("9000", minioPort));
173+
}
174+
final String minioHostname = props.getProperty("MINIO_HOSTNAME");
175+
if(minioHostname != null) {
176+
storageProfile.setStsEndpoint(storageProfile.getStsEndpoint().replace("minio", minioHostname));
177+
storageProfile.setHostname(minioHostname);
178+
}
144179
adminStorageProfileApi.apiStorageprofileS3stsPut(storageProfile);
145180
}
146181
catch(ApiException e) {

hub/src/test/java/cloud/katta/core/HubSynchronizeTest.java

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,7 @@ class HubSynchronizeTest {
2727
@TestInstance(PER_CLASS)
2828
public class Local extends AbstractHubSynchronizeTest {
2929
private Stream<Arguments> arguments() {
30-
return Stream.of(
31-
LOCAL_MINIO_STATIC,
32-
LOCAL_MINIO_STS);
30+
return Stream.of(LOCAL_MINIO_STATIC, LOCAL_MINIO_STS);
3331
}
3432
}
3533

@@ -58,12 +56,7 @@ private Stream<Arguments> arguments() {
5856
@TestInstance(PER_CLASS)
5957
public class Hybrid extends AbstractHubSynchronizeTest {
6058
private Stream<Arguments> arguments() {
61-
return Stream.of(
62-
HYBRID_MINIO_STATIC,
63-
HYBRID_MINIO_STS ,
64-
HYBRID_AWS_STATIC,
65-
HYBRID_AWS_STS
66-
);
59+
return Stream.of(HYBRID_MINIO_STATIC, HYBRID_MINIO_STS, HYBRID_AWS_STATIC, HYBRID_AWS_STS);
6760
}
6861
}
6962

hub/src/test/java/cloud/katta/testsetup/AbstractHubTest.java

Lines changed: 25 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -44,18 +44,9 @@ public abstract class AbstractHubTest extends VaultTest {
4444
credentials();
4545
}
4646

47-
private static final HubTestConfig.VaultSpec minioSTSVaultConfig = new HubTestConfig.VaultSpec("MinIO STS", "732D43FA-3716-46C4-B931-66EA5405EF1C",
48-
null, null, "eu-central-1");
49-
private static final HubTestConfig.VaultSpec minioStaticVaultConfig = new HubTestConfig.VaultSpec("MinIO static", "71B910E0-2ECC-46DE-A871-8DB28549677E",
50-
"minioadmin", "minioadmin", "us-east-1");
51-
private static final HubTestConfig.VaultSpec awsSTSVaultConfig = new HubTestConfig.VaultSpec("AWS STS", "844BD517-96D4-4787-BCFA-238E103149F6",
52-
null, null, "eu-west-1");
53-
private static final HubTestConfig.VaultSpec awsStaticVaultConfig = new HubTestConfig.VaultSpec("AWS static", "72736C19-283C-49D3-80A5-AB74B5202543",
54-
PROPERTIES.get("handmade2.s3.amazonaws.com.username"), PROPERTIES.get("handmade2.s3.amazonaws.com.password"), "us-east-1"
55-
);
5647

5748
/**
58-
* Local: hub, Keycloak, MinIO started via testcontainers+docker-compose.
49+
* LOCAL: hub, Keycloak, MinIO, localstack started via testcontainers+docker-compose.
5950
*/
6051
public static final HubTestConfig.Setup LOCAL;
6152
public static final HubTestConfig.Setup.DockerConfig LOCAL_DOCKER_CONFIG;
@@ -69,27 +60,18 @@ public abstract class AbstractHubTest extends VaultTest {
6960
.withDockerConfig(LOCAL_DOCKER_CONFIG);
7061
}
7162

72-
private static final Function<HubTestConfig.VaultSpec, Arguments> argumentUnattendedLocalOnly = vs -> Arguments.of(Named.of(
63+
private static final Function<HubTestConfig.VaultSpec, Arguments> prepareArgumentLocal = vs -> Arguments.of(Named.of(
7364
String.format("%s %s", vs.storageProfileName, LOCAL.hubURL),
7465
new HubTestConfig(LOCAL, vs)));
7566

67+
public static final Arguments LOCAL_MINIO_STATIC = prepareArgumentLocal.apply(new HubTestConfig.VaultSpec(
68+
"MinIO static", "71B910E0-2ECC-46DE-A871-8DB28549677E", "handmade_access", "top-secret", "us-east-1"));
69+
public static final Arguments LOCAL_MINIO_STS = prepareArgumentLocal.apply(new HubTestConfig.VaultSpec(
70+
"MinIO STS", "732D43FA-3716-46C4-B931-66EA5405EF1C", null, null, "eu-central-1"));
7671

77-
public static final Arguments LOCAL_MINIO_STATIC = argumentUnattendedLocalOnly.apply(minioStaticVaultConfig);
78-
public static final Arguments LOCAL_MINIO_STS = argumentUnattendedLocalOnly.apply(minioSTSVaultConfig);
7972

8073
/**
81-
* Local attended: re-use running local stetup.
82-
*/
83-
private static final HubTestConfig.Setup LOCAL_ATTENDED = new HubTestConfig.Setup()
84-
.withHubURL("http://localhost:8080")
85-
.withAdminConfig(new HubTestConfig.Setup.UserConfig("admin", "admin", staticSetupCode()))
86-
.withUserConfig(new HubTestConfig.Setup.UserConfig("alice", "asd", staticSetupCode()));
87-
private static final Function<HubTestConfig.VaultSpec, Arguments> argumentAttendedLocalOnly = vs -> Arguments.of(Named.of(
88-
String.format("%s %s", vs.storageProfileName, LOCAL_ATTENDED.hubURL),
89-
new HubTestConfig(LOCAL_ATTENDED, vs)));
90-
91-
/**
92-
* Hybrid: local hub (testcontainers+docker-compose) against AWS/MinIO/Keycloak remote.
74+
* HYBRID: local hub (testcontainers+docker-compose) against AWS/MinIO/Keycloak remote.
9375
*/
9476
public static final HubTestConfig.Setup HYBRID;
9577
public static final HubTestConfig.Setup.DockerConfig HYBRID_DOCKER_CONFIG;
@@ -98,7 +80,7 @@ public abstract class AbstractHubTest extends VaultTest {
9880
HYBRID_DOCKER_CONFIG = new HubTestConfig.Setup.DockerConfig(
9981
"/docker-compose-minio-localhost-hub.yml",
10082
"/.hybrid.env",
101-
null,
83+
"hybrid",
10284
PROPERTIES.get("testing.katta.cloud.chipotle.admin.name"),
10385
PROPERTIES.get("testing.katta.cloud.chipotle.admin.password"),
10486
PROPERTIES.get("testing.katta.cloud.chipotle.syncer.password")
@@ -120,15 +102,27 @@ public abstract class AbstractHubTest extends VaultTest {
120102
.withDockerConfig(HYBRID_DOCKER_CONFIG);
121103
}
122104

123-
private static final Function<HubTestConfig.VaultSpec, Arguments> argumentUnattendedHybrid = vs -> Arguments.of(Named.of(
105+
private static final Function<HubTestConfig.VaultSpec, Arguments> prepareArgumentsHybrid = vs -> Arguments.of(Named.of(
124106
String.format("%s %s", vs.storageProfileName, HYBRID.hubURL),
125107
new HubTestConfig(HYBRID, vs)));
126108

127109

128-
public static final Arguments HYBRID_MINIO_STATIC = argumentUnattendedHybrid.apply(minioStaticVaultConfig);
129-
public static final Arguments HYBRID_MINIO_STS = argumentUnattendedHybrid.apply(minioSTSVaultConfig);
130-
public static final Arguments HYBRID_AWS_STATIC = argumentUnattendedHybrid.apply(awsStaticVaultConfig);
131-
public static final Arguments HYBRID_AWS_STS = argumentUnattendedHybrid.apply(awsSTSVaultConfig);
110+
public static final Arguments HYBRID_MINIO_STATIC = prepareArgumentsHybrid.apply(new HubTestConfig.VaultSpec(
111+
"MinIO static", "71B910E0-2ECC-46DE-A871-8DB28549677E", PROPERTIES.get("minio.testing.katta.cloud.handmade_access_user.name"), PROPERTIES.get("minio.testing.katta.cloud.handmade_access_user.password"), "us-east-1"
112+
));
113+
public static final Arguments HYBRID_MINIO_STS = prepareArgumentsHybrid.apply(new HubTestConfig.VaultSpec(
114+
"MinIO STS", "732D43FA-3716-46C4-B931-66EA5405EF1C", null, null, "eu-central-1"
115+
));
116+
117+
public static final Arguments HYBRID_AWS_STATIC = prepareArgumentsHybrid.apply(new HubTestConfig.VaultSpec(
118+
"AWS static", "72736C19-283C-49D3-80A5-AB74B5202543", PROPERTIES.get("handmade2.s3.amazonaws.com.username"), PROPERTIES.get("handmade2.s3.amazonaws.com.password"),
119+
// TODO https://github.com/shift7-ch/katta-server/issues/87
120+
// "eu-north-1"
121+
"us-east-1"
122+
));
123+
public static final Arguments HYBRID_AWS_STS = prepareArgumentsHybrid.apply(new HubTestConfig.VaultSpec(
124+
"AWS STS", "844BD517-96D4-4787-BCFA-238E103149F6", null, null, "eu-west-1"
125+
));
132126

133127
@BeforeEach
134128
public void preferences() throws IOException {

0 commit comments

Comments
 (0)