use of org.apache.flink.runtime.webmonitor.handlers.JarActionHandler.JarActionHandlerConfig in project flink by apache.
the class JarActionHandlerTest method testSavepointRestoreSettings.
/**
* Test that the savepoint settings are correctly parsed.
*/
@Test
public void testSavepointRestoreSettings() throws Exception {
Map<String, String> pathParams = new HashMap<>();
// required
pathParams.put("jarid", "required");
// the following should be ignored, because they are parsed from the query params
pathParams.put("savepointPath", "ignored");
pathParams.put("allowNonRestoredState", "ignored");
// <-- everything goes here
Map<String, String> queryParams = new HashMap<>();
// Nothing configured
JarActionHandlerConfig config = JarActionHandlerConfig.fromParams(pathParams, queryParams);
assertEquals(SavepointRestoreSettings.none(), config.getSavepointRestoreSettings());
// Set path
queryParams.put("savepointPath", "the-savepoint-path");
queryParams.put("allowNonRestoredState", "");
SavepointRestoreSettings expected = SavepointRestoreSettings.forPath("the-savepoint-path", false);
config = JarActionHandlerConfig.fromParams(pathParams, queryParams);
assertEquals(expected, config.getSavepointRestoreSettings());
// Set flag
queryParams.put("allowNonRestoredState", "true");
expected = SavepointRestoreSettings.forPath("the-savepoint-path", true);
config = JarActionHandlerConfig.fromParams(pathParams, queryParams);
assertEquals(expected, config.getSavepointRestoreSettings());
}
use of org.apache.flink.runtime.webmonitor.handlers.JarActionHandler.JarActionHandlerConfig in project flink by apache.
the class JarActionHandlerTest method testEmptyStringParams.
/**
* Tests that empty String params are handled ignored.
*/
@Test
public void testEmptyStringParams() throws Exception {
Map<String, String> pathParams = new HashMap<>();
// required
pathParams.put("jarid", "required");
Map<String, String> queryParams = new HashMap<>();
queryParams.put("program-args", "");
queryParams.put("entry-class", "");
queryParams.put("parallelism", "");
queryParams.put("savepointPath", "");
queryParams.put("allowNonRestoredState", "");
// Nothing configured
JarActionHandlerConfig config = JarActionHandlerConfig.fromParams(pathParams, queryParams);
assertEquals(0, config.getProgramArgs().length);
assertNull(config.getEntryClass());
assertEquals(1, config.getParallelism());
assertEquals(SavepointRestoreSettings.none(), config.getSavepointRestoreSettings());
}
Aggregations