Skip to content

Commit ea9ac21

Browse files
idear1203Dongwei Wang
andauthored
[Synapse] - Use Az Powershell defined exception types and refine test cases (Azure#14361)
* [Synapse] - Use Az PowerShell defined exception and re-record test cases * Update help doc for Restore-AzSynapseSqlPool * Update changelog * Remove TODO comment * Update session records * Fix CI MacOS build error * Update breaking change issues Co-authored-by: Dongwei Wang <[email protected]>
1 parent 9a5e18f commit ea9ac21

File tree

67 files changed

+23332
-11737
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+23332
-11737
lines changed

src/Synapse/Synapse.Test/ScenarioTests/Common.ps1

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,20 @@ function Invoke-HandledCmdlet
114114

115115
<#
116116
.SYNOPSIS
117-
Creates the test environment needed to perform the Sql auditing tests
117+
Creates the test environment needed to perform the Synapse SQL related tests
118118
#>
119-
function Create-TestEnvironmentWithParams ($params, $location, $denyAsNetworkRuleDefaultAction = $False)
119+
function Create-SqlTestEnvironmentWithParams ($params, $location)
120+
{
121+
Create-BasicTestEnvironmentWithParams $params $location
122+
New-AzSynapseSqlPool -ResourceGroupName $params.rgname -WorkspaceName $params.workspaceName -SqlPoolName $params.sqlPoolName -PerformanceLevel $params.perfLevel
123+
Wait-Seconds 10
124+
}
125+
126+
<#
127+
.SYNOPSIS
128+
Creates the test environment needed to perform the Synapse tests
129+
#>
130+
function Create-TestEnvironmentWithParams ($params, $location)
120131
{
121132
Create-BasicTestEnvironmentWithParams $params $location
122133
Wait-Seconds 10
@@ -135,5 +146,4 @@ function Create-BasicTestEnvironmentWithParams ($params, $location)
135146
$workspacePassword = $params.pwd
136147
$credentials = new-object System.Management.Automation.PSCredential($workspaceLogin, ($workspacePassword | ConvertTo-SecureString -asPlainText -Force))
137148
New-AzSynapseWorkspace -ResourceGroupName $params.rgname -WorkspaceName $params.workspaceName -Location $location -SqlAdministratorLoginCredential $credentials -DefaultDataLakeStorageAccountName $params.storageAccountName -DefaultDataLakeStorageFilesystem $params.fileSystemName
138-
New-AzSynapseSqlPool -ResourceGroupName $params.rgname -WorkspaceName $params.workspaceName -SqlPoolName $params.sqlPoolName -PerformanceLevel $params.perfLevel
139149
}

src/Synapse/Synapse.Test/ScenarioTests/FirewallTests.cs

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -32,25 +32,9 @@ public FirewallTests(Xunit.Abstractions.ITestOutputHelper output)
3232
[Trait(Category.AcceptanceType, Category.CheckIn)]
3333
public void TestSynapseFirewall()
3434
{
35-
string testResourceGroupName = SynapseTestBase.TestResourceGroupName;
36-
if (string.IsNullOrEmpty(testResourceGroupName))
37-
{
38-
testResourceGroupName = nameof(TestResourceGroupName);
39-
}
40-
41-
string testWorkspaceName = SynapseTestBase.TestWorkspaceName;
42-
if (string.IsNullOrEmpty(testWorkspaceName))
43-
{
44-
testWorkspaceName = nameof(TestWorkspaceName);
45-
}
46-
4735
SynapseTestBase.NewInstance.RunPsTest(
4836
_logger,
49-
string.Format(
50-
"Test-SynapseFirewall -resourceGroupName '{0}' -workspaceName '{1}'",
51-
"testResourceGroupName",
52-
"testWorkspaceName"
53-
));
37+
"Test-SynapseFirewall");
5438
}
5539
}
5640
}

src/Synapse/Synapse.Test/ScenarioTests/FirewallTests.ps1

