feat:update getPort method of PolarisRegistration. (#804)

pull/819/head
Haotian Zhang 2 years ago committed by GitHub
parent a15e2ceaa4
commit c750c206d9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -23,3 +23,4 @@
- [set reporter.enabled default to true](https://github.com/Tencent/spring-cloud-tencent/pull/786) - [set reporter.enabled default to true](https://github.com/Tencent/spring-cloud-tencent/pull/786)
- [fix:fix nacos enabled condition bugs.](https://github.com/Tencent/spring-cloud-tencent/pull/794) - [fix:fix nacos enabled condition bugs.](https://github.com/Tencent/spring-cloud-tencent/pull/794)
- [fix:fix instance's weight hard code to 100 bug.](https://github.com/Tencent/spring-cloud-tencent/pull/801) - [fix:fix instance's weight hard code to 100 bug.](https://github.com/Tencent/spring-cloud-tencent/pull/801)
- [feat:update getPort method of PolarisRegistration.](https://github.com/Tencent/spring-cloud-tencent/pull/804)

@ -67,12 +67,6 @@ public class PolarisDiscoveryProperties {
@Value("${spring.cloud.polaris.discovery.protocol:http}") @Value("${spring.cloud.polaris.discovery.protocol:http}")
private String protocol; private String protocol;
/**
* Port of instance.
*/
@Value("${server.port:8080}")
private int port;
/** /**
* Enable polaris discovery or not. * Enable polaris discovery or not.
*/ */
@ -130,18 +124,10 @@ public class PolarisDiscoveryProperties {
return enabled; return enabled;
} }
public void setEnabled(Boolean enabled) {
this.enabled = enabled;
}
public boolean isRegisterEnabled() { public boolean isRegisterEnabled() {
return registerEnabled; return registerEnabled;
} }
public void setRegisterEnabled(boolean registerEnabled) {
this.registerEnabled = registerEnabled;
}
public String getToken() { public String getToken() {
return token; return token;
} }
@ -166,14 +152,6 @@ public class PolarisDiscoveryProperties {
this.protocol = protocol; this.protocol = protocol;
} }
public int getPort() {
return port;
}
public void setPort(int port) {
this.port = port;
}
public String getHealthCheckUrl() { public String getHealthCheckUrl() {
return healthCheckUrl; return healthCheckUrl;
} }
@ -205,10 +183,18 @@ public class PolarisDiscoveryProperties {
return enabled; return enabled;
} }
public void setEnabled(Boolean enabled) {
this.enabled = enabled;
}
public Boolean getRegisterEnabled() { public Boolean getRegisterEnabled() {
return registerEnabled; return registerEnabled;
} }
public void setRegisterEnabled(boolean registerEnabled) {
this.registerEnabled = registerEnabled;
}
public void setRegisterEnabled(Boolean registerEnabled) { public void setRegisterEnabled(Boolean registerEnabled) {
this.registerEnabled = registerEnabled; this.registerEnabled = registerEnabled;
} }
@ -222,7 +208,6 @@ public class PolarisDiscoveryProperties {
", weight=" + weight + ", weight=" + weight +
", version='" + version + '\'' + ", version='" + version + '\'' +
", protocol='" + protocol + '\'' + ", protocol='" + protocol + '\'' +
", port=" + port +
", enabled=" + enabled + ", enabled=" + enabled +
", registerEnabled=" + registerEnabled + ", registerEnabled=" + registerEnabled +
", heartbeatInterval=" + heartbeatInterval + ", heartbeatInterval=" + heartbeatInterval +

@ -44,9 +44,6 @@ public class PolarisAutoServiceRegistration extends AbstractAutoServiceRegistrat
@Override @Override
protected PolarisRegistration getRegistration() { protected PolarisRegistration getRegistration() {
if (this.registration.getPort() <= 0) {
this.registration.setPort(this.getPort().get());
}
return this.registration; return this.registration;
} }
@ -61,9 +58,6 @@ public class PolarisAutoServiceRegistration extends AbstractAutoServiceRegistrat
log.debug("Registration disabled."); log.debug("Registration disabled.");
return; return;
} }
if (this.registration.getPort() <= 0) {
this.registration.setPort(getPort().get());
}
super.register(); super.register();
} }

