[ https://issues.apache.org/jira/browse/BEAM-5886?focusedWorklogId=159769&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-159769 ]
ASF GitHub Bot logged work on BEAM-5886: ---------------------------------------- Author: ASF GitHub Bot Created on: 28/Oct/18 21:36 Start Date: 28/Oct/18 21:36 Worklog Time Spent: 10m Work Description: lgajowy closed pull request #6863: [BEAM-5886] Fix incorrectly formulated condition in checkState method URL: https://github.com/apache/beam/pull/6863 This is a PR merged from a forked repository. As GitHub hides the original diff on merge, it is displayed below for the sake of provenance: As this is a foreign pull request (from a fork), the diff is supplied below (as it won't show otherwise due to GitHub magic): diff --git a/sdks/java/testing/test-utils/src/main/java/org/apache/beam/sdk/testutils/metrics/MetricsReader.java b/sdks/java/testing/test-utils/src/main/java/org/apache/beam/sdk/testutils/metrics/MetricsReader.java index 77dccc03261..7dd8bcb5785 100644 --- a/sdks/java/testing/test-utils/src/main/java/org/apache/beam/sdk/testutils/metrics/MetricsReader.java +++ b/sdks/java/testing/test-utils/src/main/java/org/apache/beam/sdk/testutils/metrics/MetricsReader.java @@ -124,9 +124,13 @@ private long getDistributionMetric(String name, DistributionType distType, long private <T> void checkIfMetricResultIsUnique(String name, Iterable<MetricResult<T>> metricResult) throws IllegalStateException { + int resultCount = Iterables.size(metricResult); Preconditions.checkState( - Iterables.size(metricResult) == 1, - String.format("More than one metric matches name: %s in namespace %s.", name, namespace)); + resultCount <= 1, + "More than one metric result matches name: %s in namespace %s. Metric results count: %s", + name, + namespace, + resultCount); } /** Return the current value for a time counter, or -1 if can't be retrieved. */ diff --git a/sdks/java/testing/test-utils/src/test/java/org/apache/beam/sdk/testutils/metrics/MetricsReaderTest.java b/sdks/java/testing/test-utils/src/test/java/org/apache/beam/sdk/testutils/metrics/MetricsReaderTest.java index 521317f2665..d0ad4a74524 100644 --- a/sdks/java/testing/test-utils/src/test/java/org/apache/beam/sdk/testutils/metrics/MetricsReaderTest.java +++ b/sdks/java/testing/test-utils/src/test/java/org/apache/beam/sdk/testutils/metrics/MetricsReaderTest.java @@ -79,14 +79,11 @@ public void testEndTimeIsTheMaximumOfTheDistribution() { assertEquals(5, reader.getEndTimeMetric(0, "timeDist")); } - @Test(expected = IllegalStateException.class) - public void throwsIllegalStateExceptionWhenThereAreMultipleCountersOfTheSameNameAndType() { - Metrics.counter(NAMESPACE, "counter"); - Metrics.counter(NAMESPACE, "counter"); - + @Test + public void doesntThrowIllegalStateExceptionWhenThereIsNoMetricFound() { PipelineResult result = testPipeline.run(); MetricsReader reader = new MetricsReader(result, NAMESPACE); - reader.getCounterMetric("counter", -1); + reader.getCounterMetric("nonexistent", -1); } @Test ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org Issue Time Tracking ------------------- Worklog Id: (was: 159769) Time Spent: 1h 40m (was: 1.5h) > Nexmark failing due to IllegalStateException > -------------------------------------------- > > Key: BEAM-5886 > URL: https://issues.apache.org/jira/browse/BEAM-5886 > Project: Beam > Issue Type: Task > Components: test-failures, testing > Reporter: Lukasz Gajowy > Assignee: Lukasz Gajowy > Priority: Major > Time Spent: 1h 40m > Remaining Estimate: 0h > > Nexmark fails due to the following error: > > {code:java} > java.lang.RuntimeException: java.lang.IllegalStateException: More than one > metric matches name: fatal in namespace Query0. > 13:05:49 0012 *** not run *** > 13:05:49 > ========================================================================================== > 13:05:49 at org.apache.beam.sdk.nexmark.Main.runAll(Main.java:144) > 13:05:49 > 13:05:49 at org.apache.beam.sdk.nexmark.Main.main(Main.java:477) > 13:05:49 Caused by: java.lang.IllegalStateException: More than one metric > matches name: fatal in namespace Query0. > 13:05:49 at > org.apache.beam.repackaged.beam_sdks_java_test_utils.com.google.common.base.Preconditions.checkState(Preconditions.java:444) > 13:05:49 at > org.apache.beam.sdk.testutils.metrics.MetricsReader.checkIfMetricResultIsUnique(MetricsReader.java:127) > 13:05:49 at > org.apache.beam.sdk.testutils.metrics.MetricsReader.getCounterMetric(MetricsReader.java:65) > 13:05:49 at > org.apache.beam.sdk.nexmark.NexmarkLauncher.monitor(NexmarkLauncher.java:447) > 13:05:49 at > org.apache.beam.sdk.nexmark.NexmarkLauncher.run(NexmarkLauncher.java:1156) > 13:05:49 at org.apache.beam.sdk.nexmark.Main$Run.call(Main.java:108) > 13:05:49 at org.apache.beam.sdk.nexmark.Main$Run.call(Main.java:96) > 13:05:49 at java.util.concurrent.FutureTask.run(FutureTask.java:266) > 13:05:49 at > java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) > 13:05:49 at java.util.concurrent.FutureTask.run(FutureTask.java:266) > 13:05:49 at > java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) > 13:05:49 at > java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) > 13:05:49 at java.lang.Thread.run(Thread.java:748) > {code} -- This message was sent by Atlassian JIRA (v7.6.3#76005)