Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1926,7 +1926,7 @@ protected File getPackageFile(FunctionDetails.ComponentType componentType, Strin
if (isNotBlank(functionPkgUrl)) {
componentPackageFile = getPackageFile(componentType, functionPkgUrl);
} else if (existingPackagePath.startsWith(Utils.FILE) || existingPackagePath.startsWith(Utils.HTTP)) {
if (!worker().getPackageUrlValidator().isValidPackageUrl(componentType, functionPkgUrl)) {
if (!worker().getPackageUrlValidator().isValidPackageUrl(componentType, existingPackagePath)) {
throw new IllegalArgumentException("Function Package url is not valid."
+ "supported url (http/https/file)");
}
Expand All @@ -1935,7 +1935,7 @@ protected File getPackageFile(FunctionDetails.ComponentType componentType, Strin
} catch (Exception e) {
throw new IllegalArgumentException(String.format("Encountered error \"%s\" "
+ "when getting %s package from %s", e.getMessage(),
ComponentTypeUtils.toString(componentType), functionPkgUrl));
ComponentTypeUtils.toString(componentType), existingPackagePath));
}
} else if (Utils.hasPackageTypePrefix(existingPackagePath)) {
componentPackageFile = getPackageFile(componentType, existingPackagePath);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1020,6 +1020,42 @@ public void testUpdateFunctionWithUrl() throws IOException {

}

@Test
public void testUpdateFunctionWithExistingFileUrl() throws IOException {

String fileLocation = FutureUtil.class.getProtectionDomain().getCodeSource().getLocation().getPath();
Comment thread
sbourkeostk marked this conversation as resolved.
String filePackageUrl = "file://" + fileLocation;

FunctionConfig functionConfig = new FunctionConfig();
functionConfig.setOutput(OUTPUT_TOPIC);
functionConfig.setOutputSerdeClassName(OUTPUT_SERDE_CLASS_NAME);
functionConfig.setTenant(TENANT);
functionConfig.setNamespace(NAMESPACE);
functionConfig.setName(FUNCTION);
functionConfig.setClassName(CLASS_NAME);
// increment parallelism to avoid 'Update contains no change' exception
functionConfig.setParallelism(PARALLELISM + 1);
functionConfig.setRuntime(FunctionConfig.Runtime.JAVA);
functionConfig.setCustomSerdeInputs(TOPICS_TO_SER_DE_CLASS_NAME);

FunctionMetaData existingMetaData = new FunctionMetaData();
existingMetaData.setFunctionDetails().copyFrom(createDefaultFunctionDetails());
existingMetaData.setPackageLocation().setPackagePath(filePackageUrl);

when(mockedManager.containsFunction(eq(TENANT), eq(NAMESPACE), eq(FUNCTION))).thenReturn(true);
when(mockedManager.getFunctionMetaData(any(), any(), any())).thenReturn(existingMetaData);

updateFunction(
TENANT,
NAMESPACE,
FUNCTION,
null,
null,
null,
functionConfig,
null, null);
}

@Test(expectedExceptions = RestException.class, expectedExceptionsMessageRegExp = "function failed to register")
public void testUpdateFunctionFailure() throws Exception {
try {
Expand Down
Loading