use of com.alibaba.nacos.naming.misc.SwitchDomain in project nacos by alibaba.
the class OperatorControllerTest method testSwitchDomainForNotSupportUpgrade.
@Test
public void testSwitchDomainForNotSupportUpgrade() {
MockEnvironment environment = new MockEnvironment();
EnvUtil.setEnvironment(environment);
SwitchDomain switchDomain = operatorController.switches(new MockHttpServletRequest());
SwitchDomain expected = new SwitchDomain();
expected.update(switchDomain);
expected.setDoubleWriteEnabled(false);
Assert.assertEquals(expected.toString(), switchDomain.toString());
}
use of com.alibaba.nacos.naming.misc.SwitchDomain in project nacos by alibaba.
the class ServerStatusManagerTest method testUpdaterFromSwitch.
@Test
public void testUpdaterFromSwitch() {
SwitchDomain switchDomain = mock(SwitchDomain.class);
String expect = ServerStatus.DOWN.toString();
when(switchDomain.getOverriddenServerStatus()).thenReturn(expect);
ServerStatusManager serverStatusManager = new ServerStatusManager(switchDomain);
ServerStatusManager.ServerStatusUpdater updater = serverStatusManager.new ServerStatusUpdater();
// then
updater.run();
// then
ServerStatus serverStatus = serverStatusManager.getServerStatus();
Assert.assertEquals(expect, serverStatus.toString());
}
use of com.alibaba.nacos.naming.misc.SwitchDomain in project nacos by alibaba.
the class ServerStatusManagerTest method testUpdaterFromConsistency1.
@Test
public void testUpdaterFromConsistency1() throws NoSuchFieldException, IllegalAccessException {
SwitchDomain switchDomain = mock(SwitchDomain.class);
ServerStatusManager serverStatusManager = new ServerStatusManager(switchDomain);
Field field = ServerStatusManager.class.getDeclaredField("consistencyService");
field.setAccessible(true);
ConsistencyService consistencyService = mock(ConsistencyService.class);
when(consistencyService.isAvailable()).thenReturn(true);
field.set(serverStatusManager, consistencyService);
ServerStatusManager.ServerStatusUpdater updater = serverStatusManager.new ServerStatusUpdater();
// then
updater.run();
// then
Assert.assertEquals(ServerStatus.UP, serverStatusManager.getServerStatus());
}
use of com.alibaba.nacos.naming.misc.SwitchDomain in project nacos by alibaba.
the class OperatorControllerTest method testSwitchDomain.
@Test
public void testSwitchDomain() {
SwitchDomain switchDomain = operatorController.switches(new MockHttpServletRequest());
Assert.assertEquals(this.switchDomain, switchDomain);
}
use of com.alibaba.nacos.naming.misc.SwitchDomain in project nacos by alibaba.
the class DistroMapperTest method setUp.
@Before
public void setUp() {
ConcurrentSkipListMap<String, Member> serverList = new ConcurrentSkipListMap<>();
EnvUtil.setEnvironment(new StandardEnvironment());
serverList.put(ip1, Member.builder().ip(ip1).port(port).build());
serverList.put(ip2, Member.builder().ip(ip2).port(port).build());
serverList.put(ip3, Member.builder().ip(ip3).port(port).build());
EnvUtil.setLocalAddress(ip4);
serverList.put(EnvUtil.getLocalAddress(), Member.builder().ip(EnvUtil.getLocalAddress()).port(port).build());
HashSet<Member> set = new HashSet<>(serverList.values());
switchDomain = new SwitchDomain();
distroMapper = new DistroMapper(memberManager, switchDomain);
}
Aggregations