Skip to content

Commit 56ca926

Browse files
authored
Add end to end test suits. (microsoft#116)
* update library version - update gradle plugin version init end2end tests add end2end test suits * comment out mandatory parame for testing * assert end2end tests is running by failing it * clean up * wait 10 seconds for sidecar to be fully up * remove unused files
1 parent 4f8e769 commit 56ca926

File tree

8 files changed

+111
-109
lines changed

8 files changed

+111
-109
lines changed

.github/workflows/build-validation.yml

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ jobs:
4343
# TODO: Move the sidecar into a central image repository
4444
- name: Initialize Durable Task Sidecar
4545
run: docker run --name durabletask-sidecar -p 4001:4001 --env 'DURABLETASK_SIDECAR_LOGLEVEL=Debug' -d kaibocai/durabletask-sidecar:latest start --backend Emulator
46+
# wait for 10 seconds, so sidecar container can be fully up, this will avoid intermittent failing issues for integration tests causing by failed to connect to sidecar
47+
- name: Wait for 10 seconds
48+
run: sleep 10
4649
- name: Integration Tests with Gradle
4750
uses: gradle/gradle-build-action@bc3340afc5e3cc44f2321809ac090d731c13c514
4851
with:
@@ -58,7 +61,7 @@ jobs:
5861
name: Package
5962
path: client/build/libs
6063

61-
functions:
64+
functions-e2e-tests:
6265

6366
needs: build
6467
runs-on: ubuntu-latest
@@ -81,9 +84,15 @@ jobs:
8184
with:
8285
arguments: azureFunctionsPackage
8386
continue-on-error: true
84-
- name: Download azure functions java library # TODO: Remove this step once gradle plugin is updated
85-
run: |
86-
wget -P samples-azure-functions/build/azure-functions/azure-functions-sample/lib/ "https://repo.maven.apache.org/maven2/com/microsoft/azure/functions/azure-functions-java-library/2.2.0/azure-functions-java-library-2.2.0.jar" --show-progress
87-
- name: Run azure functions test
88-
run: samples-azure-functions/e2e-test.ps1 -DockerfilePath samples-azure-functions/Dockerfile -HttpStartPath api/StartOrchestration
87+
- name: Setup azure functions runtime
88+
run: samples-azure-functions/e2e-test-setup.ps1 -DockerfilePath samples-azure-functions/Dockerfile
8989
shell: pwsh
90+
- name: End to End Tests with Gradle
91+
uses: gradle/gradle-build-action@bc3340afc5e3cc44f2321809ac090d731c13c514
92+
with:
93+
arguments: endToEndTest
94+
- name: Archive test report
95+
uses: actions/upload-artifact@v2
96+
with:
97+
name: Integration test report
98+
path: client/build/reports/tests/endToEndTest

azurefunctions/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ repositories {
1717

1818
dependencies {
1919
api project(':client')
20-
implementation group: 'com.microsoft.azure.functions', name: 'azure-functions-java-library', version: '2.2.0'
20+
implementation group: 'com.microsoft.azure.functions', name: 'azure-functions-java-library', version: '3.0.0'
2121
implementation "com.google.protobuf:protobuf-java:${protocVersion}"
2222
compileOnly "com.microsoft.azure.functions:azure-functions-java-spi:1.0.0"
2323
}

client/src/test/java/com/microsoft/durabletask/IntegrationTests.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import java.util.*;
88
import java.util.concurrent.TimeUnit;
99
import java.util.concurrent.TimeoutException;
10-
import java.util.concurrent.ExecutionException;
1110
import java.util.stream.Collectors;
1211
import java.util.stream.IntStream;
1312
import java.util.stream.Stream;

samples-azure-functions/Dockerfile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
FROM mcr.microsoft.com/azure-functions/java:4-java11
22

3-
RUN rm /azure-functions-host/workers/java/azure-functions-java-worker.jar
4-
COPY samples-azure-functions/azure-functions-java-worker-2.7.0.jar /azure-functions-host/workers/java/azure-functions-java-worker.jar
53
COPY samples-azure-functions/build/azure-functions/azure-functions-sample/ /home/site/wwwroot/
64
ENV AzureWebJobsScriptRoot=/home/site/wwwroot \
75
AzureFunctionsJobHost__Logging__Console__IsEnabled=true

samples-azure-functions/build.gradle

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
plugins {
2-
id "com.microsoft.azure.azurefunctions" version "1.9.0"
2+
id "com.microsoft.azure.azurefunctions" version "1.11.1"
33
}
44
apply plugin: 'java'
55
apply plugin: "com.microsoft.azure.azurefunctions"
@@ -19,17 +19,27 @@ dependencies {
1919
implementation project(':client')
2020
implementation project(':azurefunctions')
2121

22-
implementation 'com.microsoft.azure.functions:azure-functions-java-library:2.2.0'
22+
implementation 'com.microsoft.azure.functions:azure-functions-java-library:3.0.0'
2323
testImplementation 'org.junit.jupiter:junit-jupiter:5.6.2'
24-
testImplementation 'org.mockito:mockito-core:3.3.3'
25-
runtimeOnly "io.grpc:grpc-netty-shaded:1.38.0"
24+
testImplementation 'io.rest-assured:rest-assured:5.3.0'
25+
testImplementation 'io.rest-assured:json-path:5.3.0'
26+
2627
}
2728

2829
sourceCompatibility = '1.8'
2930
targetCompatibility = '1.8'
3031

3132
compileJava.options.encoding = 'UTF-8'
3233

34+
task endToEndTest(type: Test) {
35+
useJUnitPlatform {
36+
includeTags 'e2e'
37+
}
38+
dependsOn build
39+
testLogging.showStandardStreams = true
40+
}
41+
42+
3343
azurefunctions {
3444
resourceGroup = 'java-functions-group'
3545
appName = 'azure-functions-sample'
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Installing PowerShell: https://docs.microsoft.com/powershell/scripting/install/installing-powershell
2+
3+
param(
4+
[Parameter(Mandatory=$true)]
5+
[string]$DockerfilePath,
6+
[string]$ImageName="dfapp",
7+
[string]$ContainerName="app",
8+
[switch]$NoSetup=$false,
9+
[switch]$NoValidation=$false,
10+
[string]$AzuriteVersion="3.20.1",
11+
[int]$Sleep=30
12+
)
13+
14+
$ErrorActionPreference = "Stop"
15+
16+
if ($NoSetup -eq $false) {
17+
# Build the docker image first, since that's the most critical step
18+
Write-Host "Building sample app Docker container from '$DockerfilePath'..." -ForegroundColor Yellow
19+
docker build -f $DockerfilePath -t $ImageName --progress plain .
20+
21+
# Next, download and start the Azurite emulator Docker image
22+
Write-Host "Pulling down the mcr.microsoft.com/azure-storage/azurite:$AzuriteVersion image..." -ForegroundColor Yellow
23+
docker pull "mcr.microsoft.com/azure-storage/azurite:${AzuriteVersion}"
24+
25+
Write-Host "Starting Azurite storage emulator using default ports..." -ForegroundColor Yellow
26+
docker run --name 'azurite' -p 10000:10000 -p 10001:10001 -p 10002:10002 -d "mcr.microsoft.com/azure-storage/azurite:${AzuriteVersion}"
27+
28+
# Finally, start up the smoke test container, which will connect to the Azurite container
29+
docker run --name $ContainerName -p 8080:80 -it --add-host=host.docker.internal:host-gateway -d `
30+
--env 'AzureWebJobsStorage=UseDevelopmentStorage=true;DevelopmentStorageProxyUri=http://host.docker.internal' `
31+
--env 'WEBSITE_HOSTNAME=localhost:8080' `
32+
$ImageName
33+
}
34+
35+
if ($sleep -gt 0) {
36+
# The container needs a bit more time before it can start receiving requests
37+
Write-Host "Sleeping for $Sleep seconds to let the container finish initializing..." -ForegroundColor Yellow
38+
Start-Sleep -Seconds $Sleep
39+
}
40+
41+
# Check to see what containers are running
42+
docker ps

samples-azure-functions/e2e-test.ps1

Lines changed: 0 additions & 95 deletions
This file was deleted.
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package com.functions;
2+
3+
import io.restassured.path.json.JsonPath;
4+
import io.restassured.response.Response;
5+
import org.junit.jupiter.api.Order;
6+
import org.junit.jupiter.api.Tag;
7+
import org.junit.jupiter.api.Test;
8+
9+
import static io.restassured.RestAssured.get;
10+
import static io.restassured.RestAssured.post;
11+
import static org.junit.jupiter.api.Assertions.*;
12+
13+
@Tag("e2e")
14+
public class EndToEndTests {
15+
private static final String hostHealthPingPath = "/admin/host/ping";
16+
private static final String startOrchestrationPath = "/api/StartOrchestration";
17+
18+
@Order(1)
19+
@Test
20+
public void setupHost() {
21+
post(hostHealthPingPath).then().statusCode(200);
22+
}
23+
24+
@Test
25+
public void basicChain() throws InterruptedException {
26+
Response response = post(startOrchestrationPath);
27+
JsonPath jsonPath = response.jsonPath();
28+
String statusQueryGetUri = jsonPath.get("statusQueryGetUri");
29+
String runTimeStatus = null;
30+
for (int i = 0; i < 15; i++) {
31+
Response statusResponse = get(statusQueryGetUri);
32+
runTimeStatus = statusResponse.jsonPath().get("runtimeStatus");
33+
if (!"Completed".equals(runTimeStatus)) {
34+
Thread.sleep(1000);
35+
} else break;
36+
}
37+
assertEquals("Completed", runTimeStatus);
38+
}
39+
}

0 commit comments

Comments
 (0)