Search in sources :

Example 26 with Integration

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

the class StringTrimmingConverterTest method testTrimming.

@Test
public void testTrimming() throws IOException {
    final SortedSet<String> tags = new TreeSet<>();
    tags.add("");
    tags.add(" tag");
    tags.add("\tTaggy McTagface\t");
    final Integration original = new Integration.Builder().id("test").name("  some-name\t").description("").tags(tags).build();
    final String source = Json.writer().writeValueAsString(original);
    final Integration created = Json.reader().forType(Integration.class).readValue(source);
    assertThat(created.getName()).isEqualTo("some-name");
    assertThat(created.getDescription()).isNotPresent();
    assertThat(created.getTags()).containsExactly("Taggy McTagface", "tag");
}
Also used : Integration(io.syndesis.common.model.integration.Integration) TreeSet(java.util.TreeSet) Test(org.junit.Test)

Example 27 with Integration

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

the class MetricsCollector method run.

@Override
public void run() {
    LOGGER.debug("Collecting metrics for active integration pods.");
    try {
        List<Pod> integrationPodList = kubernetes.pods().withLabel("integration").list().getItems();
        Set<String> livePods = new HashSet<>();
        for (Pod pod : integrationPodList) {
            livePods.add(pod.getMetadata().getName());
        }
        integrationPodList.stream().filter(p -> Readiness.isReady(p)).forEach(p -> executor.execute(new PodMetricsReader(kubernetes, p.getMetadata().getName(), p.getMetadata().getAnnotations().get("syndesis.io/integration-name"), p.getMetadata().getLabels().get("syndesis.io/integration-id"), p.getMetadata().getLabels().get("syndesis.io/deployment-version"), rmh)));
        Set<String> activeIntegrationIds = dataManager.fetchIds(Integration.class);
        for (String integrationId : activeIntegrationIds) {
            LOGGER.debug("Computing metrics for IntegrationId: {}", integrationId);
            Map<String, RawMetrics> rawMetrics = rmh.getRawMetrics(integrationId);
            IntegrationMetricsSummary imSummary = imh.compute(integrationId, rawMetrics, livePods);
            imh.persist(imSummary);
            rmh.curate(integrationId, rawMetrics, livePods);
        }
        rmh.curate(activeIntegrationIds);
        imh.curate(activeIntegrationIds);
    } catch (@SuppressWarnings("PMD.AvoidCatchingGenericException") Exception ex) {
        LOGGER.error("Error while iterating integration pods.", ex);
    }
}
Also used : LoggerFactory(org.slf4j.LoggerFactory) Autowired(org.springframework.beans.factory.annotation.Autowired) HashSet(java.util.HashSet) Service(org.springframework.stereotype.Service) Map(java.util.Map) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) DataManager(io.syndesis.server.dao.manager.DataManager) Integration(io.syndesis.common.model.integration.Integration) ConditionalOnProperty(org.springframework.boot.autoconfigure.condition.ConditionalOnProperty) ExecutorService(java.util.concurrent.ExecutorService) Logger(org.slf4j.Logger) CustomizableThreadFactory(org.springframework.scheduling.concurrent.CustomizableThreadFactory) Set(java.util.Set) Pod(io.fabric8.kubernetes.api.model.Pod) IOException(java.io.IOException) JsonDB(io.syndesis.server.jsondb.JsonDB) Executors(java.util.concurrent.Executors) TimeUnit(java.util.concurrent.TimeUnit) List(java.util.List) Closeable(java.io.Closeable) PostConstruct(javax.annotation.PostConstruct) KubernetesClient(io.fabric8.kubernetes.client.KubernetesClient) Readiness(io.fabric8.kubernetes.client.internal.readiness.Readiness) Collections(java.util.Collections) IntegrationMetricsSummary(io.syndesis.common.model.metrics.IntegrationMetricsSummary) Pod(io.fabric8.kubernetes.api.model.Pod) IntegrationMetricsSummary(io.syndesis.common.model.metrics.IntegrationMetricsSummary) IOException(java.io.IOException) HashSet(java.util.HashSet)

