Fix nsis installer/uninstaller to close when it's finished

This commit is contained in:
Shane Lee 2024-07-11 10:40:46 -06:00 committed by Daniel Wozniak
parent 4e707af83b
commit 2595d8ea15
101 changed files with 2427 additions and 651 deletions

View file

@ -0,0 +1,52 @@
#------------------------------------------------------------------------------
# StrContains
#
# This function does a case sensitive searches for an occurrence of a substring in a string.
# It returns the substring if it is found.
# Otherwise it returns null("").
# Written by kenglish_hi
# Adapted from StrReplace written by dandaman32
#------------------------------------------------------------------------------
!define StrContains "!insertmacro StrContains"
!macro StrContains OUT NEEDLE HAYSTACK
Push "${HAYSTACK}"
Push "${NEEDLE}"
Call StrContains
Pop "${OUT}"
!macroend
Function StrContains
# Initialize variables
Var /GLOBAL STR_HAYSTACK
Var /GLOBAL STR_NEEDLE
Var /GLOBAL STR_CONTAINS_VAR_1
Var /GLOBAL STR_CONTAINS_VAR_2
Var /GLOBAL STR_CONTAINS_VAR_3
Var /GLOBAL STR_CONTAINS_VAR_4
Var /GLOBAL STR_RETURN_VAR
Exch $STR_NEEDLE
Exch 1
Exch $STR_HAYSTACK
# Uncomment to debug
#MessageBox MB_OK 'STR_NEEDLE = $STR_NEEDLE STR_HAYSTACK = $STR_HAYSTACK '
StrCpy $STR_RETURN_VAR ""
StrCpy $STR_CONTAINS_VAR_1 -1
StrLen $STR_CONTAINS_VAR_2 $STR_NEEDLE
StrLen $STR_CONTAINS_VAR_4 $STR_HAYSTACK
loop:
IntOp $STR_CONTAINS_VAR_1 $STR_CONTAINS_VAR_1 + 1
StrCpy $STR_CONTAINS_VAR_3 $STR_HAYSTACK $STR_CONTAINS_VAR_2 $STR_CONTAINS_VAR_1
StrCmp $STR_CONTAINS_VAR_3 $STR_NEEDLE found
StrCmp $STR_CONTAINS_VAR_1 $STR_CONTAINS_VAR_4 done
Goto loop
found:
StrCpy $STR_RETURN_VAR $STR_NEEDLE
Goto done
done:
Pop $STR_NEEDLE # Prevent "invalid opcode" errors and keep the stack clean
Exch $STR_RETURN_VAR
FunctionEnd

View file

@ -12,8 +12,17 @@ clean.ps1
clean.ps1
#>
param(
[Parameter(Mandatory=$false)]
[Alias("c")]
# Don't pretify the output of the Write-Result
[Switch] $CICD
)
#-------------------------------------------------------------------------------
# Script Preferences
#-------------------------------------------------------------------------------
$ProgressPreference = "SilentlyContinue"
$ErrorActionPreference = "Stop"
@ -21,15 +30,22 @@ $ErrorActionPreference = "Stop"
# Script Variables
#-------------------------------------------------------------------------------
$SCRIPT_DIR = (Get-ChildItem "$($myInvocation.MyCommand.Definition)").DirectoryName
$SCRIPT_DIR = (Get-ChildItem "$($myInvocation.MyCommand.Definition)").DirectoryName
$PROJECT_DIR = $(git rev-parse --show-toplevel)
$WINDOWS_DIR = "$PROJECT_DIR\pkg\windows"
$BUILDENV_DIR = "$WINDOWS_DIR\buildenv"
#-------------------------------------------------------------------------------
# Script Functions
#-------------------------------------------------------------------------------
function Write-Result($result, $ForegroundColor="Green") {
$position = 80 - $result.Length - [System.Console]::CursorLeft
Write-Host -ForegroundColor $ForegroundColor ("{0,$position}$result" -f "")
if ( $CICD ) {
Write-Host $result -ForegroundColor $ForegroundColor
} else {
$position = 80 - $result.Length - [System.Console]::CursorLeft
Write-Host -ForegroundColor $ForegroundColor ("{0,$position}$result" -f "")
}
}
#-------------------------------------------------------------------------------
@ -61,6 +77,51 @@ if ( Test-Path -Path "$SCRIPT_DIR\venv" ) {
Write-Result "Success" -ForegroundColor Green
}
}
#-------------------------------------------------------------------------------
# Remove buildenv directory
#-------------------------------------------------------------------------------
if ( Test-Path -Path "$BUILDENV_DIR" ) {
Write-Host "Removing buildenv directory: " -NoNewline
Remove-Item -Path "$BUILDENV_DIR" -Recurse -Force
if ( Test-Path -Path "$BUILDENV_DIR" ) {
Write-Result "Failed" -ForegroundColor Red
exit 1
} else {
Write-Result "Success" -ForegroundColor Green
}
}
#-------------------------------------------------------------------------------
# Make sure processes are not running
#-------------------------------------------------------------------------------
$processes = "test-setup",
"Un",
"Un_A",
"Un_B",
"Un_C",
"Un_D",
"Un_E",
"Un_F",
"Un_G"
$processes | ForEach-Object {
$proc = Get-Process -Name $_ -ErrorAction SilentlyContinue
if ( ($null -ne $proc) ) {
Write-Host "Killing $($_): " -NoNewline
$proc = Get-WmiObject -Class Win32_Process -Filter "Name='$_.exe'"
$proc.Terminate() *> $null
Start-Sleep -Seconds 5
$proc = Get-Process -Name $_ -ErrorAction SilentlyContinue
if ( ($null -eq $proc) ) {
Write-Result "Success" -ForegroundColor Green
} else {
Write-Result "Failed" -ForegroundColor Red
exit 1
}
}
}
#-------------------------------------------------------------------------------
# Remove test-setup.exe
#-------------------------------------------------------------------------------
@ -75,6 +136,92 @@ if ( Test-Path -Path "$SCRIPT_DIR\test-setup.exe" ) {
}
}
#-------------------------------------------------------------------------------
# Remove custom_conf
#-------------------------------------------------------------------------------
if ( Test-Path -Path "$SCRIPT_DIR\custom_conf" ) {
Write-Host "Removing custom_conf: " -NoNewline
Remove-Item -Path "$SCRIPT_DIR\custom_conf" -Recurse -Force
if ( Test-Path -Path "$SCRIPT_DIR\custom_conf" ) {
Write-Result "Failed" -ForegroundColor Red
exit 1
} else {
Write-Result "Success" -ForegroundColor Green
}
}
#-------------------------------------------------------------------------------
# Remove the salt-minion service
#-------------------------------------------------------------------------------
if ( $(Get-Service -Name salt-minion -ErrorAction SilentlyContinue).Name ) {
Write-Host "Removing salt-minion service" -NoNewline
Stop-Service -Name salt-minion
$service = Get-WmiObject -Class Win32_Service -Filter "Name='salt-minion'"
$service.delete() *> $null
if ( $(Get-Service -Name salt-minion -ErrorAction SilentlyContinue).Name ) {
Write-Result "Failed" -ForegroundColor Red
exit 1
} else {
Write-Result "Success" -ForegroundColor Green
}
}
#-------------------------------------------------------------------------------
# Remove Salt Project directory from Program Files
#-------------------------------------------------------------------------------
if ( Test-Path -Path "$env:ProgramFiles\Salt Project" ) {
Write-Host "Removing Salt Project from Program Files: " -NoNewline
Remove-Item -Path "$env:ProgramFiles\Salt Project" -Recurse -Force
if ( Test-Path -Path "$env:ProgramFiles\Salt Project" ) {
Write-Result "Failed" -ForegroundColor Red
exit 1
} else {
Write-Result "Success" -ForegroundColor Green
}
}
#-------------------------------------------------------------------------------
# Remove Salt Project directory from ProgramData
#-------------------------------------------------------------------------------
if ( Test-Path -Path "$env:ProgramData\Salt Project" ) {
Write-Host "Removing Salt Project from ProgramData: " -NoNewline
Remove-Item -Path "$env:ProgramData\Salt Project" -Recurse -Force
if ( Test-Path -Path "$env:ProgramData\Salt Project" ) {
Write-Result "Failed" -ForegroundColor Red
exit 1
} else {
Write-Result "Success" -ForegroundColor Green
}
}
#-------------------------------------------------------------------------------
# Remove Salt Project from Registry
#-------------------------------------------------------------------------------
if ( Test-Path -Path "HKLM:SOFTWARE\Salt Project" ) {
Write-Host "Removing Salt Project from Software: " -NoNewline
Remove-Item -Path "HKLM:SOFTWARE\Salt Project" -Recurse -Force
if ( Test-Path -Path "HKLM:SOFTWARE\Salt Project" ) {
Write-Result "Failed" -ForegroundColor Red
exit 1
} else {
Write-Result "Success" -ForegroundColor Green
}
}
#-------------------------------------------------------------------------------
# Remove Salt Minion directory from Registry
#-------------------------------------------------------------------------------
if ( Test-Path -Path "HKLM:SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Salt Minion" ) {
Write-Host "Removing Salt Minion from the Uninstall: " -NoNewline
Remove-Item -Path "HKLM:SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Salt Minion" -Recurse -Force
if ( Test-Path -Path "HKLM:SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Salt Minion" ) {
Write-Result "Failed" -ForegroundColor Red
exit 1
} else {
Write-Result "Success" -ForegroundColor Green
}
}
#-------------------------------------------------------------------------------
# Script Completed
#-------------------------------------------------------------------------------

View file

@ -6,32 +6,38 @@ import pytest
@pytest.fixture(scope="module")
def install():
pytest.helpers.clean_env()
# Create a custom config
pytest.helpers.custom_config()
full_path_conf = rf"{pytest.REPO_DIR}\custom_conf"
pytest.helpers.run_command(
[pytest.INST_BIN, "/S", f"/custom-config={full_path_conf}"]
)
yield
full_path_conf = pytest.helpers.custom_config()
# Install salt with custom config
args = ["/S", f"/custom-config={full_path_conf}"]
pytest.helpers.install_salt(args)
yield args
pytest.helpers.clean_env()
def test_binaries_present(install):
assert os.path.exists(rf"{pytest.INST_DIR}\ssm.exe")
# This will show the contents of the directory on failure
inst_dir = pytest.INST_DIR
inst_dir_exists = os.path.exists(inst_dir)
dir_contents = os.listdir(inst_dir)
assert os.path.exists(rf"{inst_dir}\ssm.exe")
def test_config_present(install):
assert os.path.exists(rf"{pytest.DATA_DIR}\conf\minion")
data_dir = pytest.DATA_DIR
data_dir_exists = os.path.exists(data_dir)
assert os.path.exists(rf"{data_dir}\conf\minion")
def test_config_correct(install):
# The config file should be the custom config, unchanged
with open(rf"{pytest.REPO_DIR}\custom_conf") as f:
script_dir = pytest.SCRIPT_DIR
script_dir_exists = os.path.exists(script_dir)
with open(rf"{script_dir}\custom_conf") as f:
expected = f.readlines()
data_dir = pytest.DATA_DIR
data_dir_exists = os.path.exists(data_dir)
with open(rf"{pytest.DATA_DIR}\conf\minion") as f:
result = f.readlines()

View file

@ -6,19 +6,21 @@ import pytest
@pytest.fixture(scope="module")
def install():
pytest.helpers.clean_env()
# Create a custom config
pytest.helpers.custom_config()
pytest.helpers.run_command(
[pytest.INST_BIN, "/S", "/custom-config=custom_conf", "/master=cli_master"]
)
yield
# Install salt with custom config
args = ["/S", "/custom-config=custom_conf", "/master=cli_master"]
pytest.helpers.install_salt(args)
yield args
pytest.helpers.clean_env()
def test_binaries_present(install):
assert os.path.exists(rf"{pytest.INST_DIR}\ssm.exe")
# This will show the contents of the directory on failure
inst_dir = pytest.INST_DIR
inst_dir_exists = os.path.exists(inst_dir)
dir_contents = os.listdir(inst_dir)
assert os.path.exists(rf"{inst_dir}\ssm.exe")
def test_config_present(install):

View file

@ -6,25 +6,26 @@ import pytest
@pytest.fixture(scope="module")
def install():
pytest.helpers.clean_env()
# Create a custom config
pytest.helpers.custom_config()
pytest.helpers.run_command(
[
pytest.INST_BIN,
"/S",
"/custom-config=custom_conf",
"/master=cli_master",
"/minion-name=cli_minion",
]
)
yield
# Install salt with custom config
args = [
"/S",
"/custom-config=custom_conf",
"/master=cli_master",
"/minion-name=cli_minion",
]
pytest.helpers.install_salt(args)
yield args
pytest.helpers.clean_env()
def test_binaries_present(install):
assert os.path.exists(rf"{pytest.INST_DIR}\ssm.exe")
# This will show the contents of the directory on failure
inst_dir = pytest.INST_DIR
inst_dir_exists = os.path.exists(inst_dir)
dir_contents = os.listdir(inst_dir)
assert os.path.exists(rf"{inst_dir}\ssm.exe")
def test_config_present(install):

View file

@ -6,24 +6,21 @@ import pytest
@pytest.fixture(scope="module")
def install():
pytest.helpers.clean_env()
# Create a custom config
pytest.helpers.custom_config()
pytest.helpers.run_command(
[
pytest.INST_BIN,
"/S",
"/custom-config=custom_conf",
"/minion-name=cli_minion",
]
)
yield
# Install salt with custom config
args = ["/S", "/custom-config=custom_conf", "/minion-name=cli_minion"]
pytest.helpers.install_salt(args)
yield args
pytest.helpers.clean_env()
def test_binaries_present(install):
assert os.path.exists(rf"{pytest.INST_DIR}\ssm.exe")
# This will show the contents of the directory on failure
inst_dir = pytest.INST_DIR
inst_dir_exists = os.path.exists(inst_dir)
dir_contents = os.listdir(inst_dir)
assert os.path.exists(rf"{inst_dir}\ssm.exe")
def test_config_present(install):

View file

@ -6,17 +6,21 @@ import pytest
@pytest.fixture(scope="module")
def install():
pytest.helpers.clean_env()
# Create a custom config
pytest.helpers.custom_config()
pytest.helpers.run_command([pytest.INST_BIN, "/S", "/custom-config=custom_conf"])
yield
# Install salt with custom config
args = ["/S", "/custom-config=custom_conf"]
pytest.helpers.install_salt(args)
yield args
pytest.helpers.clean_env()
def test_binaries_present(install):
assert os.path.exists(rf"{pytest.INST_DIR}\ssm.exe")
# This will show the contents of the directory on failure
inst_dir = pytest.INST_DIR
inst_dir_exists = os.path.exists(inst_dir)
dir_contents = os.listdir(inst_dir)
assert os.path.exists(rf"{inst_dir}\ssm.exe")
def test_config_present(install):
@ -25,7 +29,7 @@ def test_config_present(install):
def test_config_correct(install):
# The config file should be the custom config, unchanged
with open(rf"{pytest.REPO_DIR}\custom_conf") as f:
with open(rf"{pytest.SCRIPT_DIR}\custom_conf") as f:
expected = f.readlines()
with open(rf"{pytest.DATA_DIR}\conf\minion") as f:

