Skip to content
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

[DataFactory] Add 2 New commands to ADF V2 #13114

Merged
merged 7 commits into from
Oct 21, 2020
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/DataFactory/DataFactoryV2.Test/Resources/pipelineWait.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"properties": {
"activities": [
{
"name": "Wait1",
"type": "Wait",
"dependsOn": [],
"userProperties": [],
"typeProperties": {
"waitTimeInSeconds": 10
}
}
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"properties": {
"type": "TumblingWindowTrigger",
"typeProperties": {
"frequency": "Minute",
"interval": 15,
"startTime": "2019-09-10T13:00:00Z",
"endtime": "2019-09-14T13:00:00Z",
"maxConcurrency": 2
},
"pipeline": {
"pipelineReference": {
"referenceName": "samplePipeline",
"type": "PipelineReference"
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@ public void TestStartTriggerThrowsWithoutPipeline()
RunPowerShellTest(_logger, "Test-StartTriggerThrowsWithoutPipeline");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestInvokeAndStopTriggerRun()
{
RunPowerShellTest(_logger, "Test-TriggerInvokeAndStop");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestTriggerRun()
Expand Down
67 changes: 67 additions & 0 deletions src/DataFactory/DataFactoryV2.Test/ScenarioTests/TriggerTests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,73 @@ function Test-BlobEventTriggerSubscriptionsByResourceId
}
}

<#
.SYNOPSIS
Creates a TumblingWindow trigger and then does a Get to compare the results.
Starts and checks that there is at least one Trigger Run
Reruns the trigger run
Stops trigger
Deletes the created trigger at the end.
#>
function Test-TriggerInvokeAndStop
{
$dfname = Get-DataFactoryName
$rgname = Get-ResourceGroupName
$rglocation = Get-ProviderLocation ResourceManagement
$dflocation = Get-ProviderLocation DataFactoryManagement

New-AzResourceGroup -Name $rgname -Location $rglocation -Force

try
{
Get-Command -Name '*AzDataFactoryV2Tr*' | Write-Debug
Set-AzDataFactoryV2 -ResourceGroupName $rgname -Name $dfname -Location $dflocation -Force

$pipelineName = "samplePipeline"
Set-AzDataFactoryV2Pipeline -ResourceGroupName $rgname -Name $pipelineName -DataFactoryName $dfname -File .\Resources\pipelineWait.json -Force

$triggername = "foo"
$expected = Set-AzDataFactoryV2Trigger -ResourceGroupName $rgname -DataFactoryName $dfname -Name $triggername -File .\Resources\tumblingTriggerWithPipeline.json -Force
$actual = Get-AzDataFactoryV2Trigger -ResourceGroupName $rgname -DataFactoryName $dfname -Name $triggername

Verify-Trigger $expected $actual $rgname $dfname $triggername

$startDate = [DateTime]::Parse("09/10/2020")
Start-AzDataFactoryV2Trigger -ResourceGroupName $rgname -DataFactoryName $dfname -Name $triggername -Force
$started = Get-AzDataFactoryV2Trigger -ResourceGroupName $rgname -DataFactoryName $dfname -Name $triggername

Assert-AreEqual 'Started' $started.RuntimeState

if ([Microsoft.Azure.Test.HttpRecorder.HttpMockServer]::Mode -ne [Microsoft.Azure.Test.HttpRecorder.HttpRecorderMode]::Playback) {
Start-Sleep -s 150
}

$endDate = $startDate.AddYears(1)
$triggerRuns = Get-AzDataFactoryV2TriggerRun -ResourceGroupName $rgname -DataFactoryName $dfname -TriggerName $triggername -TriggerRunStartedAfter $startDate -TriggerRunStartedBefore $endDate

if($triggerRuns.Count -lt 1)
{
throw "Expected atleast 1 trigger run"
}

$triggerRunId = $triggerRuns[0].TriggerRunId
Invoke-AzDataFactoryV2TriggerRun -ResourceGroupName $rgname -DataFactoryName $dfname -TriggerName $triggername -TriggerRunId $triggerRunId

Assert-ThrowsContains { Stop-AzDataFactoryV2TriggerRun -ResourceGroupName $rgname -DataFactoryName $dfname -TriggerName $triggername -TriggerRunId $triggerRunId } "not in WaitingOnDependency state"

Stop-AzDataFactoryV2Trigger -ResourceGroupName $rgname -DataFactoryName $dfname -Name $triggername -Force
$stopped = Get-AzDataFactoryV2Trigger -ResourceGroupName $rgname -DataFactoryName $dfname -Name $triggername

Assert-AreEqual 'Stopped' $stopped.RuntimeState

Remove-AzDataFactoryV2Trigger -ResourceGroupName $rgname -DataFactoryName $dfname -Name $triggername -Force
}
finally
{
CleanUp $rgname $dfname
}
}

<#
.SYNOPSIS
Creates a trigger and then does a Get with resource id to compare the results.
Expand Down
Loading