Skip to content

Sdktypes bug fix #823

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 28 commits into from
Jun 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
e7bb7d4
use a helper that looks up data in specific input sources
ahmedmuhsin Jun 3, 2025
1dc4730
revert method to what it was before sdk type changes
ahmedmuhsin Jun 3, 2025
11c7e5d
move env variable name to constants
ahmedmuhsin Jun 3, 2025
b01f05e
fix bug - add missing call to parse and verify metadata
ahmedmuhsin Jun 3, 2025
adff194
add test for blob input scenario and for scenarios where more than on…
ahmedmuhsin Jun 3, 2025
2d69081
skip regular tests for now
ahmedmuhsin Jun 3, 2025
614b10d
fix env variable
ahmedmuhsin Jun 3, 2025
c289329
make sure test containers are created and cleared
ahmedmuhsin Jun 3, 2025
55cfe2b
fix blob path for blob input binding
ahmedmuhsin Jun 4, 2025
a7854a1
upgrade maven plugin version and remove local installation
ahmedmuhsin Jun 4, 2025
1e71ab0
re-enable all disabled tests
ahmedmuhsin Jun 4, 2025
47bd493
always run sdk type tests
ahmedmuhsin Jun 4, 2025
16d7d09
no longer need to install additions locally
ahmedmuhsin Jun 4, 2025
fe52be9
update sdk types version
ahmedmuhsin Jun 4, 2025
075d2a9
remove lingering param
ahmedmuhsin Jun 4, 2025
6adcbba
update testing plugins and fix testing for jdk 17+
ahmedmuhsin Jun 4, 2025
1341276
only update the mockito version for jdk 17+
ahmedmuhsin Jun 4, 2025
91d3ac0
fix java installation for windows
ahmedmuhsin Jun 4, 2025
1d44b4e
fix jdk path
ahmedmuhsin Jun 4, 2025
b9d0ff4
add rest of required args for surefire
ahmedmuhsin Jun 4, 2025
cc8dd56
fix file extension for jdk file
ahmedmuhsin Jun 4, 2025
e4dc5d8
remove JavaHome setting since the environment already sets it up
ahmedmuhsin Jun 4, 2025
618c09c
add missing java version spec
ahmedmuhsin Jun 4, 2025
49b20c9
use docker for azurerite on windows
ahmedmuhsin Jun 4, 2025
793bf36
revert back to using npm
ahmedmuhsin Jun 4, 2025
6752a48
simplify code for getDataByNameFromInputSource
ahmedmuhsin Jun 12, 2025
0b32741
use modern semantics for mapping function call BindingData::getValue
ahmedmuhsin Jun 12, 2025
c554b7d
throw only one exception for all missing keys and throw and more enri…
ahmedmuhsin Jun 12, 2025
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 @@ -25,6 +25,7 @@ public static class Constants
public static string InputBindingBlobContainer = "test-input-java-new";
public static string OutputBindingBlobContainer = "test-output-java-new";
public static string TriggerInputBindingBlobClientSdk = "test-triggerinput-blobclient";
public static string TriggerInputBindingBlobInputBlobClientSdk = "test-triggerinput-blobinput-blobclient";
public static string TriggerInputBindingBlobContainerClientSdk = "test-triggerinput-blobcontclient";

// Xunit Fixtures and Collections
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ public async static Task ClearBlobContainers()
await ClearBlobContainer(Constants.InputBindingBlobContainer);
await ClearBlobContainer(Constants.OutputBindingBlobContainer);
await ClearBlobContainer(Constants.TriggerInputBindingBlobClientSdk);
await ClearBlobContainer(Constants.TriggerInputBindingBlobInputBlobClientSdk);
await ClearBlobContainer(Constants.TriggerInputBindingBlobContainerClientSdk);
}

