Search in sources :

Example 6 with TopologyTestRunCaseSource

use of com.hortonworks.streamline.streams.catalog.TopologyTestRunCaseSource in project streamline by hortonworks.

the class TopologyTestRunResource method addTestRunCaseSource.

@POST
@Path("/topologies/{topologyId}/testcases/{testCaseId}/sources")
public Response addTestRunCaseSource(@PathParam("topologyId") Long topologyId, @PathParam("testCaseId") Long testCaseId, TopologyTestRunCaseSource testRunCaseSource, @Context SecurityContext securityContext) {
    SecurityUtil.checkRoleOrPermissions(authorizer, securityContext, Roles.ROLE_TOPOLOGY_USER, Topology.NAMESPACE, topologyId, WRITE);
    TopologySource topologySource = getAssociatedTopologySource(topologyId, testCaseId, testRunCaseSource.getSourceId());
    testRunCaseSource.setVersionId(topologySource.getVersionId());
    TopologyTestRunCaseSource addedCaseSource = catalogService.addTopologyTestRunCaseSource(testRunCaseSource);
    return WSUtils.respondEntity(addedCaseSource, CREATED);
}
Also used : TopologySource(com.hortonworks.streamline.streams.catalog.TopologySource) TopologyTestRunCaseSource(com.hortonworks.streamline.streams.catalog.TopologyTestRunCaseSource) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST)

Example 7 with TopologyTestRunCaseSource

use of com.hortonworks.streamline.streams.catalog.TopologyTestRunCaseSource in project streamline by hortonworks.

the class TopologyTestRunResource method testRunTopology.

@POST
@Path("/topologies/{topologyId}/actions/testrun")
@Timed
public Response testRunTopology(@Context UriInfo urlInfo, @PathParam("topologyId") Long topologyId, TopologyTestRunParam topologyTestRunParam, @Context SecurityContext securityContext) throws Exception {
    SecurityUtil.checkRoleOrPermissions(authorizer, securityContext, Roles.ROLE_TOPOLOGY_USER, Topology.NAMESPACE, topologyId, EXECUTE);
    Topology result = catalogService.getTopology(topologyId);
    if (result != null) {
        Long testCaseId = topologyTestRunParam.getTestCaseId();
        Long durationSecs = topologyTestRunParam.getDurationSecs();
        if (testCaseId == null) {
            throw BadRequestException.missingParameter("testCaseId");
        }
        TopologyTestRunCase testCase = catalogService.getTopologyTestRunCase(topologyId, testCaseId);
        if (testCase == null) {
            throw EntityNotFoundException.byName("topology " + topologyId + " / topology test case " + testCaseId);
        }
        Collection<TopologyTestRunCaseSource> testCaseSources = catalogService.listTopologyTestRunCaseSource(testCaseId);
        if (testCaseSources != null) {
            for (TopologyTestRunCaseSource source : testCaseSources) {
                try {
                    doValidationForTestRunCaseSource(topologyId, testCaseId, source);
                } catch (SchemaValidationFailedException e) {
                    throw handleSchemaValidationFailedException(topologyId, source, e);
                }
            }
        }
        TopologyTestRunHistory history = actionsService.testRunTopology(result, testCase, durationSecs);
        return WSUtils.respondEntity(history, OK);
    }
    throw EntityNotFoundException.byName("topology " + topologyId.toString());
}
Also used : Topology(com.hortonworks.streamline.streams.catalog.Topology) TopologyTestRunCase(com.hortonworks.streamline.streams.catalog.TopologyTestRunCase) TopologyTestRunCaseSource(com.hortonworks.streamline.streams.catalog.TopologyTestRunCaseSource) TopologyTestRunHistory(com.hortonworks.streamline.streams.catalog.TopologyTestRunHistory) SchemaValidationFailedException(com.hortonworks.streamline.common.exception.SchemaValidationFailedException) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Timed(com.codahale.metrics.annotation.Timed)

Example 8 with TopologyTestRunCaseSource

use of com.hortonworks.streamline.streams.catalog.TopologyTestRunCaseSource in project streamline by hortonworks.

the class StreamCatalogService method copyTopologyDependencies.

