xinbinhuang commented on a change in pull request #17873:
URL: https://github.com/apache/flink/pull/17873#discussion_r762384359
##########
File path:
flink-streaming-java/src/test/java/org/apache/flink/streaming/api/graph/StreamGraphGeneratorTest.java
##########
@@ -577,6 +577,57 @@ public void invoke(Integer value, Context ctx) throws
Exception {}
env.getStreamGraph().getStreamingPlanAsJSON();
}
+ @Test
+ public void testJsonGraphSlotSharingGroup() {
+ StreamExecutionEnvironment env =
StreamExecutionEnvironment.getExecutionEnvironment();
+ DataStream<Integer> source = env.fromElements(1, 2, 3);
+ DataStream<Integer> mapper = source.map(x -> x +
1).slotSharingGroup("map");
+ mapper.addSink(
+ new SinkFunction<Integer>() {
+ @Override
+ public void invoke(Integer value, Context ctx)
throws Exception {}
+ })
+ .slotSharingGroup("sink");
+
+ String jsonGraph =
+ "{\n"
+ + " \"nodes\" : [ {\n"
+ + " \"id\" : 43,\n"
+ + " \"type\" : \"Source: Collection Source\",\n"
+ + " \"pact\" : \"Data Source\",\n"
+ + " \"slot_sharing_group\" : \"default\",\n"
+ + " \"contents\" : \"Source: Collection Source\",\n"
+ + " \"parallelism\" : 1\n"
+ + " }, {\n"
+ + " \"id\" : 44,\n"
+ + " \"type\" : \"Map\",\n"
+ + " \"pact\" : \"Operator\",\n"
+ + " \"slot_sharing_group\" : \"map\",\n"
+ + " \"contents\" : \"Map\",\n"
+ + " \"parallelism\" : 16,\n"
+ + " \"predecessors\" : [ {\n"
+ + " \"id\" : 43,\n"
+ + " \"ship_strategy\" : \"REBALANCE\",\n"
+ + " \"side\" : \"second\"\n"
+ + " } ]\n"
+ + " }, {\n"
+ + " \"id\" : 45,\n"
+ + " \"type\" : \"Sink: Unnamed\",\n"
+ + " \"pact\" : \"Data Sink\",\n"
+ + " \"slot_sharing_group\" : \"sink\",\n"
+ + " \"contents\" : \"Sink: Unnamed\",\n"
+ + " \"parallelism\" : 16,\n"
+ + " \"predecessors\" : [ {\n"
+ + " \"id\" : 44,\n"
+ + " \"ship_strategy\" : \"FORWARD\",\n"
+ + " \"side\" : \"second\"\n"
+ + " } ]\n"
+ + " } ]\n"
+ + "}";
+
+ assertEquals(jsonGraph, env.getStreamGraph().getStreamingPlanAsJSON());
Review comment:
It's possible though require some parsing on the final JSON String.
That said, I noticed that there is no existing test case for
`.getStreamingPlanAsJSON()`. So I think this is a good addition to verify the
whole JSON string output by `getStreamingPlanAsJSON`. WDYT?
--
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]