You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by tr...@apache.org on 2018/04/03 14:34:34 UTC
[3/3] flink git commit: [FLINK-6567] [tests] Harden
ExecutionGraphMetricsTest
[FLINK-6567] [tests] Harden ExecutionGraphMetricsTest
The problem was that in some cases the currentRestartingTime would not increase
because the iteration in the loop were too fast.
This closes #5782.
Project: http://git-wip-us.apache.org/repos/asf/flink/repo
Commit: http://git-wip-us.apache.org/repos/asf/flink/commit/db366cd3
Tree: http://git-wip-us.apache.org/repos/asf/flink/tree/db366cd3
Diff: http://git-wip-us.apache.org/repos/asf/flink/diff/db366cd3
Branch: refs/heads/master
Commit: db366cd3d02a823f93185f29ca7ae93da9e2a04b
Parents: 78c3d9b
Author: Till Rohrmann <tr...@apache.org>
Authored: Wed Mar 28 15:35:11 2018 +0200
Committer: Till Rohrmann <tr...@apache.org>
Committed: Tue Apr 3 14:49:53 2018 +0200
----------------------------------------------------------------------
.../ExecutionGraphMetricsTest.java | 22 +++++++++++++-------
1 file changed, 14 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flink/blob/db366cd3/flink-runtime/src/test/java/org/apache/flink/runtime/executiongraph/ExecutionGraphMetricsTest.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/executiongraph/ExecutionGraphMetricsTest.java b/flink-runtime/src/test/java/org/apache/flink/runtime/executiongraph/ExecutionGraphMetricsTest.java
index 63b3238..ec0d2e3 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/executiongraph/ExecutionGraphMetricsTest.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/executiongraph/ExecutionGraphMetricsTest.java
@@ -120,6 +120,9 @@ public class ExecutionGraphMetricsTest extends TestLogger {
assertEquals(JobStatus.RUNNING, executionGraph.getState());
assertEquals(0L, restartingTime.getValue().longValue());
+ // add some pause such that RUNNING and RESTARTING timestamps are not the same
+ Thread.sleep(1L);
+
// fail the job so that it goes into state restarting
for (ExecutionAttemptID executionID : executionIDs) {
executionGraph.updateState(new TaskExecutionState(jobGraph.getJobID(), executionID, ExecutionState.FAILED, new Exception()));
@@ -129,13 +132,13 @@ public class ExecutionGraphMetricsTest extends TestLogger {
long firstRestartingTimestamp = executionGraph.getStatusTimestamp(JobStatus.RESTARTING);
- // wait some time so that the restarting time gauge shows a value different from 0
- Thread.sleep(50);
-
long previousRestartingTime = restartingTime.getValue();
// check that the restarting time is monotonically increasing
- for (int i = 0; i < 10; i++) {
+ for (int i = 0; i < 2; i++) {
+ // add some pause to let the currentRestartingTime increase
+ Thread.sleep(1L);
+
long currentRestartingTime = restartingTime.getValue();
assertTrue(currentRestartingTime >= previousRestartingTime);
@@ -165,13 +168,16 @@ public class ExecutionGraphMetricsTest extends TestLogger {
previousRestartingTime = restartingTime.getValue();
// check that the restarting time does not increase after we've reached the running state
- for (int i = 0; i < 10; i++) {
+ for (int i = 0; i < 2; i++) {
long currentRestartingTime = restartingTime.getValue();
assertTrue(currentRestartingTime == previousRestartingTime);
previousRestartingTime = currentRestartingTime;
}
+ // add some pause such that the RUNNING and RESTARTING timestamps are not the same
+ Thread.sleep(1L);
+
// fail job again
for (ExecutionAttemptID executionID : executionIDs) {
executionGraph.updateState(new TaskExecutionState(jobGraph.getJobID(), executionID, ExecutionState.FAILED, new Exception()));
@@ -183,12 +189,12 @@ public class ExecutionGraphMetricsTest extends TestLogger {
assertTrue(firstRestartingTimestamp != secondRestartingTimestamp);
- Thread.sleep(50);
-
previousRestartingTime = restartingTime.getValue();
// check that the restarting time is increasing again
- for (int i = 0; i < 10; i++) {
+ for (int i = 0; i < 2; i++) {
+ // add some pause to the let currentRestartingTime increase
+ Thread.sleep(1L);
long currentRestartingTime = restartingTime.getValue();
assertTrue(currentRestartingTime >= previousRestartingTime);