Add testing for Windows (both local and CI)tags/v1.4.5
--- | |||||
name: CI | |||||
'on': [push, pull_request] | |||||
env: | |||||
machine_user: kitchen | |||||
machine_pass: Pass@word1 | |||||
machine_port: 5985 | |||||
KITCHEN_LOCAL_YAML: kitchen.github.yml | |||||
jobs: | |||||
build: | |||||
runs-on: windows-latest | |||||
steps: | |||||
- uses: actions/checkout@v2 | |||||
- uses: actions/cache@v1 | |||||
with: | |||||
path: vendor/bundle | |||||
key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }} | |||||
restore-keys: | | |||||
${{ runner.os }}-gems- | |||||
- shell: powershell | |||||
run: | | |||||
$password = ConvertTo-SecureString $env:machine_pass -AsPlainText -Force | |||||
New-LocalUser $env:machine_user -Password $password | |||||
Add-LocalGroupMember -Group "Administrators" -Member $env:machine_user | |||||
- shell: powershell | |||||
run: > | |||||
Set-WSManQuickConfig -Force; | |||||
Set-WSManInstance -ResourceURI winrm/config/service | |||||
-ValueSet @{AllowUnencrypted="true"} | |||||
- run: gem install bundler --quiet --no-document | |||||
- name: Bundle install | |||||
run: | | |||||
bundle config path vendor/bundle | |||||
bundle install --jobs 4 --retry 3 | |||||
- run: bundle exec kitchen test |
gem 'kitchen-docker', '>= 2.9' | gem 'kitchen-docker', '>= 2.9' | ||||
gem 'kitchen-inspec', '>= 1.1' | gem 'kitchen-inspec', '>= 1.1' | ||||
gem 'kitchen-salt', '>= 0.6.0' | gem 'kitchen-salt', '>= 0.6.0' | ||||
group :vagrant do | |||||
gem 'kitchen-vagrant' | |||||
end |
kitchen-salt (0.6.3) | kitchen-salt (0.6.3) | ||||
hashie (>= 3.5) | hashie (>= 3.5) | ||||
test-kitchen (>= 1.4) | test-kitchen (>= 1.4) | ||||
kitchen-vagrant (1.6.1) | |||||
test-kitchen (>= 1.4, < 3) | |||||
libyajl2 (1.2.0) | libyajl2 (1.2.0) | ||||
license-acceptance (1.0.19) | license-acceptance (1.0.19) | ||||
pastel (~> 0.7) | pastel (~> 0.7) | ||||
kitchen-docker (>= 2.9) | kitchen-docker (>= 2.9) | ||||
kitchen-inspec (>= 1.1) | kitchen-inspec (>= 1.1) | ||||
kitchen-salt (>= 0.6.0) | kitchen-salt (>= 0.6.0) | ||||
kitchen-vagrant | |||||
BUNDLED WITH | BUNDLED WITH | ||||
2.1.2 | 2.1.2 |
^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^ | ||||
Gives you SSH access to the instance for manual testing. | Gives you SSH access to the instance for manual testing. | ||||
Testing with Vagrant | |||||
-------------------- | |||||
Windows testing is done with ``kitchen-salt``. | |||||
Requirements | |||||
^^^^^^^^^^^^ | |||||
* Ruby | |||||
* Virtualbox | |||||
* Vagrant | |||||
Setup | |||||
^^^^^ | |||||
.. code-block:: bash | |||||
$ gem install bundler | |||||
$ bundle install --with=vagrant | |||||
$ bin/kitchen test [platform] | |||||
Where ``[platform]`` is the platform name defined in ``kitchen.yml``, | |||||
e.g. ``windows``. | |||||
Note | |||||
^^^^ | |||||
When testing using Vagrant you must set the environment variable ``KITCHEN_LOCAL_YAML`` to ``kitchen.vagrant.yml``. For example: | |||||
.. code-block:: bash | |||||
$ KITCHEN_LOCAL_YAML=kitchen.vagrant.yml bin/kitchen test # Alternatively, | |||||
$ export KITCHEN_LOCAL_YAML=kitchen.vagrant.yml | |||||
$ bin/kitchen test | |||||
Then run the following commands as needed. | |||||
``bin/kitchen converge`` | |||||
^^^^^^^^^^^^^^^^^^^^^^^^ | |||||
Creates the Vagrant instance and runs the ``salt.minion`` main state, ready for testing. | |||||
``bin/kitchen verify`` | |||||
^^^^^^^^^^^^^^^^^^^^^^ | |||||
Runs the ``inspec`` tests on the actual instance. | |||||
``bin/kitchen destroy`` | |||||
^^^^^^^^^^^^^^^^^^^^^^^ | |||||
Removes the Vagrant instance. | |||||
``bin/kitchen test`` | |||||
^^^^^^^^^^^^^^^^^^^^ | |||||
Runs all of the stages above in one go: i.e. ``destroy`` + ``converge`` + ``verify`` + ``destroy``. | |||||
``bin/kitchen login`` | |||||
^^^^^^^^^^^^^^^^^^^^^ | |||||
Gives you RDP access to the instance for manual testing. |
--- | |||||
driver: | |||||
name: proxy | |||||
host: localhost | |||||
reset_command: "exit 0" | |||||
port: 5985 | |||||
username: kitchen | |||||
password: Pass@word1 | |||||
platforms: | |||||
- name: windows | |||||
provisioner: | |||||
salt_install: bootstrap | |||||
salt_bootstrap_options: -pythonVersion 3 -version 3000.3 | |||||
init_environment: > | |||||
C:\salt\salt-call --local state.single file.managed | |||||
C:\Users\kitchen\AppData\Local\Temp\kitchen\srv\salt\win\repo-ng\salt-minion-py3.sls | |||||
source=https://github.com/saltstack/salt-winrepo-ng/raw/master/salt-minion-py3.sls | |||||
skip_verify=True makedirs=True | |||||
suites: | |||||
- name: v3000-py3 | |||||
provisioner: | |||||
state_top: | |||||
base: | |||||
'*': | |||||
- salt.minion | |||||
pillars: | |||||
top.sls: | |||||
base: | |||||
'*': | |||||
- salt | |||||
- v3000-py3 | |||||
pillars_from_files: | |||||
salt.sls: test/salt/pillar/salt.sls | |||||
v3000-py3.sls: test/salt/pillar/v3000-py3.sls | |||||
verifier: | |||||
inspec_tests: | |||||
- path: test/integration/v3000-py3 |
# -*- coding: utf-8 -*- | |||||
# vim: ft=yaml | |||||
--- | |||||
driver: | |||||
name: vagrant | |||||
platforms: | |||||
- name: windows-81 | |||||
driver: | |||||
box: techneg/win81x64-pro-salt | |||||
gui: false | |||||
linked_clone: true | |||||
provisioner: | |||||
init_environment: > | |||||
salt-call --local state.single file.managed | |||||
C:\Users\vagrant\AppData\Local\Temp\kitchen\srv\salt\win\repo-ng\salt-minion-py3.sls | |||||
source=https://github.com/saltstack/salt-winrepo-ng/raw/master/salt-minion-py3.sls | |||||
skip_verify=True makedirs=True | |||||
suites: | |||||
- name: v3000-py3 | |||||
provisioner: | |||||
state_top: | |||||
base: | |||||
'*': | |||||
- salt.minion | |||||
pillars: | |||||
top.sls: | |||||
base: | |||||
'*': | |||||
- salt | |||||
- v3000-py3 | |||||
pillars_from_files: | |||||
salt.sls: test/salt/pillar/salt.sls | |||||
v3000-py3.sls: test/salt/pillar/v3000-py3.sls | |||||
verifier: | |||||
inspec_tests: | |||||
- path: test/integration/v3000-py3 |
python_git: py-GitPython | python_git: py-GitPython | ||||
Windows: | Windows: | ||||
salt_minion: salt-minion{{ py_ver_repr or '-py3' }} | |||||
salt_minion: salt-minion{{ '-' ~ py_ver_repr if py_ver_repr else '' }} | |||||
config_path: 'C:\salt\conf' | config_path: 'C:\salt\conf' | ||||
minion_service: salt-minion | minion_service: salt-minion | ||||
# frozen_string_literal: true | # frozen_string_literal: true | ||||
pkgs = | |||||
case platform[:family] | |||||
when 'windows' | |||||
%w[Salt\ Minion] | |||||
else | |||||
%w[salt-master salt-minion] | |||||
end | |||||
control 'salt packages' do | control 'salt packages' do | ||||
title 'should be installed' | title 'should be installed' | ||||
version = '3000.3' | version = '3000.3' | ||||
%w[ | |||||
salt-master | |||||
salt-minion | |||||
].each do |p| | |||||
pkgs.each do |p| | |||||
describe package(p) do | describe package(p) do | ||||
it { should be_installed } | it { should be_installed } | ||||
its('version') { should match(/^#{version}/) } | its('version') { should match(/^#{version}/) } |
# frozen_string_literal: true | # frozen_string_literal: true | ||||
services = | |||||
case platform[:family] | |||||
when 'windows' | |||||
%w[salt-minion] | |||||
else | |||||
%w[salt-master salt-minion] | |||||
end | |||||
control 'salt services' do | control 'salt services' do | ||||
title 'should be running' | title 'should be running' | ||||
%w[ | |||||
salt-master | |||||
salt-minion | |||||
].each do |p| | |||||
services.each do |p| | |||||
describe service(p) do | describe service(p) do | ||||
it { should be_installed } | it { should be_installed } | ||||
it { should be_enabled } | it { should be_enabled } |
- platform-name: amazon | - platform-name: amazon | ||||
- platform-name: oracle | - platform-name: oracle | ||||
- platform-name: arch | - platform-name: arch | ||||
- platform: windows |