Consume cosmos emulator from install path on agent (#4316)
Co-authored-by: Chidozie Ononiwu <chononiw@microsoft.com>
This commit is contained in:
parent
696d138105
commit
b8ddcc616f
@ -1,4 +1,5 @@
|
||||
parameters:
|
||||
EmulatorInstallPath: "$(Agent.HomeDirectory)/../../Program Files/Azure Cosmos DB Emulator/Microsoft.Azure.Cosmos.Emulator.exe"
|
||||
EmulatorMsiUrl: "https://aka.ms/cosmosdb-emulator"
|
||||
StartParameters: ''
|
||||
|
||||
@ -9,16 +10,7 @@ steps:
|
||||
arguments: >
|
||||
-EmulatorMsiUrl "${{ parameters.EmulatorMsiUrl }}"
|
||||
-StartParameters "${{ parameters.StartParameters }}"
|
||||
-Stage "Install"
|
||||
pwsh: true
|
||||
displayName: Install Public Cosmos DB Emulator
|
||||
|
||||
- task: Powershell@2
|
||||
inputs:
|
||||
filePath: $(Build.SourcesDirectory)/eng/common/scripts/Cosmos-Emulator.ps1
|
||||
arguments: >
|
||||
-EmulatorMsiUrl "${{ parameters.EmulatorMsiUrl }}"
|
||||
-StartParameters "${{ parameters.StartParameters }}"
|
||||
-Emulator "${{ parameters.EmulatorInstallPath }}"
|
||||
-Stage "Launch"
|
||||
pwsh: true
|
||||
displayName: Launch Public Cosmos DB Emulator
|
||||
|
||||
@ -9,7 +9,10 @@ This script downloads, installs and launches cosmosdb-emulator.
|
||||
Uri for downloading the cosmosdb-emulator
|
||||
|
||||
.PARAMETER StartParameters
|
||||
Parameter with which to launch the cosmosdb-emulator
|
||||
Parameter with which to launch the cosmosdb-emulator\
|
||||
|
||||
.PARAMETER Emulator
|
||||
Exact path to Microsoft.Azure.Cosmos.Emulator.exe
|
||||
|
||||
.PARAMETER Stage
|
||||
Determines what part of the script to run. Has to be either Install or Launch
|
||||
@ -18,6 +21,7 @@ Determines what part of the script to run. Has to be either Install or Launch
|
||||
Param (
|
||||
[string] $EmulatorMsiUrl = "https://aka.ms/cosmosdb-emulator",
|
||||
[string] $StartParameters,
|
||||
[string] $Emulator,
|
||||
[Parameter(Mandatory=$True)]
|
||||
[ValidateSet('Install', 'Launch')]
|
||||
[string] $Stage
|
||||
@ -26,7 +30,11 @@ Param (
|
||||
$targetDir = Join-Path $Env:Temp AzureCosmosEmulator
|
||||
$logFile = Join-Path $Env:Temp log.txt
|
||||
$productName = "Azure Cosmos DB Emulator"
|
||||
$emulator = (Join-Path $targetDir (Join-Path $productName "Microsoft.Azure.Cosmos.Emulator.exe"))
|
||||
|
||||
if ([string]::IsNullOrEmpty($Emulator))
|
||||
{
|
||||
$Emulator = (Join-Path $targetDir (Join-Path $productName "Microsoft.Azure.Cosmos.Emulator.exe"))
|
||||
}
|
||||
|
||||
if ($Stage -eq "Install")
|
||||
{
|
||||
@ -58,19 +66,19 @@ if ($Stage -eq "Install")
|
||||
}
|
||||
|
||||
Write-Host "Getting Cosmos DB Emulator Version"
|
||||
$fileVersion = Get-ChildItem $emulator
|
||||
Write-Host $emulator $fileVersion.VersionInfo
|
||||
$fileVersion = Get-ChildItem $Emulator
|
||||
Write-Host $Emulator $fileVersion.VersionInfo
|
||||
}
|
||||
|
||||
if ($Stage -eq "Launch")
|
||||
{
|
||||
Write-Host "Launching Cosmos DB Emulator"
|
||||
if (!(Test-Path $emulator)) {
|
||||
Write-Error "The emulator is not installed where expected at '$emulator'"
|
||||
if (!(Test-Path $Emulator)) {
|
||||
Write-Error "The emulator is not installed where expected at '$Emulator'"
|
||||
return
|
||||
}
|
||||
|
||||
$process = Start-Process $emulator -ArgumentList "/getstatus" -PassThru -Wait
|
||||
$process = Start-Process $Emulator -ArgumentList "/getstatus" -PassThru -Wait
|
||||
switch ($process.ExitCode) {
|
||||
1 {
|
||||
Write-Host "The emulator is already starting"
|
||||
@ -97,8 +105,8 @@ if ($Stage -eq "Launch")
|
||||
$argumentList = "/noexplorer /noui /enablepreview /disableratelimiting /enableaadauthentication"
|
||||
}
|
||||
|
||||
Write-Host "Starting emulator process: $emulator $argumentList"
|
||||
$process = Start-Process $emulator -ArgumentList $argumentList -ErrorAction Stop -PassThru
|
||||
Write-Host "Starting emulator process: $Emulator $argumentList"
|
||||
$process = Start-Process $Emulator -ArgumentList $argumentList -ErrorAction Stop -PassThru
|
||||
Write-Host "Emulator process started: $($process.Name), $($process.FileVersion)"
|
||||
|
||||
$Timeout = 600
|
||||
@ -117,7 +125,7 @@ if ($Stage -eq "Launch")
|
||||
}
|
||||
|
||||
do {
|
||||
$process = Start-Process $emulator -ArgumentList "/getstatus" -PassThru -Wait
|
||||
$process = Start-Process $Emulator -ArgumentList "/getstatus" -PassThru -Wait
|
||||
switch ($process.ExitCode) {
|
||||
1 {
|
||||
Write-Host "The emulator is starting"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user