@ -30,6 +30,8 @@ import com.tencent.cloud.polaris.extend.nacos.NacosContextProperties;
import com.tencent.polaris.client.api.SDKContext; import com.tencent.polaris.client.api.SDKContext;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext;
import org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext;
import org.springframework.cloud.client.DefaultServiceInstance; import org.springframework.cloud.client.DefaultServiceInstance;
import org.springframework.cloud.client.serviceregistry.Registration; import org.springframework.cloud.client.serviceregistry.Registration;
import org.springframework.lang.Nullable; import org.springframework.lang.Nullable;
@ -37,6 +39,7 @@ import org.springframework.util.CollectionUtils;
import static com.tencent.cloud.polaris.extend.nacos.NacosContextProperties.DEFAULT_CLUSTER; import static com.tencent.cloud.polaris.extend.nacos.NacosContextProperties.DEFAULT_CLUSTER;
import static com.tencent.cloud.polaris.extend.nacos.NacosContextProperties.DEFAULT_GROUP; import static com.tencent.cloud.polaris.extend.nacos.NacosContextProperties.DEFAULT_GROUP;
/** /**
* Registration object of Polaris. * Registration object of Polaris.
* *
@ -53,29 +56,38 @@ public class PolarisRegistration implements Registration {
private final ConsulContextProperties consulContextProperties; private final ConsulContextProperties consulContextProperties;
private final NacosContextProperties nacosContextProperties;
private final SDKContext polarisContext; private final SDKContext polarisContext;
private final StaticMetadataManager staticMetadataManager; private final StaticMetadataManager staticMetadataManager;
private final NacosContextProperties nacosContextProperties;
private final ServletWebServerApplicationContext servletWebServerApplicationContext;
private final ReactiveWebServerApplicationContext reactiveWebServerApplicationContext;
private Map<String, String> metadata; private Map<String, String> metadata;
private String host; private String host;
private int port;
private String instanceId; private String instanceId;
public PolarisRegistration( public PolarisRegistration(
PolarisDiscoveryProperties polarisDiscoveryProperties, PolarisDiscoveryProperties polarisDiscoveryProperties,
@Nullable ConsulContextProperties consulContextProperties, @Nullable ConsulContextProperties consulContextProperties,
SDKContext context, StaticMetadataManager staticMetadataManager,
@Nullable NacosContextProperties nacosContextProperties, @Nullable NacosContextProperties nacosContextProperties,
SDKContext context, StaticMetadataManager staticMetadataManager) { @Nullable ServletWebServerApplicationContext servletWebServerApplicationContext,
@Nullable ReactiveWebServerApplicationContext reactiveWebServerApplicationContext) {
this.polarisDiscoveryProperties = polarisDiscoveryProperties; this.polarisDiscoveryProperties = polarisDiscoveryProperties;
this.consulContextProperties = consulContextProperties; this.consulContextProperties = consulContextProperties;
this.nacosContextProperties = nacosContextProperties;
this.polarisContext = context; this.polarisContext = context;
this.staticMetadataManager = staticMetadataManager; this.staticMetadataManager = staticMetadataManager;
this.nacosContextProperties = nacosContextProperties;
this.servletWebServerApplicationContext = servletWebServerApplicationContext;
this.reactiveWebServerApplicationContext = reactiveWebServerApplicationContext;
host = polarisContext.getConfig().getGlobal().getAPI().getBindIP(); host = polarisContext.getConfig().getGlobal().getAPI().getBindIP();
} }
@ -100,17 +112,24 @@ public class PolarisRegistration implements Registration {
return host; return host;
} }
public void setHost(String host) {
this.host = host;
}
@Override @Override
public int getPort() { public int getPort() {
return polarisDiscoveryProperties.getPort(); if (port <= 0) {
if (servletWebServerApplicationContext != null) {
port = servletWebServerApplicationContext.getWebServer().getPort();
}
else if (reactiveWebServerApplicationContext != null) {
port = reactiveWebServerApplicationContext.getWebServer().getPort();
}
else {
throw new RuntimeException("Unsupported web type.");
}
}
return port;
} }
public void setPort(int port) { protected void setPort(int port) {
this.polarisDiscoveryProperties.setPort(port); this.port = port;
} }
@Override @Override
@ -130,7 +149,7 @@ public class PolarisRegistration implements Registration {
// put internal metadata // put internal metadata
instanceMetadata.put(METADATA_KEY_IP, host); instanceMetadata.put(METADATA_KEY_IP, host);
instanceMetadata.put(METADATA_KEY_ADDRESS, host + ":" + polarisDiscoveryProperties.getPort()); instanceMetadata.put(METADATA_KEY_ADDRESS, host + ":" + port);
// put internal-nacos-cluster if necessary // put internal-nacos-cluster if necessary
String clusterName = nacosContextProperties.getClusterName(); String clusterName = nacosContextProperties.getClusterName();

@ -174,7 +174,7 @@ public class PolarisServiceRegistry implements ServiceRegistry<PolarisRegistrati
} }
for (Instance instance : instances) { for (Instance instance : instances) {
if (instance.getHost().equalsIgnoreCase(registration.getHost()) if (instance.getHost().equalsIgnoreCase(registration.getHost())
&& instance.getPort() == polarisDiscoveryProperties.getPort()) { && instance.getPort() == registration.getPort()) {
return instance.isHealthy() ? "UP" : "DOWN"; return instance.isHealthy() ? "UP" : "DOWN";
} }
} }

@ -31,6 +31,8 @@ import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext;
import org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext;
import org.springframework.cloud.client.serviceregistry.AutoServiceRegistrationAutoConfiguration; import org.springframework.cloud.client.serviceregistry.AutoServiceRegistrationAutoConfiguration;
import org.springframework.cloud.client.serviceregistry.AutoServiceRegistrationConfiguration; import org.springframework.cloud.client.serviceregistry.AutoServiceRegistrationConfiguration;
import org.springframework.cloud.client.serviceregistry.AutoServiceRegistrationProperties; import org.springframework.cloud.client.serviceregistry.AutoServiceRegistrationProperties;
@ -62,9 +64,12 @@ public class PolarisServiceRegistryAutoConfiguration {
public PolarisRegistration polarisRegistration( public PolarisRegistration polarisRegistration(
PolarisDiscoveryProperties polarisDiscoveryProperties, PolarisDiscoveryProperties polarisDiscoveryProperties,
@Autowired(required = false) ConsulContextProperties consulContextProperties, @Autowired(required = false) ConsulContextProperties consulContextProperties,
SDKContext context, StaticMetadataManager staticMetadataManager, NacosContextProperties nacosContextProperties) { SDKContext context, StaticMetadataManager staticMetadataManager, NacosContextProperties nacosContextProperties,
return new PolarisRegistration(polarisDiscoveryProperties, consulContextProperties, nacosContextProperties, context, @Autowired(required = false) ServletWebServerApplicationContext servletWebServerApplicationContext,
staticMetadataManager); @Autowired(required = false) ReactiveWebServerApplicationContext reactiveWebServerApplicationContext) {
return new PolarisRegistration(polarisDiscoveryProperties, consulContextProperties, context,
staticMetadataManager, nacosContextProperties,
servletWebServerApplicationContext, reactiveWebServerApplicationContext);
} }
@Bean @Bean

@ -21,7 +21,6 @@ package com.tencent.cloud.polaris;
import org.junit.Test; import org.junit.Test;
import static com.tencent.polaris.test.common.Consts.NAMESPACE_TEST; import static com.tencent.polaris.test.common.Consts.NAMESPACE_TEST;
import static com.tencent.polaris.test.common.Consts.PORT;
import static com.tencent.polaris.test.common.Consts.PROVIDER_TOKEN; import static com.tencent.polaris.test.common.Consts.PROVIDER_TOKEN;
import static com.tencent.polaris.test.common.Consts.SERVICE_PROVIDER; import static com.tencent.polaris.test.common.Consts.SERVICE_PROVIDER;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
@ -77,10 +76,6 @@ public class PolarisDiscoveryPropertiesTest {
polarisDiscoveryProperties.setProtocol("HTTP"); polarisDiscoveryProperties.setProtocol("HTTP");
assertThat(polarisDiscoveryProperties.getProtocol()).isEqualTo("HTTP"); assertThat(polarisDiscoveryProperties.getProtocol()).isEqualTo("HTTP");
// Port
polarisDiscoveryProperties.setPort(PORT);
assertThat(polarisDiscoveryProperties.getPort()).isEqualTo(PORT);
// HealthCheckUrl // HealthCheckUrl
polarisDiscoveryProperties.setHealthCheckUrl("/health"); polarisDiscoveryProperties.setHealthCheckUrl("/health");
assertThat(polarisDiscoveryProperties.getHealthCheckUrl()).isEqualTo("/health"); assertThat(polarisDiscoveryProperties.getHealthCheckUrl()).isEqualTo("/health");
@ -96,7 +91,6 @@ public class PolarisDiscoveryPropertiesTest {
+ ", token='19485a7674294e3c88dba293373c1534'" + ", token='19485a7674294e3c88dba293373c1534'"
+ ", weight=10, version='1.0.0'" + ", weight=10, version='1.0.0'"
+ ", protocol='HTTP'" + ", protocol='HTTP'"
+ ", port=9091"
+ ", enabled=true" + ", enabled=true"
+ ", registerEnabled=true" + ", registerEnabled=true"
+ ", heartbeatInterval=20" + ", heartbeatInterval=20"

@ -29,7 +29,6 @@ import org.springframework.cloud.client.serviceregistry.ServiceRegistry;
import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContext;
import org.springframework.core.env.Environment; import org.springframework.core.env.Environment;
import static com.tencent.polaris.test.common.Consts.PORT;
import static com.tencent.polaris.test.common.Consts.SERVICE_PROVIDER; import static com.tencent.polaris.test.common.Consts.SERVICE_PROVIDER;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.fail; import static org.junit.Assert.fail;
@ -90,15 +89,6 @@ public class PolarisAutoServiceRegistrationTest {
} }
doReturn(true).when(registration).isRegisterEnabled(); doReturn(true).when(registration).isRegisterEnabled();
doReturn(-1).when(registration).getPort();
try {
polarisAutoServiceRegistration.register();
}
catch (Exception e) {
fail();
}
doReturn(PORT).when(registration).getPort();
try { try {
polarisAutoServiceRegistration.register(); polarisAutoServiceRegistration.register();
} }

@ -33,6 +33,10 @@ import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.mockito.junit.MockitoJUnitRunner; import org.mockito.junit.MockitoJUnitRunner;
import org.springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext;
import org.springframework.boot.web.server.WebServer;
import org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext;
import static com.tencent.polaris.test.common.Consts.HOST; import static com.tencent.polaris.test.common.Consts.HOST;
import static com.tencent.polaris.test.common.Consts.PORT; import static com.tencent.polaris.test.common.Consts.PORT;
import static com.tencent.polaris.test.common.Consts.SERVICE_PROVIDER; import static com.tencent.polaris.test.common.Consts.SERVICE_PROVIDER;
@ -49,21 +53,29 @@ import static org.mockito.Mockito.when;
@RunWith(MockitoJUnitRunner.class) @RunWith(MockitoJUnitRunner.class)
public class PolarisRegistrationTest { public class PolarisRegistrationTest {
private PolarisRegistration polarisRegistration; private NacosContextProperties nacosContextProperties;
private PolarisRegistration polarisRegistration1;
private PolarisRegistration polarisRegistration2;
NacosContextProperties nacosContextProperties = mock(NacosContextProperties.class); private PolarisRegistration polarisRegistration3;
@Before @Before
public void setUp() { public void setUp() {
// mock PolarisDiscoveryProperties // mock PolarisDiscoveryProperties
PolarisDiscoveryProperties polarisDiscoveryProperties = mock(PolarisDiscoveryProperties.class); PolarisDiscoveryProperties polarisDiscoveryProperties = mock(PolarisDiscoveryProperties.class);
doReturn(SERVICE_PROVIDER).when(polarisDiscoveryProperties).getService(); doReturn(SERVICE_PROVIDER).when(polarisDiscoveryProperties).getService();
doReturn(PORT).when(polarisDiscoveryProperties).getPort();
doReturn("http").when(polarisDiscoveryProperties).getProtocol(); doReturn("http").when(polarisDiscoveryProperties).getProtocol();
doReturn(true).when(polarisDiscoveryProperties).isRegisterEnabled(); doReturn(true).when(polarisDiscoveryProperties).isRegisterEnabled();
// mock // mock ConsulContextProperties
ConsulContextProperties consulContextProperties = mock(ConsulContextProperties.class); ConsulContextProperties consulContextProperties = mock(ConsulContextProperties.class);
doReturn(true).when(consulContextProperties).isEnabled();
doReturn(true).when(consulContextProperties).isRegister();
// mock NacosContextProperties
nacosContextProperties = mock(NacosContextProperties.class);
doReturn(true).when(nacosContextProperties).isEnabled();
doReturn(true).when(nacosContextProperties).isRegisterEnabled();
// mock SDKContext // mock SDKContext
APIConfig apiConfig = mock(APIConfig.class); APIConfig apiConfig = mock(APIConfig.class);
@ -79,38 +91,72 @@ public class PolarisRegistrationTest {
StaticMetadataManager staticMetadataManager = mock(StaticMetadataManager.class); StaticMetadataManager staticMetadataManager = mock(StaticMetadataManager.class);
doReturn(Collections.singletonMap("key1", "value1")).when(staticMetadataManager).getMergedStaticMetadata(); doReturn(Collections.singletonMap("key1", "value1")).when(staticMetadataManager).getMergedStaticMetadata();
polarisRegistration = new PolarisRegistration(polarisDiscoveryProperties, consulContextProperties, // mock ServletWebServerApplicationContext
nacosContextProperties, polarisContext, staticMetadataManager); WebServer servletwebServer = mock(WebServer.class);
doReturn(PORT).when(servletwebServer).getPort();
ServletWebServerApplicationContext servletWebServerApplicationContext = mock(ServletWebServerApplicationContext.class);
doReturn(servletwebServer).when(servletWebServerApplicationContext).getWebServer();
// mock ReactiveWebServerApplicationContext
WebServer reactiveWebServer = mock(WebServer.class);
doReturn(PORT + 1).when(reactiveWebServer).getPort();
ReactiveWebServerApplicationContext reactiveWebServerApplicationContext = mock(ReactiveWebServerApplicationContext.class);
doReturn(reactiveWebServer).when(reactiveWebServerApplicationContext).getWebServer();
polarisRegistration1 = new PolarisRegistration(polarisDiscoveryProperties, consulContextProperties,
polarisContext, staticMetadataManager, nacosContextProperties,
servletWebServerApplicationContext, null);
polarisRegistration2 = new PolarisRegistration(polarisDiscoveryProperties, consulContextProperties,
polarisContext, staticMetadataManager, nacosContextProperties,
null, reactiveWebServerApplicationContext);
polarisRegistration3 = new PolarisRegistration(polarisDiscoveryProperties, consulContextProperties,
polarisContext, staticMetadataManager, nacosContextProperties,
null, null);
} }
@Test @Test
public void testGetServiceId() { public void testGetServiceId() {
assertThat(polarisRegistration.getServiceId()).isEqualTo(SERVICE_PROVIDER); assertThat(polarisRegistration1.getServiceId()).isEqualTo(SERVICE_PROVIDER);
} }
@Test @Test
public void testGetHost() { public void testGetHost() {
assertThat(polarisRegistration.getHost()).isEqualTo(HOST); assertThat(polarisRegistration1.getHost()).isEqualTo(HOST);
} }
@Test @Test
public void testGetPort() { public void testGetPort() {
assertThat(polarisRegistration.getPort()).isEqualTo(PORT); assertThat(polarisRegistration1.getPort()).isEqualTo(PORT);
assertThat(polarisRegistration2.getPort()).isEqualTo(PORT + 1);
try {
polarisRegistration3.getPort();
}
catch (RuntimeException e) {
assertThat(e.getMessage()).isEqualTo("Unsupported web type.");
}
} }
@Test @Test
public void testIsSecure() { public void testIsSecure() {
assertThat(polarisRegistration.isSecure()).isFalse(); assertThat(polarisRegistration1.isSecure()).isFalse();
} }
@Test @Test
public void testGetUri() { public void testGetUri() {
assertThat(polarisRegistration.getUri().toString()).isEqualTo("http://" + HOST + ":" + PORT); assertThat(polarisRegistration1.getUri().toString()).isEqualTo("http://" + HOST + ":" + PORT);
}
@Test
public void testInstanceId() {
polarisRegistration1.setInstanceId("TEST");
assertThat(polarisRegistration1.getInstanceId()).isEqualTo("TEST");
} }
@Test @Test
public void testGetMetadata() { public void testGetMetadata() {
Map<String, String> metadata = polarisRegistration.getMetadata(); Map<String, String> metadata = polarisRegistration1.getMetadata();
assertThat(metadata).isNotNull(); assertThat(metadata).isNotNull();
assertThat(metadata).isNotEmpty(); assertThat(metadata).isNotEmpty();
assertThat(metadata.size()).isEqualTo(3); assertThat(metadata.size()).isEqualTo(3);
@ -119,17 +165,17 @@ public class PolarisRegistrationTest {
@Test @Test
public void testGetPolarisProperties() { public void testGetPolarisProperties() {
assertThat(polarisRegistration.getPolarisProperties()).isNotNull(); assertThat(polarisRegistration1.getPolarisProperties()).isNotNull();
} }
@Test @Test
public void testIsRegisterEnabled() { public void testIsRegisterEnabled() {
assertThat(polarisRegistration.isRegisterEnabled()).isTrue(); assertThat(polarisRegistration1.isRegisterEnabled()).isTrue();
} }
@Test @Test
public void testToString() { public void testToString() {
System.out.println(polarisRegistration); System.out.println(polarisRegistration1);
} }
@Test @Test
@ -137,7 +183,7 @@ public class PolarisRegistrationTest {
String groupName = "group"; String groupName = "group";
String format = "%s__%s"; String format = "%s__%s";
when(nacosContextProperties.getGroup()).thenReturn(groupName); when(nacosContextProperties.getGroup()).thenReturn(groupName);
String serviceId = polarisRegistration.getServiceId(); String serviceId = polarisRegistration1.getServiceId();
assertThat(String.format(format, groupName, SERVICE_PROVIDER).equals(serviceId)); assertThat(String.format(format, groupName, SERVICE_PROVIDER).equals(serviceId));
} }
@ -145,7 +191,7 @@ public class PolarisRegistrationTest {
public void testGetNacosMetadata() { public void testGetNacosMetadata() {
String clusterName = "cluster"; String clusterName = "cluster";
when(nacosContextProperties.getClusterName()).thenReturn(clusterName); when(nacosContextProperties.getClusterName()).thenReturn(clusterName);
Map<String, String> metadata = polarisRegistration.getMetadata(); Map<String, String> metadata = polarisRegistration1.getMetadata();
assertThat(metadata).isNotNull(); assertThat(metadata).isNotNull();
assertThat(metadata).isNotEmpty(); assertThat(metadata).isNotEmpty();
assertThat(metadata.size()).isEqualTo(4); assertThat(metadata.size()).isEqualTo(4);

@ -14,6 +14,16 @@
<name>Polaris Discovery Callee Service</name> <name>Polaris Discovery Callee Service</name>
<dependencies> <dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
</dependency>
<!-- <dependency>-->
<!-- <groupId>org.springframework.boot</groupId>-->
<!-- <artifactId>spring-boot-starter-web</artifactId>-->
<!-- </dependency>-->
<dependency> <dependency>
<groupId>com.tencent.cloud</groupId> <groupId>com.tencent.cloud</groupId>
<artifactId>spring-cloud-starter-tencent-polaris-discovery</artifactId> <artifactId>spring-cloud-starter-tencent-polaris-discovery</artifactId>

@ -1,5 +1,5 @@
server: server:
port: 48084 port: ${random.int(7003,7005)}
spring: spring:
application: application:
name: DiscoveryCalleeService name: DiscoveryCalleeService

@ -18,6 +18,11 @@
</properties> </properties>
<dependencies> <dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency> <dependency>
<groupId>com.tencent.cloud</groupId> <groupId>com.tencent.cloud</groupId>
<artifactId>spring-cloud-starter-tencent-polaris-discovery</artifactId> <artifactId>spring-cloud-starter-tencent-polaris-discovery</artifactId>

@ -20,15 +20,10 @@
</modules> </modules>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId> <artifactId>spring-boot-starter-actuator</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency> <dependency>
<groupId>org.springframework.cloud</groupId> <groupId>org.springframework.cloud</groupId>

@ -54,7 +54,8 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when; import static org.mockito.Mockito.when;
/** /**
* Test for {@link EnhancedRestTemplateReporter} * Test for {@link EnhancedRestTemplateReporter}.
*
* @author lepdou 2022-09-06 * @author lepdou 2022-09-06
*/ */
@RunWith(MockitoJUnitRunner.class) @RunWith(MockitoJUnitRunner.class)

Loading…
Cancel
Save