Skip to content

Commit 105b21e

Browse files
test: add unit tests for ConfigurationModifier and fix TsfConsul report logic (#1802)
* test: add unit tests for ConfigurationModifier and fix TsfConsul report logic - Disable report when only TsfConsul is enabled in ConfigurationModifier - Add comprehensive unit tests for ConfigurationModifier - Fix test issues with lenient mocking and localFile -> local datasource type Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Haotian Zhang <928016560@qq.com> * fix: replace hardcoded IP 10.0.0.1 with 127.0.0.1 in tests CI hardcoded IP detection rejects non-loopback IPs. Use 127.0.0.1 with different ports to distinguish addresses in test cases. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Haotian Zhang <928016560@qq.com> * fix: replace leading spaces with tabs to pass checkstyle Fix 11 lines with mixed tab+space indentation that violated the RegexpSinglelineJava checkstyle rule. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Haotian Zhang <928016560@qq.com> * fix: correct PR number in CHANGELOG from #1801 to #1802 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Haotian Zhang <928016560@qq.com> --------- Signed-off-by: Haotian Zhang <928016560@qq.com> Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent d16e0af commit 105b21e

File tree

3 files changed

+834
-38
lines changed

3 files changed

+834
-38
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@
77
- [refactor: modify the initialization of ApplicationContextAwareUtils.](https://github.com/Tencent/spring-cloud-tencent/pull/1778)
88
- [feat: support enable/disable cloud location provider via configuration.](https://github.com/Tencent/spring-cloud-tencent/pull/1799)
99
- [feat: refactor Feign eager load, add LoadBalancer warm-up, and fix gateway trailing slash compatibility](https://github.com/Tencent/spring-cloud-tencent/pull/1800)
10+
- [test: add unit tests for ConfigurationModifier and fix TsfConsul report logic](https://github.com/Tencent/spring-cloud-tencent/pull/1802)

spring-cloud-starter-tencent-polaris-config/src/main/java/com/tencent/cloud/polaris/config/ConfigurationModifier.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import java.util.List;
2424

2525
import com.tencent.cloud.common.constant.OrderConstant;
26+
import com.tencent.cloud.common.tsf.TsfContextUtils;
2627
import com.tencent.cloud.common.util.AddressUtils;
2728
import com.tencent.cloud.polaris.config.config.PolarisConfigProperties;
2829
import com.tencent.cloud.polaris.config.config.PolarisCryptoConfigProperties;
@@ -126,7 +127,11 @@ private void initDataSource(ConfigurationImpl configuration) {
126127
connectorConfig.setEmptyProtectionEnable(polarisConfigProperties.isEmptyProtectionEnabled());
127128
connectorConfig.setEmptyProtectionExpiredInterval(polarisConfigProperties.getEmptyProtectionExpiredInterval());
128129

130+
// config report client address
129131
ServerConnectorConfigImpl reportClientConnectorConfig = configuration.getGlobal().getServerConnector();
132+
if (TsfContextUtils.isOnlyTsfConsulEnabled()) {
133+
configuration.getGlobal().getAPI().setReportEnable(false);
134+
}
130135
if (StringUtils.isNotBlank(polarisContextProperties.getAddress())) {
131136
reportClientConnectorConfig.setAddresses(AddressUtils.parseAddressList(polarisContextProperties.getAddress()));
132137
}

0 commit comments

Comments
 (0)