flink-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mbode <...@git.apache.org>
Subject [GitHub] flink pull request #4586: [FLINK-7502] [metrics] Improve PrometheusReporter
Date Fri, 01 Sep 2017 05:54:15 GMT
Github user mbode commented on a diff in the pull request:

    https://github.com/apache/flink/pull/4586#discussion_r136503621
  
    --- Diff: flink-metrics/flink-metrics-prometheus/src/test/java/org/apache/flink/metrics/prometheus/PrometheusReporterTest.java
---
    @@ -160,6 +151,43 @@ public void invalidCharactersAreReplacedWithUnderscore() {
     		assertThat(PrometheusReporter.replaceInvalidChars("a,=;:?'b,=;:?'c"), equalTo("a___:__b___:__c"));
     	}
     
    +	@Test
    +	public void registeringSameMetricTwiceDoesNotThrowException() {
    +		Counter counter = new SimpleCounter();
    +		counter.inc();
    +		String counterName = "testCounter";
    +		final FrontMetricGroup<TaskManagerMetricGroup> group = new FrontMetricGroup<>(0,
new TaskManagerMetricGroup(registry, HOST_NAME, TASK_MANAGER));
    +
    +		reporter.notifyOfAddedMetric(counter, counterName, group);
    +		reporter.notifyOfAddedMetric(counter, counterName, group);
    +	}
    +
    +	@Test
    +	public void cannotStartTwoReportersOnSamePort() {
    +		final MetricRegistry fixedPort1 = new MetricRegistry(MetricRegistryConfiguration.fromConfiguration(createConfigWithOneReporter("test1",
"12345")));
    +		final MetricRegistry fixedPort2 = new MetricRegistry(MetricRegistryConfiguration.fromConfiguration(createConfigWithOneReporter("test2",
"12345")));
    +		assertThat(fixedPort1.getReporters(), hasSize(1));
    +		assertThat(fixedPort2.getReporters(), hasSize(0));
    +	}
    +
    +	@Test
    +	public void canStartTwoReportersWhenUsingPortRange() {
    +		final MetricRegistry portRange1 = new MetricRegistry(MetricRegistryConfiguration.fromConfiguration(createConfigWithOneReporter("test1",
"9249-9252")));
    +		final MetricRegistry portRange2 = new MetricRegistry(MetricRegistryConfiguration.fromConfiguration(createConfigWithOneReporter("test2",
"9249-9252")));
    +		assertThat(portRange1.getReporters(), hasSize(1));
    +		assertThat(portRange2.getReporters(), hasSize(1));
    +	}
    +
    +	@Test
    +	public void cannotStartThreeReportersWhenPortRangeIsTooSmall() {
    +		final MetricRegistry smallPortRange1 = new MetricRegistry(MetricRegistryConfiguration.fromConfiguration(createConfigWithOneReporter("test1",
"9253-9254")));
    --- End diff --
    
    done


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message