private void copyTopologyDependencies(Long topologyId, Long oldVersionId, Long newVersionId) throws Exception {
    List<QueryParam> topologyIdVersionIdQueryParams = WSUtils.buildTopologyIdAndVersionIdAwareQueryParams(topologyId, oldVersionId, null);
    // topology editor metadata
    TopologyEditorMetadata metadata = getTopologyEditorMetadata(topologyId, oldVersionId);
    if (metadata != null) {
        addTopologyEditorMetadata(topologyId, newVersionId, new TopologyEditorMetadata(metadata));
    }
    // sources, output streams
    Collection<TopologySource> sources = listTopologySources(topologyIdVersionIdQueryParams);
    for (TopologySource source : sources) {
        addTopologySource(topologyId, newVersionId, new TopologySource(source));
    }
    // processors, output streams
    Collection<TopologyProcessor> processors = listTopologyProcessors(topologyIdVersionIdQueryParams);
    for (TopologyProcessor processor : processors) {
        addTopologyProcessor(topologyId, newVersionId, new TopologyProcessor(processor));
    }
    // add sinks
    Collection<TopologySink> sinks = listTopologySinks(topologyIdVersionIdQueryParams);
    for (TopologySink sink : sinks) {
        addTopologySink(topologyId, newVersionId, new TopologySink(sink));
    }
    // branch rules
    Collection<TopologyBranchRule> topologyBranchRules = listBranchRules(topologyIdVersionIdQueryParams);
    for (TopologyBranchRule topologyBranchRule : topologyBranchRules) {
        addBranchRule(topologyId, newVersionId, new TopologyBranchRule(topologyBranchRule));
    }
    // windowed rules
    Collection<TopologyWindow> topologyWindows = listWindows(topologyIdVersionIdQueryParams);
    for (TopologyWindow topologyWindow : topologyWindows) {
        addWindow(topologyId, newVersionId, new TopologyWindow(topologyWindow));
    }
    // rules
    Collection<TopologyRule> topologyRules = listRules(topologyIdVersionIdQueryParams);
    for (TopologyRule topologyRule : topologyRules) {
        addRule(topologyId, newVersionId, new TopologyRule(topologyRule));
    }
    // add edges
    Collection<TopologyEdge> edges = listTopologyEdges(topologyIdVersionIdQueryParams);
    for (TopologyEdge edge : edges) {
        addTopologyEdge(topologyId, newVersionId, new TopologyEdge(edge));
    }
    // add topology test run case
    Collection<TopologyTestRunCase> runCases = listTopologyTestRunCase(topologyIdVersionIdQueryParams);
    for (TopologyTestRunCase runCase : runCases) {
        Collection<TopologyTestRunCaseSource> runCaseSources = listTopologyTestRunCaseSource(runCase.getId());
        Collection<TopologyTestRunCaseSink> runCaseSinks = listTopologyTestRunCaseSink(runCase.getId());
        TopologyTestRunCase newCase = addTopologyTestRunCase(topologyId, newVersionId, new TopologyTestRunCase(runCase));
        // add topology test run case source
        for (TopologyTestRunCaseSource runCaseSource : runCaseSources) {
            addTopologyTestRunCaseSource(newCase.getId(), newVersionId, new TopologyTestRunCaseSource(runCaseSource));
        }
        // add topology test run case sink
        for (TopologyTestRunCaseSink runCaseSink : runCaseSinks) {
            addTopologyTestRunCaseSink(newCase.getId(), newVersionId, new TopologyTestRunCaseSink(runCaseSink));
        }
    }
}
Also used : TopologyWindow(com.hortonworks.streamline.streams.catalog.TopologyWindow) TopologySink(com.hortonworks.streamline.streams.catalog.TopologySink) TopologyBranchRule(com.hortonworks.streamline.streams.catalog.TopologyBranchRule) TopologySource(com.hortonworks.streamline.streams.catalog.TopologySource) TopologyEditorMetadata(com.hortonworks.streamline.streams.catalog.TopologyEditorMetadata) TopologyRule(com.hortonworks.streamline.streams.catalog.TopologyRule) BaseTopologyRule(com.hortonworks.streamline.streams.catalog.BaseTopologyRule) TopologyEdge(com.hortonworks.streamline.streams.catalog.TopologyEdge) TopologyTestRunCaseSink(com.hortonworks.streamline.streams.catalog.TopologyTestRunCaseSink) QueryParam(com.hortonworks.registries.common.QueryParam) WSUtils.versionIdQueryParam(com.hortonworks.streamline.common.util.WSUtils.versionIdQueryParam) WSUtils.buildEdgesFromQueryParam(com.hortonworks.streamline.common.util.WSUtils.buildEdgesFromQueryParam) WSUtils.currentVersionQueryParam(com.hortonworks.streamline.common.util.WSUtils.currentVersionQueryParam) WSUtils.buildEdgesToQueryParam(com.hortonworks.streamline.common.util.WSUtils.buildEdgesToQueryParam) TopologyTestRunCase(com.hortonworks.streamline.streams.catalog.TopologyTestRunCase) TopologyTestRunCaseSource(com.hortonworks.streamline.streams.catalog.TopologyTestRunCaseSource) TopologyProcessor(com.hortonworks.streamline.streams.catalog.TopologyProcessor)

Example 9 with TopologyTestRunCaseSource

use of com.hortonworks.streamline.streams.catalog.TopologyTestRunCaseSource in project streamline by hortonworks.

the class StreamCatalogService method removeAllTopologyTestSources.

