Skip to content

Commit 0bd1d9e

Browse files
committed
Merge pull request Azure#394 from huangpf/dev
HPF PR: vmss <- huangpf:dev
2 parents b765fce + 37faca8 commit 0bd1d9e

File tree

11 files changed

+891
-885
lines changed

11 files changed

+891
-885
lines changed

src/ResourceManager/LogicApp/Commands.LogicApp.Test/Commands.LogicApp.Test.csproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,9 @@
160160
<None Include="Resources\TestSimpleWorkflowTriggerDefinition.json">
161161
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
162162
</None>
163+
<None Include="Resources\TestSimpleWorkflowTriggerDefinitionWithDelayAction.json">
164+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
165+
</None>
163166
<None Include="ScenarioTests\Common.ps1">
164167
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
165168
</None>
@@ -190,6 +193,9 @@
190193
<None Include="SessionRecords\Microsoft.Azure.Commands.LogicApp.Test.ScenarioTests.WorkflowRunTests\TestRunLogicApp.json">
191194
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
192195
</None>
196+
<None Include="SessionRecords\Microsoft.Azure.Commands.LogicApp.Test.ScenarioTests.WorkflowRunTests\TestStopAzureRmLogicAppRun.json">
197+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
198+
</None>
193199
<None Include="SessionRecords\Microsoft.Azure.Commands.LogicApp.Test.ScenarioTests.WorkflowTests\TestCreateAndGetLogicAppUsingDefinitionWithActions.json">
194200
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
195201
</None>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
{
2+
"$schema": "http://schema.management.azure.com/providers/Microsoft.Logic/schemas/2014-12-01-preview/workflowdefinition.json#",
3+
"contentVersion": "1.0.0.0",
4+
"parameters": {
5+
"runworkflowmanually": {
6+
"defaultValue": false,
7+
"type": "bool"
8+
}
9+
},
10+
"triggers": {
11+
"httpTrigger": {
12+
"type": "Http",
13+
"inputs": {
14+
"method": "GET",
15+
"uri": "http://www.bing.com"
16+
},
17+
"recurrence": {
18+
"frequency": "Hour",
19+
"interval": 1
20+
},
21+
"conditions": [
22+
{
23+
"expression": "@bool('true')"
24+
}
25+
]
26+
}
27+
},
28+
"actions": {
29+
"http": {
30+
"until": {
31+
"limit": {
32+
"timeout": "PT1H"
33+
},
34+
"conditions": [
35+
{
36+
"expression": "@bool('false')"
37+
}
38+
]
39+
},
40+
"type": "Http",
41+
"inputs": {
42+
"method": "GET",
43+
"uri": "http://www.bing.com",
44+
},
45+
"conditions": [
46+
{
47+
"expression": "@bool('true')"
48+
}
49+
]
50+
}
51+
},
52+
"outputs": {
53+
"output1": {
54+
"type": "string",
55+
"value": "true"
56+
}
57+
}
58+
}

src/ResourceManager/LogicApp/Commands.LogicApp.Test/ScenarioTests/Common.ps1

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,4 +106,17 @@ function TestSetup-CreateWorkflow ([string]$resourceGroupName, [string]$workflow
106106
$parameterFilePath = "Resources\TestSimpleWorkflowParameter.json"
107107
$workflow = $resourceGroup | New-AzureRmLogicApp -Name $workflowName -AppServicePlan $AppServicePlan -DefinitionFilePath $definitionFilePath -ParameterFilePath $parameterFilePath
108108
return $workflow
109+
}
110+
111+
<#
112+
.SYNOPSIS
113+
Sleep in record mode only
114+
#>
115+
function SleepInRecordMode ([int]$SleepIntervalInMillisec)
116+
{
117+
$mode = $env:AZURE_TEST_MODE
118+
if ( $mode.ToUpperInvariant() -eq "RECORD")
119+
{
120+
Sleep -Milliseconds $SleepIntervalInMillisec
121+
}
109122
}

src/ResourceManager/LogicApp/Commands.LogicApp.Test/ScenarioTests/WorkflowRunTests.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,5 +52,15 @@ public void TestGetAzureLogicAppRunAction()
5252
{
5353
WorkflowController.NewInstance.RunPowerShellTest("Test-GetAzureLogicAppRunAction");
5454
}
55+
56+
/// <summary>
57+
/// Test Stop-AzureRmLogicAppRun command to cancel logic app run
58+
/// </summary>
59+
[Fact]
60+
[Trait(Category.AcceptanceType, Category.CheckIn)]
61+
public void TestStopAzureRmLogicAppRun()
62+
{
63+
WorkflowController.NewInstance.RunPowerShellTest("Test-StopAzureRmLogicAppRun");
64+
}
5565
}
5666
}

src/ResourceManager/LogicApp/Commands.LogicApp.Test/ScenarioTests/WorkflowRunTests.ps1

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ function Test-StartLogicApp
3030

3131
[int]$counter = 0
3232
do {
33-
Sleep -seconds 2
33+
SleepInRecordMode 2000
3434
$workflow = Get-AzureRmLogicApp -ResourceGroupName $resourceGroupName -Name $workflowName
3535
} while ($workflow.State -ne "Enabled" -and $counter++ -lt 5)
3636

@@ -55,7 +55,7 @@ function Test-GetAzureLogicAppRunHistory
5555

