[ISSUE #58]Supports adding namesrvAddr cluster management (#66)

Co-authored-by: zhangjidi2016 <zhangjidi@cmss.chinamobile.com>
This commit is contained in:
zhangjidi2016
2022-04-08 15:43:21 +08:00
committed by GitHub
parent f5b9bbb9a7
commit daa181ccfd
7 changed files with 70 additions and 4 deletions

View File

@@ -63,7 +63,7 @@ public abstract class BaseControllerTest extends BaseTest {
when(configure.getAccessKey()).thenReturn("12345678");
when(configure.getSecretKey()).thenReturn("rocketmq");
when(configure.getNamesrvAddr()).thenReturn("127.0.0.1:9876");
when(configure.getNamesrvAddrs()).thenReturn(Lists.asList("127.0.0.1:9876", new String[] {"127.0.0.2:9876"}));
when(configure.getNamesrvAddrs()).thenReturn(Lists.newArrayList("127.0.0.1:9876", "127.0.0.2:9876"));
when(configure.isACLEnabled()).thenReturn(true);
when(configure.isUseTLS()).thenReturn(false);
}

View File

@@ -35,6 +35,7 @@ import org.springframework.test.util.ReflectionTestUtils;
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
import static org.hamcrest.Matchers.hasSize;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.doNothing;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
@@ -83,6 +84,20 @@ public class OpsControllerTest extends BaseControllerTest {
Assert.assertEquals(configure.getNamesrvAddr(), "127.0.0.1:9876");
}
@Test
public void testAddNameSvrAddr() throws Exception {
final String url = "/ops/addNameSvrAddr.do";
{
doNothing().when(configure).setNamesrvAddrs(any());
}
requestBuilder = MockMvcRequestBuilders.post(url);
requestBuilder.param("newNamesrvAddr", "127.0.0.3:9876");
perform = mockMvc.perform(requestBuilder);
perform.andExpect(status().isOk())
.andExpect(jsonPath("$.data").value(true));
Assert.assertEquals(configure.getNamesrvAddrs().size(), 3);
}
@Test
public void testUpdateIsVIPChannel() throws Exception {
final String url = "/ops/updateIsVIPChannel.do";