[
https://issues.apache.org/jira/browse/BEAM-6883?focusedWorklogId=284094&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-284094
]
ASF GitHub Bot logged work on BEAM-6883:
----------------------------------------
Author: ASF GitHub Bot
Created on: 29/Jul/19 08:17
Start Date: 29/Jul/19 08:17
Worklog Time Spent: 10m
Work Description: RyanSkraba commented on pull request #9178: [BEAM-6883]
Improve long-running spark streaming test.
URL: https://github.com/apache/beam/pull/9178#discussion_r308104616
##########
File path:
sdks/java/core/src/test/java/org/apache/beam/sdk/metrics/MetricResultsMatchers.java
##########
@@ -43,9 +43,50 @@
return metricsResult(namespace, name, step, value, true);
}
+ /**
+ * Matches a {@link MetricResult} with the given namespace, name and step,
and a matcher for the
+ * value for either committed or attempted (based on {@code isCommitted})
metrics.
+ */
+ public static <T> Matcher<MetricResult<T>> metricsResult(
+ final String namespace,
+ final String name,
+ final String step,
+ final Matcher<T> valueMatcher,
+ final boolean isCommitted) {
+
+ final String metricState = isCommitted ? "committed" : "attempted";
+ return new MatchNameAndKey<T>(namespace, name, step) {
+ @Override
+ protected boolean matchesSafely(MetricResult<T> item) {
+ final T metricValue = isCommitted ? item.getCommitted() :
item.getAttempted();
+ return super.matchesSafely(item) && valueMatcher.matches(metricValue);
+ }
+
+ @Override
+ public void describeTo(Description description) {
+ super.describeTo(description);
+ description.appendText(String.format(", %s=", metricState));
+ valueMatcher.describeTo(description);
+ description.appendText("}");
+ }
+
+ @Override
+ protected void describeMismatchSafely(MetricResult<T> item, Description
mismatchDescription) {
+ final T metricValue = isCommitted ? item.getCommitted() :
item.getAttempted();
+ super.describeMismatchSafely(item, mismatchDescription);
+ mismatchDescription.appendText(String.format("%s: ", metricState));
+ valueMatcher.describeMismatch(metricValue, mismatchDescription);
+ mismatchDescription.appendText("}");
+ }
+ };
+ }
+
/**
* Matches a {@link MetricResult} with the given namespace, name and step,
and whose value equals
* the given value for either committed or attempted (based on {@code
isCommitted}) metrics.
+ *
+ * <p>For metrics with a {@link {@link GaugeResult}}, only the value is
matched and the timestamp
+ * is ignored.
*/
public static <T> Matcher<MetricResult<T>> metricsResult(
Review comment:
Another note: I checked that these modifications to existing methods produce
the same error messages as before by manually forcing other existing metrics
tests to fail.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
Issue Time Tracking
-------------------
Worklog Id: (was: 284094)
Time Spent: 0.5h (was: 20m)
> StreamingSourceMetricsTest takes too long to finish
> ---------------------------------------------------
>
> Key: BEAM-6883
> URL: https://issues.apache.org/jira/browse/BEAM-6883
> Project: Beam
> Issue Type: Test
> Components: runner-spark
> Affects Versions: 2.11.0
> Reporter: Ismaël Mejía
> Assignee: Ryan Skraba
> Priority: Minor
> Time Spent: 0.5h
> Remaining Estimate: 0h
>
> This test is part of Spark's ValidatesRunner suite and it takes more than 10
> minutes to end.
--
This message was sent by Atlassian JIRA
(v7.6.14#76016)