Lines changed: 45 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@ Tests Synapse Firewall Lifecycle (Create, Update, Get, List, Delete).
44
#>
55
function Test-SynapseFirewall
66
{
7-
param
8-
(
9-
$resourceGroupName = (Get-ResourceGroupName),
10-
$workspaceName = (Get-SynapseWorkspaceName)
11-
)
7+
# Setup
8+
$testSuffix = getAssetName
9+
Create-FirewallRuleTestEnvironment $testSuffix
10+
$params = Get-FirewallRuleTestEnvironmentParameters $testSuffix
11+
12+
$resourceGroupName = $params.rgname
13+
$workspaceName = $params.workspaceName
1214

1315
try
1416
{
15-
$resourceGroupName = [Microsoft.Azure.Test.HttpRecorder.HttpMockServer]::GetVariable("resourceGroupName", $resourceGroupName)
16-
$workspaceName = [Microsoft.Azure.Test.HttpRecorder.HttpMockServer]::GetVariable("workspaceName", $workspaceName)
1717
$workspace = Get-AzSynapseWorkspace -resourceGroupName $resourceGroupName -Name $workspaceName
1818
$firewallRuleName = "originRuleName"
1919
$StartIpAddress = "0.0.0.0"
@@ -51,6 +51,43 @@ function Test-SynapseFirewall
5151
}
5252
finally
5353
{
54-
# cleanup the firewallRuleName created by test code.
54+
# Cleanup
55+
Remove-FirewallRuleTestEnvironment $testSuffix
5556
}
5657
}
58+
59+
<#
60+
.SYNOPSIS
61+
Creates the test environment needed to perform the tests
62+
#>
63+
function Create-FirewallRuleTestEnvironment ($testSuffix)
64+
{
65+
$params = Get-FirewallRuleTestEnvironmentParameters $testSuffix
66+
Create-TestEnvironmentWithParams $params $params.location
67+
}
68+
69+
<#
70+
.SYNOPSIS
71+
Gets the values of the parameters used at the tests
72+
#>
73+
function Get-FirewallRuleTestEnvironmentParameters ($testSuffix)
74+
{
75+
return @{ rgname = "fw-cmdlet-test-rg" +$testSuffix;
76+
workspaceName = "fw" +$testSuffix;
77+
storageAccountName = "fwstorage" + $testSuffix;
78+
fileSystemName = "fwcmdletfs" + $testSuffix;
79+
loginName = "testlogin";
80+
pwd = "testp@ssMakingIt1007Longer";
81+
location = "westcentralus";
82+
}
83+
}
84+
85+
<#
86+
.SYNOPSIS
87+
Removes the test environment that was needed to perform the tests
88+
#>
89+
function Remove-FirewallRuleTestEnvironment ($testSuffix)
90+
{
91+
$params = Get-FirewallRuleTestEnvironmentParameters $testSuffix
92+
Remove-AzResourceGroup -Name $params.rgname -Force
93+
}

src/Synapse/Synapse.Test/ScenarioTests/IntegrationRuntimeTests.cs

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -32,24 +32,9 @@ public IntegrationRuntimeTests(Xunit.Abstractions.ITestOutputHelper output)
3232
[Trait(Category.AcceptanceType, Category.CheckIn)]
3333
public void TestSelfHostedIntegrationRuntime()
3434
{
35-
string testResourceGroupName = SynapseTestBase.TestResourceGroupName;
36-
if (string.IsNullOrEmpty(testResourceGroupName))
37-
{
38-
testResourceGroupName = nameof(TestResourceGroupName);
39-
}
40-
41-
string testWorkspaceName = SynapseTestBase.TestWorkspaceName;
42-
if (string.IsNullOrEmpty(testWorkspaceName))
43-
{
44-
testWorkspaceName = nameof(TestWorkspaceName);
45-
}
46-
4735
SynapseTestBase.NewInstance.RunPsTest(
4836
_logger,
49-
string.Format(
50-
"Test-SelfHosted-IntegrationRuntime -resourceGroupName '{0}' -workspaceName '{1}'",
51-
testResourceGroupName,
52-
testWorkspaceName));
37+
"Test-SelfHosted-IntegrationRuntime");
5338
}
5439

5540
[Fact]
@@ -70,10 +55,7 @@ public void TestAzureIntegrationRuntime()
7055

