echonesis commented on code in PR #9960:
URL: https://github.com/apache/gravitino/pull/9960#discussion_r2935424232
##########
clients/client-java/src/test/java/org/apache/gravitino/client/integration/test/JobIT.java:
##########
@@ -452,4 +452,93 @@ private String generateTestLibScript() {
throw new RuntimeException("Failed to create test lib script", e);
}
}
+
+ @Test
+ public void testJobTemplateWithOptionalArguments() throws Exception {
+ String optArgTestScriptPath = generateOptionalArgTestScript();
+
+ // Template with flag/value optional pairs. The first positional arg
({{mode}})
+ // tells the validation script which flags it should or should not receive.
+ ShellJobTemplate template =
+ ShellJobTemplate.builder()
+ .withName("test_optional_args_template")
+ .withComment("Test template with optional flag/value pairs")
+ .withExecutable(optArgTestScriptPath)
+ .withArguments(
+ Lists.newArrayList(
+ "{{mode}}", "?--opt1", "?{{optional_arg1}}", "?--opt2",
"?{{optional_arg2}}"))
+ .withEnvironments(Collections.emptyMap())
+ .withScripts(Collections.emptyList())
+ .withCustomFields(Collections.emptyMap())
+ .build();
+
+ metalake.registerJobTemplate(template);
+ Assertions.assertNotNull(metalake.getJobTemplate(template.name()));
+
+ // Case 1: No optional args — script asserts neither flag is received.
+ runJobAndAwait(template, ImmutableMap.of("mode", "no_optionals"),
JobHandle.Status.SUCCEEDED);
+
+ // Case 2: opt1 provided, opt2 absent — script asserts --opt1 is present
and --opt2 is absent.
+ runJobAndAwait(
+ template,
+ ImmutableMap.of("mode", "opt1_only", "optional_arg1", "val1"),
+ JobHandle.Status.SUCCEEDED);
+
+ // Case 3: Both optional args provided — script asserts both flags are
received.
+ runJobAndAwait(
+ template,
+ ImmutableMap.of("mode", "both_optionals", "optional_arg1", "val1",
"optional_arg2", "val2"),
+ JobHandle.Status.SUCCEEDED);
+ }
Review Comment:
Thanks for mentioning.
I will update `JobIT` to verify the actual runtime args, not just the final
job status.
--
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]