|
54 | 54 | @Tag("testcontainers")
|
55 | 55 | class CloudConfigTests {
|
56 | 56 |
|
57 |
| - public static final String CONFIG_STORE_NAME = "democonfigconf"; |
58 |
| - public static final String CONFIG_MULTI_NAME = "multivalue-yaml"; |
59 |
| - public static final String CONFIG_SINGLE_NAME = "dapr.spring.demo-config-config.singlevalue"; |
60 |
| - |
61 |
| - public static final String SECRET_STORE_NAME = "democonfig"; |
62 |
| - public static final String SECRET_MULTI_NAME = "multivalue-properties"; |
63 |
| - public static final String SECRET_SINGLE_NAME = "dapr.spring.demo-config-secret.singlevalue"; |
64 |
| - |
65 |
| - public static final String SECRET_STORE_NAME_MULTI = "democonfigMultivalued"; |
66 |
| - |
67 |
| - private static final Map<String, String> SINGLE_VALUE_PROPERTY = generateSingleValueProperty(); |
68 |
| - private static final Map<String, String> MULTI_VALUE_PROPERTY = generateMultiValueProperty(); |
69 |
| - |
70 |
| - |
71 |
| - private static final Map<String, String> STORE_PROPERTY = generateStoreProperty(); |
72 |
| - |
73 |
| - private static final Network DAPR_NETWORK = Network.newNetwork(); |
74 |
| - |
75 |
| - @Container |
76 |
| - private static final RedisContainer REDIS_CONTAINER = new RedisContainer( |
77 |
| - RedisContainer.DEFAULT_IMAGE_NAME.withTag(RedisContainer.DEFAULT_TAG)) { |
78 |
| - @Override |
79 |
| - protected void containerIsStarted(InspectContainerResponse containerInfo) { |
80 |
| - super.containerIsStarted(containerInfo); |
81 |
| - |
82 |
| - String address = getHost(); |
83 |
| - Integer port = getMappedPort(6379); |
84 |
| - |
85 |
| - Logger logger = LoggerFactory.getLogger(CloudConfigTests.class); |
86 |
| - // Put values using Jedis |
87 |
| - try (Jedis jedis = new Jedis(address, port)) { |
88 |
| - logger.info("Putting Dapr Cloud config to {}:{}", address, port); |
89 |
| - jedis.set(CloudConfigTests.CONFIG_MULTI_NAME, DaprConfigurationStores.YAML_CONFIG); |
90 |
| - jedis.set(CloudConfigTests.CONFIG_SINGLE_NAME, "testvalue"); |
91 |
| - } |
92 |
| - } |
93 |
| - } |
94 |
| - .withNetworkAliases("redis") |
95 |
| - .withCommand() |
96 |
| - .withNetwork(DAPR_NETWORK); |
97 |
| - |
98 |
| - @Container |
99 |
| - @ServiceConnection |
100 |
| - private static final DaprContainer DAPR_CONTAINER = new DaprContainer("daprio/daprd:1.14.4") |
101 |
| - .withAppName("configuration-dapr-app") |
102 |
| - .withNetwork(DAPR_NETWORK) |
103 |
| - .withComponent(new Component(CONFIG_STORE_NAME, "configuration.redis", "v1", STORE_PROPERTY)) |
104 |
| - .withComponent(new Component(SECRET_STORE_NAME, "secretstores.local.file", "v1", SINGLE_VALUE_PROPERTY)) |
105 |
| - .withComponent(new Component(SECRET_STORE_NAME_MULTI, "secretstores.local.file", "v1", MULTI_VALUE_PROPERTY)) |
106 |
| - .withDaprLogLevel(DaprLogLevel.DEBUG) |
107 |
| - .withLogConsumer(outputFrame -> System.out.println(outputFrame.getUtf8String())) |
108 |
| - .dependsOn(REDIS_CONTAINER) |
109 |
| - .withCopyToContainer(Transferable.of(DaprSecretStores.SINGLE_VALUED_SECRET), "/dapr-secrets/singlevalued.json") |
110 |
| - .withCopyToContainer(Transferable.of(DaprSecretStores.MULTI_VALUED_SECRET), "/dapr-secrets/multivalued.json"); |
111 |
| - |
112 | 57 | static {
|
113 |
| - DAPR_CONTAINER.setPortBindings(List.of("3500:3500", "50001:50001")); |
114 |
| - } |
115 |
| - |
116 |
| - private static Map<String, String> generateStoreProperty() { |
117 |
| - return Map.of("redisHost", "redis:6379", |
118 |
| - "redisPassword", ""); |
119 |
| - } |
120 |
| - |
121 |
| - private static Map<String, String> generateSingleValueProperty() { |
122 |
| - return Map.of("secretsFile", "/dapr-secrets/singlevalued.json", |
123 |
| - "multiValued", "false"); |
124 |
| - } |
125 |
| - |
126 |
| - private static Map<String, String> generateMultiValueProperty() { |
127 |
| - return Map.of("secretsFile", "/dapr-secrets/multivalued.json", |
128 |
| - "nestedSeparator", ".", |
129 |
| - "multiValued", "true"); |
| 58 | + DaprTestContainersConfig.DAPR_CONTAINER.start(); |
130 | 59 | }
|
131 | 60 |
|
132 | 61 | @BeforeEach
|
|
0 commit comments