Skip to content

Commit cc517ad

Browse files
committed
[hotfix][test] Adds some additional logging to RescaleOnCheckpointITCase
1 parent 2b8f012 commit cc517ad

File tree

1 file changed

+34
-4
lines changed

1 file changed

+34
-4
lines changed

flink-tests/src/test/java/org/apache/flink/test/scheduling/RescaleOnCheckpointITCase.java

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import org.apache.flink.runtime.jobgraph.JobGraph;
2828
import org.apache.flink.runtime.jobgraph.JobResourceRequirements;
2929
import org.apache.flink.runtime.jobgraph.JobVertex;
30+
import org.apache.flink.runtime.jobgraph.JobVertexID;
3031
import org.apache.flink.runtime.minicluster.MiniCluster;
3132
import org.apache.flink.runtime.testutils.MiniClusterResourceConfiguration;
3233
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
@@ -40,6 +41,8 @@
4041
import org.junit.jupiter.api.Test;
4142
import org.junit.jupiter.api.extension.ExtendWith;
4243
import org.junit.jupiter.api.extension.RegisterExtension;
44+
import org.slf4j.Logger;
45+
import org.slf4j.LoggerFactory;
4346

4447
import java.time.Duration;
4548
import java.util.Iterator;
@@ -51,6 +54,8 @@
5154
@ExtendWith(TestLoggerExtension.class)
5255
class RescaleOnCheckpointITCase {
5356

57+
private static final Logger LOG = LoggerFactory.getLogger(RescaleOnCheckpointITCase.class);
58+
5459
// Scaling down is used here because scaling up is not supported by the NumberSequenceSource
5560
// that's used in this test.
5661
private static final int NUMBER_OF_SLOTS = 4;
@@ -111,34 +116,59 @@ void testRescaleOnCheckpoint(
111116
assertThat(jobVertexIterator.hasNext())
112117
.as("There needs to be at least one JobVertex.")
113118
.isTrue();
119+
final JobVertexID jobVertexId = jobVertexIterator.next().getID();
114120
final JobResourceRequirements jobResourceRequirements =
115121
JobResourceRequirements.newBuilder()
116-
.setParallelismForJobVertex(
117-
jobVertexIterator.next().getID(), 1, AFTER_RESCALE_PARALLELISM)
122+
.setParallelismForJobVertex(jobVertexId, 1, AFTER_RESCALE_PARALLELISM)
118123
.build();
119124
assertThat(jobVertexIterator.hasNext())
120125
.as("This test expects to have only one JobVertex.")
121126
.isFalse();
122127

123128
restClusterClient.submitJob(jobGraph).join();
129+
130+
final JobID jobId = jobGraph.getJobID();
124131
try {
125-
final JobID jobId = jobGraph.getJobID();
126132

133+
LOG.info(
134+
"Waiting for job {} to reach parallelism of {} for vertex {}.",
135+
jobId,
136+
BEFORE_RESCALE_PARALLELISM,
137+
jobVertexId);
127138
waitForRunningTasks(restClusterClient, jobId, BEFORE_RESCALE_PARALLELISM);
128139

140+
LOG.info(
141+
"Job {} reached parallelism of {} for vertex {}. Updating the vertex parallelism next to {}.",
142+
jobId,
143+
BEFORE_RESCALE_PARALLELISM,
144+
jobVertexId,
145+
AFTER_RESCALE_PARALLELISM);
129146
restClusterClient.updateJobResourceRequirements(jobId, jobResourceRequirements).join();
130147

131148
// timeout to allow any unexpected rescaling to happen anyway
132149
Thread.sleep(REQUIREMENT_UPDATE_TO_CHECKPOINT_GAP.toMillis());
133150

134151
// verify that the previous timeout didn't result in a change of parallelism
152+
LOG.info(
153+
"Checking that job {} hasn't changed its parallelism even after some delay, yet.",
154+
jobId);
135155
waitForRunningTasks(restClusterClient, jobId, BEFORE_RESCALE_PARALLELISM);
136156

137157
miniCluster.triggerCheckpoint(jobId);
138158

159+
LOG.info(
160+
"Waiting for job {} to reach parallelism of {} for vertex {}.",
161+
jobId,
162+
AFTER_RESCALE_PARALLELISM,
163+
jobVertexId);
139164
waitForRunningTasks(restClusterClient, jobId, AFTER_RESCALE_PARALLELISM);
140165

141-
waitForAvailableSlots(restClusterClient, NUMBER_OF_SLOTS - AFTER_RESCALE_PARALLELISM);
166+
final int expectedFreeSlotCount = NUMBER_OF_SLOTS - AFTER_RESCALE_PARALLELISM;
167+
LOG.info(
168+
"Waiting for {} slot(s) to become available due to the scale down.",
169+
expectedFreeSlotCount);
170+
waitForAvailableSlots(restClusterClient, expectedFreeSlotCount);
171+
LOG.info("{} free slot(s) detected. Finishing test.", expectedFreeSlotCount);
142172
} finally {
143173
restClusterClient.cancel(jobGraph.getJobID()).join();
144174
}

0 commit comments

Comments
 (0)