use of com.hortonworks.streamline.streams.catalog.TopologyTestRunHistory in project streamline by hortonworks.
the class TopologyTestRunner method initializeTopologyTestRunHistory.
private TopologyTestRunHistory initializeTopologyTestRunHistory(Topology topology, TopologyTestRunCase testRunCase, Map<String, List<Map<String, Object>>> expectedOutputRecords, String eventLogFilePath) throws JsonProcessingException {
Long topologyVersionId = catalogService.getCurrentVersionId(topology.getId());
TopologyTestRunHistory history = new TopologyTestRunHistory();
history.setTopologyId(topology.getId());
history.setVersionId(topologyVersionId);
history.setTestCaseId(testRunCase.getId());
if (expectedOutputRecords != null) {
String expectedOutputRecordsJson = objectMapper.writeValueAsString(expectedOutputRecords);
history.setExpectedOutputRecords(expectedOutputRecordsJson);
}
history.setFinished(false);
history.setStartTime(System.currentTimeMillis());
history.setEventLogFilePath(eventLogFilePath);
return history;
}
use of com.hortonworks.streamline.streams.catalog.TopologyTestRunHistory in project streamline by hortonworks.
the class TopologyTestRunResource method getEventLogFile.
private File getEventLogFile(Long topologyId, Long historyId) {
TopologyTestRunHistory history = catalogService.getTopologyTestRunHistory(historyId);
if (history == null) {
throw EntityNotFoundException.byId(String.valueOf(historyId));
}
if (!history.getTopologyId().equals(topologyId)) {
throw BadRequestException.message("Test history " + historyId + " is not belong to topology " + topologyId);
}
String eventLogFilePath = history.getEventLogFilePath();
File eventLogFile = new File(eventLogFilePath);
if (!eventLogFile.exists() || eventLogFile.isDirectory() || !eventLogFile.canRead()) {
throw BadRequestException.message("Event log file of history " + historyId + " does not exist or is not readable.");
}
return eventLogFile;
}
use of com.hortonworks.streamline.streams.catalog.TopologyTestRunHistory in project streamline by hortonworks.
the class TopologyTestRunResource method killTestRunTopology.
@POST
@Path("/topologies/{topologyId}/actions/killtest/{historyId}")
@Timed
public Response killTestRunTopology(@Context UriInfo urlInfo, @PathParam("topologyId") Long topologyId, @PathParam("historyId") Long historyId, @Context SecurityContext securityContext) throws Exception {
SecurityUtil.checkRoleOrPermissions(authorizer, securityContext, Roles.ROLE_TOPOLOGY_USER, Topology.NAMESPACE, topologyId, EXECUTE);
Topology topology = catalogService.getTopology(topologyId);
TopologyTestRunHistory history = catalogService.getTopologyTestRunHistory(historyId);
if (topology == null) {
throw EntityNotFoundException.byName("Topology with ID " + topologyId.toString());
} else if (history == null) {
throw EntityNotFoundException.byName("TopologyTestRunHistory with ID " + historyId.toString());
}
boolean flagged = actionsService.killTestRunTopology(topology, history);
return WSUtils.respondEntity(Collections.singletonMap("flagged", flagged), OK);
}
Aggregations