Skip to content

Commit

Permalink
Disable codeql for test coverage and reduce the frequency of live tes…
Browse files Browse the repository at this point in the history
…t for sql and synapse (#25650)
  • Loading branch information
vidai-msft authored Jul 25, 2024
1 parent 508b8c0 commit 754c9b3
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 22 deletions.
1 change: 1 addition & 0 deletions .azure-pipelines/test-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ parameters:
variables:
EnableTestCoverage: true
TestCoverageLocation: $(Pipeline.Workspace)/artifacts
Codeql.Enabled: false

pr: none
trigger: none
Expand Down
28 changes: 13 additions & 15 deletions src/Sql/Sql.Test/LiveTests/TestLiveScenarios.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Invoke-LiveTestScenario -Name "Create, get, update and remove a new SQL Server" -Description "Test on new SQL Server" -ScenarioScript `
Invoke-LiveTestScenario -Name "Create, get, update and remove a new SQL Server" -Description "Test on new SQL Server" -PowerShellVersion "5.1", "Latest" -ScenarioScript `
{
param ($rg)

Expand All @@ -11,8 +11,7 @@ Invoke-LiveTestScenario -Name "Create, get, update and remove a new SQL Server"
$actual = New-AzSqlServer -ResourceGroupName $rgName `
-ServerName $serverName `
-Location $location `
-SqlAdministratorCredentials `
$(New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $adminSqlLogin, $(ConvertTo-SecureString -String $password -AsPlainText -Force))
-SqlAdministratorCredentials $(New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $adminSqlLogin, $(ConvertTo-SecureString -String $password -AsPlainText -Force))
Assert-AreEqual $serverName $actual.ServerName
Assert-AreEqual $rgName $actual.ResourceGroupName
# Get created Sql Server
Expand All @@ -23,11 +22,11 @@ Invoke-LiveTestScenario -Name "Create, get, update and remove a new SQL Server"
$secureString = ConvertTo-SecureString $updatedPassword -AsPlainText -Force
$null = Set-AzSqlServer -ResourceGroupName $rgName -ServerName $serverName -PublicNetworkAccess Disabled
$actual = Get-AzSqlServer -ResourceGroupName $rgName -ServerName $serverName
Assert-AreEqual "Disabled" $actual.PublicNetworkAccess
Assert-AreEqual "Disabled" $actual.PublicNetworkAccess
# Remove a Sql server
$null = Remove-AzSqlServer -ResourceGroup $rgName -ServerName $serverName
$actual = Get-AzSqlServer -ResourceGroup $rgName
Assert-False { $actual.ServerName -contains $serverName}
Assert-False { $actual.ServerName -contains $serverName }
}
# After testing the cmdlets of Sql Server, create a Sql Server for sql database testing.

Expand All @@ -44,10 +43,9 @@ $ServerName = New-LiveTestResourceName
$SqlServer = New-AzSqlServer -ResourceGroupName $RgName `
-ServerName $ServerName `
-Location $ResourceGroupLocation `
-SqlAdministratorCredentials `
$(New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $AdminSqlLogin, $(ConvertTo-SecureString -String $Password -AsPlainText -Force))
-SqlAdministratorCredentials $(New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $AdminSqlLogin, $(ConvertTo-SecureString -String $Password -AsPlainText -Force))

Invoke-LiveTestScenario -Name "Create a Sql Database" -Description "Test New-AzSqlDatabase" -NoResourceGroup -ScenarioScript `
Invoke-LiveTestScenario -Name "Create a Sql Database" -Description "Test New-AzSqlDatabase" -PowerShellVersion "5.1", "Latest" -NoResourceGroup -ScenarioScript `
{
$dbName = New-LiveTestResourceName

Expand All @@ -59,19 +57,19 @@ Invoke-LiveTestScenario -Name "Create a Sql Database" -Description "Test New-AzS
Remove-AzSqlDatabase -ResourceGroupName $RgName -ServerName $ServerName -DatabaseName $dbName
}

Invoke-LiveTestScenario -Name "Get a Sql Database" -Description "Test Get-AzSqlDatabase" -NoResourceGroup -ScenarioScript `
Invoke-LiveTestScenario -Name "Get a Sql Database" -Description "Test Get-AzSqlDatabase" -PowerShellVersion "5.1", "Latest" -NoResourceGroup -ScenarioScript `
{
$dbName = New-LiveTestResourceName

$null = New-AzSqlDatabase -ResourceGroupName $RgName -ServerName $ServerName -DatabaseName $dbName
$actual = Get-AzSqlDatabase -ResourceGroupName $RgName -ServerName $ServerName -DatabaseName $dbName
$actual = Get-AzSqlDatabase -ResourceGroupName $RgName -ServerName $ServerName -DatabaseName $dbName
Assert-AreEqual $serverName $actual.ServerName
Assert-AreEqual $rgName $actual.ResourceGroupName
Assert-AreEqual $dbName $actual.DatabaseName
Remove-AzSqlDatabase -ResourceGroupName $RgName -ServerName $ServerName -DatabaseName $dbName
}

Invoke-LiveTestScenario -Name "Update a Sql Database" -Description "Test Set-AzSqlDatabase" -NoResourceGroup -ScenarioScript `
Invoke-LiveTestScenario -Name "Update a Sql Database" -Description "Test Set-AzSqlDatabase" -PowerShellVersion "5.1", "Latest" -NoResourceGroup -ScenarioScript `
{
$dbName = New-LiveTestResourceName

Expand All @@ -80,19 +78,19 @@ Invoke-LiveTestScenario -Name "Update a Sql Database" -Description "Test Set-AzS
$actual = Get-AzSqlDatabase -ResourceGroupName $RgName -ServerName $ServerName -DatabaseName $dbName
Assert-AreEqual $dbName $actual.DatabaseName
Assert-AreEqual "S0" $actual.RequestedServiceObjectiveName
Assert-AreEqual "Standard" $actual.Edition
Assert-AreEqual "Standard" $actual.Edition
Remove-AzSqlDatabase -ResourceGroupName $RgName -ServerName $ServerName -DatabaseName $dbName
}

Invoke-LiveTestScenario -Name "Remove a Sql Database" -Description "Test Remove-AzSqlDatabase" -NoResourceGroup -ScenarioScript `
Invoke-LiveTestScenario -Name "Remove a Sql Database" -Description "Test Remove-AzSqlDatabase" -PowerShellVersion "5.1", "Latest" -NoResourceGroup -ScenarioScript `
{
$dbName = New-LiveTestResourceName

$null = New-AzSqlDatabase -ResourceGroupName $RgName -ServerName $ServerName -DatabaseName $dbName
Remove-AzSqlDatabase -ResourceGroupName $RgName -ServerName $ServerName -DatabaseName $dbName
$actual = Get-AzSqlDatabase -ResourceGroupName $RgName -ServerName $ServerName

Assert-False { $actual.DatabaseName -contains $dbName}
Assert-False { $actual.DatabaseName -contains $dbName }
}
# At the end of db test, clear the resource group
Clear-LiveTestResources -Name $RgName
Clear-LiveTestResources -Name $RgName
14 changes: 7 additions & 7 deletions src/Synapse/Synapse.Test/LiveTests/TestLiveScenarios.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,22 @@ function GenerateDefinitionFile {
)

$definition = [PSCustomObject]@{
name = "DataFlow"
name = "DataFlow"
properties = [PSCustomObject]@{
type = "MappingDataFlow"
type = "MappingDataFlow"
typeProperties = [PSCustomObject]@{
sources = @()
sinks = @()
sources = @()
sinks = @()
transformations = @()
scriptLines = @("")
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 `
Invoke-LiveTestScenario -Name "Create synapse data flow" -Description "Test creating a synapse data flow" -PowerShellVersion "5.1", "Latest" -ScenarioScript `
{
param ($rg)

Expand Down Expand Up @@ -50,7 +50,7 @@ Invoke-LiveTestScenario -Name "Create synapse data flow" -Description "Test crea
Assert-AreEqual $flowName $actual.Name
}

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

Expand Down

0 comments on commit 754c9b3

Please sign in to comment.