-
Notifications
You must be signed in to change notification settings - Fork 7
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
Split e2e tests from samples #186
Merged
Merged
Changes from 6 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
89f17dc
split e2e tests from samples
kaibocai 57c0bd2
remove duplicate gradle test
kaibocai 4a31599
remove flaky test
kaibocai f31ed61
add back test for samples
kaibocai c2f485a
quick test
kaibocai b9a12bb
revert quick test
kaibocai 4c800bb
add back docker file
kaibocai e3cb946
minor fix for style
kaibocai File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
FROM mcr.microsoft.com/azure-functions/java:4-java11 | ||
|
||
COPY samples-azure-functions/build/azure-functions/azure-functions-sample/ /home/site/wwwroot/ | ||
COPY endtoendtests/build/azure-functions/azure-functions-sample/ /home/site/wwwroot/ | ||
kaibocai marked this conversation as resolved.
Show resolved
Hide resolved
|
||
ENV AzureWebJobsScriptRoot=/home/site/wwwroot \ | ||
AzureFunctionsJobHost__Logging__Console__IsEnabled=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
plugins { | ||
id "com.microsoft.azure.azurefunctions" version "1.11.1" | ||
} | ||
apply plugin: 'java' | ||
apply plugin: "com.microsoft.azure.azurefunctions" | ||
|
||
group 'com.durabletask.endtoend' | ||
version '0.0.0-SNAPSHOT' | ||
|
||
repositories { | ||
mavenLocal() | ||
maven { | ||
url "https://oss.sonatype.org/content/repositories/snapshots/" | ||
} | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
implementation project(':client') | ||
implementation project(':azurefunctions') | ||
|
||
implementation 'com.microsoft.azure.functions:azure-functions-java-library:3.0.0' | ||
testImplementation 'org.junit.jupiter:junit-jupiter:5.6.2' | ||
testImplementation 'io.rest-assured:rest-assured:5.3.0' | ||
testImplementation 'io.rest-assured:json-path:5.3.0' | ||
|
||
} | ||
|
||
sourceCompatibility = '1.8' | ||
targetCompatibility = '1.8' | ||
|
||
compileJava.options.encoding = 'UTF-8' | ||
|
||
task endToEndTest(type: Test) { | ||
useJUnitPlatform { | ||
includeTags 'e2e' | ||
} | ||
dependsOn build | ||
testLogging.showStandardStreams = true | ||
} | ||
|
||
|
||
azurefunctions { | ||
resourceGroup = 'java-functions-group' | ||
appName = 'azure-functions-sample' | ||
pricingTier = 'Consumption' | ||
region = 'westus' | ||
runtime { | ||
os = 'Windows' | ||
javaVersion = 'Java 8' | ||
} | ||
auth { | ||
type = 'azure_cli' | ||
} | ||
localDebug = "transport=dt_socket,server=y,suspend=n,address=5005" | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"version": "2.0", | ||
"logging": { | ||
"logLevel": { | ||
"DurableTask.AzureStorage": "Warning", | ||
"DurableTask.Core": "Warning" | ||
}, | ||
"applicationInsights": { | ||
"samplingSettings": { | ||
"isEnabled": false | ||
} | ||
} | ||
}, | ||
"extensions": { | ||
"durableTask": { | ||
"hubName": "DFJavaSmokeTest" | ||
} | ||
}, | ||
"extensionBundle": { | ||
"id": "Microsoft.Azure.Functions.ExtensionBundle", | ||
"version": "[4.*, 5.0.0)" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"IsEncrypted": false, | ||
"Values": { | ||
"AzureWebJobsStorage": "UseDevelopmentStorage=true", | ||
"FUNCTIONS_WORKER_RUNTIME": "java" | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
endtoendtests/src/main/java/com/functions/AzureFunctions.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package com.functions; | ||
|
||
import com.microsoft.azure.functions.annotation.*; | ||
import com.microsoft.azure.functions.*; | ||
import java.util.*; | ||
|
||
import com.microsoft.durabletask.*; | ||
import com.microsoft.durabletask.azurefunctions.DurableActivityTrigger; | ||
import com.microsoft.durabletask.azurefunctions.DurableClientContext; | ||
import com.microsoft.durabletask.azurefunctions.DurableClientInput; | ||
import com.microsoft.durabletask.azurefunctions.DurableOrchestrationTrigger; | ||
|
||
/** | ||
* Azure Durable Functions with HTTP trigger. | ||
*/ | ||
public class AzureFunctions { | ||
/** | ||
* This HTTP-triggered function starts the orchestration. | ||
*/ | ||
@FunctionName("StartOrchestration") | ||
public HttpResponseMessage startOrchestration( | ||
@HttpTrigger(name = "req", methods = {HttpMethod.GET, HttpMethod.POST}, authLevel = AuthorizationLevel.ANONYMOUS) HttpRequestMessage<Optional<String>> request, | ||
@DurableClientInput(name = "durableContext") DurableClientContext durableContext, | ||
final ExecutionContext context) { | ||
context.getLogger().info("Java HTTP trigger processed a request."); | ||
|
||
DurableTaskClient client = durableContext.getClient(); | ||
String instanceId = client.scheduleNewOrchestrationInstance("Cities"); | ||
context.getLogger().info("Created new Java orchestration with instance ID = " + instanceId); | ||
return durableContext.createCheckStatusResponse(request, instanceId); | ||
} | ||
|
||
/** | ||
* This is the orchestrator function, which can schedule activity functions, create durable timers, | ||
* or wait for external events in a way that's completely fault-tolerant. | ||
*/ | ||
@FunctionName("Cities") | ||
public String citiesOrchestrator( | ||
@DurableOrchestrationTrigger(name = "ctx") TaskOrchestrationContext ctx) { | ||
String result = ""; | ||
result += ctx.callActivity("Capitalize", "Tokyo", String.class).await() + ", "; | ||
result += ctx.callActivity("Capitalize", "London", String.class).await() + ", "; | ||
result += ctx.callActivity("Capitalize", "Seattle", String.class).await() + ", "; | ||
result += ctx.callActivity("Capitalize", "Austin", String.class).await(); | ||
return result; | ||
} | ||
|
||
/** | ||
* This is the activity function that gets invoked by the orchestration. | ||
*/ | ||
@FunctionName("Capitalize") | ||
public String capitalize( | ||
@DurableActivityTrigger(name = "name") String name, | ||
final ExecutionContext context) { | ||
context.getLogger().info("Capitalizing: " + name); | ||
return name.toUpperCase(); | ||
} | ||
} |
66 changes: 66 additions & 0 deletions
66
endtoendtests/src/main/java/com/functions/ContinueAsNew.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package com.functions; | ||
|
||
import com.microsoft.azure.functions.ExecutionContext; | ||
import com.microsoft.azure.functions.HttpMethod; | ||
import com.microsoft.azure.functions.HttpRequestMessage; | ||
import com.microsoft.azure.functions.HttpResponseMessage; | ||
import com.microsoft.azure.functions.annotation.AuthorizationLevel; | ||
import com.microsoft.azure.functions.annotation.FunctionName; | ||
import com.microsoft.azure.functions.annotation.HttpTrigger; | ||
import com.microsoft.durabletask.DurableTaskClient; | ||
import com.microsoft.durabletask.Task; | ||
import com.microsoft.durabletask.TaskOrchestrationContext; | ||
import com.microsoft.durabletask.azurefunctions.DurableClientContext; | ||
import com.microsoft.durabletask.azurefunctions.DurableClientInput; | ||
import com.microsoft.durabletask.azurefunctions.DurableOrchestrationTrigger; | ||
|
||
import java.time.Duration; | ||
import java.util.Optional; | ||
|
||
public class ContinueAsNew { | ||
@FunctionName("ContinueAsNew") | ||
public HttpResponseMessage continueAsNew( | ||
@HttpTrigger(name = "req", methods = {HttpMethod.GET, HttpMethod.POST}, authLevel = AuthorizationLevel.ANONYMOUS) HttpRequestMessage<Optional<String>> request, | ||
@DurableClientInput(name = "durableContext") DurableClientContext durableContext, | ||
final ExecutionContext context) { | ||
context.getLogger().info("Java HTTP trigger processed a request."); | ||
|
||
DurableTaskClient client = durableContext.getClient(); | ||
String instanceId = client.scheduleNewOrchestrationInstance("EternalOrchestrator"); | ||
context.getLogger().info("Created new Java orchestration with instance ID = " + instanceId); | ||
return durableContext.createCheckStatusResponse(request, instanceId); | ||
} | ||
|
||
@FunctionName("EternalOrchestrator") | ||
public void eternalOrchestrator(@DurableOrchestrationTrigger(name = "runtimeState") TaskOrchestrationContext ctx) | ||
{ | ||
System.out.println("Processing stuff..."); | ||
ctx.createTimer(Duration.ofSeconds(2)).await(); | ||
ctx.continueAsNew(null); | ||
} | ||
|
||
@FunctionName("ContinueAsNewExternalEvent") | ||
public HttpResponseMessage continueAsNewExternalEvent( | ||
@HttpTrigger(name = "req", methods = {HttpMethod.GET, HttpMethod.POST}, authLevel = AuthorizationLevel.ANONYMOUS) HttpRequestMessage<Optional<String>> request, | ||
@DurableClientInput(name = "durableContext") DurableClientContext durableContext, | ||
final ExecutionContext context) { | ||
context.getLogger().info("Java HTTP trigger processed a request."); | ||
|
||
DurableTaskClient client = durableContext.getClient(); | ||
String instanceId = client.scheduleNewOrchestrationInstance("EternalEvent"); | ||
context.getLogger().info("Created new Java orchestration with instance ID = " + instanceId); | ||
return durableContext.createCheckStatusResponse(request, instanceId); | ||
} | ||
|
||
@FunctionName("EternalEvent") | ||
public void eternalEvent(@DurableOrchestrationTrigger(name = "runtimeState") TaskOrchestrationContext ctx) | ||
{ | ||
System.out.println("Waiting external event..."); | ||
Task<Void> event = ctx.waitForExternalEvent("event"); | ||
Task<Void> timer = ctx.createTimer(Duration.ofSeconds(10)); | ||
Task<?> result = ctx.anyOf(event, timer).await(); | ||
if (result == event) { | ||
ctx.continueAsNew(null); | ||
} | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test is pretty flaky, commented it out for now, will investigate this one and create PR accordingly. It may be an issue with the sidecar.