Skip to content

Commit dfa4a41

Browse files
authored
fix: fix test case unstable issues (#1324)
1 parent a96d541 commit dfa4a41

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

CHANGELOG.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,5 @@
1919
- [fix:fix the ratelimit bug for 2022](https://github.com/Tencent/spring-cloud-tencent/pull/1314)
2020
- [feat:add Tencent Cloud TSF support.](https://github.com/Tencent/spring-cloud-tencent/pull/1317)
2121
- [feat:support consul config.](https://github.com/Tencent/spring-cloud-tencent/pull/1319)
22-
- [feat:add trace report support.](https://github.com/Tencent/spring-cloud-tencent/pull/1322)
22+
- [feat:add trace report support.](https://github.com/Tencent/spring-cloud-tencent/pull/1322)
23+
- [fix: fix lossless test case unstable issues.](https://github.com/Tencent/spring-cloud-tencent/pull/1324)

spring-cloud-starter-tencent-polaris-discovery/src/test/java/com/tencent/cloud/plugin/lossless/LosslessRegistryAspectTest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,8 @@ public void testRegister() {
140140
assertThatCode(() -> {
141141
assertThat(OkHttpUtil.checkUrl(HOST, LOSSLESS_PORT_1, "/online", Collections.EMPTY_MAP)).isFalse();
142142
}).doesNotThrowAnyException();
143-
// delay register after 5s
144-
Thread.sleep(5000);
143+
// delay register after 10s
144+
Thread.sleep(10000);
145145
PolarisServiceRegistry registry = context.getBean(PolarisServiceRegistry.class);
146146
PolarisRegistration registration = context.getBean(PolarisRegistration.class);
147147

spring-cloud-tencent-polaris-context/src/main/java/com/tencent/cloud/polaris/context/PolarisSDKContextManager.java

+9-6
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import java.util.Objects;
2323

2424
import com.tencent.cloud.polaris.context.config.PolarisContextProperties;
25+
import com.tencent.polaris.api.config.Configuration;
2526
import com.tencent.polaris.api.control.Destroyable;
2627
import com.tencent.polaris.api.core.ConsumerAPI;
2728
import com.tencent.polaris.api.core.LosslessAPI;
@@ -229,9 +230,10 @@ public void initService() {
229230
}
230231
}
231232
// init SDKContext
232-
serviceSdkContext = SDKContext.initContextByConfig(properties.configuration(serviceModifierList,
233+
Configuration configuration = properties.configuration(serviceModifierList,
233234
() -> environment.getProperty("spring.cloud.client.ip-address"),
234-
() -> environment.getProperty("spring.cloud.polaris.local-port", Integer.class, 0)));
235+
() -> environment.getProperty("spring.cloud.polaris.local-port", Integer.class, 0));
236+
serviceSdkContext = SDKContext.initContextByConfig(configuration);
235237
serviceSdkContext.init();
236238

237239
// init ProviderAPI
@@ -269,7 +271,7 @@ public void initService() {
269271
}
270272
}
271273
}));
272-
LOG.info("create Polaris SDK context successfully. properties: {}, ", properties);
274+
LOG.info("create Polaris SDK context successfully. properties: {}, configuration: {}", properties, configuration);
273275
}
274276
catch (Throwable throwable) {
275277
LOG.error("create Polaris SDK context failed. properties: {}, ", properties, throwable);
@@ -289,14 +291,15 @@ public void initConfig() {
289291
if (null == configSDKContext && CollectionUtils.isNotEmpty(configModifierList)) {
290292
try {
291293
// init config SDKContext
292-
configSDKContext = SDKContext.initContextByConfig(properties.configuration(configModifierList,
294+
Configuration configuration = properties.configuration(configModifierList,
293295
() -> environment.getProperty("spring.cloud.client.ip-address"),
294-
() -> environment.getProperty("spring.cloud.polaris.local-port", Integer.class, 0)));
296+
() -> environment.getProperty("spring.cloud.polaris.local-port", Integer.class, 0));
297+
configSDKContext = SDKContext.initContextByConfig(configuration);
295298
configSDKContext.init();
296299

297300
// add shutdown hook
298301
Runtime.getRuntime().addShutdownHook(new Thread(PolarisSDKContextManager::innerConfigDestroy));
299-
LOG.info("create Polaris config SDK context successfully. properties: {}, ", properties);
302+
LOG.info("create Polaris config SDK context successfully. properties: {}, configuration: {}", properties, configuration);
300303
}
301304
catch (Throwable throwable) {
302305
LOG.error("create Polaris config SDK context failed. properties: {}, ", properties, throwable);

0 commit comments

Comments
 (0)