spuru9 commented on code in PR #30180:
URL: https://github.com/apache/flink/pull/30180#discussion_r4722971215
##########
flink-runtime/src/test/java/org/apache/flink/runtime/jobgraph/jsonplan/JsonGeneratorTest.java:
##########
@@ -35,126 +35,100 @@
import
org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonProcessingException;
import
org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectMapper;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
+import java.util.stream.StreamSupport;
import static
org.apache.flink.runtime.util.JobVertexConnectionUtils.connectNewDataSetAsInput;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-public class JsonGeneratorTest {
+class JsonGeneratorTest {
@Test
- public void testGeneratorWithoutAnyAttachements() {
- try {
- JobVertex source1 = new JobVertex("source 1");
-
- JobVertex source2 = new JobVertex("source 2");
- source2.setInvokableClass(DummyInvokable.class);
-
- JobVertex source3 = new JobVertex("source 3");
-
- JobVertex intermediate1 = new JobVertex("intermediate 1");
- JobVertex intermediate2 = new JobVertex("intermediate 2");
-
- JobVertex join1 = new JobVertex("join 1");
- JobVertex join2 = new JobVertex("join 2");
-
- JobVertex sink1 = new JobVertex("sink 1");
- JobVertex sink2 = new JobVertex("sink 2");
-
- connectNewDataSetAsInput(
- intermediate1,
- source1,
- DistributionPattern.POINTWISE,
- ResultPartitionType.PIPELINED);
- connectNewDataSetAsInput(
- intermediate2,
- source2,
- DistributionPattern.ALL_TO_ALL,
- ResultPartitionType.PIPELINED);
-
- connectNewDataSetAsInput(
- join1,
- intermediate1,
- DistributionPattern.POINTWISE,
- ResultPartitionType.BLOCKING);
- connectNewDataSetAsInput(
- join1,
- intermediate2,
- DistributionPattern.ALL_TO_ALL,
- ResultPartitionType.BLOCKING);
-
- connectNewDataSetAsInput(
- join2, join1, DistributionPattern.POINTWISE,
ResultPartitionType.PIPELINED);
- connectNewDataSetAsInput(
- join2, source3, DistributionPattern.POINTWISE,
ResultPartitionType.BLOCKING);
-
- connectNewDataSetAsInput(
- sink1, join2, DistributionPattern.POINTWISE,
ResultPartitionType.PIPELINED);
- connectNewDataSetAsInput(
- sink2, join1, DistributionPattern.ALL_TO_ALL,
ResultPartitionType.PIPELINED);
-
- JobGraph jg =
- JobGraphTestUtils.batchJobGraph(
- source1,
- source2,
- source3,
- intermediate1,
- intermediate2,
- join1,
- join2,
- sink1,
- sink2);
-
- JobPlanInfo.Plan plan = JsonPlanGenerator.generatePlan(jg);
- assertNotNull(plan);
-
- // core fields
- assertEquals(jg.getJobID().toString(), plan.getJobId());
- assertEquals(jg.getName(), plan.getName());
- assertEquals(jg.getJobType().name(), plan.getType());
-
- assertThat(plan.getNodes()).isNotEmpty();
- assertThat(plan.getNodes().size()).isEqualTo(9);
-
- for (JobPlanInfo.Plan.Node node : plan.getNodes()) {
- checkVertexExists(node.getId(), jg);
-
- String description = node.getDescription();
- assertTrue(
- description.startsWith("source")
- || description.startsWith("sink")
- || description.startsWith("intermediate")
- || description.startsWith("join"));
- }
- } catch (Exception e) {
- e.printStackTrace();
- fail(e.getMessage());
- }
- }
-
- private void checkVertexExists(String vertexId, JobGraph graph) {
- // validate that the vertex has a valid
- JobVertexID id = JobVertexID.fromHexString(vertexId);
- for (JobVertex vertex : graph.getVertices()) {
- if (vertex.getID().equals(id)) {
- return;
- }
- }
- fail("could not find vertex with id " + vertexId + " in JobGraph");
+ void testGeneratorWithoutAnyAttachements() {
+ JobVertex source1 = new JobVertex("source 1");
+
+ JobVertex source2 = new JobVertex("source 2");
+ source2.setInvokableClass(DummyInvokable.class);
+
+ JobVertex source3 = new JobVertex("source 3");
+
+ JobVertex intermediate1 = new JobVertex("intermediate 1");
+ JobVertex intermediate2 = new JobVertex("intermediate 2");
+
+ JobVertex join1 = new JobVertex("join 1");
+ JobVertex join2 = new JobVertex("join 2");
+
+ JobVertex sink1 = new JobVertex("sink 1");
+ JobVertex sink2 = new JobVertex("sink 2");
+
+ connectNewDataSetAsInput(
+ intermediate1,
+ source1,
+ DistributionPattern.POINTWISE,
+ ResultPartitionType.PIPELINED);
+ connectNewDataSetAsInput(
+ intermediate2,
+ source2,
+ DistributionPattern.ALL_TO_ALL,
+ ResultPartitionType.PIPELINED);
+
+ connectNewDataSetAsInput(
+ join1, intermediate1, DistributionPattern.POINTWISE,
ResultPartitionType.BLOCKING);
+ connectNewDataSetAsInput(
+ join1, intermediate2, DistributionPattern.ALL_TO_ALL,
ResultPartitionType.BLOCKING);
+
+ connectNewDataSetAsInput(
+ join2, join1, DistributionPattern.POINTWISE,
ResultPartitionType.PIPELINED);
+ connectNewDataSetAsInput(
+ join2, source3, DistributionPattern.POINTWISE,
ResultPartitionType.BLOCKING);
+
+ connectNewDataSetAsInput(
+ sink1, join2, DistributionPattern.POINTWISE,
ResultPartitionType.PIPELINED);
+ connectNewDataSetAsInput(
+ sink2, join1, DistributionPattern.ALL_TO_ALL,
ResultPartitionType.PIPELINED);
+
+ JobGraph jg =
+ JobGraphTestUtils.batchJobGraph(
+ source1,
+ source2,
+ source3,
+ intermediate1,
+ intermediate2,
+ join1,
+ join2,
+ sink1,
+ sink2);
+
+ JobPlanInfo.Plan plan = JsonPlanGenerator.generatePlan(jg);
+ assertThat(plan).isNotNull();
+
+ // core fields
+ assertThat(plan.getJobId()).isEqualTo(jg.getJobID().toString());
Review Comment:
I swapped the sides, since hasToString only takes a String:
assertThat(jg.getJobID()).hasToString(plan.getJobId()). Same for the other.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]