View file

@ -6,13 +6,18 @@ import pytest
@pytest.fixture(scope="module")
def install():
pytest.helpers.clean_env()
pytest.helpers.run_command([pytest.INST_BIN, "/S"])
yield
args = ["/S"]
pytest.helpers.install_salt(args)
yield args
pytest.helpers.clean_env()
def test_binaries_present(install):
assert os.path.exists(rf"{pytest.INST_DIR}\ssm.exe")
# This will show the contents of the directory on failure
inst_dir = pytest.INST_DIR
inst_dir_exists = os.path.exists(inst_dir)
dir_contents = os.listdir(inst_dir)
assert os.path.exists(rf"{inst_dir}\ssm.exe")
def test_config_present(install):
@ -21,7 +26,7 @@ def test_config_present(install):
def test_config_correct(install):
# The config file should be the default config, unchanged
with open(rf"{pytest.REPO_DIR}\_files\minion") as f:
with open(rf"{pytest.SCRIPT_DIR}\_files\minion") as f:
expected = f.readlines()
with open(rf"{pytest.DATA_DIR}\conf\minion") as f:

View file

@ -6,13 +6,18 @@ import pytest
@pytest.fixture(scope="module")
def install():
pytest.helpers.clean_env()
pytest.helpers.run_command([pytest.INST_BIN, "/S", "/master=cli_master"])
yield
args = ["/S", "/master=cli_master"]
pytest.helpers.install_salt(args)
yield args
pytest.helpers.clean_env()
def test_binaries_present(install):
assert os.path.exists(rf"{pytest.INST_DIR}\ssm.exe")
# This will show the contents of the directory on failure
inst_dir = pytest.INST_DIR
inst_dir_exists = os.path.exists(inst_dir)
dir_contents = os.listdir(inst_dir)
assert os.path.exists(rf"{inst_dir}\ssm.exe")
def test_config_present(install):

View file

@ -6,15 +6,18 @@ import pytest
@pytest.fixture(scope="module")
def install():
pytest.helpers.clean_env()
pytest.helpers.run_command(
[pytest.INST_BIN, "/S", "/master=cli_master", "/minion-name=cli_minion"]
)
yield
args = ["/S", "/master=cli_master", "/minion-name=cli_minion"]
pytest.helpers.install_salt(args)
yield args
pytest.helpers.clean_env()
def test_binaries_present(install):
assert os.path.exists(rf"{pytest.INST_DIR}\ssm.exe")
# This will show the contents of the directory on failure
inst_dir = pytest.INST_DIR
inst_dir_exists = os.path.exists(inst_dir)
dir_contents = os.listdir(inst_dir)
assert os.path.exists(rf"{inst_dir}\ssm.exe")
def test_config_present(install):

View file

@ -6,13 +6,18 @@ import pytest
@pytest.fixture(scope="module")
def install():
pytest.helpers.clean_env()
pytest.helpers.run_command([pytest.INST_BIN, "/S", "/minion-name=cli_minion"])
yield
args = ["/S", "/minion-name=cli_minion"]
pytest.helpers.install_salt(args)
yield args
pytest.helpers.clean_env()
def test_binaries_present(install):
assert os.path.exists(rf"{pytest.INST_DIR}\ssm.exe")
# This will show the contents of the directory on failure
inst_dir = pytest.INST_DIR
inst_dir_exists = os.path.exists(inst_dir)
dir_contents = os.listdir(inst_dir)
assert os.path.exists(rf"{inst_dir}\ssm.exe")
def test_config_present(install):

View file

@ -6,17 +6,20 @@ import pytest
@pytest.fixture(scope="module")
def install():
pytest.helpers.clean_env()
# Create an existing config
pytest.helpers.existing_config()
pytest.helpers.run_command([pytest.INST_BIN, "/S"])
yield
args = ["/S"]
pytest.helpers.install_salt(args)
yield args
pytest.helpers.clean_env()
def test_binaries_present(install):
assert os.path.exists(rf"{pytest.INST_DIR}\ssm.exe")
# This will show the contents of the directory on failure
inst_dir = pytest.INST_DIR
inst_dir_exists = os.path.exists(inst_dir)
dir_contents = os.listdir(inst_dir)
assert os.path.exists(rf"{inst_dir}\ssm.exe")
def test_config_present(install):

View file

@ -6,20 +6,22 @@ import pytest
@pytest.fixture(scope="module")
def install():
pytest.helpers.clean_env()
# Create an existing config
pytest.helpers.existing_config()
# Create a custom config
pytest.helpers.custom_config()
pytest.helpers.run_command([pytest.INST_BIN, "/S", "/custom-config=custom_conf"])
yield
args = ["/S", "/custom-config=custom_conf"]
pytest.helpers.install_salt(args)
yield args
pytest.helpers.clean_env()
def test_binaries_present(install):
assert os.path.exists(rf"{pytest.INST_DIR}\ssm.exe")
# This will show the contents of the directory on failure
inst_dir = pytest.INST_DIR
inst_dir_exists = os.path.exists(inst_dir)
dir_contents = os.listdir(inst_dir)
assert os.path.exists(rf"{inst_dir}\ssm.exe")
def test_config_present(install):
@ -28,7 +30,7 @@ def test_config_present(install):
def test_config_correct(install):
# The config file should be the custom config, unchanged
with open(rf"{pytest.REPO_DIR}\custom_conf") as f:
with open(rf"{pytest.SCRIPT_DIR}\custom_conf") as f:
expected = f.readlines()
with open(rf"{pytest.DATA_DIR}\conf\minion") as f:

View file

@ -6,22 +6,22 @@ import pytest
@pytest.fixture(scope="module")
def install():
pytest.helpers.clean_env()
# Create an existing config
pytest.helpers.existing_config()
# Create a custom config
pytest.helpers.custom_config()
pytest.helpers.run_command(
[pytest.INST_BIN, "/S", "/custom-config=custom_conf", "/master=cli_master"]
)
yield
args = ["/S", "/custom-config=custom_conf", "/master=cli_master"]
pytest.helpers.install_salt(args)
yield args
pytest.helpers.clean_env()
def test_binaries_present(install):
assert os.path.exists(rf"{pytest.INST_DIR}\ssm.exe")
# This will show the contents of the directory on failure
inst_dir = pytest.INST_DIR
inst_dir_exists = os.path.exists(inst_dir)
dir_contents = os.listdir(inst_dir)
assert os.path.exists(rf"{inst_dir}\ssm.exe")
def test_config_present(install):

View file

@ -6,28 +6,27 @@ import pytest
@pytest.fixture(scope="module")
def install():
pytest.helpers.clean_env()
# Create an existing config
pytest.helpers.existing_config()
# Create a custom config
pytest.helpers.custom_config()
pytest.helpers.run_command(
[
pytest.INST_BIN,
"/S",
"/custom-config=custom_conf",
"/master=cli_master",
"/minion-name=cli_minion",
]
)
yield
args = [
"/S",
"/custom-config=custom_conf",
"/master=cli_master",
"/minion-name=cli_minion",
]
pytest.helpers.install_salt(args)
yield args
pytest.helpers.clean_env()
def test_binaries_present(install):
assert os.path.exists(rf"{pytest.INST_DIR}\ssm.exe")
# This will show the contents of the directory on failure
inst_dir = pytest.INST_DIR
inst_dir_exists = os.path.exists(inst_dir)
dir_contents = os.listdir(inst_dir)
assert os.path.exists(rf"{inst_dir}\ssm.exe")
def test_config_present(install):

View file

@ -8,24 +8,20 @@ def install():
pytest.helpers.clean_env()
# Create an existing config
pytest.helpers.existing_config()
# Create a custom config
pytest.helpers.custom_config()
pytest.helpers.run_command(
[
pytest.INST_BIN,
"/S",
"/custom-config=custom_conf",
"/minion-name=cli_minion",
]
)
yield
args = ["/S", "/custom-config=custom_conf", "/minion-name=cli_minion"]
pytest.helpers.install_salt(args)
yield args
pytest.helpers.clean_env()
def test_binaries_present(install):
assert os.path.exists(rf"{pytest.INST_DIR}\ssm.exe")
# This will show the contents of the directory on failure
inst_dir = pytest.INST_DIR
inst_dir_exists = os.path.exists(inst_dir)
dir_contents = os.listdir(inst_dir)
assert os.path.exists(rf"{inst_dir}\ssm.exe")
def test_config_present(install):

View file

@ -6,17 +6,20 @@ import pytest
@pytest.fixture(scope="module")
def install():
pytest.helpers.clean_env()
# Create an existing config
pytest.helpers.existing_config()
pytest.helpers.run_command([pytest.INST_BIN, "/S", "/default-config"])
yield
args = ["/S", "/default-config"]
pytest.helpers.install_salt(args)
yield args
pytest.helpers.clean_env()
def test_binaries_present(install):
assert os.path.exists(rf"{pytest.INST_DIR}\ssm.exe")
# This will show the contents of the directory on failure
inst_dir = pytest.INST_DIR
inst_dir_exists = os.path.exists(inst_dir)
dir_contents = os.listdir(inst_dir)
assert os.path.exists(rf"{inst_dir}\ssm.exe")
def test_config_present(install):
@ -25,7 +28,7 @@ def test_config_present(install):
def test_config_correct(install):
# The config file should be the default config, unchanged
with open(rf"{pytest.REPO_DIR}\_files\minion") as f:
with open(rf"{pytest.SCRIPT_DIR}\_files\minion") as f:
expected = f.readlines()
with open(rf"{pytest.DATA_DIR}\conf\minion") as f:

View file

@ -6,19 +6,20 @@ import pytest
@pytest.fixture(scope="module")
def install():
pytest.helpers.clean_env()
# Create an existing config
pytest.helpers.existing_config()
pytest.helpers.run_command(
[pytest.INST_BIN, "/S", "/default-config", "/master=cli_master"]
)
yield
args = ["/S", "/default-config", "/master=cli_master"]
pytest.helpers.install_salt(args)
yield args
pytest.helpers.clean_env()
def test_binaries_present(install):
assert os.path.exists(rf"{pytest.INST_DIR}\ssm.exe")
# This will show the contents of the directory on failure
inst_dir = pytest.INST_DIR
inst_dir_exists = os.path.exists(inst_dir)
dir_contents = os.listdir(inst_dir)
assert os.path.exists(rf"{inst_dir}\ssm.exe")
def test_config_present(install):

View file

@ -6,25 +6,20 @@ import pytest
@pytest.fixture(scope="module")
def install():
pytest.helpers.clean_env()
# Create an existing config
pytest.helpers.existing_config()
pytest.helpers.run_command(
[
pytest.INST_BIN,
"/S",
"/default-config",
"/master=cli_master",
"/minion-name=cli_minion",
]
)
yield
args = ["/S", "/default-config", "/master=cli_master", "/minion-name=cli_minion"]
pytest.helpers.install_salt(args)
yield args
pytest.helpers.clean_env()
def test_binaries_present(install):
assert os.path.exists(rf"{pytest.INST_DIR}\ssm.exe")
# This will show the contents of the directory on failure
inst_dir = pytest.INST_DIR
inst_dir_exists = os.path.exists(inst_dir)
dir_contents = os.listdir(inst_dir)
assert os.path.exists(rf"{inst_dir}\ssm.exe")
def test_config_present(install):

View file

@ -6,19 +6,20 @@ import pytest
@pytest.fixture(scope="module")
def install():
pytest.helpers.clean_env()
# Create an existing config
pytest.helpers.existing_config()
pytest.helpers.run_command(
[pytest.INST_BIN, "/S", "/default-config", "/minion-name=cli_minion"]
)
yield
args = ["/S", "/default-config", "/minion-name=cli_minion"]
pytest.helpers.install_salt(args)
yield args
pytest.helpers.clean_env()
def test_binaries_present(install):
assert os.path.exists(rf"{pytest.INST_DIR}\ssm.exe")
# This will show the contents of the directory on failure
inst_dir = pytest.INST_DIR
inst_dir_exists = os.path.exists(inst_dir)
dir_contents = os.listdir(inst_dir)
assert os.path.exists(rf"{inst_dir}\ssm.exe")
def test_config_present(install):

View file

@ -10,24 +10,19 @@ def inst_dir():
@pytest.fixture(scope="module")
def install(inst_dir):
pytest.helpers.clean_env(inst_dir)
pytest.helpers.clean_env()
# Create a custom config
pytest.helpers.custom_config()
pytest.helpers.run_command(
[
pytest.INST_BIN,
"/S",
f"/install-dir={inst_dir}",
"/custom-config=custom_conf",
]
)
yield
args = ["/S", f"/install-dir={inst_dir}", "/custom-config=custom_conf"]
pytest.helpers.install_salt(args)
yield args
pytest.helpers.clean_env(inst_dir)
def test_binaries_present(install, inst_dir):
# This will show the contents of the directory on failure
inst_dir_exists = os.path.exists(inst_dir)
dir_contents = os.listdir(inst_dir)
assert os.path.exists(rf"{inst_dir}\ssm.exe")
@ -37,7 +32,7 @@ def test_config_present(install):
def test_config_correct(install):
# The config file should be the custom config, unchanged
with open(rf"{pytest.REPO_DIR}\custom_conf") as f:
with open(rf"{pytest.SCRIPT_DIR}\custom_conf") as f:
expected = f.readlines()
with open(rf"{pytest.DATA_DIR}\conf\minion") as f:

View file

@ -10,25 +10,24 @@ def inst_dir():
@pytest.fixture(scope="module")
def install(inst_dir):
pytest.helpers.clean_env(inst_dir)
pytest.helpers.clean_env()
# Create a custom config
pytest.helpers.custom_config()
pytest.helpers.run_command(
[
pytest.INST_BIN,
"/S",
f"/install-dir={inst_dir}",
"/custom-config=custom_conf",
"/master=cli_master",
]
)
yield
args = [
"/S",
f"/install-dir={inst_dir}",
"/custom-config=custom_conf",
"/master=cli_master",
]
pytest.helpers.install_salt(args)
yield args
pytest.helpers.clean_env(inst_dir)
def test_binaries_present(install, inst_dir):
# This will show the contents of the directory on failure
inst_dir_exists = os.path.exists(inst_dir)
dir_contents = os.listdir(inst_dir)
assert os.path.exists(rf"{inst_dir}\ssm.exe")

View file

@ -10,26 +10,25 @@ def inst_dir():
@pytest.fixture(scope="module")
def install(inst_dir):
pytest.helpers.clean_env(inst_dir)
pytest.helpers.clean_env()
# Create a custom config
pytest.helpers.custom_config()
pytest.helpers.run_command(
[
pytest.INST_BIN,
"/S",
f"/install-dir={inst_dir}",
"/custom-config=custom_conf",
"/master=cli_master",
"/minion-name=cli_minion",
]
)
yield
args = [
"/S",
f"/install-dir={inst_dir}",
"/custom-config=custom_conf",
"/master=cli_master",
"/minion-name=cli_minion",
]
pytest.helpers.install_salt(args)
yield args
pytest.helpers.clean_env(inst_dir)
def test_binaries_present(install, inst_dir):
# This will show the contents of the directory on failure
inst_dir_exists = os.path.exists(inst_dir)
dir_contents = os.listdir(inst_dir)
assert os.path.exists(rf"{inst_dir}\ssm.exe")

