Search in sources :

Example 1 with ServiceSpec

use of com.marcnuri.yakc.model.io.k8s.api.core.v1.ServiceSpec in project yakc by manusa.

the class ServiceLegacyIT method replaceNamespacedService.

@Test
@DisplayName("replaceNamespacedService, should replace existing Service's port")
void replaceNamespacedService() throws IOException {
    // Given
    final Service existingService = KC.create(CoreV1Api.class).readNamespacedService(serviceName, NAMESPACE).get();
    existingService.getSpec().getPorts().get(0).setTargetPort("http");
    // When
    final Service result = KC.create(CoreV1Api.class).replaceNamespacedService(serviceName, NAMESPACE, existingService).get();
    // Then
    assertThat(result).isNotNull().hasFieldOrPropertyWithValue("metadata.name", serviceName).extracting(Service::getSpec).extracting(ServiceSpec::getPorts).asList().hasSize(2).element(0).hasFieldOrPropertyWithValue("targetPort", "http");
}
Also used : ServiceSpec(com.marcnuri.yakc.model.io.k8s.api.core.v1.ServiceSpec) Service(com.marcnuri.yakc.model.io.k8s.api.core.v1.Service) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 2 with ServiceSpec

use of com.marcnuri.yakc.model.io.k8s.api.core.v1.ServiceSpec in project yakc by manusa.

the class ServiceIT method replaceNamespacedService.

@Test
@DisplayName("replaceNamespacedService, should replace existing Service's port")
void replaceNamespacedService() throws IOException {
    // Given
    final Service existingService = KC.create(CoreV1Api.class).readNamespacedService(serviceName, NAMESPACE).get();
    existingService.getSpec().getPorts().get(0).setTargetPort("http");
    // When
    final Service result = KC.create(CoreV1Api.class).replaceNamespacedService(serviceName, NAMESPACE, existingService).get();
    // Then
    assertThat(result).isNotNull().hasFieldOrPropertyWithValue("metadata.name", serviceName).extracting(Service::getSpec).extracting(ServiceSpec::getPorts).asList().hasSize(2).element(0).hasFieldOrPropertyWithValue("targetPort", "http");
}
Also used : ServiceSpec(com.marcnuri.yakc.model.io.k8s.api.core.v1.ServiceSpec) Service(com.marcnuri.yakc.model.io.k8s.api.core.v1.Service) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Aggregations

Service (com.marcnuri.yakc.model.io.k8s.api.core.v1.Service)2 ServiceSpec (com.marcnuri.yakc.model.io.k8s.api.core.v1.ServiceSpec)2 DisplayName (org.junit.jupiter.api.DisplayName)2 Test (org.junit.jupiter.api.Test)2