From ec103fe0d98645ac37b084a2022f940aa5757230 Mon Sep 17 00:00:00 2001 From: Heena Gupta Date: Sat, 27 Apr 2024 00:21:35 +0530 Subject: [PATCH 01/10] Tests for mysql extensions --- azure-pipelines-e2e-integration-tests.yml | 173 +++++++++++ azure-pipelines.yml | 280 ++++++++++++++++++ .../Constants.cs | 3 + .../MySqlEndToEndTests.cs | 44 +++ endtoendtests/local.settings.json | 1 + endtoendtests/pom.xml | 6 + .../functions/endtoend/MySqlTriggerTests.java | 61 ++++ 7 files changed, 568 insertions(+) create mode 100644 azure-pipelines-e2e-integration-tests.yml create mode 100644 azure-pipelines.yml create mode 100644 endtoendtests/Azure.Functions.Java.Tests.E2E/Azure.Functions.Java.Tests.E2E/MySqlEndToEndTests.cs create mode 100644 endtoendtests/src/main/java/com/microsoft/azure/functions/endtoend/MySqlTriggerTests.java diff --git a/azure-pipelines-e2e-integration-tests.yml b/azure-pipelines-e2e-integration-tests.yml new file mode 100644 index 00000000..0ab404bf --- /dev/null +++ b/azure-pipelines-e2e-integration-tests.yml @@ -0,0 +1,173 @@ +# Starter pipeline +# Start with a minimal pipeline that you can customize to build and deploy your code. +# Add steps that build, run tests, deploy, and more: + +pr: none +trigger: none + +jobs: + - job: "End_to_end_integration_tests" + variables: + ApplicationInsightAgentVersion: 3.5.1 + displayName: 'End to end integration tests' + strategy: + maxParallel: 1 + matrix: + open-jdk-8-linux: + IMAGE_TYPE: 'ubuntu-latest' + JDK_DOWNLOAD_LINK: 'https://github.com/adoptium/temurin8-binaries/releases/download/jdk8u392-b08/OpenJDK8U-jdk_x64_linux_hotspot_8u392b08.tar.gz' + JAVA_VERSION: 'OpenJDK8U-jdk_x64_linux_hotspot_8u392b08' + JDK_PATH: 'jdk8u392-b08' + JAVA_VERSION_SPEC: '8' + open-jdk-8-windows: + IMAGE_TYPE: 'windows-latest' + 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' + microsoft-open-jdk-11-linux: + IMAGE_TYPE: 'ubuntu-latest' + JDK_DOWNLOAD_LINK: 'https://aka.ms/download-jdk/microsoft-jdk-11.0.21-linux-x64.tar.gz' + JAVA_VERSION: 'microsoft-jdk-11.0.21-linux-x64' + JDK_PATH: 'jdk-11.0.21+9' + JAVA_VERSION_SPEC: '11' + microsoft-open-jdk-11-windows: + IMAGE_TYPE: 'windows-latest' + 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' + microsoft-open-jdk-17-linux: + IMAGE_TYPE: 'ubuntu-latest' + 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-17-windows: + IMAGE_TYPE: 'windows-latest' + 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' + microsoft-open-jdk-21-linux: + IMAGE_TYPE: 'ubuntu-latest' + 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-21-windows: + IMAGE_TYPE: 'windows-latest' + 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' + + pool: + vmImage: $(IMAGE_TYPE) + + steps: + - task: NuGetToolInstaller@1 + inputs: + checkLatest: true + displayName: 'Install NuGet Tool' + + - pwsh: | + Get-Command mvn + displayName: 'Check Maven is installed' + + - task: JavaToolInstaller@0 # This step is necessary as Linux image has Java 11 as default + inputs: + versionSpec: '8' + jdkArchitectureOption: 'x64' + jdkSourceOption: 'PreInstalled' + condition: eq( variables['Agent.OS'], 'Linux' ) + displayName: 'Setup Java for Linux' + + - pwsh: | + java -version + displayName: 'Check default java version' + + - task: UseDotNet@2 + displayName: 'Install .NET 6' + inputs: + version: 6.0.x + + - pwsh: | + .\setup-tests-pipeline.ps1 -UseCoreToolsBuildFromIntegrationTests + displayName: 'Setup test environment -- Install the Core Tools' + - pwsh: | + $currDir = Get-Location + $Env:Path = $Env:Path+";$currDir\Azure.Functions.Cli" + ls $currDir\Azure.Functions.Cli + func --version + condition: eq( variables['Agent.OS'], 'Windows_NT' ) + displayName: 'Setup Core Tools - Windows' + - bash: | + chmod +x ./Azure.Functions.Cli/func + chmod +x ./Azure.Functions.Cli/gozip + ls ./Azure.Functions.Cli + export PATH=$PATH:./Azure.Functions.Cli + func --version + condition: eq( variables['Agent.OS'], 'Linux' ) + displayName: 'Setup Core Tools - Linux' + + - pwsh: | + java -version + cd ./endtoendtests + 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-endtoendtests" + displayName: 'Package Java for E2E' + + - pwsh: | # Download JDK for later installation + Invoke-WebRequest $(JDK_DOWNLOAD_LINK) -OutFile "$(JAVA_VERSION).tar.gz" + $current = get-location | select -ExpandProperty Path + Write-Host "##vso[task.setvariable variable=downloadPath;]$current" + displayName: 'Download jdk for Linux' + condition: eq( variables['Agent.OS'], 'Linux' ) + - task: JavaToolInstaller@0 # Install JDK downloaded from previous task + inputs: + versionSpec: $(JAVA_VERSION_SPEC) + jdkArchitectureOption: 'x64' + jdkSourceOption: LocalDirectory + jdkFile: "$(downloadPath)/$(JAVA_VERSION).tar.gz" + jdkDestinationDirectory: "$(downloadPath)/externals" + cleanDestinationDirectory: true + condition: eq( variables['Agent.OS'], 'Linux' ) + displayName: 'Setup Java for Linux' + - pwsh: | + 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' + condition: eq( variables['Agent.OS'], 'Windows_NT' ) + + - task: DotNetCoreCLI@2 + inputs: + command: 'test' + projects: | + endtoendtests/Azure.Functions.Java.Tests.E2E/Azure.Functions.Java.Tests.E2E/Azure.Functions.Java.Tests.E2E.csproj + env: + JAVA_HOME: $(JavaHome) + AzureWebJobsStorage: $(AzureWebJobsStorage) + AzureWebJobsCosmosDBConnectionString: $(AzureWebJobsCosmosDBConnectionString) + AzureWebJobsMySqlConnectionString: $(AzureWebJobsMySqlConnectionString) + AzureWebJobsSqlConnectionString: $(AzureWebJobsSqlConnectionString) + AzureWebJobsServiceBus: $(AzureWebJobsServiceBus) + AzureWebJobsEventHubSender_2: $(AzureWebJobsEventHubSender_2) + AzureWebJobsEventHubReceiver: $(AzureWebJobsEventHubReceiver) + AzureWebJobsEventHubSender: $(AzureWebJobsEventHubSender) + AzureWebJobsEventHubPath: $(AzureWebJobsEventHubPath) + SBTopicName: $(SBTopicName) + SBTopicSubName: $(SBTopicSubName) + CosmosDBDatabaseName: $(CosmosDBDatabaseName) + SBQueueName: $(SBQueueName) + BrokerList": $(BrokerList) + ConfluentCloudUsername: $(ConfluentCloudUsername) + ConfluentCloudPassword: $(ConfluentCloudPassword) + AzureWebJobsEventGridOutputBindingTopicUriString: $(AzureWebJobsEventGridOutputBindingTopicUriString) + AzureWebJobsEventGridOutputBindingTopicKeyString: $(AzureWebJobsEventGridOutputBindingTopicKeyString) + ApplicationInsightAPIKey: $(ApplicationInsightAPIKey) + ApplicationInsightAPPID: $(ApplicationInsightAPPID) + ApplicationInsightAgentVersion: $(ApplicationInsightAgentVersion) + displayName: 'Build & Run tests' + continueOnError: false + diff --git a/azure-pipelines.yml b/azure-pipelines.yml new file mode 100644 index 00000000..fd350404 --- /dev/null +++ b/azure-pipelines.yml @@ -0,0 +1,280 @@ +# Starter pipeline +# Start with a minimal pipeline that you can customize to build and deploy your code. +# Add steps that build, run tests, deploy, and more: + + +trigger: + tags: + include: + - '*' + branches: + include: + - dev + - v3.x + - release/3.x + - release/main + +pr: + branches: + include: + - dev + - v3.x + - release/3.x + - release/main + +jobs: + - job: "Build" + displayName: 'Build java worker' + + pool: + name: '1ES-Hosted-AzFunc' + demands: + - ImageOverride -equals MMS2019TLS + + variables: + ${{ if contains(variables['Build.SourceBranch'], '/tags/' ) }}: + isTagTemp: true + isTag: $[variables.isTagTemp] + + steps: + - task: NuGetToolInstaller@1 + inputs: + checkLatest: true + displayName: 'Install NuGet Tool' + - pwsh: | + Get-Command mvn + displayName: 'Check Maven is installed' + - pwsh: | + java -version + displayName: 'Check default java version' + - 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 + name: output + displayName: 'Executing build script' + - pwsh: | + mvn dependency-check:check + condition: and(eq(variables['Build.SourceBranch'], 'refs/heads/dev'), eq(variables['SkipMavenDependencyCheck'], 'false')) + displayName: 'Maven dependency check' + - task: CopyFiles@2 + inputs: + SourceFolder: '$(Build.Repository.LocalPath)/pkg' + Contents: '*.nupkg' + TargetFolder: '$(Build.ArtifactStagingDirectory)' + CleanTargetFolder: true + displayName: 'Copying files for artifacts' + - task: PublishBuildArtifacts@1 + inputs: + PathtoPublish: '$(Build.ArtifactStagingDirectory)' + ArtifactName: 'buildDrop' + displayName: 'Upload build artifacts' + + - job: "Test" + displayName: 'Test java worker' + dependsOn: Build + variables: + buildNumber: $[ dependencies.Build.outputs['output.buildNumber'] ] + ApplicationInsightAgentVersion: 3.5.1 + strategy: + maxParallel: 1 + matrix: + open-jdk-8-linux: + IMAGE_TYPE: 'ubuntu-latest' + JDK_DOWNLOAD_LINK: 'https://github.com/adoptium/temurin8-binaries/releases/download/jdk8u392-b08/OpenJDK8U-jdk_x64_linux_hotspot_8u392b08.tar.gz' + JAVA_VERSION: 'OpenJDK8U-jdk_x64_linux_hotspot_8u392b08' + JDK_PATH: 'jdk8u392-b08' + JAVA_VERSION_SPEC: '8' + open-jdk-8-windows: + IMAGE_TYPE: 'windows-latest' + 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' + microsoft-open-jdk-11-linux: + IMAGE_TYPE: 'ubuntu-latest' + JDK_DOWNLOAD_LINK: 'https://aka.ms/download-jdk/microsoft-jdk-11.0.21-linux-x64.tar.gz' + JAVA_VERSION: 'microsoft-jdk-11.0.21-linux-x64' + JDK_PATH: 'jdk-11.0.21+9' + JAVA_VERSION_SPEC: '11' + microsoft-open-jdk-11-windows: + IMAGE_TYPE: 'windows-latest' + 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' + microsoft-open-jdk-17-linux: + IMAGE_TYPE: 'ubuntu-latest' + 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-17-windows: + IMAGE_TYPE: 'windows-latest' + 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' + microsoft-open-jdk-21-linux: + IMAGE_TYPE: 'ubuntu-latest' + 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-21-windows: + IMAGE_TYPE: 'windows-latest' + 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' + + pool: + vmImage: $(IMAGE_TYPE) + + steps: + - task: NuGetToolInstaller@1 + inputs: + checkLatest: true + displayName: 'Install NuGet Tool' + - pwsh: | + Get-Command mvn + displayName: 'Check Maven is installed' + - task: JavaToolInstaller@0 # This step is necessary as Linux image has Java 11 as default + inputs: + versionSpec: '8' + jdkArchitectureOption: 'x64' + jdkSourceOption: 'PreInstalled' + condition: eq( variables['Agent.OS'], 'Linux' ) + displayName: 'Setup Java for Linux' + - pwsh: | + java -version + displayName: 'Check default java version' + - pwsh: | + .\package-pipeline.ps1 -buildNumber $(buildNumber) + displayName: 'Executing build script' + - task: UseDotNet@2 + displayName: 'Install .NET 6' + inputs: + version: 6.0.x + - pwsh: | # Download JDK for later installation + Invoke-WebRequest $(JDK_DOWNLOAD_LINK) -OutFile "$(JAVA_VERSION).tar.gz" + $current = get-location | select -ExpandProperty Path + Write-Host "##vso[task.setvariable variable=downloadPath;]$current" + displayName: 'Download jdk for Linux' + condition: eq( variables['Agent.OS'], 'Linux' ) + - task: JavaToolInstaller@0 # Install JDK downloaded from previous task + inputs: + versionSpec: $(JAVA_VERSION_SPEC) + jdkArchitectureOption: 'x64' + jdkSourceOption: LocalDirectory + jdkFile: "$(downloadPath)/$(JAVA_VERSION).tar.gz" + jdkDestinationDirectory: "$(downloadPath)/externals" + cleanDestinationDirectory: true + condition: eq( variables['Agent.OS'], 'Linux' ) + displayName: 'Setup Java for Linux' + - pwsh: | + 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' + condition: eq( variables['Agent.OS'], 'Windows_NT' ) + + - 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 + condition: eq( variables['Agent.OS'], 'Windows_NT' ) + displayName: 'Setup Core Tools - Windows' + - bash: | + chmod +x ./Azure.Functions.Cli/func + chmod +x ./Azure.Functions.Cli/gozip + export PATH=$PATH:./Azure.Functions.Cli + func --version + condition: eq( variables['Agent.OS'], 'Linux' ) + displayName: 'Setup Core Tools - Linux' + - pwsh: | + cd ./endtoendtests + 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-endtoendtests" + displayName: 'Package Java for E2E' + - task: DotNetCoreCLI@2 + inputs: + command: 'test' + projects: | + endtoendtests/Azure.Functions.Java.Tests.E2E/Azure.Functions.Java.Tests.E2E/Azure.Functions.Java.Tests.E2E.csproj + env: + JAVA_HOME: $(JavaHome) + AzureWebJobsStorage: $(AzureWebJobsStorage) + AzureWebJobsCosmosDBConnectionString: $(AzureWebJobsCosmosDBConnectionString) + AzureWebJobsMySqlConnectionString: $(AzureWebJobsMySqlConnectionString) + AzureWebJobsSqlConnectionString: $(AzureWebJobsSqlConnectionString) + AzureWebJobsServiceBus: $(AzureWebJobsServiceBus) + AzureWebJobsEventHubReceiver: $(AzureWebJobsEventHubReceiver) + AzureWebJobsEventHubSender_2: $(AzureWebJobsEventHubSender_2) + AzureWebJobsEventHubSender: $(AzureWebJobsEventHubSender) + AzureWebJobsEventHubPath: $(AzureWebJobsEventHubPath) + SBTopicName: $(SBTopicName) + SBTopicSubName: $(SBTopicSubName) + CosmosDBDatabaseName: $(CosmosDBDatabaseName) + SBQueueName: $(SBQueueName) + BrokerList": $(BrokerList) + ConfluentCloudUsername: $(ConfluentCloudUsername) + ConfluentCloudPassword: $(ConfluentCloudPassword) + AzureWebJobsEventGridOutputBindingTopicUriString: $(AzureWebJobsEventGridOutputBindingTopicUriString) + AzureWebJobsEventGridOutputBindingTopicKeyString: $(AzureWebJobsEventGridOutputBindingTopicKeyString) + ApplicationInsightAPIKey: $(ApplicationInsightAPIKey) + ApplicationInsightAPPID: $(ApplicationInsightAPPID) + ApplicationInsightAgentVersion: $(ApplicationInsightAgentVersion) + displayName: 'Build & Run tests' + continueOnError: false + + - job: "Publish" + displayName: 'Publish build artifacts' + dependsOn: Test + + pool: + name: '1ES-Hosted-AzFunc' + demands: + - ImageOverride -equals MMS2019TLS + + steps: + - task: DownloadBuildArtifacts@0 + inputs: + buildType: 'current' + downloadType: 'single' + artifactName: 'buildDrop' + downloadPath: '$(Build.ArtifactStagingDirectory)' + displayName: 'Download build artifacts' + - pwsh: | + Move-Item -Path "$(Build.ArtifactStagingDirectory)/buildDrop/*.nupkg" -Destination $(Build.ArtifactStagingDirectory) + Remove-Item "$(Build.ArtifactStagingDirectory)/buildDrop" -Recurse + - task: ManifestGeneratorTask@0 + inputs: + BuildDropPath: '$(Build.ArtifactStagingDirectory)' + Verbosity: 'Information' + displayName: 'SBOM Generation Task' + - task: PublishBuildArtifacts@1 + inputs: + PathtoPublish: '$(Build.ArtifactStagingDirectory)' + ArtifactName: 'drop' + publishLocation: 'Container' + displayName: 'Publishing build artifacts' + - task: NuGetCommand@2 + condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/dev'), eq(variables['UPLOADPACKAGETOPRERELEASEFEED'], true)) + inputs: + command: 'push' + packagesToPush: '$(Build.ArtifactStagingDirectory)/**/*.nupkg;!$(Build.ArtifactStagingDirectory)/**/*.symbols.nupkg' + nuGetFeedType: 'internal' + publishVstsFeed: 'e6a70c92-4128-439f-8012-382fe78d6396/f37f760c-aebd-443e-9714-ce725cd427df' + allowPackageConflicts: true + displayName: 'Push NuGet package to the AzureFunctionsPreRelease feed' + diff --git a/endtoendtests/Azure.Functions.Java.Tests.E2E/Azure.Functions.Java.Tests.E2E/Constants.cs b/endtoendtests/Azure.Functions.Java.Tests.E2E/Azure.Functions.Java.Tests.E2E/Constants.cs index 4a0ecb63..552d8cc1 100644 --- a/endtoendtests/Azure.Functions.Java.Tests.E2E/Azure.Functions.Java.Tests.E2E/Constants.cs +++ b/endtoendtests/Azure.Functions.Java.Tests.E2E/Azure.Functions.Java.Tests.E2E/Constants.cs @@ -96,5 +96,8 @@ public static class Constants // SQL Binding tests public static string SqlConnectionStringSetting = Environment.GetEnvironmentVariable("AzureWebJobsSqlConnectionString"); + + // MySql tests + public static string MySqlConnectionStringSetting = Environment.GetEnvironmentVariable("AzureWebJobsMySqlConnectionString"); } } diff --git a/endtoendtests/Azure.Functions.Java.Tests.E2E/Azure.Functions.Java.Tests.E2E/MySqlEndToEndTests.cs b/endtoendtests/Azure.Functions.Java.Tests.E2E/Azure.Functions.Java.Tests.E2E/MySqlEndToEndTests.cs new file mode 100644 index 00000000..eb0cf5a0 --- /dev/null +++ b/endtoendtests/Azure.Functions.Java.Tests.E2E/Azure.Functions.Java.Tests.E2E/MySqlEndToEndTests.cs @@ -0,0 +1,44 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Net; +using System.Threading; +using System.Threading.Tasks; +using Xunit; + +namespace Azure.Functions.Java.Tests.E2E +{ + [Collection(Constants.FunctionAppCollectionName)] + public class MySqlEndToEndTests + { + private readonly FunctionAppFixture _fixture; + + public MySqlEndToEndTests(FunctionAppFixture fixture) + { + this._fixture = fixture; + } + + [Fact] + public async Task MySqlInput_Output_Succeeds() + { + TimeSpan t = DateTime.UtcNow - new DateTime(1970, 1, 1); + int id = (int) t.TotalSeconds; + var product = new Dictionary() + { + { "ProductId", id }, + { "Name", "test" }, + { "Cost", 100 } + }; + + var productString = JsonConvert.SerializeObject(product); + // Insert row into Products table using MySqlOutput + Assert.True(await Utilities.InvokeHttpTriggerPost("AddProduct", productString, HttpStatusCode.OK)); + + // Read row from Products table using MySqlInput + Assert.True(await Utilities.InvokeHttpTrigger("GetProducts", "/" + id.ToString(), HttpStatusCode.OK, productString)); + } + } +} \ No newline at end of file diff --git a/endtoendtests/local.settings.json b/endtoendtests/local.settings.json index 5d4d5201..4ae3343a 100644 --- a/endtoendtests/local.settings.json +++ b/endtoendtests/local.settings.json @@ -18,6 +18,7 @@ "AzureWebJobsEventGridOutputBindingTopicUriString": "", "AzureWebJobsEventGridOutputBindingTopicKeyString": "", "AzureWebJobsSqlConnectionString": "", + "AzureWebJobsMySqlConnectionString": "", "FUNCTIONS_WORKER_RUNTIME": "java" } } diff --git a/endtoendtests/pom.xml b/endtoendtests/pom.xml index 720b27a7..2afda14f 100644 --- a/endtoendtests/pom.xml +++ b/endtoendtests/pom.xml @@ -24,6 +24,7 @@ 1.18.0 3.1.0 2.1.0 + 1.0.0 1.0.0-beta.1 azure-functions-java-endtoendtests westus @@ -69,6 +70,11 @@ com.microsoft.azure.functions azure-functions-java-library-sql ${azure.functions.java.library.sql.version} + + + com.microsoft.azure.functions + azure-functions-java-library-mysql + ${azure.functions.java.library.mysql.version} com.microsoft diff --git a/endtoendtests/src/main/java/com/microsoft/azure/functions/endtoend/MySqlTriggerTests.java b/endtoendtests/src/main/java/com/microsoft/azure/functions/endtoend/MySqlTriggerTests.java new file mode 100644 index 00000000..a5afc03c --- /dev/null +++ b/endtoendtests/src/main/java/com/microsoft/azure/functions/endtoend/MySqlTriggerTests.java @@ -0,0 +1,61 @@ +package com.microsoft.azure.functions.endtoend; + +import com.microsoft.azure.functions.annotation.*; +import com.google.gson.Gson; +import com.microsoft.azure.functions.*; +import com.microsoft.azure.functions.HttpMethod; +import com.microsoft.azure.functions.mysql.annotation.CommandType; +import com.microsoft.azure.functions.mysql.annotation.MySqlInput; +import com.microsoft.azure.functions.mysql.annotation.MySqlOutput; + +import java.io.IOException; +import java.lang.reflect.Array; +import java.util.*; + +/** + * Azure Functions with Azure MySql Database. + */ +public class MySqlTriggerTests { + + @FunctionName("GetProducts") + public HttpResponseMessage GetProducts(@HttpTrigger(name = "req", methods = { HttpMethod.GET, + HttpMethod.POST }, route = "getproducts/{productid}", authLevel = AuthorizationLevel.ANONYMOUS) + HttpRequestMessage> request, + @MySqlInput(name = "products", commandText = "SELECT TOP 1 * FROM Products WHERE ProductId = @ProductId", + commandType = CommandType.Text, parameters = "@ProductId={productid}", + connectionStringSetting = "AzureWebJobsMySqlConnectionString") Product[] products, + final ExecutionContext context) { + + context.getLogger().info("Java HTTP trigger processed a MySql Input Binding request."); + + if (products.length != 0) { + return request.createResponseBuilder(HttpStatus.OK).body(products[0].toString()).build(); + } else { + return request.createResponseBuilder(HttpStatus.INTERNAL_SERVER_ERROR) + .body("Did not find expected product in table Products").build(); + } + } + + @FunctionName("AddProduct") + public HttpResponseMessage AddProduct(@HttpTrigger(name = "req", methods = { HttpMethod.GET, + HttpMethod.POST }, authLevel = AuthorizationLevel.ANONYMOUS) HttpRequestMessage> request, + @MySqlOutput(name = "product", tableName = "Products", connectionStringSetting = "AzureWebJobsMySqlConnectionString") OutputBinding product, + final ExecutionContext context) { + context.getLogger().info("Java HTTP trigger processed a MySql Output Binding request."); + + String json = request.getBody().get(); + product.setValue(new Gson().fromJson(json, Product.class)); + + return request.createResponseBuilder(HttpStatus.OK).body(product).build(); + } + + public class Product { + public int ProductId; + public String Name; + public int Cost; + + public String toString() { + return "{\"ProductId\":" + ProductId + ",\"Name\":\"" + Name + "\",\"Cost\":" + Cost + "}"; + } + } +} \ No newline at end of file From 633968f3251ae0e31cdd030358ccde5539e739e4 Mon Sep 17 00:00:00 2001 From: Heena Gupta Date: Tue, 17 Sep 2024 23:12:38 +0530 Subject: [PATCH 02/10] changes to new yml files --- azure-pipelines-e2e-integration-tests.yml | 173 ----------- azure-pipelines.yml | 280 ------------------ .../official/jobs/run-e2e-tests-linux.yml | 1 + .../official/jobs/run-e2e-tests-windows.yml | 1 + 4 files changed, 2 insertions(+), 453 deletions(-) delete mode 100644 azure-pipelines-e2e-integration-tests.yml delete mode 100644 azure-pipelines.yml diff --git a/azure-pipelines-e2e-integration-tests.yml b/azure-pipelines-e2e-integration-tests.yml deleted file mode 100644 index 0ab404bf..00000000 --- a/azure-pipelines-e2e-integration-tests.yml +++ /dev/null @@ -1,173 +0,0 @@ -# Starter pipeline -# Start with a minimal pipeline that you can customize to build and deploy your code. -# Add steps that build, run tests, deploy, and more: - -pr: none -trigger: none - -jobs: - - job: "End_to_end_integration_tests" - variables: - ApplicationInsightAgentVersion: 3.5.1 - displayName: 'End to end integration tests' - strategy: - maxParallel: 1 - matrix: - open-jdk-8-linux: - IMAGE_TYPE: 'ubuntu-latest' - JDK_DOWNLOAD_LINK: 'https://github.com/adoptium/temurin8-binaries/releases/download/jdk8u392-b08/OpenJDK8U-jdk_x64_linux_hotspot_8u392b08.tar.gz' - JAVA_VERSION: 'OpenJDK8U-jdk_x64_linux_hotspot_8u392b08' - JDK_PATH: 'jdk8u392-b08' - JAVA_VERSION_SPEC: '8' - open-jdk-8-windows: - IMAGE_TYPE: 'windows-latest' - 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' - microsoft-open-jdk-11-linux: - IMAGE_TYPE: 'ubuntu-latest' - JDK_DOWNLOAD_LINK: 'https://aka.ms/download-jdk/microsoft-jdk-11.0.21-linux-x64.tar.gz' - JAVA_VERSION: 'microsoft-jdk-11.0.21-linux-x64' - JDK_PATH: 'jdk-11.0.21+9' - JAVA_VERSION_SPEC: '11' - microsoft-open-jdk-11-windows: - IMAGE_TYPE: 'windows-latest' - 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' - microsoft-open-jdk-17-linux: - IMAGE_TYPE: 'ubuntu-latest' - 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-17-windows: - IMAGE_TYPE: 'windows-latest' - 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' - microsoft-open-jdk-21-linux: - IMAGE_TYPE: 'ubuntu-latest' - 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-21-windows: - IMAGE_TYPE: 'windows-latest' - 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' - - pool: - vmImage: $(IMAGE_TYPE) - - steps: - - task: NuGetToolInstaller@1 - inputs: - checkLatest: true - displayName: 'Install NuGet Tool' - - - pwsh: | - Get-Command mvn - displayName: 'Check Maven is installed' - - - task: JavaToolInstaller@0 # This step is necessary as Linux image has Java 11 as default - inputs: - versionSpec: '8' - jdkArchitectureOption: 'x64' - jdkSourceOption: 'PreInstalled' - condition: eq( variables['Agent.OS'], 'Linux' ) - displayName: 'Setup Java for Linux' - - - pwsh: | - java -version - displayName: 'Check default java version' - - - task: UseDotNet@2 - displayName: 'Install .NET 6' - inputs: - version: 6.0.x - - - pwsh: | - .\setup-tests-pipeline.ps1 -UseCoreToolsBuildFromIntegrationTests - displayName: 'Setup test environment -- Install the Core Tools' - - pwsh: | - $currDir = Get-Location - $Env:Path = $Env:Path+";$currDir\Azure.Functions.Cli" - ls $currDir\Azure.Functions.Cli - func --version - condition: eq( variables['Agent.OS'], 'Windows_NT' ) - displayName: 'Setup Core Tools - Windows' - - bash: | - chmod +x ./Azure.Functions.Cli/func - chmod +x ./Azure.Functions.Cli/gozip - ls ./Azure.Functions.Cli - export PATH=$PATH:./Azure.Functions.Cli - func --version - condition: eq( variables['Agent.OS'], 'Linux' ) - displayName: 'Setup Core Tools - Linux' - - - pwsh: | - java -version - cd ./endtoendtests - 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-endtoendtests" - displayName: 'Package Java for E2E' - - - pwsh: | # Download JDK for later installation - Invoke-WebRequest $(JDK_DOWNLOAD_LINK) -OutFile "$(JAVA_VERSION).tar.gz" - $current = get-location | select -ExpandProperty Path - Write-Host "##vso[task.setvariable variable=downloadPath;]$current" - displayName: 'Download jdk for Linux' - condition: eq( variables['Agent.OS'], 'Linux' ) - - task: JavaToolInstaller@0 # Install JDK downloaded from previous task - inputs: - versionSpec: $(JAVA_VERSION_SPEC) - jdkArchitectureOption: 'x64' - jdkSourceOption: LocalDirectory - jdkFile: "$(downloadPath)/$(JAVA_VERSION).tar.gz" - jdkDestinationDirectory: "$(downloadPath)/externals" - cleanDestinationDirectory: true - condition: eq( variables['Agent.OS'], 'Linux' ) - displayName: 'Setup Java for Linux' - - pwsh: | - 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' - condition: eq( variables['Agent.OS'], 'Windows_NT' ) - - - task: DotNetCoreCLI@2 - inputs: - command: 'test' - projects: | - endtoendtests/Azure.Functions.Java.Tests.E2E/Azure.Functions.Java.Tests.E2E/Azure.Functions.Java.Tests.E2E.csproj - env: - JAVA_HOME: $(JavaHome) - AzureWebJobsStorage: $(AzureWebJobsStorage) - AzureWebJobsCosmosDBConnectionString: $(AzureWebJobsCosmosDBConnectionString) - AzureWebJobsMySqlConnectionString: $(AzureWebJobsMySqlConnectionString) - AzureWebJobsSqlConnectionString: $(AzureWebJobsSqlConnectionString) - AzureWebJobsServiceBus: $(AzureWebJobsServiceBus) - AzureWebJobsEventHubSender_2: $(AzureWebJobsEventHubSender_2) - AzureWebJobsEventHubReceiver: $(AzureWebJobsEventHubReceiver) - AzureWebJobsEventHubSender: $(AzureWebJobsEventHubSender) - AzureWebJobsEventHubPath: $(AzureWebJobsEventHubPath) - SBTopicName: $(SBTopicName) - SBTopicSubName: $(SBTopicSubName) - CosmosDBDatabaseName: $(CosmosDBDatabaseName) - SBQueueName: $(SBQueueName) - BrokerList": $(BrokerList) - ConfluentCloudUsername: $(ConfluentCloudUsername) - ConfluentCloudPassword: $(ConfluentCloudPassword) - AzureWebJobsEventGridOutputBindingTopicUriString: $(AzureWebJobsEventGridOutputBindingTopicUriString) - AzureWebJobsEventGridOutputBindingTopicKeyString: $(AzureWebJobsEventGridOutputBindingTopicKeyString) - ApplicationInsightAPIKey: $(ApplicationInsightAPIKey) - ApplicationInsightAPPID: $(ApplicationInsightAPPID) - ApplicationInsightAgentVersion: $(ApplicationInsightAgentVersion) - displayName: 'Build & Run tests' - continueOnError: false - diff --git a/azure-pipelines.yml b/azure-pipelines.yml deleted file mode 100644 index fd350404..00000000 --- a/azure-pipelines.yml +++ /dev/null @@ -1,280 +0,0 @@ -# Starter pipeline -# Start with a minimal pipeline that you can customize to build and deploy your code. -# Add steps that build, run tests, deploy, and more: - - -trigger: - tags: - include: - - '*' - branches: - include: - - dev - - v3.x - - release/3.x - - release/main - -pr: - branches: - include: - - dev - - v3.x - - release/3.x - - release/main - -jobs: - - job: "Build" - displayName: 'Build java worker' - - pool: - name: '1ES-Hosted-AzFunc' - demands: - - ImageOverride -equals MMS2019TLS - - variables: - ${{ if contains(variables['Build.SourceBranch'], '/tags/' ) }}: - isTagTemp: true - isTag: $[variables.isTagTemp] - - steps: - - task: NuGetToolInstaller@1 - inputs: - checkLatest: true - displayName: 'Install NuGet Tool' - - pwsh: | - Get-Command mvn - displayName: 'Check Maven is installed' - - pwsh: | - java -version - displayName: 'Check default java version' - - 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 - name: output - displayName: 'Executing build script' - - pwsh: | - mvn dependency-check:check - condition: and(eq(variables['Build.SourceBranch'], 'refs/heads/dev'), eq(variables['SkipMavenDependencyCheck'], 'false')) - displayName: 'Maven dependency check' - - task: CopyFiles@2 - inputs: - SourceFolder: '$(Build.Repository.LocalPath)/pkg' - Contents: '*.nupkg' - TargetFolder: '$(Build.ArtifactStagingDirectory)' - CleanTargetFolder: true - displayName: 'Copying files for artifacts' - - task: PublishBuildArtifacts@1 - inputs: - PathtoPublish: '$(Build.ArtifactStagingDirectory)' - ArtifactName: 'buildDrop' - displayName: 'Upload build artifacts' - - - job: "Test" - displayName: 'Test java worker' - dependsOn: Build - variables: - buildNumber: $[ dependencies.Build.outputs['output.buildNumber'] ] - ApplicationInsightAgentVersion: 3.5.1 - strategy: - maxParallel: 1 - matrix: - open-jdk-8-linux: - IMAGE_TYPE: 'ubuntu-latest' - JDK_DOWNLOAD_LINK: 'https://github.com/adoptium/temurin8-binaries/releases/download/jdk8u392-b08/OpenJDK8U-jdk_x64_linux_hotspot_8u392b08.tar.gz' - JAVA_VERSION: 'OpenJDK8U-jdk_x64_linux_hotspot_8u392b08' - JDK_PATH: 'jdk8u392-b08' - JAVA_VERSION_SPEC: '8' - open-jdk-8-windows: - IMAGE_TYPE: 'windows-latest' - 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' - microsoft-open-jdk-11-linux: - IMAGE_TYPE: 'ubuntu-latest' - JDK_DOWNLOAD_LINK: 'https://aka.ms/download-jdk/microsoft-jdk-11.0.21-linux-x64.tar.gz' - JAVA_VERSION: 'microsoft-jdk-11.0.21-linux-x64' - JDK_PATH: 'jdk-11.0.21+9' - JAVA_VERSION_SPEC: '11' - microsoft-open-jdk-11-windows: - IMAGE_TYPE: 'windows-latest' - 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' - microsoft-open-jdk-17-linux: - IMAGE_TYPE: 'ubuntu-latest' - 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-17-windows: - IMAGE_TYPE: 'windows-latest' - 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' - microsoft-open-jdk-21-linux: - IMAGE_TYPE: 'ubuntu-latest' - 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-21-windows: - IMAGE_TYPE: 'windows-latest' - 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' - - pool: - vmImage: $(IMAGE_TYPE) - - steps: - - task: NuGetToolInstaller@1 - inputs: - checkLatest: true - displayName: 'Install NuGet Tool' - - pwsh: | - Get-Command mvn - displayName: 'Check Maven is installed' - - task: JavaToolInstaller@0 # This step is necessary as Linux image has Java 11 as default - inputs: - versionSpec: '8' - jdkArchitectureOption: 'x64' - jdkSourceOption: 'PreInstalled' - condition: eq( variables['Agent.OS'], 'Linux' ) - displayName: 'Setup Java for Linux' - - pwsh: | - java -version - displayName: 'Check default java version' - - pwsh: | - .\package-pipeline.ps1 -buildNumber $(buildNumber) - displayName: 'Executing build script' - - task: UseDotNet@2 - displayName: 'Install .NET 6' - inputs: - version: 6.0.x - - pwsh: | # Download JDK for later installation - Invoke-WebRequest $(JDK_DOWNLOAD_LINK) -OutFile "$(JAVA_VERSION).tar.gz" - $current = get-location | select -ExpandProperty Path - Write-Host "##vso[task.setvariable variable=downloadPath;]$current" - displayName: 'Download jdk for Linux' - condition: eq( variables['Agent.OS'], 'Linux' ) - - task: JavaToolInstaller@0 # Install JDK downloaded from previous task - inputs: - versionSpec: $(JAVA_VERSION_SPEC) - jdkArchitectureOption: 'x64' - jdkSourceOption: LocalDirectory - jdkFile: "$(downloadPath)/$(JAVA_VERSION).tar.gz" - jdkDestinationDirectory: "$(downloadPath)/externals" - cleanDestinationDirectory: true - condition: eq( variables['Agent.OS'], 'Linux' ) - displayName: 'Setup Java for Linux' - - pwsh: | - 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' - condition: eq( variables['Agent.OS'], 'Windows_NT' ) - - - 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 - condition: eq( variables['Agent.OS'], 'Windows_NT' ) - displayName: 'Setup Core Tools - Windows' - - bash: | - chmod +x ./Azure.Functions.Cli/func - chmod +x ./Azure.Functions.Cli/gozip - export PATH=$PATH:./Azure.Functions.Cli - func --version - condition: eq( variables['Agent.OS'], 'Linux' ) - displayName: 'Setup Core Tools - Linux' - - pwsh: | - cd ./endtoendtests - 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-endtoendtests" - displayName: 'Package Java for E2E' - - task: DotNetCoreCLI@2 - inputs: - command: 'test' - projects: | - endtoendtests/Azure.Functions.Java.Tests.E2E/Azure.Functions.Java.Tests.E2E/Azure.Functions.Java.Tests.E2E.csproj - env: - JAVA_HOME: $(JavaHome) - AzureWebJobsStorage: $(AzureWebJobsStorage) - AzureWebJobsCosmosDBConnectionString: $(AzureWebJobsCosmosDBConnectionString) - AzureWebJobsMySqlConnectionString: $(AzureWebJobsMySqlConnectionString) - AzureWebJobsSqlConnectionString: $(AzureWebJobsSqlConnectionString) - AzureWebJobsServiceBus: $(AzureWebJobsServiceBus) - AzureWebJobsEventHubReceiver: $(AzureWebJobsEventHubReceiver) - AzureWebJobsEventHubSender_2: $(AzureWebJobsEventHubSender_2) - AzureWebJobsEventHubSender: $(AzureWebJobsEventHubSender) - AzureWebJobsEventHubPath: $(AzureWebJobsEventHubPath) - SBTopicName: $(SBTopicName) - SBTopicSubName: $(SBTopicSubName) - CosmosDBDatabaseName: $(CosmosDBDatabaseName) - SBQueueName: $(SBQueueName) - BrokerList": $(BrokerList) - ConfluentCloudUsername: $(ConfluentCloudUsername) - ConfluentCloudPassword: $(ConfluentCloudPassword) - AzureWebJobsEventGridOutputBindingTopicUriString: $(AzureWebJobsEventGridOutputBindingTopicUriString) - AzureWebJobsEventGridOutputBindingTopicKeyString: $(AzureWebJobsEventGridOutputBindingTopicKeyString) - ApplicationInsightAPIKey: $(ApplicationInsightAPIKey) - ApplicationInsightAPPID: $(ApplicationInsightAPPID) - ApplicationInsightAgentVersion: $(ApplicationInsightAgentVersion) - displayName: 'Build & Run tests' - continueOnError: false - - - job: "Publish" - displayName: 'Publish build artifacts' - dependsOn: Test - - pool: - name: '1ES-Hosted-AzFunc' - demands: - - ImageOverride -equals MMS2019TLS - - steps: - - task: DownloadBuildArtifacts@0 - inputs: - buildType: 'current' - downloadType: 'single' - artifactName: 'buildDrop' - downloadPath: '$(Build.ArtifactStagingDirectory)' - displayName: 'Download build artifacts' - - pwsh: | - Move-Item -Path "$(Build.ArtifactStagingDirectory)/buildDrop/*.nupkg" -Destination $(Build.ArtifactStagingDirectory) - Remove-Item "$(Build.ArtifactStagingDirectory)/buildDrop" -Recurse - - task: ManifestGeneratorTask@0 - inputs: - BuildDropPath: '$(Build.ArtifactStagingDirectory)' - Verbosity: 'Information' - displayName: 'SBOM Generation Task' - - task: PublishBuildArtifacts@1 - inputs: - PathtoPublish: '$(Build.ArtifactStagingDirectory)' - ArtifactName: 'drop' - publishLocation: 'Container' - displayName: 'Publishing build artifacts' - - task: NuGetCommand@2 - condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/dev'), eq(variables['UPLOADPACKAGETOPRERELEASEFEED'], true)) - inputs: - command: 'push' - packagesToPush: '$(Build.ArtifactStagingDirectory)/**/*.nupkg;!$(Build.ArtifactStagingDirectory)/**/*.symbols.nupkg' - nuGetFeedType: 'internal' - publishVstsFeed: 'e6a70c92-4128-439f-8012-382fe78d6396/f37f760c-aebd-443e-9714-ce725cd427df' - allowPackageConflicts: true - displayName: 'Push NuGet package to the AzureFunctionsPreRelease feed' - diff --git a/eng/ci/templates/official/jobs/run-e2e-tests-linux.yml b/eng/ci/templates/official/jobs/run-e2e-tests-linux.yml index 368007c9..936999c8 100644 --- a/eng/ci/templates/official/jobs/run-e2e-tests-linux.yml +++ b/eng/ci/templates/official/jobs/run-e2e-tests-linux.yml @@ -109,6 +109,7 @@ jobs: AzureWebJobsStorage: $(AzureWebJobsStorage) AzureWebJobsCosmosDBConnectionString: $(AzureWebJobsCosmosDBConnectionString) AzureWebJobsSqlConnectionString: $(AzureWebJobsSqlConnectionString) + AzureWebJobsMySqlConnectionString: $(AzureWebJobsMySqlConnectionString) AzureWebJobsServiceBus: $(AzureWebJobsServiceBus) AzureWebJobsEventHubReceiver: $(AzureWebJobsEventHubReceiver) AzureWebJobsEventHubSender_2: $(AzureWebJobsEventHubSender_2) diff --git a/eng/ci/templates/official/jobs/run-e2e-tests-windows.yml b/eng/ci/templates/official/jobs/run-e2e-tests-windows.yml index df27ff58..0c130319 100644 --- a/eng/ci/templates/official/jobs/run-e2e-tests-windows.yml +++ b/eng/ci/templates/official/jobs/run-e2e-tests-windows.yml @@ -94,6 +94,7 @@ jobs: AzureWebJobsStorage: $(AzureWebJobsStorage) AzureWebJobsCosmosDBConnectionString: $(AzureWebJobsCosmosDBConnectionString) AzureWebJobsSqlConnectionString: $(AzureWebJobsSqlConnectionString) + AzureWebJobsMySqlConnectionString: $(AzureWebJobsMySqlConnectionString) AzureWebJobsServiceBus: $(AzureWebJobsServiceBus) AzureWebJobsEventHubReceiver: $(AzureWebJobsEventHubReceiver) AzureWebJobsEventHubSender_2: $(AzureWebJobsEventHubSender_2) From b2579f480be9b3de28f33a2d64c4bcf8a2e06352 Mon Sep 17 00:00:00 2001 From: guptaheena <150243077+guptaheena@users.noreply.github.com> Date: Tue, 17 Sep 2024 23:14:34 +0530 Subject: [PATCH 03/10] Update java version --- endtoendtests/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/endtoendtests/pom.xml b/endtoendtests/pom.xml index 2afda14f..39b3a9ed 100644 --- a/endtoendtests/pom.xml +++ b/endtoendtests/pom.xml @@ -24,7 +24,7 @@ 1.18.0 3.1.0 2.1.0 - 1.0.0 + 1.0.0-preview 1.0.0-beta.1 azure-functions-java-endtoendtests westus From 14b033d75f4d3e8440f4635d03aed67d8820dc41 Mon Sep 17 00:00:00 2001 From: peterstone2017 <12449837+YunchuWang@users.noreply.github.com> Date: Thu, 19 Sep 2024 09:48:40 -0700 Subject: [PATCH 04/10] test: trigger e2e tests --- .../Azure.Functions.Java.Tests.E2E/MySqlEndToEndTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/endtoendtests/Azure.Functions.Java.Tests.E2E/Azure.Functions.Java.Tests.E2E/MySqlEndToEndTests.cs b/endtoendtests/Azure.Functions.Java.Tests.E2E/Azure.Functions.Java.Tests.E2E/MySqlEndToEndTests.cs index eb0cf5a0..c84f1180 100644 --- a/endtoendtests/Azure.Functions.Java.Tests.E2E/Azure.Functions.Java.Tests.E2E/MySqlEndToEndTests.cs +++ b/endtoendtests/Azure.Functions.Java.Tests.E2E/Azure.Functions.Java.Tests.E2E/MySqlEndToEndTests.cs @@ -34,7 +34,7 @@ public async Task MySqlInput_Output_Succeeds() }; var productString = JsonConvert.SerializeObject(product); - // Insert row into Products table using MySqlOutput + // Insert a row into Products table using MySqlOutput Assert.True(await Utilities.InvokeHttpTriggerPost("AddProduct", productString, HttpStatusCode.OK)); // Read row from Products table using MySqlInput From f10853c35056e3b961a5a7c6b50cbddc0fccccef Mon Sep 17 00:00:00 2001 From: peterstone2017 <12449837+YunchuWang@users.noreply.github.com> Date: Thu, 19 Sep 2024 13:35:03 -0700 Subject: [PATCH 05/10] revert: copy public br to internal for testing --- eng/ci/code-mirror.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/ci/code-mirror.yml b/eng/ci/code-mirror.yml index 8ad6641e..278110d0 100644 --- a/eng/ci/code-mirror.yml +++ b/eng/ci/code-mirror.yml @@ -3,7 +3,7 @@ trigger: include: - dev - release/* # azure-functions-java-worker github repo restricts creation of release/* branches, so using a pattern is safe here. - + - heenagupta/mysqlextensiontests resources: repositories: - repository: eng From 4892ee9c878edc4ab07527e8ecc7a6dff0a452bc Mon Sep 17 00:00:00 2001 From: guptaheena <150243077+guptaheena@users.noreply.github.com> Date: Sun, 22 Sep 2024 21:13:55 +0530 Subject: [PATCH 06/10] Update MySqlTriggerTests.java --- .../microsoft/azure/functions/endtoend/MySqlTriggerTests.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/endtoendtests/src/main/java/com/microsoft/azure/functions/endtoend/MySqlTriggerTests.java b/endtoendtests/src/main/java/com/microsoft/azure/functions/endtoend/MySqlTriggerTests.java index a5afc03c..8c099309 100644 --- a/endtoendtests/src/main/java/com/microsoft/azure/functions/endtoend/MySqlTriggerTests.java +++ b/endtoendtests/src/main/java/com/microsoft/azure/functions/endtoend/MySqlTriggerTests.java @@ -7,6 +7,7 @@ import com.microsoft.azure.functions.mysql.annotation.CommandType; import com.microsoft.azure.functions.mysql.annotation.MySqlInput; import com.microsoft.azure.functions.mysql.annotation.MySqlOutput; +import com.microsoft.azure.functions.mysql.annotation.MySqlTrigger; import java.io.IOException; import java.lang.reflect.Array; @@ -58,4 +59,4 @@ public String toString() { return "{\"ProductId\":" + ProductId + ",\"Name\":\"" + Name + "\",\"Cost\":" + Cost + "}"; } } -} \ No newline at end of file +} From ca693a6056a17cfe5095bd1a445f650113eed5d6 Mon Sep 17 00:00:00 2001 From: guptaheena <150243077+guptaheena@users.noreply.github.com> Date: Mon, 23 Sep 2024 23:27:43 +0530 Subject: [PATCH 07/10] Update MySqlTriggerTests.java --- .../microsoft/azure/functions/endtoend/MySqlTriggerTests.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/endtoendtests/src/main/java/com/microsoft/azure/functions/endtoend/MySqlTriggerTests.java b/endtoendtests/src/main/java/com/microsoft/azure/functions/endtoend/MySqlTriggerTests.java index 8c099309..7335d2ae 100644 --- a/endtoendtests/src/main/java/com/microsoft/azure/functions/endtoend/MySqlTriggerTests.java +++ b/endtoendtests/src/main/java/com/microsoft/azure/functions/endtoend/MySqlTriggerTests.java @@ -40,7 +40,7 @@ public HttpResponseMessage GetProducts(@HttpTrigger(name = "req", methods = { Ht @FunctionName("AddProduct") public HttpResponseMessage AddProduct(@HttpTrigger(name = "req", methods = { HttpMethod.GET, HttpMethod.POST }, authLevel = AuthorizationLevel.ANONYMOUS) HttpRequestMessage> request, - @MySqlOutput(name = "product", tableName = "Products", connectionStringSetting = "AzureWebJobsMySqlConnectionString") OutputBinding product, + @MySqlOutput(name = "product", commandText = "Products", connectionStringSetting = "AzureWebJobsMySqlConnectionString") OutputBinding product, final ExecutionContext context) { context.getLogger().info("Java HTTP trigger processed a MySql Output Binding request."); From 50402d601541aeb7f7e8151c7427d3abd14ee225 Mon Sep 17 00:00:00 2001 From: guptaheena <150243077+guptaheena@users.noreply.github.com> Date: Wed, 25 Sep 2024 00:56:06 +0530 Subject: [PATCH 08/10] Update version --- endtoendtests/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/endtoendtests/pom.xml b/endtoendtests/pom.xml index 39b3a9ed..b4fc0600 100644 --- a/endtoendtests/pom.xml +++ b/endtoendtests/pom.xml @@ -24,7 +24,7 @@ 1.18.0 3.1.0 2.1.0 - 1.0.0-preview + 1.0.1-preview 1.0.0-beta.1 azure-functions-java-endtoendtests westus From e52de5585182ad39b826d0c6db36997ef282996c Mon Sep 17 00:00:00 2001 From: guptaheena <150243077+guptaheena@users.noreply.github.com> Date: Wed, 29 Jan 2025 10:56:49 +0530 Subject: [PATCH 09/10] Fix indentation in local.settings.json --- endtoendtests/local.settings.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/endtoendtests/local.settings.json b/endtoendtests/local.settings.json index 4ae3343a..757e47eb 100644 --- a/endtoendtests/local.settings.json +++ b/endtoendtests/local.settings.json @@ -18,7 +18,7 @@ "AzureWebJobsEventGridOutputBindingTopicUriString": "", "AzureWebJobsEventGridOutputBindingTopicKeyString": "", "AzureWebJobsSqlConnectionString": "", - "AzureWebJobsMySqlConnectionString": "", + "AzureWebJobsMySqlConnectionString": "", "FUNCTIONS_WORKER_RUNTIME": "java" } } From de9536a8ffca3b41d74999043dbcd33a73ee2037 Mon Sep 17 00:00:00 2001 From: guptaheena <150243077+guptaheena@users.noreply.github.com> Date: Fri, 11 Apr 2025 22:54:57 +0530 Subject: [PATCH 10/10] updating java mysql version --- endtoendtests/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/endtoendtests/pom.xml b/endtoendtests/pom.xml index b4fc0600..3d090785 100644 --- a/endtoendtests/pom.xml +++ b/endtoendtests/pom.xml @@ -24,7 +24,7 @@ 1.18.0 3.1.0 2.1.0 - 1.0.1-preview + 1.0.2 1.0.0-beta.1 azure-functions-java-endtoendtests westus