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");
}
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);
}
}
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();
}
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();
}
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();
}
Aggregations