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

Added live test for Synapse #21109

Merged
merged 1 commit into from
Mar 2, 2023
Merged
Changes from all 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
80 changes: 80 additions & 0 deletions src/Synapse/Synapse.Test/LiveTests/TestLiveScenarios.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
function GenerateDefinitionFile {
param (
[Parameter()]
[string] $File
)

$definition = [PSCustomObject]@{
name = "DataFlow"
properties = [PSCustomObject]@{
type = "MappingDataFlow"
typeProperties = [PSCustomObject]@{
sources = @()
sinks = @()
transformations = @()
scriptLines = @("")
}
}
}

ConvertTo-Json $definition -Compress -Depth 3 | Out-File -FilePath $File -Encoding utf8 -NoNewline -Force
}

Invoke-LiveTestScenario -Name "Create synapse data flow" -Description "Test creating a synapse data flow" -ScenarioScript `
{
param ($rg)

$rgName = $rg.ResourceGroupName
$wsName = New-LiveTestResourceName
$location = "eastus"
$saName = New-LiveTestStorageAccountName
$fsName = New-LiveTestStorageAccountName
$flowName = New-LiveTestResourceName
$fileName = New-LiveTestRandomName -Option AllLetters -MaxLength 8
$file = "$fileName.json"

$username = "sqladmin"
$password = ConvertTo-SecureString "Password123!" -AsPlainText -Force
$sqlAdminCred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $username, $password
New-AzSynapseWorkspace -Name $wsName -ResourceGroupName $rgName -Location $location -DefaultDataLakeStorageAccountName $saName -DefaultDataLakeStorageFilesystem $fsName -SqlAdministratorLoginCredential $sqlAdminCred
New-AzSynapseFirewallRule -WorkspaceName $wsName -AllowAllIp

Start-Sleep -Seconds 30

GenerateDefinitionFile($file)
Set-AzSynapseDataFlow -Name $flowName -WorkspaceName $wsName -DefinitionFile $file

$actual = Get-AzSynapseDataFlow -Name $flowName -WorkspaceName $wsName
Assert-NotNull $actual
Assert-AreEqual $wsName $actual.WorkspaceName
Assert-AreEqual $flowName $actual.Name
}

Invoke-LiveTestScenario -Name "Remove synapse data flow" -Description "Test removing a synapse data flow" -ScenarioScript `
{
param ($rg)

$rgName = $rg.ResourceGroupName
$wsName = New-LiveTestResourceName
$location = "eastus"
$saName = New-LiveTestStorageAccountName
$fsName = New-LiveTestStorageAccountName
$flowName = New-LiveTestResourceName
$fileName = New-LiveTestRandomName -Option AllLetters -MaxLength 8
$file = "$fileName.json"

$username = "sqladmin"
$password = ConvertTo-SecureString "Password123!" -AsPlainText -Force
$sqlAdminCred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $username, $password
New-AzSynapseWorkspace -Name $wsName -ResourceGroupName $rgName -Location $location -DefaultDataLakeStorageAccountName $saName -DefaultDataLakeStorageFilesystem $fsName -SqlAdministratorLoginCredential $sqlAdminCred
New-AzSynapseFirewallRule -WorkspaceName $wsName -AllowAllIp

Start-Sleep -Seconds 60

GenerateDefinitionFile($file)
Set-AzSynapseDataFlow -Name $flowName -WorkspaceName $wsName -DefinitionFile $file
Remove-AzSynapseDataFlow -Name $flowName -WorkspaceName $wsName -Force

$actual = Get-AzSynapseDataFlow -Name $flowName -WorkspaceName $wsName -ErrorAction SilentlyContinue
Assert-Null $actual
}