7156
SynapseTestBase.NewInstance.RunPsTest(
7257
_logger,
73-
string.Format(
74-
"Test-Azure-IntegrationRuntime -resourceGroupName '{0}' -workspaceName '{1}'",
75-
testResourceGroupName,
76-
testWorkspaceName));
58+
"Test-Azure-IntegrationRuntime");
7759
}
7860

7961
[Fact]

src/Synapse/Synapse.Test/ScenarioTests/IntegrationRuntimeTests.ps1

Lines changed: 66 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,17 @@ Deletes the created integration runtime at the end.
55
#>
66
function Test-SelfHosted-IntegrationRuntime
77
{
8-
param
9-
(
10-
$resourceGroupName = (Get-ResourceGroupName),
11-
$workspaceName = (Get-SynapseWorkspaceName),
12-
$irname = "selfhosted-test-integrationruntime"
13-
)
8+
# Setup
9+
$testSuffix = getAssetName
10+
Create-WorkspaceTestEnvironment $testSuffix
11+
$params = Get-WorkspaceTestEnvironmentParameters $testSuffix
12+
13+
$resourceGroupName = $params.rgname
14+
$workspaceName = $params.workspaceName
15+
$irname = "selfhosted-test-integrationruntime"
1416

1517
try
1618
{
17-
$resourceGroupName = [Microsoft.Azure.Test.HttpRecorder.HttpMockServer]::GetVariable("resourceGroupName", $resourceGroupName)
18-
$workspaceName = [Microsoft.Azure.Test.HttpRecorder.HttpMockServer]::GetVariable("workspaceName", $workspaceName)
19-
2019
$actual = Set-AzSynapseIntegrationRuntime -ResourceGroupName $resourceGroupName `
2120
-WorkspaceName $workspaceName `
2221
-Name $irname `
@@ -58,7 +57,8 @@ function Test-SelfHosted-IntegrationRuntime
5857
}
5958
finally
6059
{
61-
Invoke-HandledCmdlet -Command {Remove-AzSynapseIntegrationRuntime -ResourceGroupName $resourceGroupName -WorkspaceName $workspaceName -Name $irname} -IgnoreFailures
60+
# Cleanup
61+
Remove-WorkspaceTestEnvironment $testSuffix
6262
}
6363
}
6464

@@ -69,18 +69,17 @@ Deletes the created integration runtime at the end.
6969
#>
7070
function Test-Azure-IntegrationRuntime
7171
{
72-
param
73-
(
74-
$resourceGroupName = (Get-ResourceGroupName),
75-
$workspaceName = (Get-SynapseWorkspaceName),
76-
$irname = "test-ManagedElastic-integrationruntime"
77-
)
72+
# Setup
73+
$testSuffix = getAssetName
74+
Create-WorkspaceTestEnvironment $testSuffix
75+
$params = Get-WorkspaceTestEnvironmentParameters $testSuffix
76+
77+
$resourceGroupName = $params.rgname
78+
$workspaceName = $params.workspaceName
79+
$irname = "test-ManagedElastic-integrationruntime"
7880

7981
try
8082
{
81-
$resourceGroupName = [Microsoft.Azure.Test.HttpRecorder.HttpMockServer]::GetVariable("resourceGroupName", $resourceGroupName)
82-
$workspaceName = [Microsoft.Azure.Test.HttpRecorder.HttpMockServer]::GetVariable("workspaceName", $workspaceName)
83-
8483
$description = "ManagedElastic"
8584

8685
$actual = Set-AzSynapseIntegrationRuntime -ResourceGroupName $resourceGroupName `
@@ -100,7 +99,8 @@ function Test-Azure-IntegrationRuntime
10099
}
101100
finally
102101
{
103-
Invoke-HandledCmdlet -Command {Remove-AzSynapseIntegrationRuntime -ResourceGroupName $resourceGroupName -WorkspaceName $workspaceName -Name $irname} -IgnoreFailures
102+
# Cleanup
103+
Remove-WorkspaceTestEnvironment $testSuffix
104104
}
105105
}
106106