View file

@ -10,25 +10,24 @@ def inst_dir():
@pytest.fixture(scope="module")
def install(inst_dir):
pytest.helpers.clean_env(inst_dir)
pytest.helpers.clean_env()
# Create a custom config
pytest.helpers.custom_config()
pytest.helpers.run_command(
[
pytest.INST_BIN,
"/S",
f"/install-dir={inst_dir}",
"/custom-config=custom_conf",
"/minion-name=cli_minion",
]
)
yield
args = [
"/S",
f"/install-dir={inst_dir}",
"/custom-config=custom_conf",
"/minion-name=cli_minion",
]
pytest.helpers.install_salt(args)
yield args
pytest.helpers.clean_env(inst_dir)
def test_binaries_present(install, inst_dir):
# This will show the contents of the directory on failure
inst_dir_exists = os.path.exists(inst_dir)
dir_contents = os.listdir(inst_dir)
assert os.path.exists(rf"{inst_dir}\ssm.exe")

View file

@ -10,13 +10,17 @@ def inst_dir():
@pytest.fixture(scope="module")
def install(inst_dir):
pytest.helpers.clean_env(inst_dir)
pytest.helpers.run_command([pytest.INST_BIN, "/S", f"/install-dir={inst_dir}"])
yield
pytest.helpers.clean_env()
args = ["/S", f"/install-dir={inst_dir}"]
pytest.helpers.install_salt(args)
yield args
pytest.helpers.clean_env(inst_dir)
def test_binaries_present(install, inst_dir):
# This will show the contents of the directory on failure
inst_dir_exists = os.path.exists(inst_dir)
dir_contents = os.listdir(inst_dir)
assert os.path.exists(rf"{inst_dir}\ssm.exe")
@ -26,7 +30,7 @@ def test_config_present(install):
def test_config_correct(install):
# The config file should be the default config, unchanged
with open(rf"{pytest.REPO_DIR}\_files\minion") as f:
with open(rf"{pytest.SCRIPT_DIR}\_files\minion") as f:
expected = f.readlines()
with open(rf"{pytest.DATA_DIR}\conf\minion") as f:

View file

@ -5,20 +5,22 @@ import pytest
@pytest.fixture(scope="module")
def inst_dir():
return r"C:\custom_location"
return "C:\\custom_location"
@pytest.fixture(scope="module")
def install(inst_dir):
pytest.helpers.clean_env(inst_dir)
pytest.helpers.run_command(
[pytest.INST_BIN, "/S", f"/install-dir={inst_dir}", "/master=cli_master"]
)
yield
pytest.helpers.clean_env()
args = ["/S", f"/install-dir={inst_dir}", "/master=cli_master"]
pytest.helpers.install_salt(args)
yield args
pytest.helpers.clean_env(inst_dir)
def test_binaries_present(install, inst_dir):
# This will show the contents of the directory on failure
inst_dir_exists = os.path.exists(inst_dir)
dir_contents = os.listdir(inst_dir)
assert os.path.exists(rf"{inst_dir}\ssm.exe")

View file

@ -5,26 +5,27 @@ import pytest
@pytest.fixture(scope="module")
def inst_dir():
return r"C:\custom_location"
return "C:\\custom_location"
@pytest.fixture(scope="module")
def install(inst_dir):
pytest.helpers.clean_env(inst_dir)
pytest.helpers.run_command(
[
pytest.INST_BIN,
"/S",
f"/install-dir={inst_dir}",
"/master=cli_master",
"/minion-name=cli_minion",
]
)
yield
pytest.helpers.clean_env()
args = [
"/S",
f"/install-dir={inst_dir}",
"/master=cli_master",
"/minion-name=cli_minion",
]
pytest.helpers.install_salt(args)
yield args
pytest.helpers.clean_env(inst_dir)
def test_binaries_present(install, inst_dir):
# This will show the contents of the directory on failure
inst_dir_exists = os.path.exists(inst_dir)
dir_contents = os.listdir(inst_dir)
assert os.path.exists(rf"{inst_dir}\ssm.exe")

View file

@ -5,20 +5,22 @@ import pytest
@pytest.fixture(scope="module")
def inst_dir():
return r"C:\custom_location"
return "C:\\custom_location"
@pytest.fixture(scope="module")
def install(inst_dir):
pytest.helpers.clean_env(inst_dir)
pytest.helpers.run_command(
[pytest.INST_BIN, "/S", f"/install-dir={inst_dir}", "/minion-name=cli_minion"]
)
yield {"inst_dir": inst_dir}
pytest.helpers.clean_env()
args = ["/S", f"/install-dir={inst_dir}", "/minion-name=cli_minion"]
pytest.helpers.install_salt(args)
yield args
pytest.helpers.clean_env(inst_dir)
def test_binaries_present(install, inst_dir):
# This will show the contents of the directory on failure
inst_dir_exists = os.path.exists(inst_dir)
dir_contents = os.listdir(inst_dir)
assert os.path.exists(rf"{inst_dir}\ssm.exe")

View file

@ -5,22 +5,24 @@ import pytest
@pytest.fixture(scope="module")
def inst_dir():
return r"C:\custom_location"
return "C:\\custom_location"
@pytest.fixture(scope="module")
def install(inst_dir):
pytest.helpers.clean_env(inst_dir)
pytest.helpers.clean_env()
# Create an existing config
pytest.helpers.existing_config()
pytest.helpers.run_command([pytest.INST_BIN, "/S", f"/install-dir={inst_dir}"])
yield
args = ["/S", f"/install-dir={inst_dir}"]
pytest.helpers.install_salt(args)
yield args
pytest.helpers.clean_env(inst_dir)
def test_binaries_present(install, inst_dir):
# This will show the contents of the directory on failure
inst_dir_exists = os.path.exists(inst_dir)
dir_contents = os.listdir(inst_dir)
assert os.path.exists(rf"{inst_dir}\ssm.exe")

View file

@ -5,24 +5,23 @@ import pytest
@pytest.fixture(scope="module")
def inst_dir():
return r"C:\custom_location"
return "C:\\custom_location"
@pytest.fixture(scope="module")
def install(inst_dir):
pytest.helpers.clean_env()
# Create old install
pytest.helpers.old_install()
pytest.helpers.run_command(
[pytest.INST_BIN, "/S", f"/install-dir={inst_dir}", "/move-config"]
)
yield
args = ["/S", f"/install-dir={inst_dir}", "/move-config"]
pytest.helpers.install_salt(args)
yield args
pytest.helpers.clean_env()
def test_binaries_present_old_location(install):
# This will show the contents of the directory on failure
dir_contents = os.listdir(rf"{pytest.OLD_DIR}\bin")
# Apparently we don't move the binaries even if they pass install-dir
# TODO: Decide if this is expected behavior
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\ssm.exe")

View file

@ -6,20 +6,20 @@ import pytest
@pytest.fixture(scope="module")
def install():
pytest.helpers.clean_env()
# Create old config
pytest.helpers.old_install()
pytest.helpers.run_command([pytest.INST_BIN, "/S"])
yield
args = ["/S"]
pytest.helpers.install_salt(args)
yield args
pytest.helpers.clean_env()
def test_ssm_present_old_location(install):
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\ssm.exe")
def test_binaries_present_old_location(install):
# This will show the contents of the directory on failure
dir_contents = os.listdir(rf"{pytest.OLD_DIR}\bin")
# Apparently we don't move the binaries even if they pass install-dir
# TODO: Decide if this is expected behavior
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\ssm.exe")
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\python.exe")

View file

@ -6,23 +6,22 @@ import pytest
@pytest.fixture(scope="module")
def install():
pytest.helpers.clean_env()
# Create old config
pytest.helpers.old_install()
# Create a custom config
pytest.helpers.custom_config()
pytest.helpers.run_command([pytest.INST_BIN, "/S", "/custom-config=custom_conf"])
yield
args = ["/S", "/custom-config=custom_conf"]
pytest.helpers.install_salt(args)
yield args
pytest.helpers.clean_env()
def test_ssm_present_old_location(install):
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\ssm.exe")
def test_binaries_present_old_location(install):
# This will show the contents of the directory on failure
dir_contents = os.listdir(rf"{pytest.OLD_DIR}\bin")
# Apparently we don't move the binaries even if they pass install-dir
# TODO: Decide if this is expected behavior
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\ssm.exe")
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\python.exe")
@ -32,7 +31,7 @@ def test_config_present_old_location(install):
def test_config_correct(install):
# The config file should be the custom config, unchanged
with open(rf"{pytest.REPO_DIR}\custom_conf") as f:
with open(rf"{pytest.SCRIPT_DIR}\custom_conf") as f:
expected = f.readlines()
with open(rf"{pytest.OLD_DIR}\conf\minion") as f:

View file

@ -6,25 +6,22 @@ import pytest
@pytest.fixture(scope="module")
def install():
pytest.helpers.clean_env()
# Create old config
pytest.helpers.old_install()
# Create a custom config
pytest.helpers.custom_config()
pytest.helpers.run_command(
[pytest.INST_BIN, "/S", "/custom-config=custom_conf", "/master=cli_master"]
)
yield
args = ["/S", "/custom-config=custom_conf", "/master=cli_master"]
pytest.helpers.install_salt(args)
yield args
pytest.helpers.clean_env()
def test_ssm_present_old_location(install):
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\ssm.exe")
def test_binaries_present_old_location(install):
# This will show the contents of the directory on failure
dir_contents = os.listdir(rf"{pytest.OLD_DIR}\bin")
# Apparently we don't move the binaries even if they pass install-dir
# TODO: Decide if this is expected behavior
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\ssm.exe")
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\python.exe")

View file

@ -6,31 +6,27 @@ import pytest
@pytest.fixture(scope="module")
def install():
pytest.helpers.clean_env()
# Create old config
pytest.helpers.old_install()
# Create a custom config
pytest.helpers.custom_config()
pytest.helpers.run_command(
[
pytest.INST_BIN,
"/S",
"/custom-config=custom_conf",
"/master=cli_master",
"/minion-name=cli_minion",
]
)
yield
args = [
"/S",
"/custom-config=custom_conf",
"/master=cli_master",
"/minion-name=cli_minion",
]
pytest.helpers.install_salt(args)
yield args
pytest.helpers.clean_env()
def test_ssm_present_old_location(install):
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\ssm.exe")
def test_binaries_present_old_location(install):
# This will show the contents of the directory on failure
dir_contents = os.listdir(rf"{pytest.OLD_DIR}\bin")
# Apparently we don't move the binaries even if they pass install-dir
# TODO: Decide if this is expected behavior
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\ssm.exe")
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\python.exe")

View file

@ -6,25 +6,22 @@ import pytest
@pytest.fixture(scope="module")
def install():
pytest.helpers.clean_env()
# Create old config
pytest.helpers.old_install()
# Create a custom config
pytest.helpers.custom_config()
pytest.helpers.run_command(
[pytest.INST_BIN, "/S", "/custom-config=custom_conf", "/minion-name=cli_minion"]
)
yield
args = ["/S", "/custom-config=custom_conf", "/minion-name=cli_minion"]
pytest.helpers.install_salt(args)
yield args
pytest.helpers.clean_env()
def test_ssm_present_old_location(install):
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\ssm.exe")
def test_binaries_present_old_location(install):
# This will show the contents of the directory on failure
dir_contents = os.listdir(rf"{pytest.OLD_DIR}\bin")
# Apparently we don't move the binaries even if they pass install-dir
# TODO: Decide if this is expected behavior
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\ssm.exe")
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\python.exe")

View file

@ -6,20 +6,20 @@ import pytest
@pytest.fixture(scope="module")
def install():
pytest.helpers.clean_env()
# Create old config
# Create old install
pytest.helpers.old_install()
pytest.helpers.run_command([pytest.INST_BIN, "/S", "/default-config"])
yield
args = ["/S", "/default-config"]
pytest.helpers.install_salt(args)
yield args
pytest.helpers.clean_env()
def test_ssm_present_old_location(install):
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\ssm.exe")
def test_binaries_present_old_location(install):
# This will show the contents of the directory on failure
dir_contents = os.listdir(rf"{pytest.OLD_DIR}\bin")
# Apparently we don't move the binaries even if they pass install-dir
# TODO: Decide if this is expected behavior
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\ssm.exe")
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\python.exe")
@ -29,7 +29,7 @@ def test_config_present_old_location(install):
def test_config_correct(install):
# The config file should be the default config, unchanged
with open(rf"{pytest.REPO_DIR}\_files\minion") as f:
with open(rf"{pytest.SCRIPT_DIR}\_files\minion") as f:
expected = f.readlines()
with open(rf"{pytest.OLD_DIR}\conf\minion") as f:

View file

@ -6,22 +6,20 @@ import pytest
@pytest.fixture(scope="module")
def install():
pytest.helpers.clean_env()
# Create old config
pytest.helpers.old_install()
pytest.helpers.run_command(
[pytest.INST_BIN, "/S", "/default-config", "/master=cli_master"]
)
yield
args = ["/S", "/default-config", "/master=cli_master"]
pytest.helpers.install_salt(args)
yield args
pytest.helpers.clean_env()
def test_ssm_present_old_location(install):
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\ssm.exe")
def test_binaries_present_old_location(install):
# This will show the contents of the directory on failure
dir_contents = os.listdir(rf"{pytest.OLD_DIR}\bin")
# Apparently we don't move the binaries even if they pass install-dir
# TODO: Decide if this is expected behavior
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\ssm.exe")
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\python.exe")

View file

@ -6,28 +6,25 @@ import pytest
@pytest.fixture(scope="module")
def install():
pytest.helpers.clean_env()
# Create old config
pytest.helpers.old_install()
pytest.helpers.run_command(
[
pytest.INST_BIN,
"/S",
"/default-config",
"/master=cli_master",
"/minion-name=cli_minion",
]
)
yield
args = [
"/S",
"/default-config",
"/master=cli_master",
"/minion-name=cli_minion",
]
pytest.helpers.install_salt(args)
yield args
pytest.helpers.clean_env()
def test_ssm_present_old_location(install):
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\ssm.exe")
def test_binaries_present_old_location(install):
# This will show the contents of the directory on failure
dir_contents = os.listdir(rf"{pytest.OLD_DIR}\bin")
# Apparently we don't move the binaries even if they pass install-dir
# TODO: Decide if this is expected behavior
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\ssm.exe")
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\python.exe")

View file

