Search in sources :

Example 1 with ServerAbilities

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();
}
Also used : MockEnvironment(org.springframework.mock.env.MockEnvironment) ServerRemoteAbility(com.alibaba.nacos.api.remote.ability.ServerRemoteAbility) ServerAbilities(com.alibaba.nacos.api.ability.ServerAbilities) Member(com.alibaba.nacos.core.cluster.Member) Before(org.junit.Before)

Example 2 with ServerAbilities

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());
}
Also used : HashMap(java.util.HashMap) MockEnvironment(org.springframework.mock.env.MockEnvironment) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) ServerLoaderInfoResponse(com.alibaba.nacos.api.remote.response.ServerLoaderInfoResponse) ServerRemoteAbility(com.alibaba.nacos.api.remote.ability.ServerRemoteAbility) ServerAbilities(com.alibaba.nacos.api.ability.ServerAbilities) Member(com.alibaba.nacos.core.cluster.Member) Test(org.junit.Test)

Example 3 with ServerAbilities

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());
}
Also used : ServerAbilities(com.alibaba.nacos.api.ability.ServerAbilities) Test(org.junit.Test)

Example 4 with ServerAbilities

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());
}
Also used : ServerAbilities(com.alibaba.nacos.api.ability.ServerAbilities) Test(org.junit.Test)

Example 5 with ServerAbilities

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());
}
Also used : HashMap(java.util.HashMap) MockEnvironment(org.springframework.mock.env.MockEnvironment) ServerLoaderInfoResponse(com.alibaba.nacos.api.remote.response.ServerLoaderInfoResponse) ServerRemoteAbility(com.alibaba.nacos.api.remote.ability.ServerRemoteAbility) ServerAbilities(com.alibaba.nacos.api.ability.ServerAbilities) Member(com.alibaba.nacos.core.cluster.Member) HashMap(java.util.HashMap) Map(java.util.Map) Test(org.junit.Test)

Aggregations

ServerAbilities (com.alibaba.nacos.api.ability.ServerAbilities)5 Test (org.junit.Test)4 ServerRemoteAbility (com.alibaba.nacos.api.remote.ability.ServerRemoteAbility)3 Member (com.alibaba.nacos.core.cluster.Member)3 MockEnvironment (org.springframework.mock.env.MockEnvironment)3 ServerLoaderInfoResponse (com.alibaba.nacos.api.remote.response.ServerLoaderInfoResponse)2 HashMap (java.util.HashMap)2 Map (java.util.Map)1 Before (org.junit.Before)1 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)1