use of com.sequenceiq.cloudbreak.orchestrator.salt.client.SaltConnector in project cloudbreak by hortonworks.
the class GrainAddRunnerTest method submitTest.
@Test
public void submitTest() {
Set<String> targets = new HashSet<>();
targets.add("10.0.0.1");
targets.add("10.0.0.2");
targets.add("10.0.0.3");
Set<Node> allNode = new HashSet<>();
allNode.add(new Node("10.0.0.1", "5.5.5.1", "10-0-0-1.example.com", "hg"));
allNode.add(new Node("10.0.0.2", "5.5.5.2", "10-0-0-2.example.com", "hg"));
allNode.add(new Node("10.0.0.3", "5.5.5.3", "10-0-0-3.example.com", "hg"));
PowerMockito.mockStatic(SaltStates.class);
ApplyResponse applyResponse = new ApplyResponse();
List<Map<String, Object>> result = new ArrayList<>();
Map<String, Object> nodes = new HashMap<>();
nodes.put("10-0-0-1.example.com", "something");
nodes.put("10-0-0-2.example.com", "something");
result.add(nodes);
applyResponse.setResult(result);
PowerMockito.when(SaltStates.addGrain(any(), any(), anyString(), any())).thenReturn(applyResponse);
GrainAddRunner addRoleChecker = new GrainAddRunner(targets, allNode, "ambari_server");
SaltConnector saltConnector = Mockito.mock(SaltConnector.class);
String missingIps = addRoleChecker.submit(saltConnector);
assertThat(addRoleChecker.getTarget(), hasItems("10.0.0.3"));
assertEquals("[10.0.0.3]", missingIps);
}
use of com.sequenceiq.cloudbreak.orchestrator.salt.client.SaltConnector in project cloudbreak by hortonworks.
the class HighStateRunnerTest method submit.
@Test
public void submit() {
targets = new HashSet<>();
targets.add("10.0.0.1");
targets.add("10.0.0.2");
targets.add("10.0.0.3");
allNode = new HashSet<>();
allNode.add(new Node("10.0.0.1", "5.5.5.1", "10-0-0-1.example.com", "hg"));
allNode.add(new Node("10.0.0.2", "5.5.5.2", "10-0-0-2.example.com", "hg"));
allNode.add(new Node("10.0.0.3", "5.5.5.3", "10-0-0-3.example.com", "hg"));
HighStateRunner highStateRunner = new HighStateRunner(targets, allNode);
SaltConnector saltConnector = Mockito.mock(SaltConnector.class);
PowerMockito.mockStatic(SaltStates.class);
String jobId = "1";
PowerMockito.when(SaltStates.highstate(any())).thenReturn(jobId);
String jid = highStateRunner.submit(saltConnector);
assertEquals(jobId, jid);
PowerMockito.verifyStatic();
SaltStates.highstate(eq(saltConnector));
}
use of com.sequenceiq.cloudbreak.orchestrator.salt.client.SaltConnector in project cloudbreak by hortonworks.
the class SyncGrainsRunnerTest method submit.
@Test
public void submit() {
Set<String> targets = new HashSet<>();
targets.add("10.0.0.1");
targets.add("10.0.0.2");
targets.add("10.0.0.3");
Set<Node> allNode = new HashSet<>();
allNode.add(new Node("10.0.0.1", "5.5.5.1", "10-0-0-1.example.com", "hg"));
allNode.add(new Node("10.0.0.2", "5.5.5.2", "10-0-0-2.example.com", "hg"));
allNode.add(new Node("10.0.0.3", "5.5.5.3", "10-0-0-3.example.com", "hg"));
PowerMockito.mockStatic(SaltStates.class);
ApplyResponse applyResponse = new ApplyResponse();
List<Map<String, Object>> result = new ArrayList<>();
Map<String, Object> nodes = new HashMap<>();
nodes.put("10-0-0-1.example.com", "something");
nodes.put("10-0-0-2.example.com", "something");
result.add(nodes);
applyResponse.setResult(result);
PowerMockito.when(SaltStates.syncGrains(any())).thenReturn(applyResponse);
SyncGrainsRunner syncGrainsRunner = new SyncGrainsRunner(targets, allNode);
SaltConnector saltConnector = Mockito.mock(SaltConnector.class);
String missingIps = syncGrainsRunner.submit(saltConnector);
assertThat(syncGrainsRunner.getTarget(), hasItems("10.0.0.3"));
assertEquals("[10.0.0.3]", missingIps);
}
use of com.sequenceiq.cloudbreak.orchestrator.salt.client.SaltConnector in project cloudbreak by hortonworks.
the class SaltStatesTest method setUp.
@Before
public void setUp() {
Set<String> targets = new HashSet<>();
targets.add("10-0-0-1.example.com");
targets.add("10-0-0-2.example.com");
targets.add("10-0-0-3.example.com");
target = new Compound(targets);
saltConnector = mock(SaltConnector.class);
}
use of com.sequenceiq.cloudbreak.orchestrator.salt.client.SaltConnector in project cloudbreak by hortonworks.
the class SaltBootstrapTest method setUp.
@Before
public void setUp() {
saltConnector = mock(SaltConnector.class);
gatewayConfig = new GatewayConfig("1.1.1.1", "10.0.0.1", "172.16.252.43", "10-0-0-1.example.com", 9443, "serverCert", "clientCert", "clientKey", "saltpasswd", "saltbootpassword", "signkey", false, true, null, null);
GenericResponse response = new GenericResponse();
response.setStatusCode(HttpStatus.OK.value());
GenericResponses genericResponses = new GenericResponses();
genericResponses.setResponses(Collections.singletonList(response));
when(saltConnector.action(Mockito.any(SaltAction.class))).thenReturn(genericResponses);
when(saltConnector.run(Mockito.any(), Mockito.eq("network.default_route"), Mockito.any(), Mockito.any())).thenReturn(new DefaultRouteResponse(Collections.emptyList()));
NetworkInterfaceResponse networkInterfaceResponse = new NetworkInterfaceResponse();
List<Map<String, String>> networkResultList = new ArrayList<>();
networkMap = new HashMap<>();
networkMap.put("host-10-0-0-1.example.com", "10.0.0.1");
networkMap.put("host-10-0-0-2.example.com", "10.0.0.2");
networkMap.put("host-10-0-0-3.example.com", "10.0.0.3");
networkResultList.add(networkMap);
networkInterfaceResponse.setResult(networkResultList);
when(saltConnector.run(Mockito.any(), Mockito.eq("network.interface_ip"), Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(networkInterfaceResponse);
}
Aggregations