Example 28 with Integration

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

the class IntegrationHandler method createIntegrationFromGivenStepsWithStateAndValidation.

private void createIntegrationFromGivenStepsWithStateAndValidation(String integrationName, String desiredState, String validate) {
    if (validate == null || validate.isEmpty()) {
        verifyConnections();
    }
    processAggregateSteps();
    processMapperSteps();
    Set<String> tags = new HashSet<>();
    for (Step step : steps.getSteps()) {
        if (step.getConnection().isPresent()) {
            tags.addAll(step.getConnection().get().getTags());
        }
    }
    Integration integration = new Integration.Builder().name(integrationName).description("Awkward integration.").tags(tags).exposure(Exposure.SERVICE.toString()).addFlow(new Flow.Builder().id(UUID.randomUUID().toString()).description(integrationName + "Flow").steps(steps.getSteps()).build()).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) Step(io.syndesis.common.model.integration.Step) HashSet(java.util.HashSet)

Example 29 with Integration

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

the class IntegrationHandler method sameNameIntegrationValidation.

@Then("try to create new integration with the same name: {string} and state: {string}")
public void sameNameIntegrationValidation(String integrationName, String desiredState) {
    final Integration integration = new Integration.Builder().steps(steps.getSteps()).name(integrationName).description("Awkward integration.").build();
    log.info("Creating integration {}", integration.getName());
    Assertions.assertThatExceptionOfType(BadRequestException.class).isThrownBy(() -> {
        EndpointClient.getClient().target(integrationsEndpoint.getEndpointUrl()).request(MediaType.APPLICATION_JSON).header("X-Forwarded-User", "pista").header("X-Forwarded-Access-Token", "kral").header("SYNDESIS-XSRF-TOKEN", "awesome").post(Entity.entity(integration, MediaType.APPLICATION_JSON), JsonNode.class);
    }).withMessageContaining("HTTP 400 Bad Request").withNoCause();
    log.debug("Flushing used steps");
    steps.flushStepDefinitions();
}
Also used : Integration(io.syndesis.common.model.integration.Integration) BadRequestException(javax.ws.rs.BadRequestException) Then(io.cucumber.java.en.Then)

Example 30 with Integration

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

the class IntegrationUtils method getIdByIntegrationName.

public String getIdByIntegrationName(String integrationName) {
    List<Integration> integrations = integrationsEndpoint.list();
    Integration integr = integrations.stream().filter(integration -> integrationName.equalsIgnoreCase(integration.getName())).findAny().orElse(null);
    if (integr == null) {
        integr = integrations.stream().filter(integration -> integrationName.replaceAll("-", " ").equalsIgnoreCase(integration.getName())).findAny().orElse(null);
    }
    assertThat(integr).as(String.format("Integration %s not found. Be sure you provide the correct name of the integration. (same name as in the UI)", integrationName)).isNotNull();
    return integr.getId().get();
}
Also used : TestConfiguration(io.syndesis.qe.TestConfiguration) Component(org.springframework.stereotype.Component) List(java.util.List) Activity(io.syndesis.server.endpoint.v1.handler.activity.Activity) IntegrationsEndpoint(io.syndesis.qe.endpoint.IntegrationsEndpoint) IntegrationsMetricsEndpoint(io.syndesis.qe.endpoint.IntegrationsMetricsEndpoint) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) ActivityIntegrationsEndpoint(io.syndesis.qe.endpoint.ActivityIntegrationsEndpoint) Autowired(org.springframework.beans.factory.annotation.Autowired) Integration(io.syndesis.common.model.integration.Integration) IntegrationMetricsSummary(io.syndesis.common.model.metrics.IntegrationMetricsSummary) Integration(io.syndesis.common.model.integration.Integration)

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