5656
[int]$counter = 0
5757
do {
58-
Sleep -seconds 2
58+
SleepInRecordMode 2000
5959
$workflow = Get-AzureRmLogicApp -ResourceGroupName $resourceGroupName -Name $workflowName
6060
} while ($workflow.State -ne "Enabled" -and $counter++ -lt 5)
6161

@@ -86,7 +86,7 @@ function Test-GetAzureLogicAppRunAction
8686

8787
[int]$counter = 0
8888
do {
89-
Sleep -seconds 2
89+
SleepInRecordMode 2000
9090
$workflow = Get-AzureRmLogicApp -ResourceGroupName $resourceGroupName -Name $workflowName
9191
} while ($workflow.State -ne "Enabled" -and $counter++ -lt 5)
9292

@@ -101,5 +101,34 @@ function Test-GetAzureLogicAppRunAction
101101

102102
$action = Get-AzureRmLogicAppRunAction -ResourceGroupName $resourceGroupName -Name $workflowName -RunName $runHistory[0].Name -ActionName "http"
103103
Assert-NotNull $action
104+
}
105+
106+
<#
107+
.SYNOPSIS
108+
Test Start and Stop AzureLogicApp command for logic app workflow.
109+
#>
110+
function Test-StopAzureRmLogicAppRun
111+
{
112+
$resourceGroup = TestSetup-CreateResourceGroup
113+
$resourceGroupName = $resourceGroup.ResourceGroupName
114+
$planName = "StandardServicePlan"
115+
$Plan = TestSetup-CreateAppServicePlan $resourceGroup.ResourceGroupName $planName
116+
117+
$workflowName = getAssetname
118+
$definitionFilePath = "Resources\TestSimpleWorkflowTriggerDefinitionWithDelayAction.json"
119+
120+
$workflow = New-AzureRmLogicApp -ResourceGroupName $resourceGroupName -Name $workflowName -DefinitionFilePath $definitionFilePath -AppServicePlan $planName
121+
122+
[int]$counter = 0
123+
do {
124+
SleepInRecordMode 2000
125+
$workflow = Get-AzureRmLogicApp -ResourceGroupName $resourceGroupName -Name $workflowName
126+
} while ($workflow.State -ne "Enabled" -and $counter++ -lt 5)
127+
128+
Start-AzureRmLogicApp -ResourceGroupName $resourceGroupName -Name $workflowName -TriggerName "httpTrigger"
129+
130+
$runHistory = Get-AzureRmLogicAppRunHistory -ResourceGroupName $resourceGroupName -Name $workflowName
131+
132+
Stop-AzureRmLogicAppRun -ResourceGroupName $resourceGroupName -Name $workflowName -RunName $runHistory[0].Name
104133

105134
}

src/ResourceManager/LogicApp/Commands.LogicApp.Test/ScenarioTests/WorkflowTriggerTests.ps1

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ function Test-GetAzureLogicAppTriggerHistory
5353

5454
[int]$counter = 0
5555
do {
56-
Sleep -seconds 2
56+
SleepInRecordMode 2000
5757
$workflow = Get-AzureRmLogicApp -ResourceGroupName $resourceGroupName -Name $workflowName
58-
} while ($workflow.State -ne "Enabled" -or $counter++ -lt 5)
58+
} while ($workflow.State -ne "Enabled" -and $counter++ -lt 5)
5959

6060
Start-AzureRmLogicApp -ResourceGroupName $resourceGroupName -Name $workflowName -TriggerName "httpTrigger"
6161

@@ -85,20 +85,13 @@ function Test-StartAzureLogicAppTrigger
8585

8686
[int]$counter = 0
8787
do {
88-
Sleep -seconds 2
88+
SleepInRecordMode 2000
8989
$workflow = Get-AzureRmLogicApp -ResourceGroupName $resourceGroupName -Name $workflowName
90-
} while ($workflow.State -ne "Enabled" -or $counter++ -lt 5)
90+
} while ($workflow.State -ne "Enabled" -and $counter++ -lt 5)
9191

92-
$workflowTriggerHistories1 = Get-AzureRmLogicAppTriggerHistory -ResourceGroupName $resourceGroupName -Name $workflowName -TriggerName "httpTrigger"
93-
$counter = 2
94-
while($val -lt $counter)
95-
{
96-
Start-AzureRmLogicApp -ResourceGroupName $resourceGroupName -Name $workflowName -TriggerName "httpTrigger"
97-
Sleep -seconds 1
98-
$val++
99-
}
92+
Start-AzureRmLogicApp -ResourceGroupName $resourceGroupName -Name $workflowName -TriggerName "httpTrigger"
10093

101-
$workflowTriggerHistories2 = Get-AzureRmLogicAppTriggerHistory -ResourceGroupName $resourceGroupName -Name $workflowName -TriggerName "httpTrigger"
102-
$count = $workflowTriggerHistories2.Count - $workflowTriggerHistories1.Count
103-
Assert-AreEqual $counter $count
94+
$workflowTriggerHistories = Get-AzureRmLogicAppTriggerHistory -ResourceGroupName $resourceGroupName -Name $workflowName -TriggerName "httpTrigger"
95+
96+
Assert-AreEqual 1 $workflowTriggerHistories.Count
10497
}

0 commit comments

Comments
 (0)