Skip to content

Commit 7cfe76f

Browse files
author
Aman Orazaev
committed
Better live test
1 parent fe4d010 commit 7cfe76f

File tree

1 file changed

+25
-3
lines changed
  • src/ResourceManager/AnalysisServices/Commands.AnalysisServices.Test/ScenarioTests

1 file changed

+25
-3
lines changed

src/ResourceManager/AnalysisServices/Commands.AnalysisServices.Test/ScenarioTests/AsTests.ps1

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -229,23 +229,45 @@ function Test-NegativeAnalysisServicesServer
229229
<#
230230
.SYNOPSIS
231231
Test log exporting from Azure Analysis Service server.
232+
In order to run this test successfully, Following environment variables need to be set.
233+
ASAZURE_TEST_ROLLOUT e.x. value 'aspaaswestusloop1.asazure-int.windows.net'
234+
ASAZURE_TESTUSER_PWD e.x. value 'samplepwd'
232235
#>
233236
function Test-AnalysisServicesServerLogExport
234237
{
238+
param
239+
(
240+
$rolloutEnvironment = $env.ASAZURE_TEST_ROLLOUT
241+
)
235242
try
236243
{
244+
$location = Get-Location
245+
$resourceGroupName = Get-ResourceGroupName
246+
$serverName = Get-AnalysisServicesServerName
247+
New-AzureRmResourceGroup -Name $resourceGroupName -Location $location
248+
249+
$serverCreated = New-AzureRmAnalysisServicesServer -ResourceGroupName $resourceGroupName -Name $serverName -Location $location -Sku 'S1' -Administrators '[email protected],[email protected]'
250+
Assert-True {$serverCreated.ProvisioningState -like "Succeeded"}
251+
Assert-True {$serverCreated.State -like "Succeeded"}
252+
253+
$secpasswd = ConvertTo-SecureString $env.ASAZURE_TESTUSER_PWD -AsPlainText -Force
254+
$cred = New-Object System.Management.Automation.PSCredential ('[email protected]', $secpasswd)
255+
$asAzureProfile = Login-AzureAsAccount -RolloutEnvironment $rolloutEnvironment -Credential $cred
256+
Assert-NotNull $asAzureProfile "Login-AzureAsAccount $rolloutEnvironment must not return null"
257+
237258
$tempFile = [System.IO.Path]::GetTempFileName()
238-
Login-AzureAsAccount
239-
Export-AzureAnalysisServicesInstanceLog -Instance asazure://westus.asazure.windows.net/oratest -OutputPath $tempFile
259+
Export-AzureAnalysisServicesInstanceLog -Instance $serverName -OutputPath $tempFile
240260
Assert-Exists $tempFile
241261
$logContent = [System.IO.File]::ReadAllText($tempFile)
242-
Assert-False ([string]::IsNullOrEmpty($logContent))
262+
Assert-False { [string]::IsNullOrEmpty($logContent); }
243263
}
244264
finally
245265
{
246266
if (Test-Path $tempFile) {
247267
Remove-Item $tempFile
248268
}
269+
Invoke-HandledCmdlet -Command {Remove-AzureRmAnalysisServicesServer -ResourceGroupName $resourceGroupName -Name $serverName -Force -ErrorAction SilentlyContinue} -IgnoreFailures
270+
Invoke-HandledCmdlet -Command {Remove-AzureRmResourceGroup -Name $resourceGroupName -Force -ErrorAction SilentlyContinue} -IgnoreFailures
249271
}
250272
}
251273

0 commit comments

Comments
 (0)