Skip to content

Commit 946ea37

Browse files
committed
develop E2E tests
1 parent d916d58 commit 946ea37

File tree

8 files changed

+127
-0
lines changed

8 files changed

+127
-0
lines changed

src/DurableWorker/DurableController.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@ public string GetOrchestrationParameterName()
5757

5858
public void InitializeBindings(IList<ParameterBinding> inputData)
5959
{
60+
61+
this.pwsh.AddCommand("Import-Module")
62+
.AddParameter("Name", "DurableSDK")
63+
.InvokeAndClearCommands<Action<object>>();
64+
6065
// If the function is an orchestration client, then we set the DurableClient
6166
// in the module context for the 'Start-DurableOrchestration' function to use.
6267
if (_durableFunctionInfo.IsDurableClient)

test/E2E/Azure.Functions.PowerShellWorker.E2E/Azure.Functions.PowerShellWorker.E2E/DurableEndToEndTests.cs

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,58 @@ public async Task LegacyDurableCommandNamesStillWork()
147147
}
148148
}
149149

150+
[Fact]
151+
public async Task OrchestratationContextHasAllExpectedProperties()
152+
{
153+
var initialResponse = await Utilities.GetHttpTriggerResponse("DurableClientOrchContextProperties", queryString: string.Empty);
154+
Assert.Equal(HttpStatusCode.Accepted, initialResponse.StatusCode);
155+
156+
var initialResponseBody = await initialResponse.Content.ReadAsStringAsync();
157+
dynamic initialResponseBodyObject = JsonConvert.DeserializeObject(initialResponseBody);
158+
var statusQueryGetUri = (string)initialResponseBodyObject.statusQueryGetUri;
159+
160+
var startTime = DateTime.UtcNow;
161+
162+
using (var httpClient = new HttpClient())
163+
{
164+
while (true)
165+
{
166+
var statusResponse = await httpClient.GetAsync(statusQueryGetUri);
167+
switch (statusResponse.StatusCode)
168+
{
169+
case HttpStatusCode.Accepted:
170+
{
171+
var statusResponseBody = await GetResponseBodyAsync(statusResponse);
172+
var runtimeStatus = (string)statusResponseBody.runtimeStatus;
173+
Assert.True(
174+
runtimeStatus == "Running" || runtimeStatus == "Pending",
175+
$"Unexpected runtime status: {runtimeStatus}");
176+
177+
if (DateTime.UtcNow > startTime + _orchestrationCompletionTimeout)
178+
{
179+
Assert.True(false, $"The orchestration has not completed after {_orchestrationCompletionTimeout}");
180+
}
181+
182+
await Task.Delay(TimeSpan.FromSeconds(2));
183+
break;
184+
}
185+
186+
case HttpStatusCode.OK:
187+
{
188+
var statusResponseBody = await GetResponseBodyAsync(statusResponse);
189+
Assert.Equal("Completed", (string)statusResponseBody.runtimeStatus);
190+
Assert.Equal("myInstanceId", statusResponseBody.output[0].ToString());
191+
return;
192+
}
193+
194+
default:
195+
Assert.True(false, $"Unexpected orchestration status code: {statusResponse.StatusCode}");
196+
break;
197+
}
198+
}
199+
}
200+
}
201+
150202
[Fact]
151203
public async Task ActivityCanHaveQueueBinding()
152204
{
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"bindings": [
3+
{
4+
"authLevel": "function",
5+
"name": "Request",
6+
"type": "httpTrigger",
7+
"direction": "in",
8+
"methods": [
9+
"post",
10+
"get"
11+
]
12+
},
13+
{
14+
"type": "http",
15+
"direction": "out",
16+
"name": "Response"
17+
},
18+
{
19+
"name": "starter",
20+
"type": "durableClient",
21+
"direction": "in"
22+
}
23+
]
24+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
using namespace System.Net
2+
3+
param($Request, $TriggerMetadata)
4+
5+
$FunctionName = $Request.Params.FunctionName
6+
$InstanceId = Start-DurableOrchestration -FunctionName "DurableOrchestratorAccessContextProps" -InstanceId "myInstanceId"
7+
Write-Host "Started orchestration with ID = '$InstanceId'"
8+
9+
$Response = New-DurableOrchestrationCheckStatusResponse -Request $Request -InstanceId $InstanceId
10+
Push-OutputBinding -Name Response -Value $Response
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"bindings": [
3+
{
4+
"name": "Context",
5+
"type": "orchestrationTrigger",
6+
"direction": "in"
7+
}
8+
]
9+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
param($Context)
2+
3+
$output = @()
4+
5+
$Context.InstanceId
6+
$Context.IsReplaying
7+
$output += Invoke-DurableActivity -FunctionName 'DurableActivity' -Input $Context.InstanceId
8+
$Context.IsReplaying
9+
$output
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"bindings": [
3+
{
4+
"name": "Context",
5+
"type": "orchestrationTrigger",
6+
"direction": "in"
7+
}
8+
]
9+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
param($Context)
2+
3+
$output = @()
4+
5+
$output += Invoke-DurableActivity -FunctionName 'Hello' -Input 'Tokyo'
6+
$output += Invoke-DurableActivity -FunctionName 'Hello' -Input 'Seattle'
7+
$output += Invoke-DurableActivity -FunctionName 'Hello' -Input 'London'
8+
9+
$output

0 commit comments

Comments
 (0)