Expand All @@ -94,6 +95,7 @@ public async static Task CreateBlobContainers()
await CreateBlobContainer(Constants.InputBindingBlobContainer);
await CreateBlobContainer(Constants.OutputBindingBlobContainer);
await CreateBlobContainer(Constants.TriggerInputBindingBlobClientSdk);
await CreateBlobContainer(Constants.TriggerInputBindingBlobInputBlobClientSdk);
await CreateBlobContainer(Constants.TriggerInputBindingBlobContainerClientSdk);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,26 @@ public async Task BlobTriggerToBlob_BlobClient_Succeeds()
Assert.Equal("Hello World", result);
}

[Fact]
[Trait("Category", "SdkTypes")]
public async Task BlobTriggerToBlob_FromBlobInput_BlobClient_Succeeds()
{
string fileName = "testfile";

//cleanup
await StorageHelpers.ClearBlobContainers();

//Setup
await StorageHelpers.CreateBlobContainers();

//Trigger
await StorageHelpers.UpdloadFileToContainer(Constants.TriggerInputBindingBlobInputBlobClientSdk, fileName);

//Verify
string result = await StorageHelpers.DownloadFileFromContainer(Constants.OutputBindingBlobContainer, "testfile");
Assert.Equal("Hello World", result);
}

[Fact]
[Trait("Category", "SdkTypes")]
public async Task BlobTriggerToBlob_BlobContainerClient_Succeeds()
Expand Down
2 changes: 1 addition & 1 deletion emulatedtests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
<azure.functions.maven.plugin.version>1.37.1</azure.functions.maven.plugin.version>
<azure.functions.maven.plugin.version>1.38.0</azure.functions.maven.plugin.version>
<azure.functions.java.library.version>3.1.0</azure.functions.java.library.version>
<azure.functions.java.library.sql.version>2.1.0</azure.functions.java.library.sql.version>
<durabletask.azure.functions>1.0.0-beta.1</durabletask.azure.functions>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class BlobTriggerSdkTypesTests {
@FunctionName("BlobTriggerUsingBlobClientToBlobTest")
@StorageAccount("AzureWebJobsStorage")
public void BlobTriggerToBlobTest_BlobClient(
@BlobTrigger(name = "triggerBlob", path = "test-triggerinput-blobclient/{name}", dataType = "binary") BlobClient triggerBlobClient,
@BlobTrigger(name = "triggerBlob", path = "test-triggerinput-blobclient/{name}") BlobClient triggerBlobClient,
@BindingName("name") String fileName,
@BlobOutput(name = "outputBlob", path = "test-output-java-new/testfile.txt", dataType = "binary") OutputBinding<byte[]> outputBlob,
final ExecutionContext context
Expand All @@ -34,13 +34,35 @@ public void BlobTriggerToBlobTest_BlobClient(
context.getLogger().info("Uploaded blob " + fileName + " to container test-output-java-new/testfile.txt");
}

/**
* This function will be invoked when a new or updated blob is detected at the specified path. The blob contents are provided as input to this function.
*/
@FunctionName("BlobTriggerUsingBlobInputBlobClientToBlobTest")
@StorageAccount("AzureWebJobsStorage")
public void BlobTriggerBlobInputToBlobTest_BlobClient(
@BlobTrigger(name = "triggerBlob", path = "test-triggerinput-blobinput-blobclient/{name}") BlobClient triggerBlobClient,
@BlobInput(name = "inputBlob", path = "test-triggerinput-blobinput-blobclient/testfile.txt") BlobClient outputBlobClient,
@BlobOutput(name = "outputBlob", path = "test-output-java-new/testfile.txt", dataType = "binary") OutputBinding<byte[]> outputBlob,
final ExecutionContext context
) {
context.getLogger().info("BlobTriggerUsingBlobInputBlobClientToBlobTest triggered for blob: " + triggerBlobClient.getBlobName());

// Download the blob content
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
outputBlobClient.downloadStream(outputStream);

// Set the downloaded content as output
outputBlob.setValue(outputStream.toByteArray());
context.getLogger().info("Uploaded blob " + triggerBlobClient.getBlobUrl() + " to container test-output-java-new/testfile.txt");
}

/**
* This function will be invoked when a new or updated blob is detected at the specified path. The blob contents are provided as input to this function.
*/
@FunctionName("BlobTriggerUsingBlobContainerClientToBlobTest")
@StorageAccount("AzureWebJobsStorage")
public void BlobTriggerToBlobTest_BlobContainerClient(
@BlobTrigger(name = "triggerBlob", path = "test-triggerinput-blobcontclient/{name}", dataType = "binary") BlobContainerClient triggerBlobContainerClient,
@BlobTrigger(name = "triggerBlob", path = "test-triggerinput-blobcontclient/{name}") BlobContainerClient triggerBlobContainerClient,
@BindingName("name") String fileName,
@BlobOutput(name = "outputBlob", path = "test-output-java-new/testfile.txt", dataType = "binary") OutputBinding<byte[]> outputBlob,
final ExecutionContext context
Expand Down
9 changes: 1 addition & 8 deletions eng/ci/public-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@ resources:
name: 1ESPipelineTemplates/1ESPipelineTemplates
ref: refs/tags/release

parameters:
- name: runSdkTypesTests
type: boolean
default: false

extends:
template: v1/1ES.Unofficial.PipelineTemplate.yml@1es
parameters:
Expand Down Expand Up @@ -60,12 +55,10 @@ extends:
- template: /eng/ci/templates/jobs/run-emulated-tests-windows.yml@self
parameters:
poolName: 1es-pool-azfunc-public
runSdkTypesTests: ${{ parameters.runSdkTypesTests }}

- stage: TestLinux
dependsOn: []
jobs:
- template: /eng/ci/templates/jobs/run-emulated-tests-linux.yml@self
parameters:
poolName: 1es-pool-azfunc-public
runSdkTypesTests: ${{ parameters.runSdkTypesTests }}
poolName: 1es-pool-azfunc-public
3 changes: 0 additions & 3 deletions eng/ci/templates/jobs/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ jobs:
- pwsh: |
java -version
displayName: 'Check default java version'
- pwsh: |
.\installAdditionsLocally.ps1
displayName: 'Install java-additions locally'
- pwsh: |
mvn clean package
displayName: 'Build java worker'
78 changes: 13 additions & 65 deletions eng/ci/templates/jobs/run-emulated-tests-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ parameters:
- name: poolName
type: string
default: ''
- name: runSdkTypesTests
type: boolean
default: false

jobs:
- job: "TestLinux"
Expand Down Expand Up @@ -34,16 +31,16 @@ jobs:
JAVA_VERSION: 'microsoft-jdk-11.0.21-linux-x64'
JDK_PATH: 'jdk-11.0.21+9'
JAVA_VERSION_SPEC: '11'
# microsoft-open-jdk-17-linux:
# JDK_DOWNLOAD_LINK: 'https://aka.ms/download-jdk/microsoft-jdk-17.0.9-linux-x64.tar.gz'
# JAVA_VERSION: 'microsoft-jdk-17.0.9-linux-x64'
# JDK_PATH: 'jdk-17.0.9+8'
# JAVA_VERSION_SPEC: '17'
# microsoft-open-jdk-21-linux:
# JDK_DOWNLOAD_LINK: 'https://aka.ms/download-jdk/microsoft-jdk-21.0.1-linux-x64.tar.gz'
# JAVA_VERSION: 'microsoft-jdk-21.0.1-linux-x64'
# JDK_PATH: 'jdk-21.0.1+12'
# JAVA_VERSION_SPEC: '21'
microsoft-open-jdk-17-linux:
JDK_DOWNLOAD_LINK: 'https://aka.ms/download-jdk/microsoft-jdk-17.0.9-linux-x64.tar.gz'
JAVA_VERSION: 'microsoft-jdk-17.0.9-linux-x64'
JDK_PATH: 'jdk-17.0.9+8'
JAVA_VERSION_SPEC: '17'
microsoft-open-jdk-21-linux:
JDK_DOWNLOAD_LINK: 'https://aka.ms/download-jdk/microsoft-jdk-21.0.1-linux-x64.tar.gz'
JAVA_VERSION: 'microsoft-jdk-21.0.1-linux-x64'
JDK_PATH: 'jdk-21.0.1+12'
JAVA_VERSION_SPEC: '21'

steps:
- task: NuGetToolInstaller@1
Expand Down Expand Up @@ -84,9 +81,6 @@ jobs:
docker compose -f emulatedtests/utils/docker-compose.yml pull
docker compose -f emulatedtests/utils/docker-compose.yml up -d
displayName: 'Install Azurite and Start Emulators'
- pwsh: |
.\installAdditionsLocally.ps1
displayName: 'Install java-additions locally'
- pwsh: |
if ("$(isTag)"){
$buildNumber="$(Build.SourceBranchName)"
Expand All @@ -101,7 +95,7 @@ jobs:
displayName: 'Executing build script'
- pwsh: |
cd ./emulatedtests
mvn clean package -DexcludedClassPattern="**/BlobTriggerSdkTypesTests.java" `-Dmaven`.javadoc`.skip=true `-Dmaven`.test`.skip `-Dorg`.slf4j`.simpleLogger`.log`.org`.apache`.maven`.cli`.transfer`.Slf4jMavenTransferListener=warn `-B
mvn clean package `-Dmaven`.javadoc`.skip=true `-Dmaven`.test`.skip `-Dorg`.slf4j`.simpleLogger`.log`.org`.apache`.maven`.cli`.transfer`.Slf4jMavenTransferListener=warn `-B
Copy-Item "confluent_cloud_cacert.pem" "./target/azure-functions/azure-functions-java-emulatedtests"
displayName: 'Package Java for E2E'
- pwsh: |
Expand All @@ -119,54 +113,8 @@ jobs:
command: 'test'
projects: |
emulatedtests/Azure.Functions.Java.Tests.E2E/Azure.Functions.Java.Tests.E2E/Azure.Functions.Java.Tests.E2E.csproj
arguments: '--filter "Category!=SdkTypes"'
env:
JAVA_HOME: $(JavaHome)
AzureWebJobsStorage: "UseDevelopmentStorage=true"
JAVA_ENABLE_SDK_TYPES: "true"
displayName: 'Build & Run tests'
continueOnError: false
# ------------------------------------------
# Conditionally run an additional set of steps for "SDK types" scenario
# ------------------------------------------
- ${{ if eq(parameters.runSdkTypesTests, true) }}:
- pwsh: |
.\installMavenPluginLocally.ps1
displayName: 'Install maven plugin locally'
- pwsh: |
if ("$(isTag)"){
$buildNumber="$(Build.SourceBranchName)"
Write-Host "Found git tag."
}
else {
$buildNumber="$(Build.BuildNumber)-v4"
Write-Host "git tag not found. Setting package suffix to '$buildNumber'"
}
Write-Host "##vso[task.setvariable variable=buildNumber;isOutput=true;]$buildNumber"
.\package-pipeline.ps1 -buildNumber $buildNumber
displayName: 'Executing build script'
- pwsh: |
cd ./emulatedtests
mvn clean package `-Dmaven`.javadoc`.skip=true `-Dmaven`.test`.skip `-Dorg`.slf4j`.simpleLogger`.log`.org`.apache`.maven`.cli`.transfer`.Slf4jMavenTransferListener=warn `-B
Copy-Item "confluent_cloud_cacert.pem" "./target/azure-functions/azure-functions-java-emulatedtests"
displayName: 'Package Java for E2E'
- pwsh: |
.\setup-tests-pipeline.ps1
displayName: 'Setup test environment -- Install the Core Tools'
- bash: |
chmod +x ./Azure.Functions.Cli/func
chmod +x ./Azure.Functions.Cli/gozip
export PATH=$PATH:./Azure.Functions.Cli
func --version
displayName: 'Setup Core Tools - Linux'
- task: DotNetCoreCLI@2
retryCountOnTaskFailure: 3
inputs:
command: 'test'
projects: |
emulatedtests/Azure.Functions.Java.Tests.E2E/Azure.Functions.Java.Tests.E2E/Azure.Functions.Java.Tests.E2E.csproj
env:
JAVA_HOME: $(JavaHome)
AzureWebJobsStorage: "UseDevelopmentStorage=true"
ENABLE_SDK_TYPES: "true"
displayName: 'Build & Run tests'
continueOnError: false
continueOnError: false
80 changes: 19 additions & 61 deletions eng/ci/templates/jobs/run-emulated-tests-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ parameters:
- name: poolName
type: string
default: ''
- name: runSdkTypesTests
type: boolean
default: false

jobs:
- job: "TestWindows"
Expand All @@ -28,18 +25,22 @@ jobs:
JDK_DOWNLOAD_LINK: 'https://github.com/adoptium/temurin8-binaries/releases/download/jdk8u392-b08/OpenJDK8U-jdk_x64_windows_hotspot_8u392b08.zip'
JAVA_VERSION: 'OpenJDK8U-jdk_x64_windows_hotspot_8u392b08'
JDK_PATH: 'jdk8u392-b08'
JAVA_VERSION_SPEC: '8'
microsoft-open-jdk-11-windows:
JDK_DOWNLOAD_LINK: 'https://aka.ms/download-jdk/microsoft-jdk-11.0.21-windows-x64.zip'
JAVA_VERSION: 'microsoft-jdk-11.0.21-windows-x64'
JDK_PATH: 'jdk-11.0.21+9'
JAVA_VERSION_SPEC: '11'
microsoft-open-jdk-17-windows:
JDK_DOWNLOAD_LINK: 'https://aka.ms/download-jdk/microsoft-jdk-17.0.9-windows-x64.zip'
JAVA_VERSION: 'microsoft-jdk-17.0.9-windows-x64'
JDK_PATH: 'jdk-17.0.9+8'
JAVA_VERSION_SPEC: '17'
microsoft-open-jdk-21-windows:
JDK_DOWNLOAD_LINK: 'https://aka.ms/download-jdk/microsoft-jdk-21.0.1-windows-x64.zip'
JAVA_VERSION: 'microsoft-jdk-21.0.1-windows-x64'
JDK_PATH: 'jdk-21.0.1+12'
JAVA_VERSION_SPEC: '21'

steps:
- task: NuGetToolInstaller@1
Expand All @@ -56,22 +57,25 @@ jobs:
displayName: 'Install .NET 6'
inputs:
version: 6.0.x
- pwsh: |
- pwsh: | # Download JDK for later installation
Invoke-WebRequest $(JDK_DOWNLOAD_LINK) -OutFile "$(JAVA_VERSION).zip"
Expand-Archive -Force "$(JAVA_VERSION).zip" .
cd $(JDK_PATH)
$current = get-location | select -ExpandProperty Path
cd ..
Write-Host "##vso[task.setvariable variable=JavaHome;]$current"
displayName: 'Download and setup Java for Windows'
Write-Host "##vso[task.setvariable variable=downloadPath;]$current"
displayName: 'Download jdk for Windows'
- task: JavaToolInstaller@0 # Install JDK downloaded from previous task
inputs:
versionSpec: $(JAVA_VERSION_SPEC)
jdkArchitectureOption: 'x64'
jdkSourceOption: LocalDirectory
jdkFile: "$(downloadPath)/$(JAVA_VERSION).zip"
jdkDestinationDirectory: "$(downloadPath)/externals"
cleanDestinationDirectory: true
displayName: 'Setup Java for Windows'
- bash: |
npm install -g azurite
mkdir azurite
azurite --silent --location azurite --debug azurite\debug.log &
displayName: 'Install and Run Azurite'
- pwsh: |
.\installAdditionsLocally.ps1
displayName: 'Install java-additions locally'
- pwsh: |
if ("$(isTag)"){
$buildNumber="$(Build.SourceBranchName)"
Expand All @@ -86,7 +90,7 @@ jobs:
displayName: 'Executing build script'
- pwsh: |
cd ./emulatedtests
mvn clean package -DexcludedClassPattern="**/BlobTriggerSdkTypesTests.java" `-Dmaven`.javadoc`.skip=true `-Dmaven`.test`.skip `-Dorg`.slf4j`.simpleLogger`.log`.org`.apache`.maven`.cli`.transfer`.Slf4jMavenTransferListener=warn `-B
mvn clean package `-Dmaven`.javadoc`.skip=true `-Dmaven`.test`.skip `-Dorg`.slf4j`.simpleLogger`.log`.org`.apache`.maven`.cli`.transfer`.Slf4jMavenTransferListener=warn `-B
Copy-Item "confluent_cloud_cacert.pem" "./target/azure-functions/azure-functions-java-emulatedtests"
displayName: 'Package Java for E2E'
- pwsh: |
Expand All @@ -103,54 +107,8 @@ jobs:
command: 'test'
projects: |
emulatedtests/Azure.Functions.Java.Tests.E2E/Azure.Functions.Java.Tests.E2E/Azure.Functions.Java.Tests.E2E.csproj
arguments: '--filter "Category!=SdkTypes"'
env:
JAVA_HOME: $(JavaHome)
AzureWebJobsStorage: "UseDevelopmentStorage=true"
ENABLE_SDK_TYPES: "true"
JAVA_ENABLE_SDK_TYPES: "true"
displayName: 'Build & Run tests'
continueOnError: false
# ------------------------------------------
# Conditionally run an additional set of steps for "SDK types" scenario
# ------------------------------------------
- ${{ if eq(parameters.runSdkTypesTests, true) }}:
- pwsh: |
.\installMavenPluginLocally.ps1
displayName: 'Install maven plugin locally'
- pwsh: |
if ("$(isTag)"){
$buildNumber="$(Build.SourceBranchName)"
Write-Host "Found git tag."
}
else {
$buildNumber="$(Build.BuildNumber)-v4"
Write-Host "git tag not found. Setting package suffix to '$buildNumber'"
}
Write-Host "##vso[task.setvariable variable=buildNumber;isOutput=true;]$buildNumber"
.\package-pipeline.ps1 -buildNumber $buildNumber
displayName: 'Executing build script (SDK types)'
- pwsh: |
cd ./emulatedtests
mvn clean package `-Dmaven`.javadoc`.skip=true `-Dmaven`.test`.skip `-Dorg`.slf4j`.simpleLogger`.log`.org`.apache`.maven`.cli`.transfer`.Slf4jMavenTransferListener=warn `-B
Copy-Item "confluent_cloud_cacert.pem" "./target/azure-functions/azure-functions-java-emulatedtests"
displayName: 'Package Java for E2E (SDK types)'
- pwsh: |
.\setup-tests-pipeline.ps1
displayName: 'Setup test environment -- Install the Core Tools'
- pwsh: |
$currDir = Get-Location
$Env:Path = $Env:Path+";$currDir/Azure.Functions.Cli"
func --version
displayName: 'Setup Core Tools - Windows'
- task: DotNetCoreCLI@2
retryCountOnTaskFailure: 3
inputs:
command: 'test'
projects: |
emulatedtests/Azure.Functions.Java.Tests.E2E/Azure.Functions.Java.Tests.E2E/Azure.Functions.Java.Tests.E2E.csproj
env:
JAVA_HOME: $(JavaHome)
AzureWebJobsStorage: "UseDevelopmentStorage=true"
ENABLE_SDK_TYPES: "true"
displayName: 'Build & Run tests (SDK types)'
continueOnError: false
continueOnError: false
Loading