use of com.redhat.service.smartevents.infra.models.dto.ProcessorDTO in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class WebhookActionInvokerBuilderTest method testInvoker.
@Test
void testInvoker() {
ProcessorDTO processor = createProcessor();
ActionInvoker actionInvoker = builder.build(processor, processor.getDefinition().getResolvedAction());
assertThat(actionInvoker).isNotNull().isInstanceOf(WebhookActionInvoker.class);
WebhookActionInvoker webhookActionInvoker = (WebhookActionInvoker) actionInvoker;
assertThat(webhookActionInvoker.getEndpoint()).isEqualTo(TEST_ENDPOINT);
assertThat(webhookActionInvoker.getWebClient()).isNotNull();
assertThat(webhookActionInvoker.getOidcClient()).isNull();
assertThat(webhookActionInvoker.getBasicAuthUsername()).isNull();
assertThat(webhookActionInvoker.getBasicAuthPassword()).isNull();
}
use of com.redhat.service.smartevents.infra.models.dto.ProcessorDTO in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class ManagerSyncServiceTest method testProcessorsAreDeletedWhenNotDeployed.
@Test
public void testProcessorsAreDeletedWhenNotDeployed() throws JsonProcessingException, InterruptedException {
ProcessorDTO processor = TestSupport.newRequestedProcessorDTO();
processor.setStatus(ManagedResourceStatus.DEPROVISION);
stubProcessorsToDeployOrDelete(List.of(processor));
stubProcessorUpdate();
String expectedJsonUpdateRequestForDeprovisioning = String.format("{\"id\": \"%s\", \"name\": \"%s\", \"bridgeId\": \"%s\", \"customerId\": \"%s\", \"status\": \"deleting\"}", processor.getId(), processor.getName(), processor.getBridgeId(), processor.getCustomerId());
String expectedJsonUpdateRequest = String.format("{\"id\": \"%s\", \"name\": \"%s\", \"bridgeId\": \"%s\", \"customerId\": \"%s\", \"status\": \"deleted\"}", processor.getId(), processor.getName(), processor.getBridgeId(), processor.getCustomerId());
// The BridgeExecutorController does not need to execute if the CRD is not deployed
CountDownLatch latch = new CountDownLatch(1);
addProcessorUpdateRequestListener(latch);
managerSyncService.doProcessors().await().atMost(Duration.ofSeconds(5));
assertThat(latch.await(60, TimeUnit.SECONDS)).isTrue();
assertJsonRequest(expectedJsonUpdateRequestForDeprovisioning, APIConstants.SHARD_API_BASE_PATH + "processors");
assertJsonRequest(expectedJsonUpdateRequest, APIConstants.SHARD_API_BASE_PATH + "processors");
}
use of com.redhat.service.smartevents.infra.models.dto.ProcessorDTO in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class BridgeExecutorServiceTest method testBridgeExecutorCreation.
@Test
public void testBridgeExecutorCreation() {
// Given
ProcessorDTO dto = TestSupport.newRequestedProcessorDTO();
// When
bridgeExecutorService.createBridgeExecutor(dto);
// Then
BridgeExecutor bridgeExecutor = kubernetesClient.resources(BridgeExecutor.class).inNamespace(customerNamespaceProvider.resolveName(dto.getCustomerId())).withName(BridgeExecutor.resolveResourceName(dto.getId())).get();
assertThat(bridgeExecutor).isNotNull();
assertThat(bridgeExecutor.getSpec().getOwner()).isEqualTo(dto.getOwner());
Secret secret = fetchBridgeExecutorSecret(dto);
assertThat(secret).isNotNull();
assertThat(secret.getMetadata().getName()).isEqualTo(bridgeExecutor.getMetadata().getName());
assertThat(secret.getData().get(GlobalConfigurationsConstants.KAFKA_BOOTSTRAP_SERVERS_ENV_VAR)).isNotEmpty();
assertThat(secret.getData().get(GlobalConfigurationsConstants.KAFKA_CLIENT_ID_ENV_VAR)).isNotEmpty();
assertThat(secret.getData().get(GlobalConfigurationsConstants.KAFKA_CLIENT_SECRET_ENV_VAR)).isNotEmpty();
assertThat(secret.getData().get(GlobalConfigurationsConstants.KAFKA_SECURITY_PROTOCOL_ENV_VAR)).isNotEmpty();
assertThat(secret.getData().get(GlobalConfigurationsConstants.KAFKA_TOPIC_ENV_VAR)).isNotEmpty();
assertThat(secret.getData().get(GlobalConfigurationsConstants.KAFKA_ERROR_STRATEGY_ENV_VAR)).isNotEmpty();
assertThat(secret.getData().get(GlobalConfigurationsConstants.KAFKA_ERROR_TOPIC_ENV_VAR)).isNotEmpty();
assertThat(secret.getData().get(GlobalConfigurationsConstants.KAFKA_GROUP_ID_ENV_VAR)).isNotEmpty();
}
use of com.redhat.service.smartevents.infra.models.dto.ProcessorDTO in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class BridgeExecutorServiceTest method testFetchOrCreateBridgeExecutorDeploymentRedeployment.
@Test
public void testFetchOrCreateBridgeExecutorDeploymentRedeployment() {
// Given
ProcessorDTO dto = TestSupport.newRequestedProcessorDTO();
String patchedImage = TestSupport.EXECUTOR_IMAGE + "-patched";
// When
bridgeExecutorService.createBridgeExecutor(dto);
// Wait until deployment is created by the controller.
Awaitility.await().atMost(Duration.ofMinutes(2)).pollInterval(Duration.ofSeconds(5)).untilAsserted(() -> {
// The deployment is deployed by the controller
Deployment deployment = fetchBridgeExecutorDeployment(dto);
assertThat(deployment).isNotNull();
});
// Patch the deployment and replace
Deployment deployment = fetchBridgeExecutorDeployment(dto);
deployment.getSpec().getTemplate().getSpec().getContainers().get(0).setImage(patchedImage);
kubernetesClient.apps().deployments().inNamespace(deployment.getMetadata().getNamespace()).createOrReplace(deployment);
// Then
deployment = bridgeExecutorService.fetchOrCreateBridgeExecutorDeployment(fetchBridgeIngress(dto), fetchBridgeExecutorSecret(dto));
assertThat(deployment.getSpec().getTemplate().getSpec().getContainers().get(0).getImage()).isEqualTo(TestSupport.EXECUTOR_IMAGE);
}
use of com.redhat.service.smartevents.infra.models.dto.ProcessorDTO in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class BridgeExecutorServiceTest method testBridgeExecutorCreationTriggersController.
@Test
public void testBridgeExecutorCreationTriggersController() {
// Given
ProcessorDTO dto = TestSupport.newRequestedProcessorDTO();
// When
bridgeExecutorService.createBridgeExecutor(dto);
// Then
Awaitility.await().atMost(Duration.ofMinutes(2)).pollInterval(Duration.ofSeconds(5)).untilAsserted(() -> {
// The deployment is deployed by the controller
Deployment deployment = kubernetesClient.apps().deployments().inNamespace(customerNamespaceProvider.resolveName(dto.getCustomerId())).withName(BridgeExecutor.resolveResourceName(dto.getId())).get();
assertThat(deployment).isNotNull();
assertThat(deployment.getSpec().getProgressDeadlineSeconds()).isEqualTo(60);
List<EnvVar> environmentVariables = deployment.getSpec().getTemplate().getSpec().getContainers().get(0).getEnv();
assertThat(environmentVariables.stream().filter(x -> x.getName().equals(Constants.CUSTOMER_ID_CONFIG_ENV_VAR)).findFirst().get().getValue().length()).isGreaterThan(0);
assertThat(environmentVariables.stream().filter(x -> x.getName().equals(Constants.BRIDGE_EXECUTOR_PROCESSOR_DEFINITION_ENV_VAR)).findFirst().get().getValue().length()).isGreaterThan(0);
assertThat(environmentVariables.stream().filter(x -> x.getName().equals(Constants.BRIDGE_EXECUTOR_WEBHOOK_SSO_ENV_VAR)).findFirst().get().getValue().length()).isGreaterThan(0);
assertThat(environmentVariables.stream().filter(x -> x.getName().equals(Constants.BRIDGE_EXECUTOR_WEBHOOK_CLIENT_ID_ENV_VAR)).findFirst().get().getValue().length()).isGreaterThan(0);
assertThat(environmentVariables.stream().filter(x -> x.getName().equals(Constants.BRIDGE_EXECUTOR_WEBHOOK_CLIENT_SECRET_ENV_VAR)).findFirst().get().getValue().length()).isGreaterThan(0);
});
}
Aggregations