Search in sources :

Example 31 with Integration

use of io.syndesis.common.model.integration.Integration in project syndesis-qe by syndesisio.

the class CommonValidationSteps method verifyIntegrationOnOffNTimes.

@Then("switch Inactive and Active state on integration {string} for {int} times and check pods")
public void verifyIntegrationOnOffNTimes(String integrationName, int switchNTimes) {
    final String integrationId = integrationsEndpoint.getIntegrationId(integrationName).get();
    for (int i = 0; i <= switchNTimes; i++) {
        final IntegrationDeploymentState newDepState;
        final Integration integration = integrationsEndpoint.get(integrationId);
        int integrationVersion = integration.getVersion();
        log.info("Getting integrationDeployment with deployment number: {}", integrationVersion);
        IntegrationDeployment currentDeployment = integrationsEndpoint.getCurrentIntegrationDeployment(integrationId, integrationVersion);
        if (currentDeployment.getCurrentState().equals(IntegrationDeploymentState.Published)) {
            newDepState = IntegrationDeploymentState.Unpublished;
            log.info("Unpublishing integration with integration version: {}", integrationVersion);
            integrationsEndpoint.deactivateIntegration(integrationId, integrationVersion);
        } else {
            newDepState = IntegrationDeploymentState.Published;
            log.info("Publishing integration: {}", integrationId);
            integrationsEndpoint.activateIntegration(integrationId);
        }
        if (newDepState.equals(IntegrationDeploymentState.Published)) {
            verifyPodCount(integrationName, 1);
        } else {
            verifyPodCount(integrationName, 0);
        }
    }
}
Also used : Integration(io.syndesis.common.model.integration.Integration) IntegrationDeploymentState(io.syndesis.common.model.integration.IntegrationDeploymentState) IntegrationDeployment(io.syndesis.common.model.integration.IntegrationDeployment) IntegrationsEndpoint(io.syndesis.qe.endpoint.IntegrationsEndpoint) IntegrationOverviewEndpoint(io.syndesis.qe.endpoint.IntegrationOverviewEndpoint) Then(io.cucumber.java.en.Then)

Example 32 with Integration

use of io.syndesis.common.model.integration.Integration in project syndesis-qe by syndesisio.

the class IntegrationHandler method createIntegrationFromGivenStepsWithState.

@When("^create new integration with name: \"([^\"]*)\" and desiredState: \"([^\"]*)\"")
public void createIntegrationFromGivenStepsWithState(String integrationName, String desiredState) {
    processMapperSteps();
    Integration integration = new Integration.Builder().steps(steps.getSteps()).name(integrationName).description("Awkward integration.").build();
    log.info("Creating integration {}", integration.getName());
    String integrationId = integrationsEndpoint.create(integration).getId().get();
    log.info("Publish integration with ID: {}", integrationId);
    if (desiredState.contentEquals("Published")) {
        publishIntegration(integrationId);
    }
    // after the integration is created - the steps are cleaned for further use.
    log.debug("Flushing used steps");
    // TODO(tplevko): find some more elegant way to flush the steps before test start.
    steps.flushStepDefinitions();
}
Also used : Integration(io.syndesis.common.model.integration.Integration) When(cucumber.api.java.en.When)

Example 33 with Integration

use of io.syndesis.common.model.integration.Integration in project syndesis-qe by syndesisio.

the class UiComplexSteps method dbToDbIntegrationWithPeriodMs.

