[
https://issues.apache.org/jira/browse/BEAM-4775?focusedWorklogId=282756&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-282756
]
ASF GitHub Bot logged work on BEAM-4775:
----------------------------------------
Author: ASF GitHub Bot
Created on: 25/Jul/19 16:36
Start Date: 25/Jul/19 16:36
Worklog Time Spent: 10m
Work Description: lgajowy commented on pull request #9020: [BEAM-4775]
Support returning metrics from job service
URL: https://github.com/apache/beam/pull/9020#discussion_r307393014
##########
File path:
runners/java-fn-execution/src/test/java/org/apache/beam/runners/fnexecution/jobsubmission/JobInvocationTest.java
##########
@@ -130,6 +128,40 @@ public void testNoCancellationWhenDone() throws Exception
{
assertThat(pipelineResult.cancelLatch.getCount(), is(1L));
}
+ @Test(timeout = 10_000)
+ public void testReturnsMetricsFromJobInvocationAfterSuccess() throws
Exception {
+ JobApi.MetricResults expectedMonitoringInfos =
JobApi.MetricResults.newBuilder().build();
+ TestPipelineResult result =
+ new TestPipelineResult(PipelineResult.State.DONE,
expectedMonitoringInfos);
+
+ jobInvocation.start();
+ runner.setResult(result);
+
+ awaitJobState(jobInvocation, JobApi.JobState.Enum.DONE);
+
+ assertThat(
+ jobInvocation.getMetrics(),
+ allOf(is(notNullValue()), is(sameInstance(result.portableMetrics()))));
+ }
+
+ @Test(timeout = 10_000)
+ public void testReturnsMetricsFromJobInvocationAfterCancellation() throws
Exception {
+ JobApi.MetricResults expectedMonitoringInfos =
JobApi.MetricResults.newBuilder().build();
+ TestPipelineResult result =
+ new TestPipelineResult(PipelineResult.State.RUNNING,
expectedMonitoringInfos);
+
+ jobInvocation.start();
+ runner.setResult(result);
+ awaitJobState(jobInvocation, JobApi.JobState.Enum.RUNNING);
+
+ jobInvocation.cancel();
+ awaitJobState(jobInvocation, JobApi.JobState.Enum.CANCELLED);
+
+ assertThat(
Review comment:
@ibzib @angoenka
Update: I know why this test is flaky!
1. Occasionally, invocationFuture in start() ends up in onFailure method due
to a CancellationException and [sets the CANCELLED
state](https://github.com/apache/beam/blob/5c6f4282c698c6fca38e576230642eacaf0bea55/runners/java-fn-execution/src/main/java/org/apache/beam/runners/fnexecution/jobsubmission/JobInvocation.java#L116).
2. In the test we are waiting for the CANCELLED state but assuming that it
will appear only when we actually cancel() the job (and that assumption is
incorrect, as point 1 shows).
3. the metrics are not there yet because neither start's onSuccess() or
cancel's onSuccess() were called so the assertion is not satisfied.
I had an idea how to test this:
```
@Test(timeout = 10_000)
public void testReturnsMetricsFromJobInvocationAfterCancellation() throws
Exception {
JobApi.MetricResults expectedMonitoringInfos =
JobApi.MetricResults.newBuilder().build();
TestPipelineResult result =
new TestPipelineResult(PipelineResult.State.RUNNING,
expectedMonitoringInfos);
runner.setResult(result);
invocationFuture = executorService.submit(() -> { runner.run(pipeline,
jobInfo);});
jobInvocation.cancel();
awaitJobState(jobInvocation, JobApi.JobState.Enum.CANCELLED);
assertThat(
jobInvocation.getMetrics(),
allOf(is(notNullValue()),
is(sameInstance(result.portableMetrics()))));
}
```
BUT it's currently not doable without using any sort of reflection (which I
don't want to do because this would be nasty) - I don't have access to
`invocationFuture` in `JobInvocationTest`.
Let me know if you have any comments or ideas on how to fix this
differently. I currently intend to **delete this flaky test**. Let me know if
you agree to that.
----------------------------------------------------------------
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: 282756)
Time Spent: 47h 40m (was: 47.5h)
> JobService should support returning metrics
> -------------------------------------------
>
> Key: BEAM-4775
> URL: https://issues.apache.org/jira/browse/BEAM-4775
> Project: Beam
> Issue Type: Bug
> Components: beam-model
> Reporter: Eugene Kirpichov
> Assignee: Lukasz Gajowy
> Priority: Major
> Time Spent: 47h 40m
> Remaining Estimate: 0h
>
> Design doc: [https://s.apache.org/get-metrics-api].
> Further discussion is ongoing on [this
> doc|https://docs.google.com/document/d/1m83TsFvJbOlcLfXVXprQm1B7vUakhbLZMzuRrOHWnTg/edit?ts=5c826bb4#heading=h.faqan9rjc6dm].
> We want to report job metrics back to the portability harness from the runner
> harness, for displaying to users.
> h1. Relevant PRs in flight:
> h2. Ready for Review:
> * [#8022|https://github.com/apache/beam/pull/8022]: correct the Job RPC
> protos from [#8018|https://github.com/apache/beam/pull/8018].
> h2. Iterating / Discussing:
> * [#7971|https://github.com/apache/beam/pull/7971]: Flink portable metrics:
> get ptransform from MonitoringInfo, not stage name
> ** this is a simpler, Flink-specific PR that is basically duplicated inside
> each of the following two, so may be worth trying to merge in first
> * #[7915|https://github.com/apache/beam/pull/7915]: use MonitoringInfo data
> model in Java SDK metrics
> * [#7868|https://github.com/apache/beam/pull/7868]: MonitoringInfo URN tweaks
> h2. Merged
> * [#8018|https://github.com/apache/beam/pull/8018]: add job metrics RPC
> protos
> * [#7867|https://github.com/apache/beam/pull/7867]: key MetricResult by a
> MetricKey
> * [#7938|https://github.com/apache/beam/pull/7938]: move MonitoringInfo
> protos to model/pipeline module
> * [#7883|https://github.com/apache/beam/pull/7883]: Add
> MetricQueryResults.allMetrics() helper
> * [#7866|https://github.com/apache/beam/pull/7866]: move function helpers
> from fn-harness to sdks/java/core
> * [#7890|https://github.com/apache/beam/pull/7890]: consolidate MetricResult
> implementations
> h2. Closed
> * [#7934|https://github.com/apache/beam/pull/7934]: job metrics RPC + SDK
> support
> * [#7876|https://github.com/apache/beam/pull/7876]: Clean up metric protos;
> support integer distributions, gauges
--
This message was sent by Atlassian JIRA
(v7.6.14#76016)