@ -6,22 +6,20 @@ import pytest
@pytest.fixture(scope="module")
def install():
pytest.helpers.clean_env()
# Create old config
pytest.helpers.old_install()
pytest.helpers.run_command(
[pytest.INST_BIN, "/S", "/default-config", "/minion-name=cli_minion"]
)
yield
args = ["/S", "/default-config", "/minion-name=cli_minion"]
pytest.helpers.install_salt(args)
yield args
pytest.helpers.clean_env()
def test_ssm_present_old_location(install):
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\ssm.exe")
def test_binaries_present_old_location(install):
# This will show the contents of the directory on failure
dir_contents = os.listdir(rf"{pytest.OLD_DIR}\bin")
# Apparently we don't move the binaries even if they pass install-dir
# TODO: Decide if this is expected behavior
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\ssm.exe")
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\python.exe")

View file

@ -6,24 +6,24 @@ import pytest
@pytest.fixture(scope="module")
def install():
pytest.helpers.clean_env()
# Create old config
pytest.helpers.old_install()
pytest.helpers.run_command([pytest.INST_BIN, "/S", "/move-config"])
yield
args = ["/S", "/move-config"]
pytest.helpers.install_salt(args)
yield args
pytest.helpers.clean_env()
def test_ssm_present_old_location(install):
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\ssm.exe")
def test_binaries_present_old_location(install):
# This will show the contents of the directory on failure
dir_contents = os.listdir(rf"{pytest.OLD_DIR}\bin")
# Apparently we don't move the binaries even if they pass install-dir
# TODO: Decide if this is expected behavior
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\ssm.exe")
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\python.exe")
def test_config_present_old_location(install):
def test_config_present_new_location(install):
assert os.path.exists(rf"{pytest.DATA_DIR}\conf\minion")

View file

@ -6,35 +6,32 @@ import pytest
@pytest.fixture(scope="module")
def install():
pytest.helpers.clean_env()
# Create old config
pytest.helpers.old_install()
# Create a custom config
pytest.helpers.custom_config()
pytest.helpers.run_command(
[pytest.INST_BIN, "/S", "/custom-config=custom_conf", "/move-config"]
)
yield
args = ["/S", "/custom-config=custom_conf", "/move-config"]
pytest.helpers.install_salt(args)
yield args
pytest.helpers.clean_env()
def test_ssm_present_old_location(install):
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\ssm.exe")
def test_binaries_present_old_location(install):
# This will show the contents of the directory on failure
dir_contents = os.listdir(rf"{pytest.OLD_DIR}\bin")
# Apparently we don't move the binaries even if they pass install-dir
# TODO: Decide if this is expected behavior
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\ssm.exe")
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\python.exe")
def test_config_present_old_location(install):
def test_config_present_new_location(install):
assert os.path.exists(rf"{pytest.DATA_DIR}\conf\minion")
def test_config_correct(install):
# The config file should be the custom config in the new location, unchanged
with open(rf"{pytest.REPO_DIR}\custom_conf") as f:
with open(rf"{pytest.SCRIPT_DIR}\custom_conf") as f:
expected = f.readlines()
with open(rf"{pytest.DATA_DIR}\conf\minion") as f:

View file

@ -6,35 +6,26 @@ import pytest
@pytest.fixture(scope="module")
def install():
pytest.helpers.clean_env()
# Create old config
pytest.helpers.old_install()
# Create a custom config
pytest.helpers.custom_config()
pytest.helpers.run_command(
[
pytest.INST_BIN,
"/S",
"/custom-config=custom_conf",
"/move-config",
"/master=cli_master",
]
)
yield
args = ["/S", "/custom-config=custom_conf", "/move-config", "/master=cli_master"]
pytest.helpers.install_salt(args)
yield args
pytest.helpers.clean_env()
def test_ssm_present_old_location(install):
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\ssm.exe")
def test_binaries_present_old_location(install):
# This will show the contents of the directory on failure
dir_contents = os.listdir(rf"{pytest.OLD_DIR}\bin")
# Apparently we don't move the binaries even if they pass install-dir
# TODO: Decide if this is expected behavior
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\ssm.exe")
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\python.exe")
def test_config_present_old_location(install):
def test_config_present_new_location(install):
assert os.path.exists(rf"{pytest.DATA_DIR}\conf\minion")

View file

@ -6,36 +6,32 @@ import pytest
@pytest.fixture(scope="module")
def install():
pytest.helpers.clean_env()
# Create old config
pytest.helpers.old_install()
# Create a custom config
pytest.helpers.custom_config()
pytest.helpers.run_command(
[
pytest.INST_BIN,
"/S",
"/custom-config=custom_conf",
"/move-config",
"/master=cli_master",
"/minion-name=cli_minion",
]
)
yield
args = [
"/S",
"/custom-config=custom_conf",
"/move-config",
"/master=cli_master",
"/minion-name=cli_minion",
]
pytest.helpers.install_salt(args)
yield args
pytest.helpers.clean_env()
def test_ssm_present_old_location(install):
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\ssm.exe")
def test_binaries_present_old_location(install):
# This will show the contents of the directory on failure
dir_contents = os.listdir(rf"{pytest.OLD_DIR}\bin")
# Apparently we don't move the binaries even if they pass install-dir
# TODO: Decide if this is expected behavior
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\ssm.exe")
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\python.exe")
def test_config_present_old_location(install):
def test_config_present_new_location(install):
assert os.path.exists(rf"{pytest.DATA_DIR}\conf\minion")

View file

@ -6,35 +6,31 @@ import pytest
@pytest.fixture(scope="module")
def install():
pytest.helpers.clean_env()
# Create old config
pytest.helpers.old_install()
# Create a custom config
pytest.helpers.custom_config()
pytest.helpers.run_command(
[
pytest.INST_BIN,
"/S",
"/custom-config=custom_conf",
"/move-config",
"/minion-name=cli_minion",
]
)
yield
args = [
"/S",
"/custom-config=custom_conf",
"/move-config",
"/minion-name=cli_minion",
]
pytest.helpers.install_salt(args)
yield args
pytest.helpers.clean_env()
def test_ssm_present_old_location(install):
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\ssm.exe")
def test_binaries_present_old_location(install):
# This will show the contents of the directory on failure
dir_contents = os.listdir(rf"{pytest.OLD_DIR}\bin")
# Apparently we don't move the binaries even if they pass install-dir
# TODO: Decide if this is expected behavior
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\ssm.exe")
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\python.exe")
def test_config_present_old_location(install):
def test_config_present_new_location(install):
assert os.path.exists(rf"{pytest.DATA_DIR}\conf\minion")

View file

@ -6,32 +6,30 @@ import pytest
@pytest.fixture(scope="module")
def install():
pytest.helpers.clean_env()
# Create old config
pytest.helpers.old_install()
pytest.helpers.run_command(
[pytest.INST_BIN, "/S", "/move-config", "/default-config"]
)
yield
args = ["/S", "/move-config", "/default-config"]
pytest.helpers.install_salt(args)
yield args
pytest.helpers.clean_env()
def test_ssm_present_old_location(install):
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\ssm.exe")
def test_binaries_present_old_location(install):
# This will show the contents of the directory on failure
dir_contents = os.listdir(rf"{pytest.OLD_DIR}\bin")
# Apparently we don't move the binaries even if they pass install-dir
# TODO: Decide if this is expected behavior
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\ssm.exe")
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\python.exe")
def test_config_present_old_location(install):
def test_config_present_new_location(install):
assert os.path.exists(rf"{pytest.DATA_DIR}\conf\minion")
def test_config_correct(install):
# The config file should be the default config in the new location, unchanged
with open(rf"{pytest.REPO_DIR}\_files\minion") as f:
with open(rf"{pytest.SCRIPT_DIR}\_files\minion") as f:
expected = f.readlines()
with open(rf"{pytest.DATA_DIR}\conf\minion") as f:

View file

@ -6,26 +6,24 @@ import pytest
@pytest.fixture(scope="module")
def install():
pytest.helpers.clean_env()
# Create old config
pytest.helpers.old_install()
pytest.helpers.run_command(
[pytest.INST_BIN, "/S", "/default-config", "/move-config", "/master=cli_master"]
)
yield
args = ["/S", "/default-config", "/move-config", "/master=cli_master"]
pytest.helpers.install_salt(args)
yield args
pytest.helpers.clean_env()
def test_ssm_present_old_location(install):
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\ssm.exe")
def test_binaries_present_old_location(install):
# This will show the contents of the directory on failure
dir_contents = os.listdir(rf"{pytest.OLD_DIR}\bin")
# Apparently we don't move the binaries even if they pass install-dir
# TODO: Decide if this is expected behavior
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\ssm.exe")
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\python.exe")
def test_config_present_old_location(install):
def test_config_present_new_location(install):
assert os.path.exists(rf"{pytest.DATA_DIR}\conf\minion")

View file

@ -6,33 +6,30 @@ import pytest
@pytest.fixture(scope="module")
def install():
pytest.helpers.clean_env()
# Create old config
pytest.helpers.old_install()
pytest.helpers.run_command(
[
pytest.INST_BIN,
"/S",
"/default-config",
"/move-config",
"/master=cli_master",
"/minion-name=cli_minion",
]
)
yield
args = [
"/S",
"/default-config",
"/move-config",
"/master=cli_master",
"/minion-name=cli_minion",
]
pytest.helpers.install_salt(args)
yield args
pytest.helpers.clean_env()
def test_ssm_present_old_location(install):
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\ssm.exe")
def test_binaries_present_old_location(install):
# This will show the contents of the directory on failure
dir_contents = os.listdir(rf"{pytest.OLD_DIR}\bin")
# Apparently we don't move the binaries even if they pass install-dir
# TODO: Decide if this is expected behavior
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\ssm.exe")
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\python.exe")
def test_config_present_old_location(install):
def test_config_present_new_location(install):
assert os.path.exists(rf"{pytest.DATA_DIR}\conf\minion")

View file

@ -6,32 +6,29 @@ import pytest
@pytest.fixture(scope="module")
def install():
pytest.helpers.clean_env()
# Create old config
pytest.helpers.old_install()
pytest.helpers.run_command(
[
pytest.INST_BIN,
"/S",
"/default-config",
"/move-config",
"/minion-name=cli_minion",
]
)
yield
args = [
"/S",
"/default-config",
"/move-config",
"/minion-name=cli_minion",
]
pytest.helpers.install_salt(args)
yield args
pytest.helpers.clean_env()
def test_ssm_present_old_location(install):
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\ssm.exe")
def test_binaries_present_old_location(install):
# This will show the contents of the directory on failure
dir_contents = os.listdir(rf"{pytest.OLD_DIR}\bin")
# Apparently we don't move the binaries even if they pass install-dir
# TODO: Decide if this is expected behavior
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\ssm.exe")
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\python.exe")
def test_config_present_old_location(install):
def test_config_present_new_location(install):
assert os.path.exists(rf"{pytest.DATA_DIR}\conf\minion")

View file

