Search in sources :

Example 11 with TopologyTestRunHistory

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;
}
Also used : TopologyTestRunHistory(com.hortonworks.streamline.streams.catalog.TopologyTestRunHistory)

Example 12 with TopologyTestRunHistory

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;
}
Also used : TopologyTestRunHistory(com.hortonworks.streamline.streams.catalog.TopologyTestRunHistory) File(java.io.File)

Example 13 with TopologyTestRunHistory

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);
}
Also used : Topology(com.hortonworks.streamline.streams.catalog.Topology) TopologyTestRunHistory(com.hortonworks.streamline.streams.catalog.TopologyTestRunHistory) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Timed(com.codahale.metrics.annotation.Timed)

Aggregations

TopologyTestRunHistory (com.hortonworks.streamline.streams.catalog.TopologyTestRunHistory)13 Topology (com.hortonworks.streamline.streams.catalog.Topology)8 TopologyTestRunCase (com.hortonworks.streamline.streams.catalog.TopologyTestRunCase)8 TopologyTestRunCaseSource (com.hortonworks.streamline.streams.catalog.TopologyTestRunCaseSource)6 TopologyTestRunCaseSink (com.hortonworks.streamline.streams.catalog.TopologyTestRunCaseSink)5 VerificationsInOrder (mockit.VerificationsInOrder)5 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)4 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)4 TopologyActions (com.hortonworks.streamline.streams.actions.TopologyActions)4 StreamCatalogService (com.hortonworks.streamline.streams.catalog.service.StreamCatalogService)4 StreamlineProcessor (com.hortonworks.streamline.streams.layout.component.StreamlineProcessor)4 StreamlineSink (com.hortonworks.streamline.streams.layout.component.StreamlineSink)4 StreamlineSource (com.hortonworks.streamline.streams.layout.component.StreamlineSource)4 TopologyLayout (com.hortonworks.streamline.streams.layout.component.TopologyLayout)4 TestRunProcessor (com.hortonworks.streamline.streams.layout.component.impl.testing.TestRunProcessor)4 TestRunRulesProcessor (com.hortonworks.streamline.streams.layout.component.impl.testing.TestRunRulesProcessor)4 File (java.io.File)4 Files (com.google.common.io.Files)3 TopologyTestHelper (com.hortonworks.streamline.streams.actions.utils.TopologyTestHelper)3 Edge (com.hortonworks.streamline.streams.layout.component.Edge)3