@@ -110,18 +110,17 @@ Creates a self-hosted integration runtime and then does piping operations.
110110
#>
111111
function Test-IntegrationRuntime-Piping
112112
{
113-
param
114-
(
115-
$resourceGroupName = (Get-ResourceGroupName),
116-
$workspaceName = (Get-SynapseWorkspaceName),
117-
$irname = "test-integrationruntime-for-piping"
118-
)
113+
# Setup
114+
$testSuffix = getAssetName
115+
Create-WorkspaceTestEnvironment $testSuffix
116+
$params = Get-WorkspaceTestEnvironmentParameters $testSuffix
117+
118+
$resourceGroupName = $params.rgname
119+
$workspaceName = $params.workspaceName
120+
$irname = "test-integrationruntime-for-piping"
119121

120122
try
121123
{
122-
$resourceGroupName = [Microsoft.Azure.Test.HttpRecorder.HttpMockServer]::GetVariable("resourceGroupName", $resourceGroupName)
123-
$workspaceName = [Microsoft.Azure.Test.HttpRecorder.HttpMockServer]::GetVariable("workspaceName", $workspaceName)
124-
125124
$result = Set-AzSynapseIntegrationRuntime -ResourceGroupName $resourceGroupName `
126125
-WorkspaceName $workspaceName `
127126
-Name $irname `
@@ -136,6 +135,43 @@ function Test-IntegrationRuntime-Piping
136135
}
137136
finally
138137
{
139-
Invoke-HandledCmdlet -Command {Remove-AzSynapseIntegrationRuntime -ResourceGroupName $resourceGroupName -WorkspaceName $workspaceName -Name $irname} -IgnoreFailures
138+
# Cleanup
139+
Remove-WorkspaceTestEnvironment $testSuffix
140140
}
141+
}
142+
143+
<#
144+
.SYNOPSIS
145+
Creates the test environment needed to perform the tests
146+
#>
147+
function Create-WorkspaceTestEnvironment ($testSuffix)
148+
{
149+
$params = Get-WorkspaceTestEnvironmentParameters $testSuffix
150+
Create-TestEnvironmentWithParams $params $params.location
151+
}
152+
153+
<#
154+
.SYNOPSIS
155+
Gets the values of the parameters used at the tests
156+
#>
157+
function Get-WorkspaceTestEnvironmentParameters ($testSuffix)
158+
{
159+
return @{ rgname = "ws-cmdlet-test-rg" +$testSuffix;
160+
workspaceName = "ws" +$testSuffix;
161+
storageAccountName = "wsstorage" + $testSuffix;
162+
fileSystemName = "wscmdletfs" + $testSuffix;
163+
loginName = "testlogin";
164+
pwd = "testp@ssMakingIt1007Longer";
165+
location = "westcentralus";
166+
}
167+
}
168+
169+
<#
170+
.SYNOPSIS
171+
Removes the test environment that was needed to perform the tests
172+
#>
173+
function Remove-WorkspaceTestEnvironment ($testSuffix)
174+
{
175+
$params = Get-WorkspaceTestEnvironmentParameters $testSuffix
176+
Remove-AzResourceGroup -Name $params.rgname -Force
141177
}

src/Synapse/Synapse.Test/ScenarioTests/SparkPoolTests.cs

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -32,24 +32,9 @@ public SparkPoolTests(Xunit.Abstractions.ITestOutputHelper output)
3232
[Trait(Category.AcceptanceType, Category.CheckIn)]
3333
public void TestSynapseSparkPool()
3434
{
35-
string testResourceGroupName = SynapseTestBase.TestResourceGroupName;
36-
if (string.IsNullOrEmpty(testResourceGroupName))
37-
{
38-
testResourceGroupName = nameof(TestResourceGroupName);
39-
}
40-
41-
string testWorkspaceName = SynapseTestBase.TestWorkspaceName;
42-
if (string.IsNullOrEmpty(testWorkspaceName))
43-
{
44-
testWorkspaceName = nameof(TestWorkspaceName);
45-
}
46-
4735
SynapseTestBase.NewInstance.RunPsTest(
4836
_logger,
49-
string.Format(
50-
"Test-SynapseSparkPool -resourceGroupName '{0}' -workspaceName '{1}'",
51-
testResourceGroupName,
52-
testWorkspaceName));
37+
"Test-SynapseSparkPool");
5338
}
5439
}
5540
}

0 commit comments

Comments
 (0)