@ -1,4 +1,5 @@
import os
import re
import shutil
import subprocess
import time
@ -49,16 +50,33 @@ INST_DIR = r"C:\Program Files\Salt Project\Salt"
DATA_DIR = r"C:\ProgramData\Salt Project\Salt"
SYSTEM_DRIVE = os.environ.get("SystemDrive")
OLD_DIR = f"{SYSTEM_DRIVE}\\salt"
SCRIPT_DIR = os.path.dirname(os.path.realpath(__file__))
INST_BIN = rf"{SCRIPT_DIR}\test-setup.exe"
PROCESSES = [
os.path.basename(INST_BIN),
"uninst.exe",
"Un.exe",
"Un_A.exe",
"Un_B.exe",
"Un_C.exe",
"Un_D.exe",
"Un_D.exe",
"Un_F.exe",
"Un_G.exe",
]
def reg_key_exists(hive=winreg.HKEY_LOCAL_MACHINE, key=None):
"""
Helper function to determine if a registry key exists. It does this by
opening the key. If the connection is successful, the key exists. Otherwise
an error is returned, which means the key does not exist
"""
try:
with winreg.OpenKey(hive, key, 0, winreg.KEY_READ):
exists = True
return True
except:
exists = False
return exists
return False
def delete_key(hive=winreg.HKEY_LOCAL_MACHINE, key=None):
@ -66,60 +84,97 @@ def delete_key(hive=winreg.HKEY_LOCAL_MACHINE, key=None):
parent, _, base = key.rpartition("\\")
with winreg.OpenKey(hive, parent, 0, winreg.KEY_ALL_ACCESS) as reg:
winreg.DeleteKey(reg, base)
assert not reg_key_exists(hive=hive, key=key)
def pytest_configure():
pytest.DATA_DIR = DATA_DIR
pytest.INST_DIR = INST_DIR
pytest.REPO_DIR = REPO_DIR
pytest.INST_BIN = INST_BIN
pytest.OLD_DIR = OLD_DIR
pytest.SCRIPT_DIR = SCRIPT_DIR
pytest.EXISTING_CONTENT = existing_content
pytest.CUSTOM_CONTENT = custom_content
pytest.OLD_CONTENT = old_content
@pytest.helpers.register
def clean_env(inst_dir=INST_DIR):
# Run uninstaller
for uninst_bin in [f"{inst_dir}\\uninst.exe", f"{OLD_DIR}\\uninst.exe"]:
if os.path.exists(uninst_bin):
run_command([uninst_bin, "/S", "/delete-root-dir", "/delete-install-dir"])
# This is needed to avoid a race condition where the uninstall is completing
start_time = time.time()
while "Un_A.exe" in (p.name() for p in psutil.process_iter()):
# Sometimes the Uninstall binary hangs... we'll kill it after 10 seconds
if (time.time() - start_time) > 10:
for proc in psutil.process_iter():
if proc.name() == "Un_A.exe":
proc.kill()
time.sleep(0.1)
# This is needed to avoid a race condition where the installer isn't closed
start_time = time.time()
while os.path.basename(INST_BIN) in (p.name() for p in psutil.process_iter()):
if (time.time() - start_time) > 10:
# If it's not dead after 10 seconds, kill it
for proc in psutil.process_iter():
if proc.name() == os.path.basename(INST_BIN):
proc.kill()
time.sleep(0.1)
def clean_fragments(inst_dir=INST_DIR):
# Remove root_dir
if os.path.exists(DATA_DIR):
shutil.rmtree(DATA_DIR)
assert not os.path.exists(DATA_DIR)
# Remove install dir
if os.path.exists(inst_dir):
shutil.rmtree(inst_dir)
assert not os.path.exists(inst_dir)
# Remove old salt dir (C:\salt)
if os.path.exists(OLD_DIR):
shutil.rmtree(OLD_DIR)
assert not os.path.exists(OLD_DIR)
# Remove custom config
if os.path.exists(rf"{REPO_DIR}\custom_conf"):
os.remove(rf"{REPO_DIR}\custom_conf")
if os.path.exists(rf"{SCRIPT_DIR}\custom_conf"):
os.remove(rf"{SCRIPT_DIR}\custom_conf")
assert not os.path.exists(rf"{SCRIPT_DIR}\custom_conf")
# Remove registry entries
delete_key(key="SOFTWARE\\Salt Project\\Salt")
assert not reg_key_exists(
hive=winreg.HKEY_LOCAL_MACHINE, key="SOFTWARE\\Salt Project\\Salt"
)
delete_key(key="SOFTWARE\\Salt Project")
assert not reg_key_exists(
hive=winreg.HKEY_LOCAL_MACHINE, key="SOFTWARE\\Salt Project"
)
return True
@pytest.helpers.register
def clean_env(inst_dir=INST_DIR, timeout=300):
# Let's make sure none of the install/uninstall processes are running
for proc in PROCESSES:
try:
assert proc not in (p.name() for p in psutil.process_iter())
except psutil.NoSuchProcess:
continue
# Uninstall existing installation
# Run the uninstaller.
for uninst_bin in [f"{inst_dir}\\uninst.exe", f"{OLD_DIR}\\uninst.exe"]:
if os.path.exists(uninst_bin):
install_dir = os.path.dirname(uninst_bin)
cmd = [f'"{uninst_bin}"', "/S", "/delete-root-dir", "/delete-install-dir"]
run_command(cmd)
# Uninst.exe launches a 2nd binary (Un.exe or Un_*.exe)
# Let's get the name of the process
proc_name = ""
for proc in PROCESSES:
try:
if proc in (p.name() for p in psutil.process_iter()):
proc_name = proc
except psutil.NoSuchProcess:
continue
# We need to give the process time to exit
if proc_name:
elapsed_time = 0
while elapsed_time < timeout:
try:
if proc_name not in (p.name() for p in psutil.process_iter()):
break
except psutil.NoSuchProcess:
continue
elapsed_time += 0.1
time.sleep(0.1)
assert clean_fragments(inst_dir=install_dir)
return True
@pytest.helpers.register
@ -134,12 +189,15 @@ def existing_config():
@pytest.helpers.register
def custom_config():
if os.path.exists(rf"{REPO_DIR}\custom_conf"):
os.remove(rf"{REPO_DIR}\custom_conf")
conf_file = rf"{SCRIPT_DIR}\custom_conf"
if os.path.exists(conf_file):
os.remove(conf_file)
# Create a custom config
with open(rf"{REPO_DIR}\custom_conf", "w") as f:
with open(conf_file, "w") as f:
# \n characters are converted to os.linesep
f.writelines(custom_content)
assert os.path.exists(conf_file)
return conf_file
@pytest.helpers.register
@ -158,25 +216,78 @@ def old_install():
with open(f"{OLD_DIR}\\conf\\minion", "w") as f:
# \n characters are converted to os.linesep
f.writelines(old_content)
while not (os.path.exists(f"{OLD_DIR}\\bin\\python.exe")):
time.sleep(0.1)
while not (os.path.exists(f"{OLD_DIR}\\bin\\ssm.exe")):
time.sleep(0.1)
while not (os.path.exists(f"{OLD_DIR}\\conf\\minion")):
time.sleep(0.1)
assert os.path.exists(f"{OLD_DIR}\\bin\\python.exe")
assert os.path.exists(f"{OLD_DIR}\\bin\\ssm.exe")
assert os.path.exists(f"{OLD_DIR}\\conf\\minion")
@pytest.helpers.register
def run_command(cmd):
result = subprocess.run(cmd, capture_output=True, text=True)
return result.stdout.strip().replace("/", "\\")
def install_salt(args):
"""
Cleans the environment and installs salt with passed arguments
"""
cmd = [f'"{INST_BIN}"']
if isinstance(args, str):
cmd.append(args)
elif isinstance(args, list):
cmd.extend(args)
else:
raise TypeError(f"Invalid args format: {args}")
run_command(cmd)
# Let's make sure none of the install/uninstall processes are running
try:
assert os.path.basename(INST_BIN) not in (
p.name() for p in psutil.process_iter()
)
except psutil.NoSuchProcess:
pass
# These are at the bottom because they depend on some of the functions
REPO_DIR = run_command(["git", "rev-parse", "--show-toplevel"])
REPO_DIR = rf"{REPO_DIR}\pkg\windows\nsis\tests"
os.chdir(REPO_DIR)
INST_BIN = rf"{REPO_DIR}\test-setup.exe"
def is_file_locked(path):
"""
Try to see if a file is locked
"""
if not (os.path.exists(path)):
return False
try:
f = open(path)
f.close()
except OSError:
return True
return False
@pytest.helpers.register
def run_command(cmd_args, timeout=300):
if isinstance(cmd_args, list):
cmd_args = " ".join(cmd_args)
bin_file = re.findall(r'"(.*?)"', cmd_args)[0]
elapsed_time = 0
while (
os.path.exists(bin_file) and is_file_locked(bin_file) and elapsed_time < timeout
):
elapsed_time += 0.1
time.sleep(0.1)
proc = subprocess.Popen(cmd_args, stderr=subprocess.PIPE, stdout=subprocess.PIPE)
elapsed_time = 0
while (
os.path.exists(bin_file) and is_file_locked(bin_file) and elapsed_time < timeout
):
elapsed_time += 0.1
time.sleep(0.1)
try:
out, err = proc.communicate(timeout=timeout)
assert proc.returncode == 0
except subprocess.TimeoutExpired:
# This hides the hung installer/uninstaller problem
proc.kill()
out = "process killed"
return out

View file

@ -6,14 +6,12 @@ import pytest
@pytest.fixture(scope="module")
def install():
pytest.helpers.clean_env()
# Create a custom config
pytest.helpers.custom_config()
full_path_conf = f"{pytest.REPO_DIR}\\custom_conf"
pytest.helpers.run_command([pytest.INST_BIN, f"/custom-config={full_path_conf}"])
yield
full_path_conf = pytest.helpers.custom_config()
# Install salt passing custom-config
args = [f"/custom-config={full_path_conf}"]
pytest.helpers.install_salt(args)
yield args
pytest.helpers.clean_env()
@ -27,7 +25,7 @@ def test_config_present(install):
def test_config_correct(install):
# The config file should be the default, unchanged
with open(f"{pytest.REPO_DIR}\\custom_conf") as f:
with open(f"{pytest.SCRIPT_DIR}\\custom_conf") as f:
expected = f.readlines()
with open(f"{pytest.DATA_DIR}\\conf\\minion") as f:

View file

@ -6,14 +6,11 @@ import pytest
@pytest.fixture(scope="module")
def install():
pytest.helpers.clean_env()
# Create a custom config
pytest.helpers.custom_config()
pytest.helpers.run_command(
[pytest.INST_BIN, "/custom-config=custom_conf", "/master=cli_master"]
)
yield
args = ["/custom-config=custom_conf", "/master=cli_master"]
pytest.helpers.install_salt(args)
yield args
pytest.helpers.clean_env()

View file

@ -6,19 +6,15 @@ import pytest
@pytest.fixture(scope="module")
def install():
pytest.helpers.clean_env()
# Create a custom config
pytest.helpers.custom_config()
pytest.helpers.run_command(
[
pytest.INST_BIN,
"/custom-config=custom_conf",
"/master=cli_master",
"/minion-name=cli_minion",
]
)
yield
args = [
"/custom-config=custom_conf",
"/master=cli_master",
"/minion-name=cli_minion",
]
pytest.helpers.install_salt(args)
yield args
pytest.helpers.clean_env()

View file

@ -6,14 +6,11 @@ import pytest
@pytest.fixture(scope="module")
def install():
pytest.helpers.clean_env()
# Create a custom config
pytest.helpers.custom_config()
pytest.helpers.run_command(
[pytest.INST_BIN, "/custom-config=custom_conf", "/minion-name=cli_minion"]
)
yield
args = ["/custom-config=custom_conf", "/minion-name=cli_minion"]
pytest.helpers.install_salt(args)
yield args
pytest.helpers.clean_env()

View file

@ -6,12 +6,11 @@ import pytest
@pytest.fixture(scope="module")
def install():
pytest.helpers.clean_env()
# Create a custom config
pytest.helpers.custom_config()
pytest.helpers.run_command([pytest.INST_BIN, "/custom-config=custom_conf"])
yield
args = ["/custom-config=custom_conf"]
pytest.helpers.install_salt(args)
yield args
pytest.helpers.clean_env()
@ -25,7 +24,7 @@ def test_config_present(install):
def test_config_correct(install):
# The config file should be the default, unchanged
with open(f"{pytest.REPO_DIR}\\custom_conf") as f:
with open(f"{pytest.SCRIPT_DIR}\\custom_conf") as f:
expected = f.readlines()
with open(f"{pytest.DATA_DIR}\\conf\\minion") as f:

View file

@ -6,8 +6,9 @@ import pytest
@pytest.fixture(scope="module")
def install():
pytest.helpers.clean_env()
pytest.helpers.run_command([pytest.INST_BIN])
yield
args = []
pytest.helpers.install_salt(args)
yield args
pytest.helpers.clean_env()
@ -21,7 +22,7 @@ def test_config_present(install):
def test_config_correct(install):
# The config file should be the default, unchanged
with open(f"{pytest.REPO_DIR}\\tests\\_files\\minion") as f:
with open(rf"{pytest.SCRIPT_DIR}\_files\minion") as f:
expected = f.readlines()
with open(f"{pytest.DATA_DIR}\\conf\\minion") as f:

View file

@ -6,13 +6,14 @@ import pytest
@pytest.fixture(scope="module")
def install():
pytest.helpers.clean_env()
pytest.helpers.run_command([pytest.INST_BIN, "/master=cli_master"])
yield
args = ["/master=cli_master"]
pytest.helpers.install_salt(args)
yield args
pytest.helpers.clean_env()
def test_binaries_present(install):
assert os.path.exists(f"{pytest.INST_DIR}\\bsm.exe")
assert os.path.exists(f"{pytest.INST_DIR}\\ssm.exe")
def test_config_present(install):

View file

@ -6,10 +6,9 @@ import pytest
@pytest.fixture(scope="module")
def install():
pytest.helpers.clean_env()
pytest.helpers.run_command(
[pytest.INST_BIN, "/master=cli_master", "/minion-name=cli_minion"]
)
yield
args = ["/master=cli_master", "/minion-name=cli_minion"]
pytest.helpers.install_salt(args)
yield args
pytest.helpers.clean_env()

View file

@ -6,8 +6,9 @@ import pytest
@pytest.fixture(scope="module")
def install():
pytest.helpers.clean_env()
pytest.helpers.run_command([pytest.INST_BIN, "/minion-name=cli_minion"])
yield
args = ["/minion-name=cli_minion"]
pytest.helpers.install_salt(args)
yield args
pytest.helpers.clean_env()

View file

@ -6,12 +6,11 @@ import pytest
@pytest.fixture(scope="module")
def install():
pytest.helpers.clean_env()
# Create an existing config
pytest.helpers.existing_config()
pytest.helpers.run_command([pytest.INST_BIN])
yield
args = []
pytest.helpers.install_salt(args)
yield args
pytest.helpers.clean_env()

View file

@ -6,15 +6,13 @@ import pytest
@pytest.fixture(scope="module")
def install():
pytest.helpers.clean_env()
# Create an existing config
pytest.helpers.existing_config()
# Create a custom config
pytest.helpers.custom_config()
pytest.helpers.run_command([pytest.INST_BIN, "/custom-config=custom_conf"])
yield
args = ["/custom-config=custom_conf"]
pytest.helpers.install_salt(args)
yield args
pytest.helpers.clean_env()
@ -28,7 +26,7 @@ def test_config_present(install):
def test_config_correct(install):
# The config file should be the default, unchanged
with open(f"{pytest.REPO_DIR}\\custom_conf") as f:
with open(f"{pytest.SCRIPT_DIR}\\custom_conf") as f:
expected = f.readlines()
with open(f"{pytest.DATA_DIR}\\conf\\minion") as f:

View file

@ -6,17 +6,13 @@ import pytest
@pytest.fixture(scope="module")
def install():
pytest.helpers.clean_env()
# Create an existing config
pytest.helpers.existing_config()
# Create a custom config
pytest.helpers.custom_config()
pytest.helpers.run_command(
[pytest.INST_BIN, "/custom-config=custom_conf", "/master=cli_master"]
)
yield
args = ["/custom-config=custom_conf", "/master=cli_master"]
pytest.helpers.install_salt(args)
yield args
pytest.helpers.clean_env()

View file

@ -6,22 +6,17 @@ import pytest
@pytest.fixture(scope="module")
def install():
pytest.helpers.clean_env()
# Create an existing config
pytest.helpers.existing_config()
# Create a custom config
pytest.helpers.custom_config()
pytest.helpers.run_command(
[
pytest.INST_BIN,
"/custom-config=custom_conf",
"/master=cli_master",
"/minion-name=cli_minion",
]
)
yield
args = [
"/custom-config=custom_conf",
"/master=cli_master",
"/minion-name=cli_minion",
]
pytest.helpers.install_salt(args)
yield args
pytest.helpers.clean_env()

View file

@ -8,14 +8,11 @@ def install():
pytest.helpers.clean_env()
# Create an existing config
pytest.helpers.existing_config()
# Create a custom config
pytest.helpers.custom_config()
pytest.helpers.run_command(
[pytest.INST_BIN, "/custom-config=custom_conf", "/minion-name=cli_minion"]
)
yield
args = ["/custom-config=custom_conf", "/minion-name=cli_minion"]
pytest.helpers.install_salt(args)
yield args
pytest.helpers.clean_env()

View file

@ -6,12 +6,11 @@ import pytest
@pytest.fixture(scope="module")
def install():
pytest.helpers.clean_env()
# Create an existing config
pytest.helpers.existing_config()
pytest.helpers.run_command([pytest.INST_BIN, "/default-config"])
yield
args = ["/default-config"]
pytest.helpers.install_salt(args)
yield args
pytest.helpers.clean_env()
@ -25,7 +24,7 @@ def test_config_present(install):
def test_config_correct(install):
# The config file should be the default, unchanged
with open(f"{pytest.REPO_DIR}\\tests\\_files\\minion") as f:
with open(rf"{pytest.SCRIPT_DIR}\_files\minion") as f:
expected = f.readlines()
with open(f"{pytest.DATA_DIR}\\conf\\minion") as f:

View file

@ -6,14 +6,11 @@ import pytest
@pytest.fixture(scope="module")
def install():
pytest.helpers.clean_env()
# Create an existing config
pytest.helpers.existing_config()
pytest.helpers.run_command(
[pytest.INST_BIN, "/default-config", "/master=cli_master"]
)
yield
args = ["/default-config", "/master=cli_master"]
pytest.helpers.install_salt(args)
yield args
pytest.helpers.clean_env()

View file

@ -6,19 +6,11 @@ import pytest
@pytest.fixture(scope="module")
def install():
pytest.helpers.clean_env()
# Create an existing config
pytest.helpers.existing_config()
pytest.helpers.run_command(
[
pytest.INST_BIN,
"/default-config",
"/master=cli_master",
"/minion-name=cli_minion",
]
)
yield
args = ["/default-config", "/master=cli_master", "/minion-name=cli_minion"]
pytest.helpers.install_salt(args)
yield args
pytest.helpers.clean_env()

View file

