use of io.strimzi.operator.common.model.NamespaceAndName in project strimzi by strimzi.
the class OperatorMetricsTest method testReconcileAll.
@Test
public void testReconcileAll(VertxTestContext context) {
MetricsProvider metrics = createCleanMetricsProvider();
Set<NamespaceAndName> resources = new HashSet<>(3);
resources.add(new NamespaceAndName("my-namespace", "avfc"));
resources.add(new NamespaceAndName("my-namespace", "vtid"));
resources.add(new NamespaceAndName("my-namespace", "utv"));
AbstractWatchableStatusedResourceOperator resourceOperator = resourceOperatorWithExistingResourceWithoutSelectorLabel();
AbstractOperator operator = new ReconcileAllMockOperator(vertx, "TestResource", resourceOperator, metrics, null);
Promise<Void> reconcileAllPromise = Promise.promise();
((ReconcileAllMockOperator) operator).setResources(resources);
operator.reconcileAll("test", "my-namespace", reconcileAllPromise);
Checkpoint async = context.checkpoint();
reconcileAllPromise.future().onComplete(context.succeeding(v -> context.verify(() -> {
MeterRegistry registry = metrics.meterRegistry();
Tag selectorTag = Tag.of("selector", "");
assertThat(registry.get(AbstractOperator.METRICS_PREFIX + "reconciliations.periodical").meter().getId().getTags().get(2), is(selectorTag));
assertThat(registry.get(AbstractOperator.METRICS_PREFIX + "reconciliations.periodical").tag("kind", "TestResource").counter().count(), is(1.0));
assertThat(registry.get(AbstractOperator.METRICS_PREFIX + "reconciliations").meter().getId().getTags().get(2), is(selectorTag));
assertThat(registry.get(AbstractOperator.METRICS_PREFIX + "reconciliations").tag("kind", "TestResource").counter().count(), is(3.0));
assertThat(registry.get(AbstractOperator.METRICS_PREFIX + "reconciliations.successful").meter().getId().getTags().get(2), is(selectorTag));
assertThat(registry.get(AbstractOperator.METRICS_PREFIX + "reconciliations.successful").tag("kind", "TestResource").counter().count(), is(3.0));
assertThat(registry.get(AbstractOperator.METRICS_PREFIX + "reconciliations.duration").meter().getId().getTags().get(2), is(selectorTag));
assertThat(registry.get(AbstractOperator.METRICS_PREFIX + "reconciliations.duration").tag("kind", "TestResource").timer().count(), is(3L));
assertThat(registry.get(AbstractOperator.METRICS_PREFIX + "reconciliations.duration").tag("kind", "TestResource").timer().totalTime(TimeUnit.MILLISECONDS), greaterThan(0.0));
assertThat(registry.get(AbstractOperator.METRICS_PREFIX + "resources").meter().getId().getTags().get(2), is(selectorTag));
assertThat(registry.get(AbstractOperator.METRICS_PREFIX + "resources").tag("kind", "TestResource").tag("namespace", "my-namespace").gauge().value(), is(3.0));
for (NamespaceAndName resource : resources) {
assertThat(registry.get(AbstractOperator.METRICS_PREFIX + "resource.state").tag("kind", "TestResource").tag("name", resource.getName()).tag("resource-namespace", resource.getNamespace()).gauge().value(), is(1.0));
}
async.flag();
})));
}
use of io.strimzi.operator.common.model.NamespaceAndName in project strimzi-kafka-operator by strimzi.
the class OperatorMetricsTest method testReconcileAllOverMultipleNamespaces.
@Test
public void testReconcileAllOverMultipleNamespaces(VertxTestContext context) {
MetricsProvider metrics = createCleanMetricsProvider();
Set<NamespaceAndName> resources = new HashSet<>(3);
resources.add(new NamespaceAndName("my-namespace", "avfc"));
resources.add(new NamespaceAndName("my-namespace", "vtid"));
resources.add(new NamespaceAndName("my-namespace2", "utv"));
Set<NamespaceAndName> updatedResources = new HashSet<>(2);
updatedResources.add(new NamespaceAndName("my-namespace", "avfc"));
updatedResources.add(new NamespaceAndName("my-namespace", "vtid"));
AbstractWatchableStatusedResourceOperator resourceOperator = resourceOperatorWithExistingResourceWithoutSelectorLabel();
AbstractOperator operator = new ReconcileAllMockOperator(vertx, "TestResource", resourceOperator, metrics, null);
Promise<Void> reconcileAllPromise = Promise.promise();
((ReconcileAllMockOperator) operator).setResources(resources);
operator.reconcileAll("test", "*", reconcileAllPromise);
Checkpoint async = context.checkpoint();
reconcileAllPromise.future().onComplete(context.succeeding(v -> context.verify(() -> {
MeterRegistry registry = metrics.meterRegistry();
assertThat(registry.get(AbstractOperator.METRICS_PREFIX + "reconciliations.periodical").tag("kind", "TestResource").counter().count(), is(1.0));
assertThat(registry.get(AbstractOperator.METRICS_PREFIX + "reconciliations").tag("kind", "TestResource").tag("namespace", "my-namespace").counter().count(), is(2.0));
assertThat(registry.get(AbstractOperator.METRICS_PREFIX + "reconciliations").tag("kind", "TestResource").tag("namespace", "my-namespace2").counter().count(), is(1.0));
assertThat(registry.get(AbstractOperator.METRICS_PREFIX + "reconciliations.successful").tag("kind", "TestResource").tag("namespace", "my-namespace").counter().count(), is(2.0));
assertThat(registry.get(AbstractOperator.METRICS_PREFIX + "reconciliations.successful").tag("kind", "TestResource").tag("namespace", "my-namespace2").counter().count(), is(1.0));
assertThat(registry.get(AbstractOperator.METRICS_PREFIX + "reconciliations.duration").tag("kind", "TestResource").tag("namespace", "my-namespace").timer().count(), is(2L));
assertThat(registry.get(AbstractOperator.METRICS_PREFIX + "reconciliations.duration").tag("kind", "TestResource").tag("namespace", "my-namespace2").timer().count(), is(1L));
assertThat(registry.get(AbstractOperator.METRICS_PREFIX + "reconciliations.duration").tag("kind", "TestResource").tag("namespace", "my-namespace").timer().totalTime(TimeUnit.MILLISECONDS), greaterThan(0.0));
assertThat(registry.get(AbstractOperator.METRICS_PREFIX + "reconciliations.duration").tag("kind", "TestResource").tag("namespace", "my-namespace2").timer().totalTime(TimeUnit.MILLISECONDS), greaterThan(0.0));
assertThat(registry.get(AbstractOperator.METRICS_PREFIX + "resources").tag("kind", "TestResource").tag("namespace", "my-namespace").gauge().value(), is(2.0));
assertThat(registry.get(AbstractOperator.METRICS_PREFIX + "resources").tag("kind", "TestResource").tag("namespace", "my-namespace2").gauge().value(), is(1.0));
for (NamespaceAndName resource : resources) {
assertThat(registry.get(AbstractOperator.METRICS_PREFIX + "resource.state").tag("kind", "TestResource").tag("name", resource.getName()).tag("resource-namespace", resource.getNamespace()).gauge().value(), is(1.0));
}
}))).compose(ignore -> {
// Reconcile again with resource in my-namespace2 deleted
Promise<Void> secondReconcileAllPromise = Promise.promise();
((ReconcileAllMockOperator) operator).setResources(updatedResources);
operator.reconcileAll("test", "*", secondReconcileAllPromise);
return secondReconcileAllPromise.future();
}).onComplete(context.succeeding(v -> context.verify(() -> {
MeterRegistry registry = metrics.meterRegistry();
assertThat(registry.get(AbstractOperator.METRICS_PREFIX + "reconciliations.periodical").tag("kind", "TestResource").counter().count(), is(2.0));
assertThat(registry.get(AbstractOperator.METRICS_PREFIX + "reconciliations").tag("kind", "TestResource").tag("namespace", "my-namespace").counter().count(), is(4.0));
assertThat(registry.get(AbstractOperator.METRICS_PREFIX + "reconciliations").tag("kind", "TestResource").tag("namespace", "my-namespace2").counter().count(), is(1.0));
assertThat(registry.get(AbstractOperator.METRICS_PREFIX + "reconciliations.successful").tag("kind", "TestResource").tag("namespace", "my-namespace").counter().count(), is(4.0));
assertThat(registry.get(AbstractOperator.METRICS_PREFIX + "reconciliations.successful").tag("kind", "TestResource").tag("namespace", "my-namespace2").counter().count(), is(1.0));
assertThat(registry.get(AbstractOperator.METRICS_PREFIX + "reconciliations.duration").tag("kind", "TestResource").tag("namespace", "my-namespace").timer().count(), is(4L));
assertThat(registry.get(AbstractOperator.METRICS_PREFIX + "reconciliations.duration").tag("kind", "TestResource").tag("namespace", "my-namespace2").timer().count(), is(1L));
assertThat(registry.get(AbstractOperator.METRICS_PREFIX + "reconciliations.duration").tag("kind", "TestResource").tag("namespace", "my-namespace").timer().totalTime(TimeUnit.MILLISECONDS), greaterThan(0.0));
assertThat(registry.get(AbstractOperator.METRICS_PREFIX + "reconciliations.duration").tag("kind", "TestResource").tag("namespace", "my-namespace2").timer().totalTime(TimeUnit.MILLISECONDS), greaterThan(0.0));
assertThat(registry.get(AbstractOperator.METRICS_PREFIX + "resources").tag("kind", "TestResource").tag("namespace", "my-namespace").gauge().value(), is(2.0));
assertThat(registry.get(AbstractOperator.METRICS_PREFIX + "resources").tag("kind", "TestResource").tag("namespace", "my-namespace2").gauge().value(), is(0.0));
for (NamespaceAndName resource : updatedResources) {
assertThat(registry.get(AbstractOperator.METRICS_PREFIX + "resource.state").tag("kind", "TestResource").tag("name", resource.getName()).tag("resource-namespace", resource.getNamespace()).gauge().value(), is(1.0));
}
async.flag();
})));
}
use of io.strimzi.operator.common.model.NamespaceAndName in project strimzi-kafka-operator by strimzi.
the class OperatorMetricsTest method testReconcileAll.
@Test
public void testReconcileAll(VertxTestContext context) {
MetricsProvider metrics = createCleanMetricsProvider();
Set<NamespaceAndName> resources = new HashSet<>(3);
resources.add(new NamespaceAndName("my-namespace", "avfc"));
resources.add(new NamespaceAndName("my-namespace", "vtid"));
resources.add(new NamespaceAndName("my-namespace", "utv"));
AbstractWatchableStatusedResourceOperator resourceOperator = resourceOperatorWithExistingResourceWithoutSelectorLabel();
AbstractOperator operator = new ReconcileAllMockOperator(vertx, "TestResource", resourceOperator, metrics, null);
Promise<Void> reconcileAllPromise = Promise.promise();
((ReconcileAllMockOperator) operator).setResources(resources);
operator.reconcileAll("test", "my-namespace", reconcileAllPromise);
Checkpoint async = context.checkpoint();
reconcileAllPromise.future().onComplete(context.succeeding(v -> context.verify(() -> {
MeterRegistry registry = metrics.meterRegistry();
Tag selectorTag = Tag.of("selector", "");
assertThat(registry.get(AbstractOperator.METRICS_PREFIX + "reconciliations.periodical").meter().getId().getTags().get(2), is(selectorTag));
assertThat(registry.get(AbstractOperator.METRICS_PREFIX + "reconciliations.periodical").tag("kind", "TestResource").counter().count(), is(1.0));
assertThat(registry.get(AbstractOperator.METRICS_PREFIX + "reconciliations").meter().getId().getTags().get(2), is(selectorTag));
assertThat(registry.get(AbstractOperator.METRICS_PREFIX + "reconciliations").tag("kind", "TestResource").counter().count(), is(3.0));
assertThat(registry.get(AbstractOperator.METRICS_PREFIX + "reconciliations.successful").meter().getId().getTags().get(2), is(selectorTag));
assertThat(registry.get(AbstractOperator.METRICS_PREFIX + "reconciliations.successful").tag("kind", "TestResource").counter().count(), is(3.0));
assertThat(registry.get(AbstractOperator.METRICS_PREFIX + "reconciliations.duration").meter().getId().getTags().get(2), is(selectorTag));
assertThat(registry.get(AbstractOperator.METRICS_PREFIX + "reconciliations.duration").tag("kind", "TestResource").timer().count(), is(3L));
assertThat(registry.get(AbstractOperator.METRICS_PREFIX + "reconciliations.duration").tag("kind", "TestResource").timer().totalTime(TimeUnit.MILLISECONDS), greaterThan(0.0));
assertThat(registry.get(AbstractOperator.METRICS_PREFIX + "resources").meter().getId().getTags().get(2), is(selectorTag));
assertThat(registry.get(AbstractOperator.METRICS_PREFIX + "resources").tag("kind", "TestResource").tag("namespace", "my-namespace").gauge().value(), is(3.0));
for (NamespaceAndName resource : resources) {
assertThat(registry.get(AbstractOperator.METRICS_PREFIX + "resource.state").tag("kind", "TestResource").tag("name", resource.getName()).tag("resource-namespace", resource.getNamespace()).gauge().value(), is(1.0));
}
async.flag();
})));
}
use of io.strimzi.operator.common.model.NamespaceAndName in project strimzi by strimzi.
the class OperatorMetricsTest method testReconcileAllOverMultipleNamespaces.
@Test
public void testReconcileAllOverMultipleNamespaces(VertxTestContext context) {
MetricsProvider metrics = createCleanMetricsProvider();
Set<NamespaceAndName> resources = new HashSet<>(3);
resources.add(new NamespaceAndName("my-namespace", "avfc"));
resources.add(new NamespaceAndName("my-namespace", "vtid"));
resources.add(new NamespaceAndName("my-namespace2", "utv"));
Set<NamespaceAndName> updatedResources = new HashSet<>(2);
updatedResources.add(new NamespaceAndName("my-namespace", "avfc"));
updatedResources.add(new NamespaceAndName("my-namespace", "vtid"));
AbstractWatchableStatusedResourceOperator resourceOperator = resourceOperatorWithExistingResourceWithoutSelectorLabel();
AbstractOperator operator = new ReconcileAllMockOperator(vertx, "TestResource", resourceOperator, metrics, null);
Promise<Void> reconcileAllPromise = Promise.promise();
((ReconcileAllMockOperator) operator).setResources(resources);
operator.reconcileAll("test", "*", reconcileAllPromise);
Checkpoint async = context.checkpoint();
reconcileAllPromise.future().onComplete(context.succeeding(v -> context.verify(() -> {
MeterRegistry registry = metrics.meterRegistry();
assertThat(registry.get(AbstractOperator.METRICS_PREFIX + "reconciliations.periodical").tag("kind", "TestResource").counter().count(), is(1.0));
assertThat(registry.get(AbstractOperator.METRICS_PREFIX + "reconciliations").tag("kind", "TestResource").tag("namespace", "my-namespace").counter().count(), is(2.0));
assertThat(registry.get(AbstractOperator.METRICS_PREFIX + "reconciliations").tag("kind", "TestResource").tag("namespace", "my-namespace2").counter().count(), is(1.0));
assertThat(registry.get(AbstractOperator.METRICS_PREFIX + "reconciliations.successful").tag("kind", "TestResource").tag("namespace", "my-namespace").counter().count(), is(2.0));
assertThat(registry.get(AbstractOperator.METRICS_PREFIX + "reconciliations.successful").tag("kind", "TestResource").tag("namespace", "my-namespace2").counter().count(), is(1.0));
assertThat(registry.get(AbstractOperator.METRICS_PREFIX + "reconciliations.duration").tag("kind", "TestResource").tag("namespace", "my-namespace").timer().count(), is(2L));
assertThat(registry.get(AbstractOperator.METRICS_PREFIX + "reconciliations.duration").tag("kind", "TestResource").tag("namespace", "my-namespace2").timer().count(), is(1L));
assertThat(registry.get(AbstractOperator.METRICS_PREFIX + "reconciliations.duration").tag("kind", "TestResource").tag("namespace", "my-namespace").timer().totalTime(TimeUnit.MILLISECONDS), greaterThan(0.0));
assertThat(registry.get(AbstractOperator.METRICS_PREFIX + "reconciliations.duration").tag("kind", "TestResource").tag("namespace", "my-namespace2").timer().totalTime(TimeUnit.MILLISECONDS), greaterThan(0.0));
assertThat(registry.get(AbstractOperator.METRICS_PREFIX + "resources").tag("kind", "TestResource").tag("namespace", "my-namespace").gauge().value(), is(2.0));
assertThat(registry.get(AbstractOperator.METRICS_PREFIX + "resources").tag("kind", "TestResource").tag("namespace", "my-namespace2").gauge().value(), is(1.0));
for (NamespaceAndName resource : resources) {
assertThat(registry.get(AbstractOperator.METRICS_PREFIX + "resource.state").tag("kind", "TestResource").tag("name", resource.getName()).tag("resource-namespace", resource.getNamespace()).gauge().value(), is(1.0));
}
}))).compose(ignore -> {
// Reconcile again with resource in my-namespace2 deleted
Promise<Void> secondReconcileAllPromise = Promise.promise();
((ReconcileAllMockOperator) operator).setResources(updatedResources);
operator.reconcileAll("test", "*", secondReconcileAllPromise);
return secondReconcileAllPromise.future();
}).onComplete(context.succeeding(v -> context.verify(() -> {
MeterRegistry registry = metrics.meterRegistry();
assertThat(registry.get(AbstractOperator.METRICS_PREFIX + "reconciliations.periodical").tag("kind", "TestResource").counter().count(), is(2.0));
assertThat(registry.get(AbstractOperator.METRICS_PREFIX + "reconciliations").tag("kind", "TestResource").tag("namespace", "my-namespace").counter().count(), is(4.0));
assertThat(registry.get(AbstractOperator.METRICS_PREFIX + "reconciliations").tag("kind", "TestResource").tag("namespace", "my-namespace2").counter().count(), is(1.0));
assertThat(registry.get(AbstractOperator.METRICS_PREFIX + "reconciliations.successful").tag("kind", "TestResource").tag("namespace", "my-namespace").counter().count(), is(4.0));
assertThat(registry.get(AbstractOperator.METRICS_PREFIX + "reconciliations.successful").tag("kind", "TestResource").tag("namespace", "my-namespace2").counter().count(), is(1.0));
assertThat(registry.get(AbstractOperator.METRICS_PREFIX + "reconciliations.duration").tag("kind", "TestResource").tag("namespace", "my-namespace").timer().count(), is(4L));
assertThat(registry.get(AbstractOperator.METRICS_PREFIX + "reconciliations.duration").tag("kind", "TestResource").tag("namespace", "my-namespace2").timer().count(), is(1L));
assertThat(registry.get(AbstractOperator.METRICS_PREFIX + "reconciliations.duration").tag("kind", "TestResource").tag("namespace", "my-namespace").timer().totalTime(TimeUnit.MILLISECONDS), greaterThan(0.0));
assertThat(registry.get(AbstractOperator.METRICS_PREFIX + "reconciliations.duration").tag("kind", "TestResource").tag("namespace", "my-namespace2").timer().totalTime(TimeUnit.MILLISECONDS), greaterThan(0.0));
assertThat(registry.get(AbstractOperator.METRICS_PREFIX + "resources").tag("kind", "TestResource").tag("namespace", "my-namespace").gauge().value(), is(2.0));
assertThat(registry.get(AbstractOperator.METRICS_PREFIX + "resources").tag("kind", "TestResource").tag("namespace", "my-namespace2").gauge().value(), is(0.0));
for (NamespaceAndName resource : updatedResources) {
assertThat(registry.get(AbstractOperator.METRICS_PREFIX + "resource.state").tag("kind", "TestResource").tag("name", resource.getName()).tag("resource-namespace", resource.getNamespace()).gauge().value(), is(1.0));
}
async.flag();
})));
}
Aggregations