14
14
import org .springframework .boot .test .context .SpringBootTest ;
15
15
import org .springframework .boot .testcontainers .service .connection .ServiceConnection ;
16
16
import org .springframework .test .context .ContextConfiguration ;
17
+ import org .springframework .test .context .DynamicPropertyRegistry ;
18
+ import org .springframework .test .context .DynamicPropertySource ;
17
19
import org .springframework .test .context .junit .jupiter .SpringExtension ;
18
20
import org .testcontainers .containers .Network ;
19
21
import org .testcontainers .junit .jupiter .Container ;
30
32
+ "/" + DaprCloudConfigIT .CONFIG_MULTI_NAME + "?type=doc&doc-type=yaml" ,
31
33
"spring.config.import[1]=dapr:config:" + DaprCloudConfigIT .CONFIG_STORE_NAME
32
34
+ "/" + DaprCloudConfigIT .CONFIG_SINGLE_NAME + "?type=value" ,
35
+ "dapr.cloudconfig.wait-sidecar-enabled=true" ,
36
+ "dapr.cloudconfig.wait-sidecar-retries=5" ,
37
+ "dapr.cloudconfig.timeout=20000"
33
38
})
34
39
@ ContextConfiguration (classes = TestDaprCloudConfigConfiguration .class )
35
40
@ ExtendWith (SpringExtension .class )
@@ -69,7 +74,7 @@ protected void containerIsStarted(InspectContainerResponse containerInfo) {
69
74
@ Container
70
75
@ ServiceConnection
71
76
private static final DaprContainer DAPR_CONTAINER = new DaprContainer (IMAGE_TAG )
72
- .withAppName ("secret-store -dapr-app" )
77
+ .withAppName ("configuration -dapr-app" )
73
78
.withNetwork (DAPR_NETWORK )
74
79
.withComponent (new Component (CONFIG_STORE_NAME , "configuration.redis" , "v1" , STORE_PROPERTY ))
75
80
.withDaprLogLevel (DaprLogLevel .DEBUG )
@@ -81,6 +86,18 @@ private static Map<String, String> generateStoreProperty() {
81
86
"redisPassword" , "" );
82
87
}
83
88
89
+ @ DynamicPropertySource
90
+ static void dynamicProperties (DynamicPropertyRegistry registry ) {
91
+ Logger logger = LoggerFactory .getLogger (DaprCloudConfigIT .class );
92
+
93
+ logger .info ("Now get dapr port and update config http:{}, grpc:{}" , DAPR_CONTAINER .getHttpPort (),
94
+ DAPR_CONTAINER .getGrpcPort ());
95
+
96
+ registry .add ("dapr.client.http-port" , DAPR_CONTAINER ::getHttpPort );
97
+ registry .add ("dapr.client.grpc-port" , DAPR_CONTAINER ::getGrpcPort );
98
+ }
99
+
100
+
84
101
@ Value ("${dapr.spring.demo-config-config.singlevalue}" )
85
102
String valueConfig ;
86
103
0 commit comments