Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

fix: handle v3004+ which can be installed to any location on Windows #340

Merged
merged 6 commits into from
Jan 10, 2022

Conversation

dafyddj
Copy link
Contributor

@dafyddj dafyddj commented Dec 31, 2021

The Windows salt-call.bat executable was hardcoded to C:\salt but this is no longer appropriate since v3004 allows to install Salt executables to any location. Answer is to rely on finding salt-call.bat in the system PATH environment variable.

  • The PR also updates and tweaks the tests to get them to a passing state.

@dafyddj
Copy link
Contributor Author

dafyddj commented Jan 5, 2022

v3004 successful test run -----> Starting Test Kitchen (v3.2.2) -----> Cleaning up any prior instances of -----> Destroying ... Finished destroying (0m0.00s). -----> Testing -----> Creating ... Bringing machine 'default' up with 'virtualbox' provider... ==> default: Cloning VM...

�[K==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'devopsgroup-io/windows_server-2012r2-standard-amd64-nocm' version '1.62.0' is up to date...
==> default: Setting the name of the VM: kitchen-kitchen-salt-vagrant-windows-2012r2-a9348408-061c-4a2d-8d29-cf7cc786c052
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
==> default: Forwarding ports...
default: 5985 (guest) => 55985 (host) (adapter 1)
default: 5986 (guest) => 55986 (host) (adapter 1)
default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
default: WinRM address: 127.0.0.1:55985
default: WinRM username: vagrant
default: WinRM execution_time_limit: PT2H
default: WinRM transport: negotiate
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
==> default: Machine not provisioned because --no-provision is specified.
[WinRM] Established

   Vagrant instance <vagrant-windows-2012r2> created.
   Finished creating <vagrant-windows-2012r2> (0m42.18s).

-----> Converging ...
Preparing files for transfer
Preparing gpg_key
Preparing salt-minion
Preparing pillars into /srv/pillar
Copying pillars from tests/pillars/ to srv/pillar/
Preparing grains into /etc/salt/grains
Preparing formula: tests from /Users/dafydd/src/salt/kitchen-salt
Preparing state_top

       Directory: C:\
   
   
   Mode                LastWriteTime     Length Name                                                                                                                                                                                                        
   ----                -------------     ------ ----                                                                                                                                                                                                        
   d----          1/5/2022  11:41 AM            temp                                                                                                                                                                                                        
   Downloading Salt minion installer Salt-Minion-3004-Py3-AMD64-Setup.exe
   Installing Salt minion
   Starting the Salt minion service
   Salt minion successfully installed
   You asked for 3004 and you have 3004 installed, sweet!
   
   
   
   
       Directory: C:\Users\vagrant\AppData\Local\Temp
   
   
   Mode                LastWriteTime     Length Name                                                                                                                                                                                                        
   ----                -------------     ------ ----                                                                                                                                                                                                        
   d----          1/5/2022  11:41 AM            kitchen                                                                                                                                                                                                     
   
   
   Transferring files to <vagrant-windows-2012r2>
   salt-call : [WARNING ] Failed to open log file, do you have permission to write to C:\ProgramData\Salt Project\Salt\var\log\salt\minion?
   At line:1 char:131
   + (get-content $env:TEMP\kitchen\etc\salt\minion) -replace '\$env:TEMP', $env:TEMP ...
   + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       + CategoryInfo          : NotSpecified: ([WARNING ] Fail...og\salt\minion?:String) [], RemoteException
       + FullyQualifiedErrorId : NativeCommandError
    
   [WARNING ] The function "module.run" is using its deprecated version and will expire in version "Phosphorus".
   
   local:
   ----------
      ID: test ping
       Function: module.run
    Name: test.ping
         Result: True
        Comment: Module function test.ping executed
        Started: 11:41:55.282651
       Duration: 15.621 ms
        Changes:   
          ----------
          ret:
              True
   
   Summary for local
   ------------
   Succeeded: 1 (changed=1)
   Failed:    0
   ------------
   Total states run:     1
   Total run time:  15.621 ms
   Downloading files from <vagrant-windows-2012r2>
   Finished converging <vagrant-windows-2012r2> (0m51.15s).

-----> Setting up ...
Finished setting up (0m0.00s).
-----> Verifying ...
[Shell] Verify on instance vagrant-windows-2012r2 with state={:hostname=>"127.0.0.1", :port=>"55985", :username=>"vagrant", :password=>"vagrant", :last_action=>"setup", :last_error=>nil}
============================= test session starts ==============================
platform darwin -- Python 3.8.9, pytest-6.2.5, py-1.11.0, pluggy-1.0.0 -- /Users/dafydd/src/envs/kitchen-salt/bin/python
cachedir: .pytest_cache
rootdir: /Users/dafydd/src/salt/kitchen-salt
plugins: testinfra-6.5.0
collecting ... collected 13 items

tests/integration/test_git.py::test_pkg[git] SKIPPED (Skip on freebs...) [ 7%]
tests/integration/test_hidden.py::test_hidden_dirs SKIPPED (dotfiles...) [ 15%]
tests/integration/test_hidden.py::test_hidden_sls SKIPPED (dotfiles ...) [ 23%]
tests/integration/test_pillar.py::test_gpg_pillar SKIPPED (Skip on w...) [ 30%]
tests/integration/test_salt.py::test_ping PASSED [ 38%]
tests/integration/test_salt.py::test_git_depends SKIPPED (git not in...) [ 46%]
tests/integration/test_salt.py::test_apt_depends SKIPPED (APT not su...) [ 53%]
tests/integration/test_salt.py::test_postfix_depends SKIPPED (git no...) [ 61%]
tests/integration/test_salt.py::test_spm_depends SKIPPED (spm not su...) [ 69%]
tests/integration/test_salt.py::test_path_depends SKIPPED (Dependenc...) [ 76%]
tests/integration/test_salt.py::test_cache_command_ran PASSED [ 84%]
tests/integration/test_salt.py::test_path_line_endings PASSED [ 92%]
tests/integration/test_user.py::test_jdoe SKIPPED (Skip on windows i...) [100%]

=============================== warnings summary ===============================
tests/integration/test_salt.py::test_ping
tests/integration/test_salt.py::test_cache_command_ran
tests/integration/test_salt.py::test_path_line_endings
/Users/dafydd/src/envs/kitchen-salt/lib/python3.8/site-packages/winrm/transport.py:360: DeprecationWarning: inspect.getargspec() is deprecated since Python 3.0, use inspect.signature() or inspect.getfullargspec()
argspec = set(inspect.getargspec(function).args)

-- Docs: https://docs.pytest.org/en/stable/warnings.html
================== 3 passed, 10 skipped, 3 warnings in 6.48s ===================
Finished verifying (0m7.39s).
-----> Destroying ...
==> default: Forcing shutdown of VM...
==> default: Destroying VM and associated drives...
Vagrant instance destroyed.
Finished destroying (0m5.56s).
Finished testing (1m46.29s).
-----> Test Kitchen is finished. (1m49.10s)

@dafyddj
Copy link
Contributor Author

dafyddj commented Jan 5, 2022

v3003.3 successful test run -----> Starting Test Kitchen (v3.2.2) -----> Cleaning up any prior instances of -----> Destroying ... Finished destroying (0m0.00s). -----> Testing -----> Creating ... Bringing machine 'default' up with 'virtualbox' provider... ==> default: Cloning VM...

�[K==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'devopsgroup-io/windows_server-2012r2-standard-amd64-nocm' version '1.62.0' is up to date...
==> default: Setting the name of the VM: kitchen-kitchen-salt-vagrant-windows-2012r2-b9a8f343-4e77-4d17-a57a-e82d76af60ad
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
==> default: Forwarding ports...
default: 5985 (guest) => 55985 (host) (adapter 1)
default: 5986 (guest) => 55986 (host) (adapter 1)
default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
default: WinRM address: 127.0.0.1:55985
default: WinRM username: vagrant
default: WinRM execution_time_limit: PT2H
default: WinRM transport: negotiate
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
==> default: Machine not provisioned because --no-provision is specified.
[WinRM] Established

   Vagrant instance <vagrant-windows-2012r2> created.
   Finished creating <vagrant-windows-2012r2> (0m45.93s).

-----> Converging ...
Preparing files for transfer
Preparing gpg_key
Preparing salt-minion
Preparing pillars into /srv/pillar
Copying pillars from tests/pillars/ to srv/pillar/
Preparing grains into /etc/salt/grains
Preparing formula: tests from /Users/dafydd/src/salt/kitchen-salt
Preparing state_top

       Directory: C:\
   
   
   Mode                LastWriteTime     Length Name                                                                                                                                                                                                        
   ----                -------------     ------ ----                                                                                                                                                                                                        
   d----          1/5/2022  11:49 AM            temp                                                                                                                                                                                                        
   Downloading Salt minion installer Salt-Minion-3003.3-Py3-AMD64-Setup.exe
   Installing Salt minion
   Starting the Salt minion service
   Salt minion successfully installed
   You asked for 3003.3 and you have 3003.3 installed, sweet!
   
   
   
   
       Directory: C:\Users\vagrant\AppData\Local\Temp
   
   
   Mode                LastWriteTime     Length Name                                                                                                                                                                                                        
   ----                -------------     ------ ----                                                                                                                                                                                                        
   d----          1/5/2022  11:50 AM            kitchen                                                                                                                                                                                                     
   
   
   Transferring files to <vagrant-windows-2012r2>
   salt-call : [WARNING ] The function "module.run" is using its deprecated version and will expire in version "Phosphorus".
   At line:1 char:131
   + (get-content $env:TEMP\kitchen\etc\salt\minion) -replace '\$env:TEMP', $env:TEMP ...
   + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       + CategoryInfo          : NotSpecified: ([WARNING ] The ...n "Phosphorus".:String) [], RemoteException
       + FullyQualifiedErrorId : NativeCommandError
    
   local:
   ----------
      ID: test ping
       Function: module.run
    Name: test.ping
         Result: True
        Comment: Module function test.ping executed
        Started: 11:50:24.055018
       Duration: 14.834 ms
        Changes:   
          ----------
          ret:
              True
   
   Summary for local
   ------------
   Succeeded: 1 (changed=1)
   Failed:    0
   ------------
   Total states run:     1
   Total run time:  14.834 ms
   Downloading files from <vagrant-windows-2012r2>
   Finished converging <vagrant-windows-2012r2> (1m4.66s).

-----> Setting up ...
Finished setting up (0m0.00s).
-----> Verifying ...
[Shell] Verify on instance vagrant-windows-2012r2 with state={:hostname=>"127.0.0.1", :port=>"55985", :username=>"vagrant", :password=>"vagrant", :last_action=>"setup", :last_error=>nil}
============================= test session starts ==============================
platform darwin -- Python 3.8.9, pytest-6.2.5, py-1.11.0, pluggy-1.0.0 -- /Users/dafydd/src/envs/kitchen-salt/bin/python
cachedir: .pytest_cache
rootdir: /Users/dafydd/src/salt/kitchen-salt
plugins: testinfra-6.5.0
collecting ... collected 13 items

tests/integration/test_git.py::test_pkg[git] SKIPPED (Skip on freebs...) [ 7%]
tests/integration/test_hidden.py::test_hidden_dirs SKIPPED (dotfiles...) [ 15%]
tests/integration/test_hidden.py::test_hidden_sls SKIPPED (dotfiles ...) [ 23%]
tests/integration/test_pillar.py::test_gpg_pillar SKIPPED (Skip on w...) [ 30%]
tests/integration/test_salt.py::test_ping PASSED [ 38%]
tests/integration/test_salt.py::test_git_depends SKIPPED (git not in...) [ 46%]
tests/integration/test_salt.py::test_apt_depends SKIPPED (APT not su...) [ 53%]
tests/integration/test_salt.py::test_postfix_depends SKIPPED (git no...) [ 61%]
tests/integration/test_salt.py::test_spm_depends SKIPPED (spm not su...) [ 69%]
tests/integration/test_salt.py::test_path_depends SKIPPED (Dependenc...) [ 76%]
tests/integration/test_salt.py::test_cache_command_ran PASSED [ 84%]
tests/integration/test_salt.py::test_path_line_endings PASSED [ 92%]
tests/integration/test_user.py::test_jdoe SKIPPED (Skip on windows i...) [100%]

=============================== warnings summary ===============================
tests/integration/test_salt.py::test_ping
tests/integration/test_salt.py::test_cache_command_ran
tests/integration/test_salt.py::test_path_line_endings
/Users/dafydd/src/envs/kitchen-salt/lib/python3.8/site-packages/winrm/transport.py:360: DeprecationWarning: inspect.getargspec() is deprecated since Python 3.0, use inspect.signature() or inspect.getfullargspec()
argspec = set(inspect.getargspec(function).args)

-- Docs: https://docs.pytest.org/en/stable/warnings.html
================== 3 passed, 10 skipped, 3 warnings in 6.47s ===================
Finished verifying (0m7.37s).
-----> Destroying ...
==> default: Forcing shutdown of VM...
==> default: Destroying VM and associated drives...
Vagrant instance destroyed.
Finished destroying (0m6.73s).
Finished testing (2m4.71s).
-----> Test Kitchen is finished. (2m7.62s)

@dafyddj
Copy link
Contributor Author

dafyddj commented Jan 6, 2022

The Debian pip test is failing, but for reasons beyond this PR I believe. I don't know enough about Python packaging to really know how to fix it.

@krionbsd krionbsd merged commit cf5c41b into saltstack:master Jan 10, 2022
@dafyddj dafyddj deleted the fix/salt-call branch January 10, 2022 16:36
myii added a commit to myii/ssf-formula that referenced this pull request Jan 12, 2022
myii added a commit to myii/ssf-formula that referenced this pull request Jan 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants