Search in sources :

Example 21 with RPCResponse

use of com.sequenceiq.cloudbreak.client.RPCResponse in project cloudbreak by hortonworks.

the class NodeServicesCheckerConclusionStepTest method checkShouldBeSuccessfulIfNodeStatusReportIsNullForOlderImageVersions.

@Test
public void checkShouldBeSuccessfulIfNodeStatusReportIsNullForOlderImageVersions() {
    RPCResponse<NodeStatusReport> response = new RPCResponse<>();
    RPCMessage message = new RPCMessage();
    message.setMessage("rpc response");
    response.setMessages(List.of(message));
    when(nodeStatusService.getServicesReport(eq(1L))).thenReturn(response);
    Conclusion stepResult = underTest.check(1L);
    assertFalse(stepResult.isFailureFound());
    assertNull(stepResult.getConclusion());
    assertNull(stepResult.getDetails());
    assertEquals(NodeServicesCheckerConclusionStep.class, stepResult.getConclusionStepClass());
    verify(nodeStatusService, times(1)).getServicesReport(eq(1L));
}
Also used : NodeStatusReport(com.cloudera.thunderhead.telemetry.nodestatus.NodeStatusProto.NodeStatusReport) RPCResponse(com.sequenceiq.cloudbreak.client.RPCResponse) RPCMessage(com.sequenceiq.cloudbreak.client.RPCMessage) Test(org.junit.jupiter.api.Test)

Example 22 with RPCResponse

use of com.sequenceiq.cloudbreak.client.RPCResponse in project cloudbreak by hortonworks.

the class SaltCheckerConclusionStepTest method checkShouldFallbackForOldImageVersionsAndReturnConclusionIfUnreachableNodeFound.

@Test
public void checkShouldFallbackForOldImageVersionsAndReturnConclusionIfUnreachableNodeFound() throws NodesUnreachableException {
    RPCResponse<SaltHealthReport> response = new RPCResponse<>();
    RPCMessage message = new RPCMessage();
    message.setMessage("rpc response");
    response.setMessages(List.of(message));
    when(nodeStatusService.saltPing(eq(1L))).thenReturn(response);
    when(stackService.getByIdWithListsInTransaction(eq(1L))).thenReturn(new Stack());
    when(stackUtil.collectNodes(any())).thenReturn(Set.of(createNode("host1"), createNode("host2")));
    when(stackUtil.collectAndCheckReachableNodes(any(), anyCollection())).thenThrow(new NodesUnreachableException("error", Set.of("host1")));
    Conclusion stepResult = underTest.check(1L);
    assertTrue(stepResult.isFailureFound());
    assertEquals("Unreachable nodes: [host1]. We detected that cluster members can’t communicate with each other. " + "Please validate if all cluster members are available and healthy through your cloud provider.", stepResult.getConclusion());
    assertEquals("Unreachable salt minions: [host1]", stepResult.getDetails());
    assertEquals(SaltCheckerConclusionStep.class, stepResult.getConclusionStepClass());
    verify(nodeStatusService, times(1)).saltPing(eq(1L));
    verify(stackService, times(1)).getByIdWithListsInTransaction(eq(1L));
    verify(stackUtil, times(1)).collectNodes(any());
    verify(stackUtil, times(1)).collectAndCheckReachableNodes(any(), any());
}
Also used : SaltHealthReport(com.cloudera.thunderhead.telemetry.nodestatus.NodeStatusProto.SaltHealthReport) RPCResponse(com.sequenceiq.cloudbreak.client.RPCResponse) RPCMessage(com.sequenceiq.cloudbreak.client.RPCMessage) NodesUnreachableException(com.sequenceiq.cloudbreak.util.NodesUnreachableException) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) Test(org.junit.jupiter.api.Test)

Example 23 with RPCResponse

use of com.sequenceiq.cloudbreak.client.RPCResponse in project cloudbreak by hortonworks.

the class SaltCheckerConclusionStepTest method checkShouldFallbackForOldImageVersionsAndBeSuccessfulIfNoUnreachableNodeFound.

@Test
public void checkShouldFallbackForOldImageVersionsAndBeSuccessfulIfNoUnreachableNodeFound() throws NodesUnreachableException {
    RPCResponse<SaltHealthReport> response = new RPCResponse<>();
    RPCMessage message = new RPCMessage();
    message.setMessage("rpc response");
    response.setMessages(List.of(message));
    when(nodeStatusService.saltPing(eq(1L))).thenReturn(response);
    when(stackService.getByIdWithListsInTransaction(eq(1L))).thenReturn(new Stack());
    Set<Node> nodes = Set.of(createNode("host1"), createNode("host2"));
    when(stackUtil.collectNodes(any())).thenReturn(nodes);
    when(stackUtil.collectAndCheckReachableNodes(any(), anyCollection())).thenReturn(nodes);
    Conclusion stepResult = underTest.check(1L);
    assertFalse(stepResult.isFailureFound());
    assertNull(stepResult.getConclusion());
    assertNull(stepResult.getDetails());
    assertEquals(SaltCheckerConclusionStep.class, stepResult.getConclusionStepClass());
    verify(nodeStatusService, times(1)).saltPing(eq(1L));
    verify(stackService, times(1)).getByIdWithListsInTransaction(eq(1L));
    verify(stackUtil, times(1)).collectNodes(any());
    verify(stackUtil, times(1)).collectAndCheckReachableNodes(any(), any());
}
Also used : SaltHealthReport(com.cloudera.thunderhead.telemetry.nodestatus.NodeStatusProto.SaltHealthReport) Node(com.sequenceiq.cloudbreak.common.orchestration.Node) RPCResponse(com.sequenceiq.cloudbreak.client.RPCResponse) RPCMessage(com.sequenceiq.cloudbreak.client.RPCMessage) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) Test(org.junit.jupiter.api.Test)

Example 24 with RPCResponse

use of com.sequenceiq.cloudbreak.client.RPCResponse in project cloudbreak by hortonworks.

the class BatchOperationTest method testInvoke.

@Test
public void testInvoke() throws FreeIpaClientException {
    Map warnings = Maps.newHashMap();
    List<Object> operations = Lists.newArrayList();
    RPCResponse<Object> rpcResponse = new RPCResponse<>();
    rpcResponse.setResult(new Object());
    when(freeIpaClient.invoke(any(), anyList(), any(), any())).thenReturn(rpcResponse);
    operations.add(UserAddOperation.create("user", "first", "last", false).getOperationParamsForBatchCall());
    BatchOperation.create(operations, warnings::put, Set.of()).invoke(freeIpaClient);
    verify(freeIpaClient).invoke(eq("batch"), anyList(), any(), any());
}
Also used : RPCResponse(com.sequenceiq.cloudbreak.client.RPCResponse) Map(java.util.Map) Test(org.junit.jupiter.api.Test)

Example 25 with RPCResponse

use of com.sequenceiq.cloudbreak.client.RPCResponse in project cloudbreak by hortonworks.

the class GroupAddMemberOperationTest method testInvoke.

@Test
public void testInvoke() throws FreeIpaClientException {
    Map warnings = Maps.newHashMap();
    RPCResponse<Object> rpcResponse = new RPCResponse<>();
    Group group = new Group();
    group.setMemberUser(USERS);
    rpcResponse.setResult(group);
    when(freeIpaClient.invoke(any(), anyList(), any(), any())).thenReturn(rpcResponse);
    GroupAddMemberOperation.create(GROUP_NAME, USERS, warnings::put).invoke(freeIpaClient);
    verify(freeIpaClient).invoke(eq("group_add_member"), anyList(), any(), any());
    assertEquals(0, warnings.size());
}
Also used : Group(com.sequenceiq.freeipa.client.model.Group) RPCResponse(com.sequenceiq.cloudbreak.client.RPCResponse) Map(java.util.Map) Test(org.junit.jupiter.api.Test)

Aggregations

RPCResponse (com.sequenceiq.cloudbreak.client.RPCResponse)43 Test (org.junit.jupiter.api.Test)31 Map (java.util.Map)17 Group (com.sequenceiq.freeipa.client.model.Group)12 User (com.sequenceiq.freeipa.client.model.User)10 FreeIpaClient (com.sequenceiq.freeipa.client.FreeIpaClient)9 FreeIpaClientException (com.sequenceiq.freeipa.client.FreeIpaClientException)9 ExtendWith (org.junit.jupiter.api.extension.ExtendWith)9 ArgumentMatchers.any (org.mockito.ArgumentMatchers.any)9 ArgumentMatchers.eq (org.mockito.ArgumentMatchers.eq)9 Mock (org.mockito.Mock)9 Mockito.verify (org.mockito.Mockito.verify)9 Mockito.when (org.mockito.Mockito.when)9 MockitoExtension (org.mockito.junit.jupiter.MockitoExtension)9 RPCMessage (com.sequenceiq.cloudbreak.client.RPCMessage)8 List (java.util.List)8 ArgumentMatchers.anyList (org.mockito.ArgumentMatchers.anyList)7 ArgumentMatchers.argThat (org.mockito.ArgumentMatchers.argThat)7 SudoRule (com.sequenceiq.freeipa.client.model.SudoRule)6 FmsUser (com.sequenceiq.freeipa.service.freeipa.user.model.FmsUser)6