Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DNM: Test the test from fix choco upgrade with custom env vars #5388

Closed
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
15 changes: 11 additions & 4 deletions .github/workflows/win-package-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,12 @@ jobs:
throw "choco install failed!"
}
$env_vars = Get-ItemPropertyValue -Path "HKLM:\SYSTEM\CurrentControlSet\Services\splunk-otel-collector" -Name "Environment"
$env_vars += "MY VAR WITH SPACES=my value"
$test_env_vars = @(
"MY VAR WITH SPACES=my value",
"GOOD_ENV_VAR_NAME=good value",
"GOOD_KEY_NEEDS_ESCAPING=`" that breaks MSI call if not escaped properly due to double-quote"
)
$env_vars += $test_env_vars
Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\splunk-otel-collector" -Name "Environment" -Value $env_vars -type MultiString
Start-Sleep 30
write-host "Upgrading $choco_file_name ..."
Expand All @@ -387,9 +392,11 @@ jobs:
throw "choco upgrade failed!"
}
$env_vars = Get-ItemPropertyValue -Path "HKLM:\SYSTEM\CurrentControlSet\Services\splunk-otel-collector" -Name "Environment"
if (!($env_vars -contains "MY VAR WITH SPACES=my value")) {
$env_vars
throw "'MY VAR WITH SPACES=my value' not found!"
foreach ($test_env_var in $test_env_vars) {
if (!($env_vars -contains $test_env_var)) {
$env_vars
throw "'$test_env_var' not found!"
}
}
}
Start-Sleep -s 30
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ if (Test-Path $reg_path) {
foreach ($entry in $previous_environment) {
$k, $v = $entry.Split("=", 2)
if ($k -Match "^[0-9A-Za-z_]+$") {
$env_vars[$k] = $v
$env_vars[$k] = $v.Replace('"', '""') # Ensure that the MSI runs correctly by escaping double quotes.
} else {
$custom_entries += $entry
}
Expand Down
Loading