mirror of
https://github.com/actions/runner-images-sangeeth.git
synced 2025-12-20 06:29:50 +00:00
[Windows] Disable mongodb service by default (#6023)
* Disable mongodb service by default * Add ErrorAction Ignore
This commit is contained in:
committed by
GitHub
parent
58ba4559eb
commit
f1bb031e43
@@ -3,11 +3,19 @@
|
|||||||
## Desc: Install MongoDB
|
## Desc: Install MongoDB
|
||||||
####################################################################################
|
####################################################################################
|
||||||
|
|
||||||
|
# Install mongodb package
|
||||||
$toolsetVersion = (Get-ToolsetContent).mongodb.version
|
$toolsetVersion = (Get-ToolsetContent).mongodb.version
|
||||||
$latestChocoPackage = Get-LatestChocoPackageVersion -TargetVersion $toolsetVersion -PackageName "mongodb"
|
$latestChocoPackage = Get-LatestChocoPackageVersion -TargetVersion $toolsetVersion -PackageName "mongodb"
|
||||||
Choco-Install -PackageName mongodb -ArgumentList "--version=$latestChocoPackage"
|
Choco-Install -PackageName mongodb -ArgumentList "--version=$latestChocoPackage"
|
||||||
$mongoPath = (Get-CimInstance Win32_Service -Filter "Name LIKE 'mongodb'").PathName
|
|
||||||
|
# Add mongodb to the PATH
|
||||||
|
$mongodbService = "mongodb"
|
||||||
|
$mongoPath = (Get-CimInstance Win32_Service -Filter "Name LIKE '$mongodbService'").PathName
|
||||||
$mongoBin = Split-Path -Path $mongoPath.split('"')[1]
|
$mongoBin = Split-Path -Path $mongoPath.split('"')[1]
|
||||||
Add-MachinePathItem "$mongoBin"
|
Add-MachinePathItem "$mongoBin"
|
||||||
|
|
||||||
|
# Stop and disable mongodb service
|
||||||
|
Stop-Service -Name $mongodbService
|
||||||
|
Set-Service $mongodbService -StartupType Disabled
|
||||||
|
|
||||||
Invoke-PesterTests -TestFile "Databases" -TestName "MongoDB"
|
Invoke-PesterTests -TestFile "Databases" -TestName "MongoDB"
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
Describe "MongoDB" {
|
Describe "MongoDB" {
|
||||||
|
Context "Version" {
|
||||||
It "<ToolName>" -TestCases @(
|
It "<ToolName>" -TestCases @(
|
||||||
@{ ToolName = "mongo" }
|
@{ ToolName = "mongo" }
|
||||||
@{ ToolName = "mongod" }
|
@{ ToolName = "mongod" }
|
||||||
@@ -8,6 +9,24 @@ Describe "MongoDB" {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Context "Service" {
|
||||||
|
$mongoService = Get-Service -Name mongodb -ErrorAction Ignore
|
||||||
|
$mongoServiceTests = @{
|
||||||
|
Name = $mongoService.Name
|
||||||
|
Status = $mongoService.Status
|
||||||
|
StartType = $mongoService.StartType
|
||||||
|
}
|
||||||
|
|
||||||
|
It "<Name> service is stopped" -TestCases $mongoServiceTests {
|
||||||
|
$Status | Should -Be "Stopped"
|
||||||
|
}
|
||||||
|
|
||||||
|
It "<Name> service is disabled" -TestCases $mongoServiceTests {
|
||||||
|
$StartType | Should -Be "Disabled"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Describe "PostgreSQL" {
|
Describe "PostgreSQL" {
|
||||||
$psqlTests = @(
|
$psqlTests = @(
|
||||||
@{envVar = "PGROOT"; pgPath = Get-EnvironmentVariable "PGROOT"}
|
@{envVar = "PGROOT"; pgPath = Get-EnvironmentVariable "PGROOT"}
|
||||||
|
|||||||
Reference in New Issue
Block a user