Skip to content

Commit

Permalink
Revert "[INTERNAL] CI: Fixes emulator set-up to leverage central SDK …
Browse files Browse the repository at this point in the history
…teams scripts (#4813)" (#4877)

This reverts commit c69feae.
  • Loading branch information
kirankumarkolli authored and kundadebdatta committed Nov 11, 2024
1 parent 8c508bb commit 852c542
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 165 deletions.
151 changes: 0 additions & 151 deletions templates/Cosmos-Emulator.ps1

This file was deleted.

81 changes: 67 additions & 14 deletions templates/emulator-setup.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,69 @@
parameters:
EmulatorInstallPath: "$(Agent.HomeDirectory)/../../Program Files/Azure Cosmos DB Emulator/Microsoft.Azure.Cosmos.Emulator.exe"
EmulatorMsiUrl: "https://aka.ms/cosmosdb-emulator"
StartParameters: ''
# File: templates/emulator-setup.yml

steps:
- task: Powershell@2
inputs:
filePath: $(Build.SourcesDirectory)/templates/Cosmos-Emulator.ps1
arguments: >
-EmulatorMsiUrl "${{ parameters.EmulatorMsiUrl }}"
-StartParameters "${{ parameters.StartParameters }}"
-Emulator "${{ parameters.EmulatorInstallPath }}"
-Stage "Launch"
pwsh: true
displayName: Launch Public Cosmos DB Emulator
- pwsh: |
Write-Host "Downloading Cosmos Emulator - $env:EMULATORMSIURL" -ForegroundColor green
Invoke-WebRequest "$env:EMULATORMSIURL" -OutFile "$env:temp\azure-cosmosdb-emulator.msi"
Write-Host "Finished Downloading Cosmos Emulator - $env:temp\azure-cosmosdb-emulator.msi" -ForegroundColor green
dir "$env:temp"
function Remove-DirectoryIfExists {
param ([string]$Path)
if (Test-Path -Path $Path -PathType Container) {
Remove-Item -Path $Path -Recurse -Force
Write-Output "Folder deleted: $Path"
} else {
Write-Output "Folder does not exist: $Path"
}
}
$lessMsiDir="$env:temp\lessmsi"
$emulatorDir="$env:temp\Azure Cosmos DB Emulator\"
Remove-DirectoryIfExists -Path $lessMsiDir
Remove-DirectoryIfExists -Path $emulatorDir
Expand-Archive -LiteralPath 'tools\lessmsi-v2.1.1.zip' -DestinationPath $lessMsiDir
&"$env:temp\lessmsi\lessmsi.exe" x "$env:temp\azure-cosmosdb-emulator.msi" "$emulatorDir"
Add-MpPreference -ExclusionPath "$emulatorDir\SourceDir\Azure Cosmos DB Emulator"
Add-MpPreference -ExclusionPath "$env:localappdata\CosmosDBEmulator"
displayName: Downloading and Installing Cosmos DB Emulator
failOnStderr: true
errorActionPreference: stop
- pwsh: |
Write-Host "Starting Cosmos DB Emulator" -ForegroundColor green
Import-Module "$env:temp\Azure Cosmos DB Emulator\SourceDir\Azure Cosmos DB Emulator\PSModules\Microsoft.Azure.CosmosDB.Emulator"
Get-Item env:* | Sort-Object -Property Name
for ($j=0; $j -lt 3; $j++) {
Write-Host "Attempt $j"
Start-Process "$env:temp\Azure Cosmos DB Emulator\SourceDir\Azure Cosmos DB Emulator\CosmosDB.Emulator.exe" "/NoExplorer /NoUI /DisableRateLimiting /PartitionCount=10 /Consistency=Strong /EnablePreview /EnableSqlComputeEndpoint" -Verb RunAs
for ($i=0; $i -lt (3+2*$j); $i++) {
$status = Get-CosmosDbEmulatorStatus
Write-Host "Cosmos DB Emulator Status: $status"
if ($status -ne "Running") {
sleep 30;
}
else {
break;
}
}
if ($status -ne "Running") {
Write-Host "Shutting down and restarting"
Start-Process "$env:temp\Azure Cosmos DB Emulator\SourceDir\Azure Cosmos DB Emulator\CosmosDB.Emulator.exe" "/Shutdown" -Verb RunAs
sleep 30;
}
else {
break;
}
}
if ($status -ne "Running") {
Write-Error "Emulator failed to start"
}
displayName: Waiting for Cosmos DB Emulator status
failOnStderr: true
errorActionPreference: stop
Binary file added tools/lessmsi-v2.1.1.zip
Binary file not shown.

0 comments on commit 852c542

Please sign in to comment.