wangyang0918 commented on a change in pull request #11070: [FLINK-16013][core]
Make complex type config options could be parsed correctly
URL: https://github.com/apache/flink/pull/11070#discussion_r383198516
##########
File path:
flink-runtime/src/test/java/org/apache/flink/runtime/clusterframework/BootstrapToolsTest.java
##########
@@ -533,4 +547,56 @@ public void testGetEnvironmentVariablesErroneous() {
Assert.assertEquals(0, res.size());
}
+
+ @Test
+ public void testWriteConfigurationAndReload() throws IOException {
+ final File flinkConfDir =
temporaryFolder.newFolder().getAbsoluteFile();
+ final Configuration flinkConfig = new Configuration();
+
+ final ConfigOption<List<String>> listStringConfigOption =
ConfigOptions
+ .key("test-list-string-key")
+ .stringType()
+ .asList()
+ .noDefaultValue();
+ final List<String> list = Arrays.asList("A,B,C,D", "A'B'C'D",
"A;BCD", "AB\"C\"D", "AB'\"D:B");
+ flinkConfig.set(listStringConfigOption, list);
+ assertThat(list,
containsInAnyOrder(flinkConfig.get(listStringConfigOption).toArray()));
+
+ final ConfigOption<List<Duration>> listDurationConfigOption =
ConfigOptions
+ .key("test-list-duration-key")
+ .durationType()
+ .asList()
+ .noDefaultValue();
+ final List<Duration> durationList =
Arrays.asList(Duration.ofSeconds(3), Duration.ofMinutes(1));
+ flinkConfig.set(listDurationConfigOption, durationList);
+ assertThat(durationList,
containsInAnyOrder(flinkConfig.get(listDurationConfigOption).toArray()));
+
+ final ConfigOption<Map<String, String>> mapConfigOption =
ConfigOptions
+ .key("test-map-key")
+ .mapType()
+ .noDefaultValue();
+ final Map<String, String> map = new HashMap<>();
+ map.put("key1", "A,B,C,D");
+ map.put("key2", "A;BCD");
+ map.put("key3", "A'B'C'D");
+ map.put("key4", "AB\"C\"D");
+ map.put("key5", "AB'\"D:B");
+ flinkConfig.set(mapConfigOption, map);
+ assertThat(map.entrySet(),
containsInAnyOrder(flinkConfig.get(mapConfigOption).entrySet().toArray()));
+
+ final ConfigOption<Duration> durationConfigOption =
ConfigOptions
+ .key("test-duration-key")
+ .durationType()
+ .noDefaultValue();
+ final Duration duration = Duration.ofMillis(3000);
+ flinkConfig.set(durationConfigOption, duration);
+ assertEquals(duration, flinkConfig.get(durationConfigOption));
+
+ BootstrapTools.writeConfiguration(flinkConfig, new
File(flinkConfDir, FLINK_CONF_FILENAME));
+ final Configuration loadedFlinkConfig =
GlobalConfiguration.loadConfiguration(flinkConfDir.getAbsolutePath());
+ assertThat(list,
containsInAnyOrder(loadedFlinkConfig.get(listStringConfigOption).toArray()));
+ assertThat(durationList,
containsInAnyOrder(flinkConfig.get(listDurationConfigOption).toArray()));
+ assertThat(map.entrySet(),
containsInAnyOrder(loadedFlinkConfig.get(mapConfigOption).entrySet().toArray()));
Review comment:
I will have quick fix and push again.
----------------------------------------------------------------
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]
With regards,
Apache Git Services