Skip to content

Commit 477754a

Browse files
committed
put sdk types feature behind an app setting
1 parent e3dc1c9 commit 477754a

File tree

8 files changed

+263
-105
lines changed

8 files changed

+263
-105
lines changed

emulatedtests/Azure.Functions.Java.Tests.E2E/Azure.Functions.Java.Tests.E2E/StorageEndToEndTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ public async Task BlobTriggerToBlob_Succeeds()
112112
}
113113

114114
[Fact]
115+
[Trait("Category", "SdkTypes")]
115116
public async Task BlobTriggerToBlob_BlobClient_Succeeds()
116117
{
117118
string fileName = Guid.NewGuid().ToString();
@@ -131,6 +132,7 @@ public async Task BlobTriggerToBlob_BlobClient_Succeeds()
131132
}
132133

133134
[Fact]
135+
[Trait("Category", "SdkTypes")]
134136
public async Task BlobTriggerToBlob_BlobContainerClient_Succeeds()
135137
{
136138
string fileName = Guid.NewGuid().ToString();

emulatedtests/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
<functionAppRegion>westus</functionAppRegion>
3030
<functionResourceGroup>java-functions-group</functionResourceGroup>
3131
<start-class>com.microsoft.azure.functions.endtoend.springcloud.Config</start-class>
32+
<!-- Empty by default: no exclusion -->
33+
<excludedClassPattern>**/___noop___.java</excludedClassPattern>
3234
</properties>
3335

3436
<repositories>
@@ -141,6 +143,9 @@
141143
<source>${java.version}</source>
142144
<target>${java.version}</target>
143145
<encoding>${project.build.sourceEncoding}</encoding>
146+
<excludes>
147+
<exclude>${excludedClassPattern}</exclude>
148+
</excludes>
144149
</configuration>
145150
</plugin>
146151
<plugin>
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
package com.microsoft.azure.functions.endtoend;
2+
3+
import com.azure.storage.blob.BlobClient;
4+
import com.azure.storage.blob.BlobContainerClient;
5+
import com.microsoft.azure.functions.ExecutionContext;
6+
import com.microsoft.azure.functions.OutputBinding;
7+
import com.microsoft.azure.functions.annotation.*;
8+
9+
import java.io.ByteArrayOutputStream;
10+
11+
/**
12+
* Azure Functions with Azure Storage Blob.
13+
*/
14+
public class BlobTriggerSdkTypesTests {
15+
/**
16+
* 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.
17+
*/
18+
@FunctionName("BlobTriggerUsingBlobClientToBlobTest")
19+
@StorageAccount("AzureWebJobsStorage")
20+
public void BlobTriggerToBlobTest_BlobClient(
21+
@BlobTrigger(name = "triggerBlob", path = "test-triggerinput-blobclient/{name}", dataType = "binary") BlobClient triggerBlobClient,
22+
@BindingName("name") String fileName,
23+
@BlobOutput(name = "outputBlob", path = "test-output-java-new/testfile.txt", dataType = "binary") OutputBinding<byte[]> outputBlob,
24+
final ExecutionContext context
25+
) {
26+
context.getLogger().info("BlobTriggerUsingBlobClient triggered for blob: " + fileName);
27+
28+
// Download the blob content
29+
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
30+
triggerBlobClient.downloadStream(outputStream);
31+
32+
// Set the downloaded content as output
33+
outputBlob.setValue(outputStream.toByteArray());
34+
context.getLogger().info("Uploaded blob " + fileName + " to container test-output-java-new/testfile.txt");
35+
}
36+
37+
/**
38+
* 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.
39+
*/
40+
@FunctionName("BlobTriggerUsingBlobContainerClientToBlobTest")
41+
@StorageAccount("AzureWebJobsStorage")
42+
public void BlobTriggerToBlobTest_BlobContainerClient(
43+
@BlobTrigger(name = "triggerBlob", path = "test-triggerinput-blobcontclient/{name}", dataType = "binary") BlobContainerClient triggerBlobContainerClient,
44+
@BindingName("name") String fileName,
45+
@BlobOutput(name = "outputBlob", path = "test-output-java-new/testfile.txt", dataType = "binary") OutputBinding<byte[]> outputBlob,
46+
final ExecutionContext context
47+
) {
48+
context.getLogger().info("BlobTriggerUsingBlobContainerClient triggered for blob: " + fileName);
49+
50+
// Download the blob content
51+
BlobClient triggerBlobClient = triggerBlobContainerClient.getBlobClient(fileName);
52+
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
53+
triggerBlobClient.downloadStream(outputStream);
54+
55+
// Set the downloaded content as output
56+
outputBlob.setValue(outputStream.toByteArray());
57+
context.getLogger().info("Uploaded blob " + fileName + " to container test-output-java-new/testfile.txt");
58+
}
59+
}

emulatedtests/src/main/java/com/microsoft/azure/functions/endtoend/BlobTriggerTests.java

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,8 @@
22

33
import com.microsoft.azure.functions.annotation.*;
44

5-
import java.io.ByteArrayOutputStream;
6-
75
import com.microsoft.azure.functions.*;
86

9-
import com.azure.storage.blob.BlobClient;
10-
import com.azure.storage.blob.BlobContainerClient;
11-
127
/**
138
* Azure Functions with Azure Storage Blob.
149
*/
@@ -59,51 +54,6 @@ public void BlobTriggerStringTest(
5954
outputBlob.setValue(triggerBlobText);
6055
}
6156

62-
/**
63-
* 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.
64-
*/
65-
@FunctionName("BlobTriggerUsingBlobClientToBlobTest")
66-
@StorageAccount("AzureWebJobsStorage")
67-
public void BlobTriggerToBlobTest_BlobClient(
68-
@BlobTrigger(name = "triggerBlob", path = "test-triggerinput-blobclient/{name}", dataType = "binary") BlobClient triggerBlobClient,
69-
@BindingName("name") String fileName,
70-
@BlobOutput(name = "outputBlob", path = "test-output-java-new/testfile.txt", dataType = "binary") OutputBinding<byte[]> outputBlob,
71-
final ExecutionContext context
72-
) {
73-
context.getLogger().info("BlobTriggerUsingBlobClient triggered for blob: " + fileName);
74-
75-
// Download the blob content
76-
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
77-
triggerBlobClient.downloadStream(outputStream);
78-
79-
// Set the downloaded content as output
80-
outputBlob.setValue(outputStream.toByteArray());
81-
context.getLogger().info("Uploaded blob " + fileName + " to container test-output-java-new/testfile.txt");
82-
}
83-
84-
/**
85-
* 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.
86-
*/
87-
@FunctionName("BlobTriggerUsingBlobContainerClientToBlobTest")
88-
@StorageAccount("AzureWebJobsStorage")
89-
public void BlobTriggerToBlobTest_BlobContainerClient(
90-
@BlobTrigger(name = "triggerBlob", path = "test-triggerinput-blobcontclient/{name}", dataType = "binary") BlobContainerClient triggerBlobContainerClient,
91-
@BindingName("name") String fileName,
92-
@BlobOutput(name = "outputBlob", path = "test-output-java-new/testfile.txt", dataType = "binary") OutputBinding<byte[]> outputBlob,
93-
final ExecutionContext context
94-
) {
95-
context.getLogger().info("BlobTriggerUsingBlobContainerClient triggered for blob: " + fileName);
96-
97-
// Download the blob content
98-
BlobClient triggerBlobClient = triggerBlobContainerClient.getBlobClient(fileName);
99-
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
100-
triggerBlobClient.downloadStream(outputStream);
101-
102-
// Set the downloaded content as output
103-
outputBlob.setValue(outputStream.toByteArray());
104-
context.getLogger().info("Uploaded blob " + fileName + " to container test-output-java-new/testfile.txt");
105-
}
106-
10757
public static class TestBlobData {
10858
public String blobText;
10959
}

eng/ci/public-build.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ resources:
2424
name: 1ESPipelineTemplates/1ESPipelineTemplates
2525
ref: refs/tags/release
2626

27+
parameters:
28+
- name: runSdkTypesTests
29+
type: boolean
30+
default: false
31+
2732
extends:
2833
template: v1/1ES.Unofficial.PipelineTemplate.yml@1es
2934
parameters:
@@ -55,10 +60,12 @@ extends:
5560
- template: /eng/ci/templates/jobs/run-emulated-tests-windows.yml@self
5661
parameters:
5762
poolName: 1es-pool-azfunc-public
63+
runSdkTypesTests: ${{ parameters.runSdkTypesTests }}
5864

5965
- stage: TestLinux
6066
dependsOn: Build
6167
jobs:
6268
- template: /eng/ci/templates/jobs/run-emulated-tests-linux.yml@self
6369
parameters:
6470
poolName: 1es-pool-azfunc-public
71+
runSdkTypesTests: ${{ parameters.runSdkTypesTests }}

eng/ci/templates/jobs/run-emulated-tests-linux.yml

Lines changed: 74 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
parameters:
2-
poolName: ''
2+
- name: poolName
3+
type: string
4+
default: ''
5+
- name: runSdkTypesTests
6+
type: boolean
7+
default: false
38

49
jobs:
510
- job: "TestLinux"
@@ -57,21 +62,6 @@ jobs:
5762
- pwsh: |
5863
java -version
5964
displayName: 'Check default java version'
60-
- pwsh: |
61-
.\installLibsLocally.ps1
62-
displayName: 'Install java-additions locally'
63-
- pwsh: |
64-
if ("$(isTag)"){
65-
$buildNumber="$(Build.SourceBranchName)"
66-
Write-Host "Found git tag."
67-
}
68-
else {
69-
$buildNumber="$(Build.BuildNumber)-v4"
70-
Write-Host "git tag not found. Setting package suffix to '$buildNumber'"
71-
}
72-
Write-Host "##vso[task.setvariable variable=buildNumber;isOutput=true;]$buildNumber"
73-
.\package-pipeline.ps1 -buildNumber $buildNumber
74-
displayName: 'Executing build script'
7565
- task: UseDotNet@2
7666
displayName: 'Install .NET 6'
7767
inputs:
@@ -90,6 +80,30 @@ jobs:
9080
jdkDestinationDirectory: "$(downloadPath)/externals"
9181
cleanDestinationDirectory: true
9282
displayName: 'Setup Java for Linux'
83+
- bash: |
84+
docker compose -f emulatedtests/utils/docker-compose.yml pull
85+
docker compose -f emulatedtests/utils/docker-compose.yml up -d
86+
displayName: 'Install Azurite and Start Emulators'
87+
- pwsh: |
88+
.\installLibsLocally.ps1
89+
displayName: 'Install java-additions locally'
90+
- pwsh: |
91+
if ("$(isTag)"){
92+
$buildNumber="$(Build.SourceBranchName)"
93+
Write-Host "Found git tag."
94+
}
95+
else {
96+
$buildNumber="$(Build.BuildNumber)-v4"
97+
Write-Host "git tag not found. Setting package suffix to '$buildNumber'"
98+
}
99+
Write-Host "##vso[task.setvariable variable=buildNumber;isOutput=true;]$buildNumber"
100+
.\package-pipeline.ps1 -buildNumber $buildNumber
101+
displayName: 'Executing build script'
102+
- pwsh: |
103+
cd ./emulatedtests
104+
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
105+
Copy-Item "confluent_cloud_cacert.pem" "./target/azure-functions/azure-functions-java-emulatedtests"
106+
displayName: 'Package Java for E2E'
93107
- pwsh: |
94108
.\setup-tests-pipeline.ps1
95109
displayName: 'Setup test environment -- Install the Core Tools'
@@ -99,23 +113,57 @@ jobs:
99113
export PATH=$PATH:./Azure.Functions.Cli
100114
func --version
101115
displayName: 'Setup Core Tools - Linux'
102-
- pwsh: |
103-
cd ./emulatedtests
104-
mvn clean package `-Dmaven`.javadoc`.skip=true `-Dmaven`.test`.skip `-Dorg`.slf4j`.simpleLogger`.log`.org`.apache`.maven`.cli`.transfer`.Slf4jMavenTransferListener=warn `-B
105-
Copy-Item "confluent_cloud_cacert.pem" "./target/azure-functions/azure-functions-java-emulatedtests"
106-
displayName: 'Package Java for E2E'
107-
- bash: |
108-
docker compose -f emulatedtests/utils/docker-compose.yml pull
109-
docker compose -f emulatedtests/utils/docker-compose.yml up -d
110-
displayName: 'Install Azurite and Start Emulators'
111116
- task: DotNetCoreCLI@2
112117
retryCountOnTaskFailure: 3
113118
inputs:
114119
command: 'test'
115120
projects: |
116121
emulatedtests/Azure.Functions.Java.Tests.E2E/Azure.Functions.Java.Tests.E2E/Azure.Functions.Java.Tests.E2E.csproj
122+
arguments: '--filter "Category!=SdkTypes"'
117123
env:
118124
JAVA_HOME: $(JavaHome)
119125
AzureWebJobsStorage: "UseDevelopmentStorage=true"
120126
displayName: 'Build & Run tests'
121-
continueOnError: false
127+
continueOnError: false
128+
# ------------------------------------------
129+
# Conditionally run an additional set of steps for "SDK types" scenario
130+
# ------------------------------------------
131+
- ${{ if eq(parameters.runSdkTypesTests, true) }}:
132+
- pwsh: |
133+
if ("$(isTag)"){
134+
$buildNumber="$(Build.SourceBranchName)"
135+
Write-Host "Found git tag."
136+
}
137+
else {
138+
$buildNumber="$(Build.BuildNumber)-v4"
139+
Write-Host "git tag not found. Setting package suffix to '$buildNumber'"
140+
}
141+
Write-Host "##vso[task.setvariable variable=buildNumber;isOutput=true;]$buildNumber"
142+
.\package-pipeline.ps1 -buildNumber $buildNumber
143+
displayName: 'Executing build script'
144+
- pwsh: |
145+
cd ./emulatedtests
146+
mvn clean package `-Dmaven`.javadoc`.skip=true `-Dmaven`.test`.skip `-Dorg`.slf4j`.simpleLogger`.log`.org`.apache`.maven`.cli`.transfer`.Slf4jMavenTransferListener=warn `-B
147+
Copy-Item "confluent_cloud_cacert.pem" "./target/azure-functions/azure-functions-java-emulatedtests"
148+
displayName: 'Package Java for E2E'
149+
- pwsh: |
150+
.\setup-tests-pipeline.ps1
151+
displayName: 'Setup test environment -- Install the Core Tools'
152+
- bash: |
153+
chmod +x ./Azure.Functions.Cli/func
154+
chmod +x ./Azure.Functions.Cli/gozip
155+
export PATH=$PATH:./Azure.Functions.Cli
156+
func --version
157+
displayName: 'Setup Core Tools - Linux'
158+
- task: DotNetCoreCLI@2
159+
retryCountOnTaskFailure: 3
160+
inputs:
161+
command: 'test'
162+
projects: |
163+
emulatedtests/Azure.Functions.Java.Tests.E2E/Azure.Functions.Java.Tests.E2E/Azure.Functions.Java.Tests.E2E.csproj
164+
env:
165+
JAVA_HOME: $(JavaHome)
166+
AzureWebJobsStorage: "UseDevelopmentStorage=true"
167+
ENABLE_SDK_TYPES: "true"
168+
displayName: 'Build & Run tests'
169+
continueOnError: false

0 commit comments

Comments
 (0)