@Given("^db to db \"([^\"]*)\" integration with period (\\d+) ms$")
public void dbToDbIntegrationWithPeriodMs(String integrationName, int ms) throws IOException {
    final Connection dbConnection = connectionsEndpoint.get(getDbConnectionId());
    final Connector dbConnector = connectorsEndpoint.get("sql");
    final String sqlStartQuery = "SELECT * FROM CONTACT";
    final String sqlFinishQuery = "INSERT INTO TODO(task, completed) VALUES (:#TASK, 2)";
    final String datamapperTemplate = "db-db.json";
    // 1.        @Then("^create start DB periodic sql invocation action step with query \"([^\"]*)\" and period \"([^\"]*)\" ms")
    final Action dbAction1 = TestUtils.findConnectorAction(dbConnector, "sql-start-connector");
    final Map<String, String> properties1 = TestUtils.map("query", sqlStartQuery, "schedulerPeriod", ms);
    final ConnectorDescriptor connectorDescriptor1 = getConnectorDescriptor(dbAction1, properties1, dbConnection.getId().get());
    // to be reported: period is not part of .json step (when checked via browser).
    final Step dbStep1 = new Step.Builder().stepKind(StepKind.endpoint).id(UUID.randomUUID().toString()).connection(dbConnection).action(dbAction1).configuredProperties(properties1).build();
    steps.getStepDefinitions().add(new StepDefinition(dbStep1, connectorDescriptor1));
    // 2.A @And("start mapper definition with name: \"([^\"]*)\"")
    String mapperName = "mapping 1";
    final Step mapperStep = new Step.Builder().stepKind(StepKind.mapper).name(mapperName).build();
    steps.getStepDefinitions().add(new StepDefinition(mapperStep, new DataMapperDefinition()));
    // 2.B @Then("MAP using Step (\\d+) and field \"([^\"]*)\" to \"([^\"]*)\"")
    int fromStep = 1;
    String fromField = "first_name";
    String toField = "TASK";
    DataMapperStepDefinition newDmStep = new DataMapperStepDefinition();
    newDmStep.setFromStep(fromStep);
    newDmStep.setInputFields(Arrays.asList(fromField));
    newDmStep.setOutputFields(Arrays.asList(toField));
    newDmStep.setMappingType(MappingType.MAP);
    newDmStep.setStrategy(null);
    steps.getLastStepDefinition().getDataMapperDefinition().get().getDataMapperStepDefinition().add(newDmStep);
    // 3.        @Then("^create finish DB invoke sql action step with query \"([^\"]*)\"")
    final Action dbAction2 = TestUtils.findConnectorAction(dbConnector, "sql-connector");
    final Map<String, String> properties2 = TestUtils.map("query", sqlFinishQuery);
    final ConnectorDescriptor connectorDescriptor2 = getConnectorDescriptor(dbAction2, properties2, dbConnection.getId().get());
    final Step dbStep2 = new Step.Builder().stepKind(StepKind.endpoint).id(UUID.randomUUID().toString()).connection(dbConnection).action(dbAction2).configuredProperties(properties2).build();
    steps.getStepDefinitions().add(new StepDefinition(dbStep2, connectorDescriptor2));
    // 4.    @When("^create integration with name: \"([^\"]*)\"")
    processMapperSteps();
    Integration integration = new Integration.Builder().steps(steps.getSteps()).name(integrationName).description("Awkward UI integration.").build();
    log.info("Creating integration {}", integration.getName());
    String integrationId = integrationsEndpoint.create(integration).getId().get();
    log.info("Publish integration with ID: {}", integrationId);
    publishIntegration(integrationId);
    log.debug("Flushing used steps");
    steps.flushStepDefinitions();
    // 5.        @Then("^wait for integration with name: \"([^\"]*)\" to become active")
    final List<Integration> integrations = integrationsEndpoint.list().stream().filter(item -> item.getName().equals(integrationName)).collect(Collectors.toList());
    final long start = System.currentTimeMillis();
    // wait for activation
    log.info("Waiting until integration \"{}\" becomes active. This may take a while...", integrationName);
    integrationOverviewEndpoint = new IntegrationOverviewEndpoint(integrationId);
    final IntegrationOverview integrationOverview = integrationOverviewEndpoint.getOverview();
    final boolean activated = TestUtils.waitForPublishing(integrationOverviewEndpoint, integrationOverview, TimeUnit.MINUTES, 10);
    Assertions.assertThat(activated).isEqualTo(true);
    log.info("Integration pod has been started. It took {}s to build the integration.", TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis() - start));
}
Also used : ConnectorDescriptor(io.syndesis.common.model.action.ConnectorDescriptor) Arrays(java.util.Arrays) Action(io.syndesis.common.model.action.Action) Step(io.syndesis.common.model.integration.Step) Autowired(org.springframework.beans.factory.annotation.Autowired) MappingType(io.atlasmap.v2.MappingType) ConnectorsEndpoint(io.syndesis.qe.endpoints.ConnectorsEndpoint) DataMapperStepDefinition(io.syndesis.qe.bdd.entities.DataMapperStepDefinition) IntegrationsDeploymentEndpoint(io.syndesis.qe.endpoints.IntegrationsDeploymentEndpoint) Connection(io.syndesis.common.model.connection.Connection) Map(java.util.Map) Given(cucumber.api.java.en.Given) Assertions(org.assertj.core.api.Assertions) StepKind(io.syndesis.common.model.integration.StepKind) Integration(io.syndesis.common.model.integration.Integration) ConnectionsEndpoint(io.syndesis.qe.endpoints.ConnectionsEndpoint) Connector(io.syndesis.common.model.connection.Connector) AtlasMapperGenerator(io.syndesis.qe.bdd.datamapper.AtlasMapperGenerator) IOException(java.io.IOException) UUID(java.util.UUID) Collectors(java.util.stream.Collectors) IntegrationOverview(io.syndesis.qe.model.IntegrationOverview) TimeUnit(java.util.concurrent.TimeUnit) List(java.util.List) Slf4j(lombok.extern.slf4j.Slf4j) IntegrationsEndpoint(io.syndesis.qe.endpoints.IntegrationsEndpoint) TestUtils(io.syndesis.qe.utils.TestUtils) DataMapperDefinition(io.syndesis.qe.bdd.entities.DataMapperDefinition) StepsStorage(io.syndesis.qe.bdd.storage.StepsStorage) StepDefinition(io.syndesis.qe.bdd.entities.StepDefinition) IntegrationOverviewEndpoint(io.syndesis.qe.endpoints.IntegrationOverviewEndpoint) Connector(io.syndesis.common.model.connection.Connector) DataMapperStepDefinition(io.syndesis.qe.bdd.entities.DataMapperStepDefinition) Action(io.syndesis.common.model.action.Action) Integration(io.syndesis.common.model.integration.Integration) IntegrationOverviewEndpoint(io.syndesis.qe.endpoints.IntegrationOverviewEndpoint) Connection(io.syndesis.common.model.connection.Connection) Step(io.syndesis.common.model.integration.Step) ConnectorsEndpoint(io.syndesis.qe.endpoints.ConnectorsEndpoint) IntegrationsDeploymentEndpoint(io.syndesis.qe.endpoints.IntegrationsDeploymentEndpoint) ConnectionsEndpoint(io.syndesis.qe.endpoints.ConnectionsEndpoint) IntegrationsEndpoint(io.syndesis.qe.endpoints.IntegrationsEndpoint) IntegrationOverviewEndpoint(io.syndesis.qe.endpoints.IntegrationOverviewEndpoint) ConnectorDescriptor(io.syndesis.common.model.action.ConnectorDescriptor) DataMapperDefinition(io.syndesis.qe.bdd.entities.DataMapperDefinition) IntegrationOverview(io.syndesis.qe.model.IntegrationOverview) DataMapperStepDefinition(io.syndesis.qe.bdd.entities.DataMapperStepDefinition) StepDefinition(io.syndesis.qe.bdd.entities.StepDefinition) Given(cucumber.api.java.en.Given)