@ -6,14 +6,11 @@ import pytest
@pytest.fixture(scope="module")
def install():
pytest.helpers.clean_env()
# Create an existing config
pytest.helpers.existing_config()
pytest.helpers.run_command(
[pytest.INST_BIN, "/default-config", "/minion-name=cli_minion"]
)
yield
args = ["/default-config", "/minion-name=cli_minion"]
pytest.helpers.install_salt(args)
yield args
pytest.helpers.clean_env()

View file

@ -0,0 +1,41 @@
import os
import pytest
@pytest.fixture(scope="module")
def inst_dir():
return "C:\\custom_location"
@pytest.fixture(scope="module")
def install(inst_dir):
pytest.helpers.clean_env()
# Create a custom config
pytest.helpers.custom_config()
args = [f"/install-dir={inst_dir}", "/custom-config=custom_conf"]
pytest.helpers.install_salt(args)
yield args
pytest.helpers.clean_env(inst_dir)
def test_binaries_present(install, inst_dir):
# This will show the contents of the directory on failure
inst_dir_exists = os.path.exists(inst_dir)
dir_contents = os.listdir(inst_dir)
assert os.path.exists(rf"{inst_dir}\ssm.exe")
def test_config_present(install):
assert os.path.exists(rf"{pytest.DATA_DIR}\conf\minion")
def test_config_correct(install):
# The config file should be the custom config, unchanged
with open(rf"{pytest.SCRIPT_DIR}\custom_conf") as f:
expected = f.readlines()
with open(rf"{pytest.DATA_DIR}\conf\minion") as f:
result = f.readlines()
assert result == expected

View file

@ -0,0 +1,53 @@
import os
import pytest
@pytest.fixture(scope="module")
def inst_dir():
return "C:\\custom_location"
@pytest.fixture(scope="module")
def install(inst_dir):
pytest.helpers.clean_env()
# Create a custom config
pytest.helpers.custom_config()
args = [
f"/install-dir={inst_dir}",
"/custom-config=custom_conf",
"/master=cli_master",
]
pytest.helpers.install_salt(args)
yield args
pytest.helpers.clean_env(inst_dir)
def test_binaries_present(install, inst_dir):
# This will show the contents of the directory on failure
inst_dir_exists = os.path.exists(inst_dir)
dir_contents = os.listdir(inst_dir)
assert os.path.exists(rf"{inst_dir}\ssm.exe")
def test_config_present(install):
assert os.path.exists(rf"{pytest.DATA_DIR}\conf\minion")
def test_config_correct(install):
# The config file should be the custom config with only master set
expected = [
"# Custom config from test suite line 1/6\n",
"master: cli_master\n",
"# Custom config from test suite line 2/6\n",
"id: custom_minion\n",
"# Custom config from test suite line 3/6\n",
"# Custom config from test suite line 4/6\n",
"# Custom config from test suite line 5/6\n",
"# Custom config from test suite line 6/6\n",
]
with open(rf"{pytest.DATA_DIR}\conf\minion") as f:
result = f.readlines()
assert result == expected

View file

@ -0,0 +1,54 @@
import os
import pytest
@pytest.fixture(scope="module")
def inst_dir():
return "C:\\custom_location"
@pytest.fixture(scope="module")
def install(inst_dir):
pytest.helpers.clean_env()
# Create a custom config
pytest.helpers.custom_config()
args = [
f"/install-dir={inst_dir}",
"/custom-config=custom_conf",
"/master=cli_master",
"/minion-name=cli_minion",
]
pytest.helpers.install_salt(args)
yield args
pytest.helpers.clean_env(inst_dir)
def test_binaries_present(install, inst_dir):
# This will show the contents of the directory on failure
inst_dir_exists = os.path.exists(inst_dir)
dir_contents = os.listdir(inst_dir)
assert os.path.exists(rf"{inst_dir}\ssm.exe")
def test_config_present(install):
assert os.path.exists(rf"{pytest.DATA_DIR}\conf\minion")
def test_config_correct(install):
# The config file should be the custom config with master and minion set
expected = [
"# Custom config from test suite line 1/6\n",
"master: cli_master\n",
"# Custom config from test suite line 2/6\n",
"id: cli_minion\n",
"# Custom config from test suite line 3/6\n",
"# Custom config from test suite line 4/6\n",
"# Custom config from test suite line 5/6\n",
"# Custom config from test suite line 6/6\n",
]
with open(rf"{pytest.DATA_DIR}\conf\minion") as f:
result = f.readlines()
assert result == expected

View file

@ -0,0 +1,53 @@
import os
import pytest
@pytest.fixture(scope="module")
def inst_dir():
return "C:\\custom_location"
@pytest.fixture(scope="module")
def install(inst_dir):
pytest.helpers.clean_env()
# Create a custom config
pytest.helpers.custom_config()
args = [
f"/install-dir={inst_dir}",
"/custom-config=custom_conf",
"/minion-name=cli_minion",
]
pytest.helpers.install_salt(args)
yield args
pytest.helpers.clean_env(inst_dir)
def test_binaries_present(install, inst_dir):
# This will show the contents of the directory on failure
inst_dir_exists = os.path.exists(inst_dir)
dir_contents = os.listdir(inst_dir)
assert os.path.exists(rf"{inst_dir}\ssm.exe")
def test_config_present(install):
assert os.path.exists(rf"{pytest.DATA_DIR}\conf\minion")
def test_config_correct(install):
# The config file should be the custom config with only minion set
expected = [
"# Custom config from test suite line 1/6\n",
"master: custom_master\n",
"# Custom config from test suite line 2/6\n",
"id: cli_minion\n",
"# Custom config from test suite line 3/6\n",
"# Custom config from test suite line 4/6\n",
"# Custom config from test suite line 5/6\n",
"# Custom config from test suite line 6/6\n",
]
with open(rf"{pytest.DATA_DIR}\conf\minion") as f:
result = f.readlines()
assert result == expected

View file

@ -0,0 +1,39 @@
import os
import pytest
@pytest.fixture(scope="module")
def inst_dir():
return "C:\\custom_location"
@pytest.fixture(scope="module")
def install(inst_dir):
pytest.helpers.clean_env()
args = [f"/install-dir={inst_dir}"]
pytest.helpers.install_salt(args)
yield args
pytest.helpers.clean_env(inst_dir)
def test_binaries_present(install, inst_dir):
# This will show the contents of the directory on failure
inst_dir_exists = os.path.exists(inst_dir)
dir_contents = os.listdir(inst_dir)
assert os.path.exists(rf"{inst_dir}\ssm.exe")
def test_config_present(install):
assert os.path.exists(rf"{pytest.DATA_DIR}\conf\minion")
def test_config_correct(install):
# The config file should be the default config, unchanged
with open(rf"{pytest.SCRIPT_DIR}\_files\minion") as f:
expected = f.readlines()
with open(rf"{pytest.DATA_DIR}\conf\minion") as f:
result = f.readlines()
assert result == expected

View file

@ -0,0 +1,47 @@
import os
import pytest
@pytest.fixture(scope="module")
def inst_dir():
return "C:\\custom_location"
@pytest.fixture(scope="module")
def install(inst_dir):
pytest.helpers.clean_env()
args = [f"/install-dir={inst_dir}", "/master=cli_master"]
pytest.helpers.install_salt(args)
yield args
pytest.helpers.clean_env(inst_dir)
def test_binaries_present(install, inst_dir):
# This will show the contents of the directory on failure
inst_dir_exists = os.path.exists(inst_dir)
dir_contents = os.listdir(inst_dir)
assert os.path.exists(rf"{inst_dir}\ssm.exe")
def test_config_present(install):
assert os.path.exists(rf"{pytest.DATA_DIR}\conf\minion")
def test_config_correct(install):
# The config file should be the default config with only master set
expected = [
"# Default config from test suite line 1/6\n",
"master: cli_master\n",
"# Default config from test suite line 2/6\n",
"#id:\n",
"# Default config from test suite line 3/6\n",
"# Default config from test suite line 4/6\n",
"# Default config from test suite line 5/6\n",
"# Default config from test suite line 6/6\n",
]
with open(rf"{pytest.DATA_DIR}\conf\minion") as f:
result = f.readlines()
assert result == expected

View file

@ -0,0 +1,47 @@
import os
import pytest
@pytest.fixture(scope="module")
def inst_dir():
return "C:\\custom_location"
@pytest.fixture(scope="module")
def install(inst_dir):
pytest.helpers.clean_env()
args = [f"/install-dir={inst_dir}", "/master=cli_master", "/minion-name=cli_minion"]
pytest.helpers.install_salt(args)
yield args
pytest.helpers.clean_env(inst_dir)
def test_binaries_present(install, inst_dir):
# This will show the contents of the directory on failure
inst_dir_exists = os.path.exists(inst_dir)
dir_contents = os.listdir(inst_dir)
assert os.path.exists(rf"{inst_dir}\ssm.exe")
def test_config_present(install):
assert os.path.exists(rf"{pytest.DATA_DIR}\conf\minion")
def test_config_correct(install):
# The config file should be the default config with master and minion set
expected = [
"# Default config from test suite line 1/6\n",
"master: cli_master\n",
"# Default config from test suite line 2/6\n",
"id: cli_minion\n",
"# Default config from test suite line 3/6\n",
"# Default config from test suite line 4/6\n",
"# Default config from test suite line 5/6\n",
"# Default config from test suite line 6/6\n",
]
with open(rf"{pytest.DATA_DIR}\conf\minion") as f:
result = f.readlines()
assert result == expected

View file

@ -0,0 +1,47 @@
import os
import pytest
@pytest.fixture(scope="module")
def inst_dir():
return "C:\\custom_location"
@pytest.fixture(scope="module")
def install(inst_dir):
pytest.helpers.clean_env()
args = [f"/install-dir={inst_dir}", "/minion-name=cli_minion"]
pytest.helpers.install_salt(args)
yield args
pytest.helpers.clean_env(inst_dir)
def test_binaries_present(install, inst_dir):
# This will show the contents of the directory on failure
inst_dir_exists = os.path.exists(inst_dir)
dir_contents = os.listdir(inst_dir)
assert os.path.exists(rf"{inst_dir}\ssm.exe")
def test_config_present(install):
assert os.path.exists(rf"{pytest.DATA_DIR}\conf\minion")
def test_config_correct(install):
# The config file should be the default config with just the minion set
expected = [
"# Default config from test suite line 1/6\n",
"#master: salt\n",
"# Default config from test suite line 2/6\n",
"id: cli_minion\n",
"# Default config from test suite line 3/6\n",
"# Default config from test suite line 4/6\n",
"# Default config from test suite line 5/6\n",
"# Default config from test suite line 6/6\n",
]
with open(rf"{pytest.DATA_DIR}\conf\minion") as f:
result = f.readlines()
assert result == expected

View file

@ -0,0 +1,40 @@
import os
import pytest
@pytest.fixture(scope="module")
def inst_dir():
return "C:\\custom_location"
@pytest.fixture(scope="module")
def install(inst_dir):
pytest.helpers.clean_env()
# Create an existing config
pytest.helpers.existing_config()
args = [f"/install-dir={inst_dir}"]
pytest.helpers.install_salt(args)
yield args
pytest.helpers.clean_env(inst_dir)
def test_binaries_present(install, inst_dir):
# This will show the contents of the directory on failure
inst_dir_exists = os.path.exists(inst_dir)
dir_contents = os.listdir(inst_dir)
assert os.path.exists(rf"{inst_dir}\ssm.exe")
def test_config_present(install):
assert os.path.exists(rf"{pytest.DATA_DIR}\conf\minion")
def test_config_correct(install):
# The config file should be the existing config, unchanged
expected = pytest.EXISTING_CONTENT
with open(rf"{pytest.DATA_DIR}\conf\minion") as f:
result = f.readlines()
assert result == expected

View file

@ -0,0 +1,42 @@
import os
import pytest
@pytest.fixture(scope="module")
def inst_dir():
return "C:\\custom_location"
@pytest.fixture(scope="module")
def install(inst_dir):
pytest.helpers.clean_env()
# Create old install
pytest.helpers.old_install()
args = [f"/install-dir={inst_dir}", "/move-config"]
pytest.helpers.install_salt(args)
yield args
pytest.helpers.clean_env()
def test_binaries_present_old_location(install):
# This will show the contents of the directory on failure
dir_contents = os.listdir(rf"{pytest.OLD_DIR}\bin")
# Apparently we don't move the binaries even if they pass install-dir
# TODO: Decide if this is expected behavior
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\ssm.exe")
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\python.exe")
def test_config_present(install):
assert os.path.exists(rf"{pytest.DATA_DIR}\conf\minion")
def test_config_correct(install):
# The config file should be the existing config in the new location, unchanged
expected = pytest.OLD_CONTENT
with open(rf"{pytest.DATA_DIR}\conf\minion") as f:
result = f.readlines()
assert result == expected

View file

@ -0,0 +1,37 @@
import os
import pytest
@pytest.fixture(scope="module")
def install():
pytest.helpers.clean_env()
# Create old config
pytest.helpers.old_install()
args = []
pytest.helpers.install_salt(args)
yield args
pytest.helpers.clean_env()
def test_binaries_present_old_location(install):
# This will show the contents of the directory on failure
dir_contents = os.listdir(rf"{pytest.OLD_DIR}\bin")
# Apparently we don't move the binaries even if they pass install-dir
# TODO: Decide if this is expected behavior
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\ssm.exe")
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\python.exe")
def test_config_present_old_location(install):
assert os.path.exists(rf"{pytest.OLD_DIR}\conf\minion")
def test_config_correct(install):
# The config file should be the old existing config, unchanged
expected = pytest.OLD_CONTENT
with open(rf"{pytest.OLD_DIR}\conf\minion") as f:
result = f.readlines()
assert result == expected

View file

@ -0,0 +1,40 @@
import os
import pytest
@pytest.fixture(scope="module")
def install():
pytest.helpers.clean_env()
# Create old config
pytest.helpers.old_install()
# Create a custom config
pytest.helpers.custom_config()
args = ["/custom-config=custom_conf"]
pytest.helpers.install_salt(args)
yield args
pytest.helpers.clean_env()
def test_binaries_present_old_location(install):
# This will show the contents of the directory on failure
dir_contents = os.listdir(rf"{pytest.OLD_DIR}\bin")
# Apparently we don't move the binaries even if they pass install-dir
# TODO: Decide if this is expected behavior
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\ssm.exe")
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\python.exe")
def test_config_present_old_location(install):
assert os.path.exists(rf"{pytest.OLD_DIR}\conf\minion")
def test_config_correct(install):
# The config file should be the custom config, unchanged
with open(rf"{pytest.SCRIPT_DIR}\custom_conf") as f:
expected = f.readlines()
with open(rf"{pytest.OLD_DIR}\conf\minion") as f:
result = f.readlines()
assert result == expected

View file