private void removeAllTopologyTestSources(TopologySource topologySource) {
    QueryParam sourceIdQuery = new QueryParam("sourceId", String.valueOf(topologySource.getId()));
    Collection<TopologyTestRunCaseSource> sources = listTopologyTestRunCaseSource(Collections.singletonList(sourceIdQuery));
    if (sources != null) {
        sources.forEach(s -> removeTopologyTestRunCaseSource(s.getId()));
    }
}
Also used : QueryParam(com.hortonworks.registries.common.QueryParam) WSUtils.versionIdQueryParam(com.hortonworks.streamline.common.util.WSUtils.versionIdQueryParam) WSUtils.buildEdgesFromQueryParam(com.hortonworks.streamline.common.util.WSUtils.buildEdgesFromQueryParam) WSUtils.currentVersionQueryParam(com.hortonworks.streamline.common.util.WSUtils.currentVersionQueryParam) WSUtils.buildEdgesToQueryParam(com.hortonworks.streamline.common.util.WSUtils.buildEdgesToQueryParam) TopologyTestRunCaseSource(com.hortonworks.streamline.streams.catalog.TopologyTestRunCaseSource)

Example 10 with TopologyTestRunCaseSource

use of com.hortonworks.streamline.streams.catalog.TopologyTestRunCaseSource in project streamline by hortonworks.

the class StreamCatalogService method getTopologyTestRunCaseSourceBySourceId.

public TopologyTestRunCaseSource getTopologyTestRunCaseSourceBySourceId(Long testCaseId, Long sourceId) {
    TopologyTestRunCaseSource testCaseSource = new TopologyTestRunCaseSource();
    testCaseSource.setId(testCaseId);
    Collection<TopologyTestRunCaseSource> sources = dao.find(TopologyTestRunCaseSource.NAMESPACE, Lists.newArrayList(new QueryParam("testCaseId", testCaseId.toString()), new QueryParam("sourceId", sourceId.toString())));
    if (sources == null || sources.isEmpty()) {
        return null;
    } else if (sources.size() > 1) {
        LOG.warn("More than one test run case source entity for same test case and source. test case id: " + testCaseId + " , source id: " + sourceId);
        LOG.warn("Returning first one...");
    }
    return sources.iterator().next();
}
Also used : QueryParam(com.hortonworks.registries.common.QueryParam) WSUtils.versionIdQueryParam(com.hortonworks.streamline.common.util.WSUtils.versionIdQueryParam) WSUtils.buildEdgesFromQueryParam(com.hortonworks.streamline.common.util.WSUtils.buildEdgesFromQueryParam) WSUtils.currentVersionQueryParam(com.hortonworks.streamline.common.util.WSUtils.currentVersionQueryParam) WSUtils.buildEdgesToQueryParam(com.hortonworks.streamline.common.util.WSUtils.buildEdgesToQueryParam) TopologyTestRunCaseSource(com.hortonworks.streamline.streams.catalog.TopologyTestRunCaseSource)

Aggregations

TopologyTestRunCaseSource (com.hortonworks.streamline.streams.catalog.TopologyTestRunCaseSource)15 Path (javax.ws.rs.Path)7 TopologyTestRunCase (com.hortonworks.streamline.streams.catalog.TopologyTestRunCase)5 QueryParam (com.hortonworks.registries.common.QueryParam)4 WSUtils.buildEdgesFromQueryParam (com.hortonworks.streamline.common.util.WSUtils.buildEdgesFromQueryParam)4 WSUtils.buildEdgesToQueryParam (com.hortonworks.streamline.common.util.WSUtils.buildEdgesToQueryParam)4 WSUtils.currentVersionQueryParam (com.hortonworks.streamline.common.util.WSUtils.currentVersionQueryParam)4 WSUtils.versionIdQueryParam (com.hortonworks.streamline.common.util.WSUtils.versionIdQueryParam)4 TopologySource (com.hortonworks.streamline.streams.catalog.TopologySource)4 TopologyTestRunCaseSink (com.hortonworks.streamline.streams.catalog.TopologyTestRunCaseSink)4 TopologyTestRunHistory (com.hortonworks.streamline.streams.catalog.TopologyTestRunHistory)3 POST (javax.ws.rs.POST)3 Timed (com.codahale.metrics.annotation.Timed)2 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)2 SchemaValidationFailedException (com.hortonworks.streamline.common.exception.SchemaValidationFailedException)2 BaseTopologyRule (com.hortonworks.streamline.streams.catalog.BaseTopologyRule)2 Topology (com.hortonworks.streamline.streams.catalog.Topology)2 TopologyBranchRule (com.hortonworks.streamline.streams.catalog.TopologyBranchRule)2 TopologyEdge (com.hortonworks.streamline.streams.catalog.TopologyEdge)2 TopologyProcessor (com.hortonworks.streamline.streams.catalog.TopologyProcessor)2