use of com.google.monitoring.v3.Service in project yakc by manusa.
the class ServiceIT method patchNamespacedService.
@Test
@DisplayName("patchNamespacedService, should patch labels of Service")
void patchNamespacedService() throws IOException {
// When
final Service result = KC.create(CoreV1Api.class).patchNamespacedService(serviceName, NAMESPACE, Service.builder().metadata(ObjectMeta.builder().putInLabels("patched", "label").build()).build()).get();
// Then
assertThat(result).isNotNull().extracting(Service::getMetadata).hasFieldOrPropertyWithValue("name", serviceName).extracting(ObjectMeta::getLabels).asInstanceOf(InstanceOfAssertFactories.MAP).hasSize(2).containsEntry("patched", "label");
}
use of com.google.monitoring.v3.Service 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");
}
use of com.google.monitoring.v3.Service in project yakc by manusa.
the class ServiceIT method awaitCreateWatch.
@Test
@DisplayName("listNamespacedService.watch, should await for notification of newly created Service")
void awaitCreateWatch() throws IOException {
// Given
final AtomicBoolean hasError = new AtomicBoolean(false);
final AtomicBoolean hasCompleted = new AtomicBoolean(false);
// When
final Disposable d = KC.create(CoreV1Api.class).listNamespacedService(NAMESPACE).watch().filter(we -> we.getObject().getMetadata().getName().equals(serviceName)).takeUntil(we -> we.getType() == Type.ADDED).timeout(20, TimeUnit.SECONDS).subscribe(we -> hasCompleted.set(true), we -> hasError.set(true));
// Then
assertThat(d).isNotNull();
assertThat(hasError.get()).as("Watch subscribe ended with an error").isFalse();
assertThat(hasCompleted.get()).as("Watch subscribe did not complete").isTrue();
}
use of com.google.monitoring.v3.Service in project yakc by manusa.
the class ServiceLegacyIT method awaitCreateWatch.
@Test
@DisplayName("listNamespacedService.watch, should await for notification of newly created Service")
void awaitCreateWatch() throws IOException {
// Given
final AtomicBoolean hasError = new AtomicBoolean(false);
final AtomicBoolean hasCompleted = new AtomicBoolean(false);
// When
final Disposable d = KC.create(CoreV1Api.class).listNamespacedService(NAMESPACE).watch().filter(we -> we.getObject().getMetadata().getName().equals(serviceName)).takeUntil(we -> we.getType() == Type.ADDED).timeout(20, TimeUnit.SECONDS).subscribe(we -> hasCompleted.set(true), we -> hasError.set(true));
// Then
assertThat(d).isNotNull();
assertThat(hasError.get()).as("Watch subscribe ended with an error").isFalse();
assertThat(hasCompleted.get()).as("Watch subscribe did not complete").isTrue();
}
use of com.google.monitoring.v3.Service in project quarkus by quarkusio.
the class KnativeWithSecretConfigTest method assertGeneratedResources.
@Test
public void assertGeneratedResources() throws IOException {
final Path kubernetesDir = prodModeTestResults.getBuildDir().resolve("kubernetes");
assertThat(kubernetesDir).isDirectoryContaining(p -> p.getFileName().endsWith("knative.json")).isDirectoryContaining(p -> p.getFileName().endsWith("knative.yml"));
List<HasMetadata> kubernetesList = DeserializationUtil.deserializeAsList(kubernetesDir.resolve("knative.yml"));
assertThat(kubernetesList).filteredOn(h -> "RoleBinding".equals(h.getKind())).hasSize(2);
assertThat(kubernetesList).filteredOn(h -> "ServiceAccount".equals(h.getKind())).singleElement().satisfies(s -> {
assertThat(s.getMetadata()).satisfies(m -> {
assertThat(m.getName()).isEqualTo("knative-with-secret-config");
});
});
assertThat(kubernetesList).filteredOn(h -> "Service".equals(h.getKind())).singleElement().isInstanceOf(Service.class).satisfies(s -> {
assertThat(s.getMetadata()).satisfies(m -> {
assertThat(m.getName()).isEqualTo("knative-with-secret-config");
});
assertThat(((Service) s).getSpec()).satisfies(serviceSpec -> {
assertThat(serviceSpec.getTemplate()).satisfies(revisionTemplateSpec -> {
assertThat(revisionTemplateSpec.getSpec()).satisfies(revisionSpec -> {
assertThat(revisionSpec.getServiceAccountName()).isEqualTo("knative-with-secret-config");
});
});
});
});
}
Aggregations