use of com.redhat.service.bridge.shard.operator.resources.BridgeIngress in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class CustomerNamespaceProviderImplTest method testNamespaceNotDeletedWithBridges.
@Test
void testNamespaceNotDeletedWithBridges() {
final BridgeDTO dto = TestSupport.newRequestedBridgeDTO();
dto.setCustomerId("cooper");
bridgeIngressService.createBridgeIngress(dto);
// Wait until BridgeIngress is really created, can take some time due to client caching
Awaitility.await().atMost(Duration.ofSeconds(5)).until(() -> kubernetesClient.resources(BridgeIngress.class).inNamespace(customerNamespaceProvider.resolveName(dto.getCustomerId())).withName(BridgeIngress.resolveResourceName(dto.getId())).get() != null);
// try to delete the namespace...
customerNamespaceProvider.deleteNamespaceIfEmpty(kubernetesClient.namespaces().withName("ob-cooper").get());
final Namespace namespace = kubernetesClient.namespaces().withName(customerNamespaceProvider.resolveName(dto.getCustomerId())).get();
assertThat(namespace).isNotNull();
}
use of com.redhat.service.bridge.shard.operator.resources.BridgeIngress in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class BridgeIngressServiceTest method testBridgeIngressRedeployment.
@Test
public void testBridgeIngressRedeployment() {
// Given
BridgeDTO dto = TestSupport.newProvisioningBridgeDTO();
String patchedCustomerId = TestSupport.CUSTOMER_ID + "-patched";
// When
bridgeIngressService.createBridgeIngress(dto);
dto.setCustomerId(patchedCustomerId);
bridgeIngressService.createBridgeIngress(dto);
// Then
BridgeIngress bridgeIngress = fetchBridgeIngress(dto);
assertThat(bridgeIngress).isNotNull();
assertThat(bridgeIngress.getSpec().getCustomerId()).isEqualTo(patchedCustomerId);
Secret secret = fetchBridgeIngressSecret(dto);
assertThat(secret).isNotNull();
assertThat(secret.getMetadata().getName()).isEqualTo(bridgeIngress.getMetadata().getName());
}
use of com.redhat.service.bridge.shard.operator.resources.BridgeIngress in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class KubernetesNetworkingService method fetchOrCreateNetworkIngress.
@Override
public NetworkResource fetchOrCreateNetworkIngress(BridgeIngress bridgeIngress, Service service) {
Ingress expected = buildIngress(bridgeIngress, service);
Ingress existing = client.network().v1().ingresses().inNamespace(service.getMetadata().getNamespace()).withName(service.getMetadata().getName()).get();
if (existing == null || !expected.getSpec().equals(existing.getSpec())) {
client.network().v1().ingresses().inNamespace(service.getMetadata().getNamespace()).withName(service.getMetadata().getName()).createOrReplace(expected);
return buildNetworkingResource(expected);
}
return buildNetworkingResource(existing);
}
use of com.redhat.service.bridge.shard.operator.resources.BridgeIngress in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class BridgeIngressServiceImpl method createBridgeIngress.
@Override
public void createBridgeIngress(BridgeDTO bridgeDTO) {
final Namespace namespace = customerNamespaceProvider.fetchOrCreateCustomerNamespace(bridgeDTO.getCustomerId());
BridgeIngress expected = BridgeIngress.fromDTO(bridgeDTO, namespace.getMetadata().getName(), ingressImage);
BridgeIngress existing = kubernetesClient.resources(BridgeIngress.class).inNamespace(namespace.getMetadata().getName()).withName(BridgeIngress.resolveResourceName(bridgeDTO.getId())).get();
if (existing == null || !expected.getSpec().equals(existing.getSpec())) {
BridgeIngress bridgeIngress = kubernetesClient.resources(BridgeIngress.class).inNamespace(namespace.getMetadata().getName()).createOrReplace(expected);
// create or update the secrets for the bridgeIngress
createOrUpdateBridgeIngressSecret(bridgeIngress, bridgeDTO);
}
}
use of com.redhat.service.bridge.shard.operator.resources.BridgeIngress in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class BridgeIngressServiceTest method testBridgeIngressDeletion.
@Test
public void testBridgeIngressDeletion() {
// Given
BridgeDTO dto = TestSupport.newProvisioningBridgeDTO();
// When
bridgeIngressService.createBridgeIngress(dto);
bridgeIngressService.deleteBridgeIngress(dto);
// Then
BridgeIngress bridgeIngress = fetchBridgeIngress(dto);
assertThat(bridgeIngress).isNull();
}
Aggregations