Skip to content
Merged
Show file tree
Hide file tree
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
103 changes: 103 additions & 0 deletions src/Synapse/Synapse.Test/ScenarioTests/IntegrationRuntimeTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
// ----------------------------------------------------------------------------------
//
// Copyright Microsoft Corporation
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ----------------------------------------------------------------------------------

namespace Microsoft.Azure.Commands.Synapse.Test.ScenarioTests
{
using Microsoft.WindowsAzure.Commands.ScenarioTest;
using ServiceManagement.Common.Models;
using Xunit;

public class IntegrationRuntimeTests : SynapseTestBase
{
public XunitTracingInterceptor _logger;

public IntegrationRuntimeTests(Xunit.Abstractions.ITestOutputHelper output)
{
_logger = new XunitTracingInterceptor(output);
XunitTracingInterceptor.AddToContext(_logger);
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestSelfHostedIntegrationRuntime()
{
string testResourceGroupName = SynapseTestBase.TestResourceGroupName;
if (string.IsNullOrEmpty(testResourceGroupName))
{
testResourceGroupName = nameof(TestResourceGroupName);
}

string testWorkspaceName = SynapseTestBase.TestWorkspaceName;
if (string.IsNullOrEmpty(testWorkspaceName))
{
testWorkspaceName = nameof(TestWorkspaceName);
}

SynapseTestBase.NewInstance.RunPsTest(
_logger,
string.Format(
"Test-SelfHosted-IntegrationRuntime -resourceGroupName '{0}' -workspaceName '{1}'",
testResourceGroupName,
testWorkspaceName));
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestAzureIntegrationRuntime()
{
string testResourceGroupName = SynapseTestBase.TestResourceGroupName;
if (string.IsNullOrEmpty(testResourceGroupName))
{
testResourceGroupName = nameof(TestResourceGroupName);
}

string testWorkspaceName = SynapseTestBase.TestWorkspaceName;
if (string.IsNullOrEmpty(testWorkspaceName))
{
testWorkspaceName = nameof(TestWorkspaceName);
}

SynapseTestBase.NewInstance.RunPsTest(
_logger,
string.Format(
"Test-Azure-IntegrationRuntime -resourceGroupName '{0}' -workspaceName '{1}'",
testResourceGroupName,
testWorkspaceName));
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestIntegrationRuntimePiping()
{
string testResourceGroupName = SynapseTestBase.TestResourceGroupName;
if (string.IsNullOrEmpty(testResourceGroupName))
{
testResourceGroupName = nameof(TestResourceGroupName);
}

string testWorkspaceName = SynapseTestBase.TestWorkspaceName;
if (string.IsNullOrEmpty(testWorkspaceName))
{
testWorkspaceName = nameof(TestWorkspaceName);
}

SynapseTestBase.NewInstance.RunPsTest(
_logger,
string.Format(
"Test-IntegrationRuntime-Piping -resourceGroupName '{0}' -workspaceName '{1}'",
testResourceGroupName,
testWorkspaceName));
}
}
}
141 changes: 141 additions & 0 deletions src/Synapse/Synapse.Test/ScenarioTests/IntegrationRuntimeTests.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
<#
.SYNOPSIS
Creates a self-hosted integration runtime and then does operations.
Deletes the created integration runtime at the end.
#>
function Test-SelfHosted-IntegrationRuntime
{
param
(
$resourceGroupName = (Get-ResourceGroupName),
$workspaceName = (Get-SynapseWorkspaceName),
$irname = "selfhosted-test-integrationruntime"
)

try
{
$resourceGroupName = [Microsoft.Azure.Test.HttpRecorder.HttpMockServer]::GetVariable("resourceGroupName", $resourceGroupName)
$workspaceName = [Microsoft.Azure.Test.HttpRecorder.HttpMockServer]::GetVariable("workspaceName", $workspaceName)

$actual = Set-AzSynapseIntegrationRuntime -ResourceGroupName $resourceGroupName `
-WorkspaceName $workspaceName `
-Name $irname `
-Type 'SelfHosted' `
-Force
Assert-AreEqual $actual.Name $irname

$expected = Get-AzSynapseIntegrationRuntime -ResourceGroupName $resourceGroupName `
-WorkspaceName $workspaceName `
-Name $irname
Assert-AreEqual $actual.Name $expected.Name

$expected = Get-AzSynapseIntegrationRuntime -ResourceId $actual.Id
Assert-AreEqual $actual.Name $expected.Name

$status = Get-AzSynapseIntegrationRuntime -ResourceId $actual.Id -Status
Assert-NotNull $status

$metric = Get-AzSynapseIntegrationRuntimeMetric -ResourceGroupName $resourceGroupName `
-WorkspaceName $workspaceName `
-Name $irname
Assert-NotNull $metric

$description = "description"
$result = Set-AzSynapseIntegrationRuntime -ResourceGroupName $resourceGroupName `
-WorkspaceName $workspaceName `
-Name $irname `
-Description $description `
-Force
Assert-AreEqual $result.Description $description

$status = Get-AzSynapseIntegrationRuntime -ResourceGroupName $resourceGroupName `
-WorkspaceName $workspaceName `
-Name $irname `
-Status
Assert-NotNull $status.LatestVersion

Remove-AzSynapseIntegrationRuntime -ResourceId $actual.Id -Force
}
finally
{
Invoke-HandledCmdlet -Command {Remove-AzSynapseIntegrationRuntime -ResourceGroupName $resourceGroupName -WorkspaceName $workspaceName -Name $irname} -IgnoreFailures
}
}

<#
.SYNOPSIS
Creates an azure integration runtime and then does operations.
Deletes the created integration runtime at the end.
#>
function Test-Azure-IntegrationRuntime
{
param
(
$resourceGroupName = (Get-ResourceGroupName),
$workspaceName = (Get-SynapseWorkspaceName),
$irname = "test-ManagedElastic-integrationruntime"
)

try
{
$resourceGroupName = [Microsoft.Azure.Test.HttpRecorder.HttpMockServer]::GetVariable("resourceGroupName", $resourceGroupName)
$workspaceName = [Microsoft.Azure.Test.HttpRecorder.HttpMockServer]::GetVariable("workspaceName", $workspaceName)

$description = "ManagedElastic"

$actual = Set-AzSynapseIntegrationRuntime -ResourceGroupName $resourceGroupName `
-WorkspaceName $workspaceName `
-Name $irname `
-Type Managed `
-Description $description `
-Force

$expected = Get-AzSynapseIntegrationRuntime -ResourceGroupName $resourceGroupName `
-WorkspaceName $workspaceName `
-Name $irname
Assert-AreEqual $actual.Name $expected.Name
Get-AzSynapseIntegrationRuntime -ResourceId $actual.Id -Status

Remove-AzSynapseIntegrationRuntime -ResourceGroupName $resourceGroupName -WorkspaceName $workspaceName -Name $irname -Force
}
finally
{
Invoke-HandledCmdlet -Command {Remove-AzSynapseIntegrationRuntime -ResourceGroupName $resourceGroupName -WorkspaceName $workspaceName -Name $irname} -IgnoreFailures
}
}

<#
.SYNOPSIS
Creates a self-hosted integration runtime and then does piping operations.
#>
function Test-IntegrationRuntime-Piping
{
param
(
$resourceGroupName = (Get-ResourceGroupName),
$workspaceName = (Get-SynapseWorkspaceName),
$irname = "test-integrationruntime-for-piping"
)

try
{
$resourceGroupName = [Microsoft.Azure.Test.HttpRecorder.HttpMockServer]::GetVariable("resourceGroupName", $resourceGroupName)
$workspaceName = [Microsoft.Azure.Test.HttpRecorder.HttpMockServer]::GetVariable("workspaceName", $workspaceName)

$result = Set-AzSynapseIntegrationRuntime -ResourceGroupName $resourceGroupName `
-WorkspaceName $workspaceName `
-Name $irname `
-Type 'SelfHosted' `
-Force

$result | Get-AzSynapseIntegrationRuntime
$result | Get-AzSynapseIntegrationRuntimeKey
$result | New-AzSynapseIntegrationRuntimeKey -KeyName AuthKey1 -Force
$result | Get-AzSynapseIntegrationRuntimeMetric
$result | Remove-AzSynapseIntegrationRuntime -Force
}
finally
{
Invoke-HandledCmdlet -Command {Remove-AzSynapseIntegrationRuntime -ResourceGroupName $resourceGroupName -WorkspaceName $workspaceName -Name $irname} -IgnoreFailures
}
}
Loading