@ -0,0 +1,48 @@
import os
import pytest
@pytest.fixture(scope="module")
def install():
pytest.helpers.clean_env()
# Create old config
pytest.helpers.old_install()
# Create a custom config
pytest.helpers.custom_config()
args = ["/custom-config=custom_conf", "/master=cli_master"]
pytest.helpers.install_salt(args)
yield args
pytest.helpers.clean_env()
def test_binaries_present_old_location(install):
# This will show the contents of the directory on failure
dir_contents = os.listdir(rf"{pytest.OLD_DIR}\bin")
# Apparently we don't move the binaries even if they pass install-dir
# TODO: Decide if this is expected behavior
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\ssm.exe")
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\python.exe")
def test_config_present_old_location(install):
assert os.path.exists(rf"{pytest.OLD_DIR}\conf\minion")
def test_config_correct(install):
# The config file should be the custom config with only master set
expected = [
"# Custom config from test suite line 1/6\n",
"master: cli_master\n",
"# Custom config from test suite line 2/6\n",
"id: custom_minion\n",
"# Custom config from test suite line 3/6\n",
"# Custom config from test suite line 4/6\n",
"# Custom config from test suite line 5/6\n",
"# Custom config from test suite line 6/6\n",
]
with open(rf"{pytest.OLD_DIR}\conf\minion") as f:
result = f.readlines()
assert result == expected

View file

@ -0,0 +1,52 @@
import os
import pytest
@pytest.fixture(scope="module")
def install():
pytest.helpers.clean_env()
# Create old config
pytest.helpers.old_install()
# Create a custom config
pytest.helpers.custom_config()
args = [
"/custom-config=custom_conf",
"/master=cli_master",
"/minion-name=cli_minion",
]
pytest.helpers.install_salt(args)
yield args
pytest.helpers.clean_env()
def test_binaries_present_old_location(install):
# This will show the contents of the directory on failure
dir_contents = os.listdir(rf"{pytest.OLD_DIR}\bin")
# Apparently we don't move the binaries even if they pass install-dir
# TODO: Decide if this is expected behavior
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\ssm.exe")
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\python.exe")
def test_config_present_old_location(install):
assert os.path.exists(rf"{pytest.OLD_DIR}\conf\minion")
def test_config_correct(install):
# The config file should be the custom config with master and minion set
expected = [
"# Custom config from test suite line 1/6\n",
"master: cli_master\n",
"# Custom config from test suite line 2/6\n",
"id: cli_minion\n",
"# Custom config from test suite line 3/6\n",
"# Custom config from test suite line 4/6\n",
"# Custom config from test suite line 5/6\n",
"# Custom config from test suite line 6/6\n",
]
with open(rf"{pytest.OLD_DIR}\conf\minion") as f:
result = f.readlines()
assert result == expected

View file

@ -0,0 +1,48 @@
import os
import pytest
@pytest.fixture(scope="module")
def install():
pytest.helpers.clean_env()
# Create old config
pytest.helpers.old_install()
# Create a custom config
pytest.helpers.custom_config()
args = ["/custom-config=custom_conf", "/minion-name=cli_minion"]
pytest.helpers.install_salt(args)
yield args
pytest.helpers.clean_env()
def test_binaries_present_old_location(install):
# This will show the contents of the directory on failure
dir_contents = os.listdir(rf"{pytest.OLD_DIR}\bin")
# Apparently we don't move the binaries even if they pass install-dir
# TODO: Decide if this is expected behavior
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\ssm.exe")
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\python.exe")
def test_config_present_old_location(install):
assert os.path.exists(rf"{pytest.OLD_DIR}\conf\minion")
def test_config_correct(install):
# The config file should be the custom config with only minion set
expected = [
"# Custom config from test suite line 1/6\n",
"master: custom_master\n",
"# Custom config from test suite line 2/6\n",
"id: cli_minion\n",
"# Custom config from test suite line 3/6\n",
"# Custom config from test suite line 4/6\n",
"# Custom config from test suite line 5/6\n",
"# Custom config from test suite line 6/6\n",
]
with open(rf"{pytest.OLD_DIR}\conf\minion") as f:
result = f.readlines()
assert result == expected

View file

@ -0,0 +1,38 @@
import os
import pytest
@pytest.fixture(scope="module")
def install():
pytest.helpers.clean_env()
# Create old install
pytest.helpers.old_install()
args = ["/default-config"]
pytest.helpers.install_salt(args)
yield args
pytest.helpers.clean_env()
def test_binaries_present_old_location(install):
# This will show the contents of the directory on failure
dir_contents = os.listdir(rf"{pytest.OLD_DIR}\bin")
# Apparently we don't move the binaries even if they pass install-dir
# TODO: Decide if this is expected behavior
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\ssm.exe")
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\python.exe")
def test_config_present_old_location(install):
assert os.path.exists(rf"{pytest.OLD_DIR}\conf\minion")
def test_config_correct(install):
# The config file should be the default config, unchanged
with open(rf"{pytest.SCRIPT_DIR}\_files\minion") as f:
expected = f.readlines()
with open(rf"{pytest.OLD_DIR}\conf\minion") as f:
result = f.readlines()
assert result == expected

View file

@ -0,0 +1,46 @@
import os
import pytest
@pytest.fixture(scope="module")
def install():
pytest.helpers.clean_env()
# Create old config
pytest.helpers.old_install()
args = ["/default-config", "/master=cli_master"]
pytest.helpers.install_salt(args)
yield args
pytest.helpers.clean_env()
def test_binaries_present_old_location(install):
# This will show the contents of the directory on failure
dir_contents = os.listdir(rf"{pytest.OLD_DIR}\bin")
# Apparently we don't move the binaries even if they pass install-dir
# TODO: Decide if this is expected behavior
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\ssm.exe")
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\python.exe")
def test_config_present_old_location(install):
assert os.path.exists(rf"{pytest.OLD_DIR}\conf\minion")
def test_config_correct(install):
# The config file should be the default config with only master set
expected = [
"# Default config from test suite line 1/6\n",
"master: cli_master\n",
"# Default config from test suite line 2/6\n",
"#id:\n",
"# Default config from test suite line 3/6\n",
"# Default config from test suite line 4/6\n",
"# Default config from test suite line 5/6\n",
"# Default config from test suite line 6/6\n",
]
with open(rf"{pytest.OLD_DIR}\conf\minion") as f:
result = f.readlines()
assert result == expected

View file

@ -0,0 +1,50 @@
import os
import pytest
@pytest.fixture(scope="module")
def install():
pytest.helpers.clean_env()
# Create old config
pytest.helpers.old_install()
args = [
"/default-config",
"/master=cli_master",
"/minion-name=cli_minion",
]
pytest.helpers.install_salt(args)
yield args
pytest.helpers.clean_env()
def test_binaries_present_old_location(install):
# This will show the contents of the directory on failure
dir_contents = os.listdir(rf"{pytest.OLD_DIR}\bin")
# Apparently we don't move the binaries even if they pass install-dir
# TODO: Decide if this is expected behavior
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\ssm.exe")
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\python.exe")
def test_config_present_old_location(install):
assert os.path.exists(rf"{pytest.OLD_DIR}\conf\minion")
def test_config_correct(install):
# The config file should be the default config with master and minion set
expected = [
"# Default config from test suite line 1/6\n",
"master: cli_master\n",
"# Default config from test suite line 2/6\n",
"id: cli_minion\n",
"# Default config from test suite line 3/6\n",
"# Default config from test suite line 4/6\n",
"# Default config from test suite line 5/6\n",
"# Default config from test suite line 6/6\n",
]
with open(rf"{pytest.OLD_DIR}\conf\minion") as f:
result = f.readlines()
assert result == expected

View file

@ -0,0 +1,46 @@
import os
import pytest
@pytest.fixture(scope="module")
def install():
pytest.helpers.clean_env()
# Create old config
pytest.helpers.old_install()
args = ["/default-config", "/minion-name=cli_minion"]
pytest.helpers.install_salt(args)
yield args
pytest.helpers.clean_env()
def test_binaries_present_old_location(install):
# This will show the contents of the directory on failure
dir_contents = os.listdir(rf"{pytest.OLD_DIR}\bin")
# Apparently we don't move the binaries even if they pass install-dir
# TODO: Decide if this is expected behavior
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\ssm.exe")
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\python.exe")
def test_config_present_old_location(install):
assert os.path.exists(rf"{pytest.OLD_DIR}\conf\minion")
def test_config_correct(install):
# The config file should be the default with only minion set
expected = [
"# Default config from test suite line 1/6\n",
"#master: salt\n",
"# Default config from test suite line 2/6\n",
"id: cli_minion\n",
"# Default config from test suite line 3/6\n",
"# Default config from test suite line 4/6\n",
"# Default config from test suite line 5/6\n",
"# Default config from test suite line 6/6\n",
]
with open(rf"{pytest.OLD_DIR}\conf\minion") as f:
result = f.readlines()
assert result == expected

View file

@ -0,0 +1,37 @@
import os
import pytest
@pytest.fixture(scope="module")
def install():
pytest.helpers.clean_env()
# Create old config
pytest.helpers.old_install()
args = ["/move-config"]
pytest.helpers.install_salt(args)
yield args
pytest.helpers.clean_env()
def test_binaries_present_old_location(install):
# This will show the contents of the directory on failure
dir_contents = os.listdir(rf"{pytest.OLD_DIR}\bin")
# Apparently we don't move the binaries even if they pass install-dir
# TODO: Decide if this is expected behavior
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\ssm.exe")
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\python.exe")
def test_config_present_new_location(install):
assert os.path.exists(rf"{pytest.DATA_DIR}\conf\minion")
def test_config_correct(install):
# The config file should be the old existing config in the new location, unchanged
expected = pytest.OLD_CONTENT
with open(rf"{pytest.DATA_DIR}\conf\minion") as f:
result = f.readlines()
assert result == expected

View file

@ -0,0 +1,40 @@
import os
import pytest
@pytest.fixture(scope="module")
def install():
pytest.helpers.clean_env()
# Create old config
pytest.helpers.old_install()
# Create a custom config
pytest.helpers.custom_config()
args = ["/custom-config=custom_conf", "/move-config"]
pytest.helpers.install_salt(args)
yield args
pytest.helpers.clean_env()
def test_binaries_present_old_location(install):
# This will show the contents of the directory on failure
dir_contents = os.listdir(rf"{pytest.OLD_DIR}\bin")
# Apparently we don't move the binaries even if they pass install-dir
# TODO: Decide if this is expected behavior
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\ssm.exe")
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\python.exe")
def test_config_present_new_location(install):
assert os.path.exists(rf"{pytest.DATA_DIR}\conf\minion")
def test_config_correct(install):
# The config file should be the custom config in the new location, unchanged
with open(rf"{pytest.SCRIPT_DIR}\custom_conf") as f:
expected = f.readlines()
with open(rf"{pytest.DATA_DIR}\conf\minion") as f:
result = f.readlines()
assert result == expected

View file

@ -0,0 +1,48 @@
import os
import pytest
@pytest.fixture(scope="module")
def install():
pytest.helpers.clean_env()
# Create old config
pytest.helpers.old_install()
# Create a custom config
pytest.helpers.custom_config()
args = ["/custom-config=custom_conf", "/move-config", "/master=cli_master"]
pytest.helpers.install_salt(args)
yield args
pytest.helpers.clean_env()
def test_binaries_present_old_location(install):
# This will show the contents of the directory on failure
dir_contents = os.listdir(rf"{pytest.OLD_DIR}\bin")
# Apparently we don't move the binaries even if they pass install-dir
# TODO: Decide if this is expected behavior
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\ssm.exe")
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\python.exe")
def test_config_present_new_location(install):
assert os.path.exists(rf"{pytest.DATA_DIR}\conf\minion")
def test_config_correct(install):
# The config file should be the custom config in the new location with only master set
expected = [
"# Custom config from test suite line 1/6\n",
"master: cli_master\n",
"# Custom config from test suite line 2/6\n",
"id: custom_minion\n",
"# Custom config from test suite line 3/6\n",
"# Custom config from test suite line 4/6\n",
"# Custom config from test suite line 5/6\n",
"# Custom config from test suite line 6/6\n",
]
with open(rf"{pytest.DATA_DIR}\conf\minion") as f:
result = f.readlines()
assert result == expected

View file

@ -0,0 +1,53 @@
import os
import pytest
@pytest.fixture(scope="module")
def install():
pytest.helpers.clean_env()
# Create old config
pytest.helpers.old_install()
# Create a custom config
pytest.helpers.custom_config()
args = [
"/custom-config=custom_conf",
"/move-config",
"/master=cli_master",
"/minion-name=cli_minion",
]
pytest.helpers.install_salt(args)
yield args
pytest.helpers.clean_env()
def test_binaries_present_old_location(install):
# This will show the contents of the directory on failure
dir_contents = os.listdir(rf"{pytest.OLD_DIR}\bin")
# Apparently we don't move the binaries even if they pass install-dir
# TODO: Decide if this is expected behavior
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\ssm.exe")
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\python.exe")
def test_config_present_new_location(install):
assert os.path.exists(rf"{pytest.DATA_DIR}\conf\minion")
def test_config_correct(install):
# The config file should be the custom config in the new location with master and minion set
expected = [
"# Custom config from test suite line 1/6\n",
"master: cli_master\n",
"# Custom config from test suite line 2/6\n",
"id: cli_minion\n",
"# Custom config from test suite line 3/6\n",
"# Custom config from test suite line 4/6\n",
"# Custom config from test suite line 5/6\n",
"# Custom config from test suite line 6/6\n",
]
with open(rf"{pytest.DATA_DIR}\conf\minion") as f:
result = f.readlines()
assert result == expected

View file

@ -0,0 +1,48 @@
import os
import pytest
@pytest.fixture(scope="module")
def install():
pytest.helpers.clean_env()
# Create old config
pytest.helpers.old_install()
# Create a custom config
pytest.helpers.custom_config()
args = ["/custom-config=custom_conf", "/move-config", "/minion-name=cli_minion"]
pytest.helpers.install_salt(args)
yield args
pytest.helpers.clean_env()
def test_binaries_present_old_location(install):
# This will show the contents of the directory on failure
dir_contents = os.listdir(rf"{pytest.OLD_DIR}\bin")
# Apparently we don't move the binaries even if they pass install-dir
# TODO: Decide if this is expected behavior
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\ssm.exe")
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\python.exe")
def test_config_present_new_location(install):
assert os.path.exists(rf"{pytest.DATA_DIR}\conf\minion")
def test_config_correct(install):
# The config file should be the custom config in the new location with only minion set
expected = [
"# Custom config from test suite line 1/6\n",
"master: custom_master\n",
"# Custom config from test suite line 2/6\n",
"id: cli_minion\n",
"# Custom config from test suite line 3/6\n",
"# Custom config from test suite line 4/6\n",
"# Custom config from test suite line 5/6\n",
"# Custom config from test suite line 6/6\n",
]
with open(rf"{pytest.DATA_DIR}\conf\minion") as f:
result = f.readlines()
assert result == expected

View file

