提交 e1547e12 编写于 作者: B Boyang Jerry Peng 提交者: Sijie Guo

Fix: Bug when function package jar/py/go and runtime is not set (#4814)

### Modifications

When submitting a function via REST interface, if user doesn't provide the function package or function runtime as part of function config, the function will get submitted and deployed to run but the typeClassName for the source will not be set causing a weird error in the function instance code
上级 19b883b7
......@@ -632,9 +632,11 @@ public class FunctionConfigUtils {
} else if (functionConfig.getRuntime() == FunctionConfig.Runtime.GO) {
doGolangChecks(functionConfig);
return null;
} else {
} else if (functionConfig.getRuntime() == FunctionConfig.Runtime.PYTHON){
doPythonChecks(functionConfig);
return null;
} else {
throw new IllegalArgumentException("Function language runtime is either not set or cannot be determined");
}
}
......
......@@ -1533,6 +1533,31 @@ public class FunctionApiV3ResourceTest {
resource.registerFunction(actualTenant, actualNamespace, actualName, null, null, filePackageUrl, functionConfig, null, null);
}
@Test(expectedExceptions = RestException.class, expectedExceptionsMessageRegExp = "Function language runtime is either not set or cannot be determined")
public void testCreateFunctionWithoutSettingRuntime() {
Configurator.setRootLevel(Level.DEBUG);
String fileLocation = FutureUtil.class.getProtectionDomain().getCodeSource().getLocation().getPath();
String filePackageUrl = "file://" + fileLocation;
when(mockedManager.containsFunction(eq(tenant), eq(namespace), eq(function))).thenReturn(false);
RequestResult rr = new RequestResult().setSuccess(true).setMessage("function registered");
CompletableFuture<RequestResult> requestResult = CompletableFuture.completedFuture(rr);
when(mockedManager.updateFunction(any(FunctionMetaData.class))).thenReturn(requestResult);
FunctionConfig functionConfig = new FunctionConfig();
functionConfig.setTenant(tenant);
functionConfig.setNamespace(namespace);
functionConfig.setName(function);
functionConfig.setClassName(className);
functionConfig.setParallelism(parallelism);
functionConfig.setCustomSerdeInputs(topicsToSerDeClassName);
functionConfig.setOutput(outputTopic);
functionConfig.setOutputSerdeClassName(outputSerdeClassName);
resource.registerFunction(tenant, namespace, function, null, null, filePackageUrl, functionConfig, null, null);
}
public static FunctionConfig createDefaultFunctionConfig() {
FunctionConfig functionConfig = new FunctionConfig();
functionConfig.setTenant(tenant);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册