use of com.alibaba.nacos.api.ability.ServerAbilities in project nacos by alibaba.
the class ClusterRpcClientProxyTest method setUp.
@Before
public void setUp() {
EnvUtil.setEnvironment(new MockEnvironment());
Member member = new Member();
member.setIp("1.1.1.1");
ServerAbilities serverAbilities = new ServerAbilities();
ServerRemoteAbility remoteAbility = new ServerRemoteAbility();
remoteAbility.setSupportRemoteConnection(true);
serverAbilities.setRemoteAbility(remoteAbility);
member.setAbilities(serverAbilities);
Mockito.when(serverMemberManager.allMembersWithoutSelf()).thenReturn(Collections.singletonList(member));
clusterRpcClientProxy.init();
}
use of com.alibaba.nacos.api.ability.ServerAbilities in project nacos by alibaba.
the class ServerLoaderControllerTest method testSmartReload.
@Test
public void testSmartReload() throws NacosException {
EnvUtil.setEnvironment(new MockEnvironment());
Member member = new Member();
member.setIp("1.1.1.1");
member.setPort(8848);
ServerAbilities serverAbilities = new ServerAbilities();
ServerRemoteAbility serverRemoteAbility = new ServerRemoteAbility();
serverRemoteAbility.setSupportRemoteConnection(true);
serverAbilities.setRemoteAbility(serverRemoteAbility);
member.setAbilities(serverAbilities);
Mockito.when(serverMemberManager.allMembersWithoutSelf()).thenReturn(Collections.singletonList(member));
Map<String, String> metrics = new HashMap<>();
metrics.put("conCount", "1");
metrics.put("sdkConCount", "1");
ServerLoaderInfoResponse serverLoaderInfoResponse = new ServerLoaderInfoResponse();
serverLoaderInfoResponse.setLoaderMetrics(metrics);
Mockito.when(serverLoaderInfoRequestHandler.handle(Mockito.any(), Mockito.any())).thenReturn(serverLoaderInfoResponse);
Mockito.when(serverMemberManager.getSelf()).thenReturn(member);
MockHttpServletRequest httpServletRequest = new MockHttpServletRequest();
ResponseEntity<String> result = serverLoaderController.smartReload(httpServletRequest, "1", null);
Assert.assertEquals("Ok", result.getBody());
}
use of com.alibaba.nacos.api.ability.ServerAbilities in project nacos by alibaba.
the class RemoteAbilityInitializerTest method testInitialize.
@Test
public void testInitialize() {
RemoteAbilityInitializer initializer = new RemoteAbilityInitializer();
ServerAbilities serverAbilities = new ServerAbilities();
assertFalse(serverAbilities.getRemoteAbility().isSupportRemoteConnection());
initializer.initialize(serverAbilities);
assertTrue(serverAbilities.getRemoteAbility().isSupportRemoteConnection());
}
use of com.alibaba.nacos.api.ability.ServerAbilities in project nacos by alibaba.
the class NamingAbilityInitializerTest method testInitialize.
@Test
public void testInitialize() {
NamingAbilityInitializer initializer = new NamingAbilityInitializer();
ServerAbilities abilities = new ServerAbilities();
assertFalse(abilities.getNamingAbility().isSupportJraft());
initializer.initialize(abilities);
assertTrue(abilities.getNamingAbility().isSupportJraft());
}
use of com.alibaba.nacos.api.ability.ServerAbilities in project nacos by alibaba.
the class ServerLoaderControllerTest method testLoaderMetrics.
@Test
public void testLoaderMetrics() throws NacosException {
EnvUtil.setEnvironment(new MockEnvironment());
Member member = new Member();
member.setIp("1.1.1.1");
member.setPort(8848);
ServerAbilities serverAbilities = new ServerAbilities();
ServerRemoteAbility serverRemoteAbility = new ServerRemoteAbility();
serverRemoteAbility.setSupportRemoteConnection(true);
serverAbilities.setRemoteAbility(serverRemoteAbility);
member.setAbilities(serverAbilities);
Mockito.when(serverMemberManager.allMembersWithoutSelf()).thenReturn(Collections.singletonList(member));
Map<String, String> metrics = new HashMap<>();
metrics.put("conCount", "1");
ServerLoaderInfoResponse serverLoaderInfoResponse = new ServerLoaderInfoResponse();
serverLoaderInfoResponse.setLoaderMetrics(metrics);
Mockito.when(serverLoaderInfoRequestHandler.handle(Mockito.any(), Mockito.any())).thenReturn(serverLoaderInfoResponse);
Mockito.when(serverMemberManager.getSelf()).thenReturn(member);
ResponseEntity<Map<String, Object>> result = serverLoaderController.loaderMetrics();
Assert.assertEquals(9, result.getBody().size());
}
Aggregations