@ -0,0 +1,38 @@
import os
import pytest
@pytest.fixture(scope="module")
def install():
pytest.helpers.clean_env()
# Create old config
pytest.helpers.old_install()
args = ["/move-config", "/default-config"]
pytest.helpers.install_salt(args)
yield args
pytest.helpers.clean_env()
def test_binaries_present_old_location(install):
# This will show the contents of the directory on failure
dir_contents = os.listdir(rf"{pytest.OLD_DIR}\bin")
# Apparently we don't move the binaries even if they pass install-dir
# TODO: Decide if this is expected behavior
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\ssm.exe")
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\python.exe")
def test_config_present_new_location(install):
assert os.path.exists(rf"{pytest.DATA_DIR}\conf\minion")
def test_config_correct(install):
# The config file should be the default config in the new location, unchanged
with open(rf"{pytest.SCRIPT_DIR}\_files\minion") as f:
expected = f.readlines()
with open(rf"{pytest.DATA_DIR}\conf\minion") as f:
result = f.readlines()
assert result == expected

View file

@ -0,0 +1,46 @@
import os
import pytest
@pytest.fixture(scope="module")
def install():
pytest.helpers.clean_env()
# Create old config
pytest.helpers.old_install()
args = ["/default-config", "/move-config", "/master=cli_master"]
pytest.helpers.install_salt(args)
yield args
pytest.helpers.clean_env()
def test_binaries_present_old_location(install):
# This will show the contents of the directory on failure
dir_contents = os.listdir(rf"{pytest.OLD_DIR}\bin")
# Apparently we don't move the binaries even if they pass install-dir
# TODO: Decide if this is expected behavior
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\ssm.exe")
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\python.exe")
def test_config_present_new_location(install):
assert os.path.exists(rf"{pytest.DATA_DIR}\conf\minion")
def test_config_correct(install):
# The config file should be the default config in the new location with only master set
expected = [
"# Default config from test suite line 1/6\n",
"master: cli_master\n",
"# Default config from test suite line 2/6\n",
"#id:\n",
"# Default config from test suite line 3/6\n",
"# Default config from test suite line 4/6\n",
"# Default config from test suite line 5/6\n",
"# Default config from test suite line 6/6\n",
]
with open(rf"{pytest.DATA_DIR}\conf\minion") as f:
result = f.readlines()
assert result == expected

View file

@ -0,0 +1,51 @@
import os
import pytest
@pytest.fixture(scope="module")
def install():
pytest.helpers.clean_env()
# Create old config
pytest.helpers.old_install()
args = [
"/default-config",
"/move-config",
"/master=cli_master",
"/minion-name=cli_minion",
]
pytest.helpers.install_salt(args)
yield args
pytest.helpers.clean_env()
def test_binaries_present_old_location(install):
# This will show the contents of the directory on failure
dir_contents = os.listdir(rf"{pytest.OLD_DIR}\bin")
# Apparently we don't move the binaries even if they pass install-dir
# TODO: Decide if this is expected behavior
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\ssm.exe")
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\python.exe")
def test_config_present_new_location(install):
assert os.path.exists(rf"{pytest.DATA_DIR}\conf\minion")
def test_config_correct(install):
# The config file should be the default config in the new location with master and minion set
expected = [
"# Default config from test suite line 1/6\n",
"master: cli_master\n",
"# Default config from test suite line 2/6\n",
"id: cli_minion\n",
"# Default config from test suite line 3/6\n",
"# Default config from test suite line 4/6\n",
"# Default config from test suite line 5/6\n",
"# Default config from test suite line 6/6\n",
]
with open(rf"{pytest.DATA_DIR}\conf\minion") as f:
result = f.readlines()
assert result == expected

View file

@ -0,0 +1,50 @@
import os
import pytest
@pytest.fixture(scope="module")
def install():
pytest.helpers.clean_env()
# Create old config
pytest.helpers.old_install()
args = [
"/default-config",
"/move-config",
"/minion-name=cli_minion",
]
pytest.helpers.install_salt(args)
yield args
pytest.helpers.clean_env()
def test_binaries_present_old_location(install):
# This will show the contents of the directory on failure
dir_contents = os.listdir(rf"{pytest.OLD_DIR}\bin")
# Apparently we don't move the binaries even if they pass install-dir
# TODO: Decide if this is expected behavior
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\ssm.exe")
assert os.path.exists(rf"{pytest.OLD_DIR}\bin\python.exe")
def test_config_present_new_location(install):
assert os.path.exists(rf"{pytest.DATA_DIR}\conf\minion")
def test_config_correct(install):
# The config file should be the default config in the new location with only minion set
expected = [
"# Default config from test suite line 1/6\n",
"#master: salt\n",
"# Default config from test suite line 2/6\n",
"id: cli_minion\n",
"# Default config from test suite line 3/6\n",
"# Default config from test suite line 4/6\n",
"# Default config from test suite line 5/6\n",
"# Default config from test suite line 6/6\n",
]
with open(rf"{pytest.DATA_DIR}\conf\minion") as f:
result = f.readlines()
assert result == expected

View file

@ -0,0 +1 @@
[pytest]

View file

@ -0,0 +1,154 @@
<#
.SYNOPSIS
Script that sets up the environment for testing
.DESCRIPTION
This script creates the directory structure and files needed build a mock salt
installer for testing
.EXAMPLE
setup.ps1
#>
param(
[Parameter(Mandatory=$false)]
[Alias("c")]
# Don't pretify the output of the Write-Result
[Switch] $CICD
)
#-------------------------------------------------------------------------------
# Script Preferences
#-------------------------------------------------------------------------------
$ProgressPreference = "SilentlyContinue"
$ErrorActionPreference = "Stop"
#-------------------------------------------------------------------------------
# Script Functions
#-------------------------------------------------------------------------------
function Write-Result($result, $ForegroundColor="Green") {
if ( $CICD ) {
Write-Host $result -ForegroundColor $ForegroundColor
} else {
$position = 80 - $result.Length - [System.Console]::CursorLeft
Write-Host -ForegroundColor $ForegroundColor ("{0,$position}$result" -f "")
}
}
#-------------------------------------------------------------------------------
# Script Variables
#-------------------------------------------------------------------------------
$PROJECT_DIR = $(git rev-parse --show-toplevel)
$SCRIPT_DIR = (Get-ChildItem "$($myInvocation.MyCommand.Definition)").DirectoryName
$WINDOWS_DIR = "$PROJECT_DIR\pkg\windows"
$NSIS_DIR = "$WINDOWS_DIR\nsis"
$BUILDENV_DIR = "$WINDOWS_DIR\buildenv"
$NSIS_BIN = "$( ${env:ProgramFiles(x86)} )\NSIS\makensis.exe"
$SALT_DEP_URL = "https://repo.saltproject.io/windows/dependencies/64"
#-------------------------------------------------------------------------------
# Script Start
#-------------------------------------------------------------------------------
Write-Host $("=" * 80)
Write-Host "Build Test Environment for NSIS Tests" -ForegroundColor Cyan
Write-Host $("-" * 80)
#-------------------------------------------------------------------------------
# Setup Directories
#-------------------------------------------------------------------------------
$directories = "$BUILDENV_DIR",
"$BUILDENV_DIR\configs"
$directories | ForEach-Object {
if ( ! (Test-Path -Path "$_") ) {
Write-Host "Creating $_`: " -NoNewline
New-Item -Path $_ -ItemType Directory | Out-Null
if ( Test-Path -Path "$_" ) {
Write-Result "Success"
} else {
Write-Result "Failed" -ForegroundColor Red
exit 1
}
}
}
#-------------------------------------------------------------------------------
# Create binaries
#-------------------------------------------------------------------------------
$binary_files = @("python.exe")
$binary_files | ForEach-Object {
Write-Host "Creating $_`: " -NoNewline
Set-Content -Path "$BUILDENV_DIR\$_" -Value "binary"
if ( Test-Path -Path "$BUILDENV_DIR\$_" ) {
Write-Result "Success"
} else {
Write-Result "Failed" -ForegroundColor Red
exit 1
}
}
# Make sure ssm.exe is present. This is needed for VMtools
if ( ! (Test-Path -Path "$BUILDENV_DIR\ssm.exe") ) {
Write-Host "Copying SSM to Build Env: " -NoNewline
Invoke-WebRequest -Uri "$SALT_DEP_URL/ssm-2.24-103-gdee49fc.exe" -OutFile "$BUILDENV_DIR\ssm.exe"
if ( Test-Path -Path "$BUILDENV_DIR\ssm.exe" ) {
Write-Result "Success" -ForegroundColor Green
} else {
Write-Result "Failed" -ForegroundColor Red
exit 1
}
}
#-------------------------------------------------------------------------------
# Copy Configs
#-------------------------------------------------------------------------------
Write-Host "Copy testing minion config: " -NoNewline
Copy-Item -Path "$NSIS_DIR\tests\_files\minion" `
-Destination "$BUILDENV_DIR\configs\"
if ( Test-Path -Path "$BUILDENV_DIR\configs\minion" ) {
Write-Result "Success"
} else {
Write-Result "Failed" -ForegroundColor Red
exit 1
}
#-------------------------------------------------------------------------------
# Build mock installer
#-------------------------------------------------------------------------------
Write-Host "Building mock installer: " -NoNewline
Start-Process -FilePath $NSIS_BIN `
-ArgumentList "/DSaltVersion=test", `
"/DPythonArchitecture=AMD64", `
"$NSIS_DIR\installer\Salt-Minion-Setup.nsi" `
-Wait -WindowStyle Hidden
$installer = "$NSIS_DIR\installer\Salt-Minion-test-Py3-AMD64-Setup.exe"
if ( Test-Path -Path "$installer" ) {
Write-Result "Success"
} else {
Write-Result "Failed" -ForegroundColor Red
Write-Host "$NSIS_BIN /DSaltVersion=test /DPythonArchitecture=AMD64 $NSIS_DIR\installer\Salt-Minion-Setup.nsi"
exit 1
}
Write-Host "Moving mock installer: " -NoNewline
$test_installer = "$NSIS_DIR\tests\test-setup.exe"
Move-Item -Path $installer -Destination "$test_installer" -Force
if ( Test-Path -Path "$test_installer" ) {
Write-Result "Success"
} else {
Write-Result "Failed" -ForegroundColor Red
exit 1
}
#-------------------------------------------------------------------------------
# Script Complete
#-------------------------------------------------------------------------------
Write-Host $("-" * 80)
Write-Host "Build Test Environment for NSIS Tests Complete" -ForegroundColor Cyan
Write-Host $("=" * 80)

View file

@ -9,6 +9,12 @@ installer for testing
.EXAMPLE
setup.ps1
#>
param(
[Parameter(Mandatory=$false)]
[Alias("c")]
# Don't pretify the output of the Write-Result
[Switch] $CICD
)
#-------------------------------------------------------------------------------
# Script Preferences
@ -22,8 +28,12 @@ $ErrorActionPreference = "Stop"
#-------------------------------------------------------------------------------
function Write-Result($result, $ForegroundColor="Green") {
$position = 80 - $result.Length - [System.Console]::CursorLeft
Write-Host -ForegroundColor $ForegroundColor ("{0,$position}$result" -f "")
if ( $CICD ) {
Write-Host $result -ForegroundColor $ForegroundColor
} else {
$position = 80 - $result.Length - [System.Console]::CursorLeft
Write-Host -ForegroundColor $ForegroundColor ("{0,$position}$result" -f "")
}
}
#-------------------------------------------------------------------------------
@ -36,6 +46,7 @@ $WINDOWS_DIR = "$PROJECT_DIR\pkg\windows"
$NSIS_DIR = "$WINDOWS_DIR\nsis"
$BUILDENV_DIR = "$WINDOWS_DIR\buildenv"
$NSIS_BIN = "$( ${env:ProgramFiles(x86)} )\NSIS\makensis.exe"
$SALT_DEP_URL = "https://repo.saltproject.io/windows/dependencies/64"
#-------------------------------------------------------------------------------
# Script Start
@ -68,8 +79,7 @@ $directories | ForEach-Object {
# Create binaries
#-------------------------------------------------------------------------------
$binary_files = "ssm.exe",
"python.exe"
$binary_files = @("python.exe")
$binary_files | ForEach-Object {
Write-Host "Creating $_`: " -NoNewline
Set-Content -Path "$BUILDENV_DIR\$_" -Value "binary"
@ -81,11 +91,23 @@ $binary_files | ForEach-Object {
}
}
# Make sure ssm.exe is present. This is needed for VMtools
if ( ! (Test-Path -Path "$BUILDENV_DIR\ssm.exe") ) {
Write-Host "Copying SSM to Build Env: " -NoNewline
Invoke-WebRequest -Uri "$SALT_DEP_URL/ssm-2.24-103-gdee49fc.exe" -OutFile "$BUILDENV_DIR\ssm.exe"
if ( Test-Path -Path "$BUILDENV_DIR\ssm.exe" ) {
Write-Result "Success" -ForegroundColor Green
} else {
Write-Result "Failed" -ForegroundColor Red
exit 1
}
}
#-------------------------------------------------------------------------------
# Copy Configs
#-------------------------------------------------------------------------------
Write-Host "Copy minion config: " -NoNewline
Write-Host "Copy testing minion config: " -NoNewline
Copy-Item -Path "$NSIS_DIR\tests\_files\minion" `
-Destination "$BUILDENV_DIR\configs\"
if ( Test-Path -Path "$BUILDENV_DIR\configs\minion" ) {
@ -109,6 +131,7 @@ if ( Test-Path -Path "$installer" ) {
Write-Result "Success"
} else {
Write-Result "Failed" -ForegroundColor Red
Write-Host "$NSIS_BIN /DSaltVersion=test /DPythonArchitecture=AMD64 $NSIS_DIR\installer\Salt-Minion-Setup.nsi"
exit 1
}
@ -127,7 +150,7 @@ if ( Test-Path -Path "$test_installer" ) {
#-------------------------------------------------------------------------------
Write-Host "Setting up venv: " -NoNewline
python.exe -m venv venv
python.exe -m venv "$SCRIPT_DIR\venv"
if ( Test-Path -Path "$SCRIPT_DIR\venv" ) {
Write-Result "Success"
} else {
@ -136,7 +159,7 @@ if ( Test-Path -Path "$SCRIPT_DIR\venv" ) {
}
Write-Host "Activating venv: " -NoNewline
.\venv\Scripts\activate
& $SCRIPT_DIR\venv\Scripts\activate.ps1
if ( "$env:VIRTUAL_ENV" ) {
Write-Result "Success"
} else {

View file

@ -0,0 +1,26 @@
import os
import pytest
@pytest.fixture
def install():
assert pytest.helpers.clean_env()
args = ["/S"]
pytest.helpers.install_salt(args)
yield args
assert pytest.helpers.clean_env()
@pytest.mark.parametrize("execution_number", range(100))
def test_repeatedly_install_uninstall(execution_number, install):
# Make sure the binaries exists. If they don't, the install failed
assert os.path.exists(
f"{pytest.INST_DIR}\\python.exe"
), "Installation failed. `python.exe` not found"
assert os.path.exists(
f"{pytest.INST_DIR}\\ssm.exe"
), "Installation failed. `ssm.exe` not found"
assert os.path.exists(
f"{pytest.INST_DIR}\\uninst.exe"
), "Installation failed. `uninst.exe` not found"

Some files were not shown because too many files have changed in this diff Show more