use of com.sequenceiq.cloudbreak.cloud.model.CloudVmMetaDataStatus in project cloudbreak by hortonworks.
the class StackCreationMock method addSPIEndpoints.
public void addSPIEndpoints() {
Map<String, CloudVmMetaDataStatus> instanceMap = getInstanceMap();
getSparkService().post(MOCK_ROOT + "/cloud_metadata_statuses", new CloudMetaDataStatuses(instanceMap), gson()::toJson);
}
use of com.sequenceiq.cloudbreak.cloud.model.CloudVmMetaDataStatus in project cloudbreak by hortonworks.
the class StackCreationMock method verifyCalls.
public void verifyCalls(String clusterName) {
verify(SALT_BOOT_ROOT + "/health", "GET").exactTimes(1).verify();
Verification distributeVerification = verify(SALT_BOOT_ROOT + "/salt/action/distribute", "POST").exactTimes(1);
for (CloudVmMetaDataStatus status : getInstanceMap().values()) {
distributeVerification.bodyContains("address\":\"" + status.getMetaData().getPrivateIp());
}
distributeVerification.verify();
verify(AMBARI_API_ROOT + "/services/AMBARI/components/AMBARI_SERVER", "GET").exactTimes(1).verify();
verify(AMBARI_API_ROOT + "/clusters", "GET").exactTimes(2).verify();
verify(AMBARI_API_ROOT + "/check", "GET").atLeast(1).verify();
verify(AMBARI_API_ROOT + "/users/admin", "PUT").exactTimes(1).bodyContains("Users/password").bodyContains("Users/old_password").verify();
verify(AMBARI_API_ROOT + "/blueprints/bp", "POST").exactTimes(1).bodyContains("blueprint_name").bodyContains("stack_name").bodyContains("stack_version").bodyContains("host_groups").exactTimes(1).verify();
verify(AMBARI_API_ROOT + "/clusters/" + clusterName, "POST").exactTimes(1).bodyContains("blueprint").bodyContains("default_password").bodyContains("host_groups").verify();
verify(AMBARI_API_ROOT + "/clusters/" + clusterName + "/requests/1", "GET").atLeast(1).verify();
verify(SALT_API_ROOT + "/run", "POST").bodyContains("fun=saltutil.sync_grains").atLeast(1).verify();
verify(SALT_API_ROOT + "/run", "POST").bodyContains("fun=mine.update").atLeast(1).verify();
verify(SALT_API_ROOT + "/run", "POST").bodyContains("fun=state.highstate").atLeast(2).verify();
verify(SALT_API_ROOT + "/run", "POST").bodyContains("fun=jobs.lookup_jid").bodyContains("jid=1").atLeast(2).verify();
verify(SALT_API_ROOT + "/run", "POST").bodyContains("fun=grains.append").bodyContains("ambari_agent_install").exactTimes(1).verify();
verify(SALT_API_ROOT + "/run", "POST").bodyContains("fun=grains.append").bodyContains("ambari_agent").exactTimes(2).verify();
verify(SALT_API_ROOT + "/run", "POST").bodyContains("fun=grains.append").bodyContains("ambari_server_install").exactTimes(1).verify();
verify(SALT_API_ROOT + "/run", "POST").bodyContains("fun=grains.append").bodyContains("ambari_server").exactTimes(2).verify();
verify(SALT_API_ROOT + "/run", "POST").bodyContains("fun=grains.append").bodyContains("recipes").exactTimes(2).verify();
verify(SALT_API_ROOT + "/run", "POST").bodyContains("fun=grains.remove").bodyContains("recipes").exactTimes(2).verify();
verify(SALT_API_ROOT + "/run", "POST").bodyContains("fun=jobs.active").atLeast(2).verify();
verify(SALT_BOOT_ROOT + "/file", "POST").exactTimes(0).verify();
verify(SALT_BOOT_ROOT + "/file/distribute", "POST").exactTimes(4).verify();
}
use of com.sequenceiq.cloudbreak.cloud.model.CloudVmMetaDataStatus in project cloudbreak by hortonworks.
the class StackCreationMock method addSaltMappings.
public void addSaltMappings() {
Map<String, CloudVmMetaDataStatus> instanceMap = getInstanceMap();
ObjectMapper objectMapper = new ObjectMapper();
Service sparkService = getSparkService();
sparkService.get(SALT_BOOT_ROOT + "/health", (request, response) -> {
GenericResponse genericResponse = new GenericResponse();
genericResponse.setStatusCode(HttpStatus.OK.value());
return genericResponse;
}, gson()::toJson);
objectMapper.setVisibility(objectMapper.getVisibilityChecker().withGetterVisibility(Visibility.NONE));
sparkService.post(SALT_API_ROOT + "/run", new SaltApiRunPostResponse(instanceMap));
sparkService.post(SALT_BOOT_ROOT + "/file", (request, response) -> {
response.status(HttpStatus.CREATED.value());
return response;
});
sparkService.post(SALT_BOOT_ROOT + "/salt/server/pillar", (request, response) -> {
GenericResponse genericResponse = new GenericResponse();
genericResponse.setStatusCode(HttpStatus.OK.value());
return genericResponse;
}, gson()::toJson);
sparkService.post(SALT_BOOT_ROOT + "/salt/action/distribute", (request, response) -> {
GenericResponses genericResponses = new GenericResponses();
genericResponses.setResponses(new ArrayList<>());
return genericResponses;
}, gson()::toJson);
sparkService.post(SALT_BOOT_ROOT + "/hostname/distribute", (request, response) -> {
GenericResponses genericResponses = new GenericResponses();
List<GenericResponse> responses = new ArrayList<>();
for (CloudVmMetaDataStatus status : instanceMap.values()) {
GenericResponse genericResponse = new GenericResponse();
genericResponse.setAddress(status.getMetaData().getPrivateIp());
genericResponse.setStatus(HostNameUtil.generateHostNameByIp(status.getMetaData().getPrivateIp()));
genericResponse.setStatusCode(HttpStatus.OK.value());
responses.add(genericResponse);
}
genericResponses.setResponses(responses);
return genericResponses;
}, gson()::toJson);
sparkService.post(SALT_BOOT_ROOT + "/file/distribute", (request, response) -> {
GenericResponses genericResponses = new GenericResponses();
GenericResponse genericResponse = new GenericResponse();
genericResponse.setStatusCode(HttpStatus.CREATED.value());
genericResponses.setResponses(Collections.singletonList(genericResponse));
return genericResponses;
}, gson()::toJson);
sparkService.post(SALT_BOOT_ROOT + "/salt/server/pillar/distribute", (request, response) -> {
GenericResponses genericResponses = new GenericResponses();
GenericResponse genericResponse = new GenericResponse();
genericResponse.setStatusCode(HttpStatus.OK.value());
genericResponses.setResponses(Collections.singletonList(genericResponse));
return genericResponses;
}, gson()::toJson);
}
use of com.sequenceiq.cloudbreak.cloud.model.CloudVmMetaDataStatus in project cloudbreak by hortonworks.
the class StackCreationMock method addAmbariMappings.
public void addAmbariMappings(String clusterName) {
Map<String, CloudVmMetaDataStatus> instanceMap = getInstanceMap();
Service sparkService = getSparkService();
sparkService.get(AMBARI_API_ROOT + "/clusters/:cluster/requests/:request", new AmbariStatusResponse());
sparkService.post(AMBARI_API_ROOT + "/views/:view/versions/1.0.0/instances/*", new EmptyAmbariResponse());
sparkService.get(AMBARI_API_ROOT + "/clusters", (req, resp) -> {
ITResponse itResp = clusterCreated ? new AmbariClusterResponse(instanceMap, clusterName) : new EmptyAmbariClusterResponse();
return itResp.handle(req, resp);
});
sparkService.post(AMBARI_API_ROOT + "/clusters/:cluster/requests", new AmbariClusterRequestsResponse());
sparkService.post(AMBARI_API_ROOT + "/clusters/:cluster", (req, resp) -> {
clusterCreated = true;
return new EmptyAmbariResponse().handle(req, resp);
}, gson()::toJson);
sparkService.get(AMBARI_API_ROOT + "/clusters", new AmbariClusterResponse(instanceMap, clusterName));
sparkService.post(AMBARI_API_ROOT + "/clusters/:cluster/requests", new AmbariClusterRequestsResponse());
sparkService.post(AMBARI_API_ROOT + "/clusters/:cluster", new EmptyAmbariResponse());
sparkService.get(AMBARI_API_ROOT + "/services/AMBARI/components/AMBARI_SERVER", new AmbariServicesComponentsResponse(), gson()::toJson);
sparkService.get(AMBARI_API_ROOT + "/hosts", new AmbariHostsResponse(instanceMap), gson()::toJson);
sparkService.get(AMBARI_API_ROOT + "/blueprints/:blueprintname", (request, response) -> {
response.type("text/plain");
return responseFromJsonFile("blueprint/" + request.params("blueprintname") + ".bp");
});
sparkService.post(AMBARI_API_ROOT + "/blueprints/*", new EmptyAmbariResponse());
sparkService.put(AMBARI_API_ROOT + "/users/admin", new EmptyAmbariResponse());
sparkService.get(AMBARI_API_ROOT + "/check", new AmbariCheckResponse());
sparkService.post(AMBARI_API_ROOT + "/users", new EmptyAmbariResponse());
sparkService.get(AMBARI_API_ROOT + "/clusters/:cluster/hosts", new AmbariClustersHostsResponse(instanceMap, "SUCCESSFUL"));
sparkService.put(AMBARI_API_ROOT + "/stacks/HDP/versions/:version/operating_systems/:os/repositories/:hdpversion", new AmbariVersionDefinitionResponse());
sparkService.get(AMBARI_API_ROOT + "/version_definitions", new AmbariVersionDefinitionResponse());
sparkService.post(AMBARI_API_ROOT + "/version_definitions", new EmptyAmbariResponse());
}
use of com.sequenceiq.cloudbreak.cloud.model.CloudVmMetaDataStatus in project cloudbreak by hortonworks.
the class InstanceTerminationReplicationErrorMock method addAmbariMappings.
public void addAmbariMappings(String clusterName) {
Map<String, CloudVmMetaDataStatus> instanceMap = getInstanceMap();
Service sparkService = getSparkService();
int requestId = 100;
sparkService.delete(AMBARI_API_ROOT + "/clusters/:cluster/hosts/:hostname", new EmptyAmbariResponse());
sparkService.delete(AMBARI_API_ROOT + "/clusters/:cluster/hosts/:hostname/host_components/*", new EmptyAmbariResponse());
sparkService.get(AMBARI_API_ROOT + "/clusters/:cluster/hosts/:hostname/host_components/*", new AmbariComponentStatusOnHostResponse());
sparkService.post(AMBARI_API_ROOT + "/clusters/" + clusterName + "/requests", new AmbariRequestIdRespone(requestId));
sparkService.get(AMBARI_API_ROOT + "/clusters/" + clusterName + "/requests/100", new AmbariRequestStatusResponse(requestId, 100));
sparkService.put(AMBARI_API_ROOT + "/clusters/" + clusterName + "/requests/" + requestId, new EmptyAmbariClusterResponse());
sparkService.put(AMBARI_API_ROOT + "/clusters/" + clusterName + "/host_components", new AmbariStrRequestIdRespone(requestId));
sparkService.get(AMBARI_API_ROOT + "/clusters/:cluster/hosts", new AmbariHostComponentStateResponse(instanceMap));
sparkService.get(AMBARI_API_ROOT + "/clusters/:cluster/hosts/:hostname", new AmbariHostResponse());
sparkService.get(AMBARI_API_ROOT + "/clusters", new AmbariClusterResponse(instanceMap, clusterName));
sparkService.get(AMBARI_API_ROOT + "/clusters/" + clusterName, new AmbariClustersHostsResponse(instanceMap, "SUCCESSFUL"));
sparkService.post(AMBARI_API_ROOT + "/clusters/" + clusterName, new EmptyAmbariClusterResponse());
sparkService.get(AMBARI_API_ROOT + "/clusters/:cluster/hosts/:hostname/host_components", new AmbariComponentStatusOnHostResponse());
sparkService.get(AMBARI_API_ROOT + "/clusters/" + clusterName + "/configurations/service_config_versions", new AmbariServiceConfigResponse(getMockServerAddress(), getMockPort()), gson()::toJson);
sparkService.get(AMBARI_API_ROOT + "/blueprints/:blueprintname", (request, response) -> {
response.type("text/plain");
return responseFromJsonFile("blueprint/" + request.params("blueprintname") + ".bp");
});
}
Aggregations