Example 34 with Integration

use of io.syndesis.common.model.integration.Integration in project syndesis-qe by syndesisio.

the class MonitoringValidationSteps method getIdByIntegrationName.

// AUXILIARIES
private String getIdByIntegrationName(String integrationName) {
    List<Integration> integrations = integrationsEndpoint.list();
    Integration integr = integrations.stream().filter(integration -> integrationName.equals(integration.getName())).findAny().orElse(null);
    return integr.getId().get();
}
Also used : Integration(io.syndesis.common.model.integration.Integration)

Example 35 with Integration

use of io.syndesis.common.model.integration.Integration in project syndesis-qe by syndesisio.

the class IntegrationHandler method processMapperSteps.

/**
 * This should be updated for more than two steps, when it will work correctly in near future.
 */
private void processMapperSteps() {
    List<StepDefinition> mappers = steps.getStepDefinitions().stream().filter(s -> s.getStep().getStepKind().equals(StepKind.mapper)).collect(Collectors.toList());
    if (mappers.isEmpty()) {
        log.debug("There are no mappers in this integration, proceeding...");
    } else {
        // mapping can be done on steps that preceed mapper step and the single step, which follows the mapper step.
        log.info("Found mapper step, creating new atlas mapping.");
        for (StepDefinition mapper : mappers) {
            List<StepDefinition> precedingSteps = steps.getStepDefinitions().subList(0, steps.getStepDefinitions().indexOf(mapper));
            StepDefinition followingStep = steps.getStepDefinitions().get(steps.getStepDefinitions().indexOf(mapper) + 1);
            if (!mapper.getStep().getConfiguredProperties().containsKey("atlasmapping")) {
                // TODO(tplevko): fix for more than one preceding step.
                amg.setSteps(mapper, precedingSteps, followingStep);
                mapper.setStep(amg.getAtlasMappingStep());
            }
        }
    }
}
Also used : Step(io.syndesis.common.model.integration.Step) Then(io.cucumber.java.en.Then) Autowired(org.springframework.beans.factory.annotation.Autowired) HashSet(java.util.HashSet) MediaType(javax.ws.rs.core.MediaType) IntegrationsEndpoint(io.syndesis.qe.endpoint.IntegrationsEndpoint) Verifier(io.syndesis.qe.endpoint.Verifier) Assertions(org.assertj.core.api.Assertions) StepKind(io.syndesis.common.model.integration.StepKind) JsonNode(com.fasterxml.jackson.databind.JsonNode) BadRequestException(javax.ws.rs.BadRequestException) Integration(io.syndesis.common.model.integration.Integration) StepDefinition(io.syndesis.qe.entities.StepDefinition) AtlasMapperGenerator(io.syndesis.qe.datamapper.AtlasMapperGenerator) EndpointClient(io.syndesis.qe.endpoint.client.EndpointClient) When(io.cucumber.java.en.When) StepsStorage(io.syndesis.qe.storage.StepsStorage) Set(java.util.Set) UUID(java.util.UUID) Flow(io.syndesis.common.model.integration.Flow) Entity(javax.ws.rs.client.Entity) Collectors(java.util.stream.Collectors) List(java.util.List) Slf4j(lombok.extern.slf4j.Slf4j) TestUtils(io.syndesis.qe.utils.TestUtils) Exposure(io.syndesis.server.openshift.Exposure) RestTestsUtils(io.syndesis.qe.util.RestTestsUtils) StepDefinition(io.syndesis.qe.entities.StepDefinition)

Aggregations

Integration (io.syndesis.common.model.integration.Integration)57 Test (org.junit.Test)19 Step (io.syndesis.common.model.integration.Step)17 List (java.util.List)16 Connection (io.syndesis.common.model.connection.Connection)15 Connector (io.syndesis.common.model.connection.Connector)11 DataManager (io.syndesis.server.dao.manager.DataManager)11 IOException (java.io.IOException)11 Set (java.util.Set)10 InputStream (java.io.InputStream)9 ArrayList (java.util.ArrayList)9 Collectors (java.util.stream.Collectors)9 IntegrationDeployment (io.syndesis.common.model.integration.IntegrationDeployment)8 IntegrationDeploymentState (io.syndesis.common.model.integration.IntegrationDeploymentState)8 Autowired (org.springframework.beans.factory.annotation.Autowired)8 IntegrationProjectGenerator (io.syndesis.integration.api.IntegrationProjectGenerator)7 Map (java.util.Map)7 Action (io.syndesis.common.model.action.Action)6 ConnectorAction (io.syndesis.common.model.action.ConnectorAction)6 StepKind (io.syndesis.common.model.integration.StepKind)6