1414import org .springframework .boot .test .context .SpringBootTest ;
1515import org .springframework .boot .testcontainers .service .connection .ServiceConnection ;
1616import org .springframework .test .context .ContextConfiguration ;
17+ import org .springframework .test .context .DynamicPropertyRegistry ;
18+ import org .springframework .test .context .DynamicPropertySource ;
1719import org .springframework .test .context .junit .jupiter .SpringExtension ;
1820import org .testcontainers .containers .Network ;
1921import org .testcontainers .junit .jupiter .Container ;
3032 + "/" + DaprCloudConfigIT .CONFIG_MULTI_NAME + "?type=doc&doc-type=yaml" ,
3133 "spring.config.import[1]=dapr:config:" + DaprCloudConfigIT .CONFIG_STORE_NAME
3234 + "/" + 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"
3338})
3439@ ContextConfiguration (classes = TestDaprCloudConfigConfiguration .class )
3540@ ExtendWith (SpringExtension .class )
@@ -69,7 +74,7 @@ protected void containerIsStarted(InspectContainerResponse containerInfo) {
6974 @ Container
7075 @ ServiceConnection
7176 private static final DaprContainer DAPR_CONTAINER = new DaprContainer (IMAGE_TAG )
72- .withAppName ("secret-store -dapr-app" )
77+ .withAppName ("configuration -dapr-app" )
7378 .withNetwork (DAPR_NETWORK )
7479 .withComponent (new Component (CONFIG_STORE_NAME , "configuration.redis" , "v1" , STORE_PROPERTY ))
7580 .withDaprLogLevel (DaprLogLevel .DEBUG )
@@ -81,6 +86,18 @@ private static Map<String, String> generateStoreProperty() {
8186 "redisPassword" , "" );
8287 }
8388
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+
84101 @ Value ("${dapr.spring.demo-config-config.singlevalue}" )
85102 String valueConfig ;
86103
0 commit comments