Skip to content

Commit 49d95fd

Browse files
wonnerWan Yang
andauthored
[Synapse] Add integration runtime management cmdlets (#12647)
* add support for integration runtime * update help doc * fix resources * fix signature issues * fix csv format * fix signature issues * add test cases * update signature issues * update test cases * update signature issues Co-authored-by: Wan Yang <[email protected]>
1 parent 821adc9 commit 49d95fd

File tree

53 files changed

+9396
-1
lines changed

Some content is hidden

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

53 files changed

+9396
-1
lines changed
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
namespace Microsoft.Azure.Commands.Synapse.Test.ScenarioTests
16+
{
17+
using Microsoft.WindowsAzure.Commands.ScenarioTest;
18+
using ServiceManagement.Common.Models;
19+
using Xunit;
20+
21+
public class IntegrationRuntimeTests : SynapseTestBase
22+
{
23+
public XunitTracingInterceptor _logger;
24+
25+
public IntegrationRuntimeTests(Xunit.Abstractions.ITestOutputHelper output)
26+
{
27+
_logger = new XunitTracingInterceptor(output);
28+
XunitTracingInterceptor.AddToContext(_logger);
29+
}
30+
31+
[Fact]
32+
[Trait(Category.AcceptanceType, Category.CheckIn)]
33+
public void TestSelfHostedIntegrationRuntime()
34+
{
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+
47+
SynapseTestBase.NewInstance.RunPsTest(
48+
_logger,
49+
string.Format(
50+
"Test-SelfHosted-IntegrationRuntime -resourceGroupName '{0}' -workspaceName '{1}'",
51+
testResourceGroupName,
52+
testWorkspaceName));
53+
}
54+
55+
[Fact]
56+
[Trait(Category.AcceptanceType, Category.CheckIn)]
57+
public void TestAzureIntegrationRuntime()
58+
{
59+
string testResourceGroupName = SynapseTestBase.TestResourceGroupName;
60+
if (string.IsNullOrEmpty(testResourceGroupName))
61+
{
62+
testResourceGroupName = nameof(TestResourceGroupName);
63+
}
64+
65+
string testWorkspaceName = SynapseTestBase.TestWorkspaceName;
66+
if (string.IsNullOrEmpty(testWorkspaceName))
67+
{
68+
testWorkspaceName = nameof(TestWorkspaceName);
69+
}
70+
71+
SynapseTestBase.NewInstance.RunPsTest(
72+
_logger,
73+
string.Format(
74+
"Test-Azure-IntegrationRuntime -resourceGroupName '{0}' -workspaceName '{1}'",
75+
testResourceGroupName,
76+
testWorkspaceName));
77+
}
78+
79+
[Fact]
80+
[Trait(Category.AcceptanceType, Category.CheckIn)]
81+
public void TestIntegrationRuntimePiping()
82+
{
83+
string testResourceGroupName = SynapseTestBase.TestResourceGroupName;
84+
if (string.IsNullOrEmpty(testResourceGroupName))
85+
{
86+
testResourceGroupName = nameof(TestResourceGroupName);
87+
}
88+
89+
string testWorkspaceName = SynapseTestBase.TestWorkspaceName;
90+
if (string.IsNullOrEmpty(testWorkspaceName))
91+
{
92+
testWorkspaceName = nameof(TestWorkspaceName);
93+
}
94+
95+
SynapseTestBase.NewInstance.RunPsTest(
96+
_logger,
97+
string.Format(
98+
"Test-IntegrationRuntime-Piping -resourceGroupName '{0}' -workspaceName '{1}'",
99+
testResourceGroupName,
100+
testWorkspaceName));
101+
}
102+
}
103+
}
Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
<#
2+
.SYNOPSIS
3+
Creates a self-hosted integration runtime and then does operations.
4+
Deletes the created integration runtime at the end.
5+
#>
6+
function Test-SelfHosted-IntegrationRuntime
7+
{
8+
param
9+
(
10+
$resourceGroupName = (Get-ResourceGroupName),
11+
$workspaceName = (Get-SynapseWorkspaceName),
12+
$irname = "selfhosted-test-integrationruntime"
13+
)
14+
15+
try
16+
{
17+
$resourceGroupName = [Microsoft.Azure.Test.HttpRecorder.HttpMockServer]::GetVariable("resourceGroupName", $resourceGroupName)
18+
$workspaceName = [Microsoft.Azure.Test.HttpRecorder.HttpMockServer]::GetVariable("workspaceName", $workspaceName)
19+
20+
$actual = Set-AzSynapseIntegrationRuntime -ResourceGroupName $resourceGroupName `
21+
-WorkspaceName $workspaceName `
22+
-Name $irname `
23+
-Type 'SelfHosted' `
24+
-Force
25+
Assert-AreEqual $actual.Name $irname
26+
27+
$expected = Get-AzSynapseIntegrationRuntime -ResourceGroupName $resourceGroupName `
28+
-WorkspaceName $workspaceName `
29+
-Name $irname
30+
Assert-AreEqual $actual.Name $expected.Name
31+
32+
$expected = Get-AzSynapseIntegrationRuntime -ResourceId $actual.Id
33+
Assert-AreEqual $actual.Name $expected.Name
34+
35+
$status = Get-AzSynapseIntegrationRuntime -ResourceId $actual.Id -Status
36+
Assert-NotNull $status
37+
38+
$metric = Get-AzSynapseIntegrationRuntimeMetric -ResourceGroupName $resourceGroupName `
39+
-WorkspaceName $workspaceName `
40+
-Name $irname
41+
Assert-NotNull $metric
42+
43+
$description = "description"
44+
$result = Set-AzSynapseIntegrationRuntime -ResourceGroupName $resourceGroupName `
45+
-WorkspaceName $workspaceName `
46+
-Name $irname `
47+
-Description $description `
48+
-Force
49+
Assert-AreEqual $result.Description $description
50+
51+
$status = Get-AzSynapseIntegrationRuntime -ResourceGroupName $resourceGroupName `
52+
-WorkspaceName $workspaceName `
53+
-Name $irname `
54+
-Status
55+
Assert-NotNull $status.LatestVersion
56+
57+
Remove-AzSynapseIntegrationRuntime -ResourceId $actual.Id -Force
58+
}
59+
finally
60+
{
61+
Invoke-HandledCmdlet -Command {Remove-AzSynapseIntegrationRuntime -ResourceGroupName $resourceGroupName -WorkspaceName $workspaceName -Name $irname} -IgnoreFailures
62+
}
63+
}
64+
65+
<#
66+
.SYNOPSIS
67+
Creates an azure integration runtime and then does operations.
68+
Deletes the created integration runtime at the end.
69+
#>
70+
function Test-Azure-IntegrationRuntime
71+
{
72+
param
73+
(
74+
$resourceGroupName = (Get-ResourceGroupName),
75+
$workspaceName = (Get-SynapseWorkspaceName),
76+
$irname = "test-ManagedElastic-integrationruntime"
77+
)
78+
79+
try
80+
{
81+
$resourceGroupName = [Microsoft.Azure.Test.HttpRecorder.HttpMockServer]::GetVariable("resourceGroupName", $resourceGroupName)
82+
$workspaceName = [Microsoft.Azure.Test.HttpRecorder.HttpMockServer]::GetVariable("workspaceName", $workspaceName)
83+
84+
$description = "ManagedElastic"
85+
86+
$actual = Set-AzSynapseIntegrationRuntime -ResourceGroupName $resourceGroupName `
87+
-WorkspaceName $workspaceName `
88+
-Name $irname `
89+
-Type Managed `
90+
-Description $description `
91+
-Force
92+
93+
$expected = Get-AzSynapseIntegrationRuntime -ResourceGroupName $resourceGroupName `
94+
-WorkspaceName $workspaceName `
95+
-Name $irname
96+
Assert-AreEqual $actual.Name $expected.Name
97+
Get-AzSynapseIntegrationRuntime -ResourceId $actual.Id -Status
98+
99+
Remove-AzSynapseIntegrationRuntime -ResourceGroupName $resourceGroupName -WorkspaceName $workspaceName -Name $irname -Force
100+
}
101+
finally
102+
{
103+
Invoke-HandledCmdlet -Command {Remove-AzSynapseIntegrationRuntime -ResourceGroupName $resourceGroupName -WorkspaceName $workspaceName -Name $irname} -IgnoreFailures
104+
}
105+
}
106+
107+
<#
108+
.SYNOPSIS
109+
Creates a self-hosted integration runtime and then does piping operations.
110+
#>
111+
function Test-IntegrationRuntime-Piping
112+
{
113+
param
114+
(
115+
$resourceGroupName = (Get-ResourceGroupName),
116+
$workspaceName = (Get-SynapseWorkspaceName),
117+
$irname = "test-integrationruntime-for-piping"
118+
)
119+
120+
try
121+
{
122+
$resourceGroupName = [Microsoft.Azure.Test.HttpRecorder.HttpMockServer]::GetVariable("resourceGroupName", $resourceGroupName)
123+
$workspaceName = [Microsoft.Azure.Test.HttpRecorder.HttpMockServer]::GetVariable("workspaceName", $workspaceName)
124+
125+
$result = Set-AzSynapseIntegrationRuntime -ResourceGroupName $resourceGroupName `
126+
-WorkspaceName $workspaceName `
127+
-Name $irname `
128+
-Type 'SelfHosted' `
129+
-Force
130+
131+
$result | Get-AzSynapseIntegrationRuntime
132+
$result | Get-AzSynapseIntegrationRuntimeKey
133+
$result | New-AzSynapseIntegrationRuntimeKey -KeyName AuthKey1 -Force
134+
$result | Get-AzSynapseIntegrationRuntimeMetric
135+
$result | Remove-AzSynapseIntegrationRuntime -Force
136+
}
137+
finally
138+
{
139+
Invoke-HandledCmdlet -Command {Remove-AzSynapseIntegrationRuntime -ResourceGroupName $resourceGroupName -WorkspaceName $workspaceName -Name $irname} -IgnoreFailures
140+
}
141+
}

0 commit comments

Comments
 (0)