소스 검색

test(windows): add local testing of Windows using Vagrant/Virtualbox

tags/v1.4.5
Dafydd Jones 4 년 전
부모
커밋
0465af72da
6개의 변경된 파일123개의 추가작업 그리고 8개의 파일을 삭제
  1. +4
    -0
      Gemfile
  2. +62
    -0
      docs/README.rst
  3. +38
    -0
      kitchen.vagrant.yml
  4. +9
    -4
      test/integration/v3000-py3/controls/pkgs_spec.rb
  5. +9
    -4
      test/integration/v3000-py3/controls/service_spec.rb
  6. +1
    -0
      test/integration/v3000-py3/inspec.yml

+ 4
- 0
Gemfile 파일 보기

@@ -5,3 +5,7 @@ source 'https://rubygems.org'
gem 'kitchen-docker', '>= 2.9'
gem 'kitchen-inspec', '>= 1.1'
gem 'kitchen-salt', '>= 0.6.0'

group :vagrant do
gem 'kitchen-vagrant'
end

+ 62
- 0
docs/README.rst 파일 보기

@@ -251,3 +251,65 @@ Runs all of the stages above in one go: i.e. ``destroy`` + ``converge`` + ``veri
^^^^^^^^^^^^^^^^^^^^^

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.

+ 38
- 0
kitchen.vagrant.yml 파일 보기

@@ -0,0 +1,38 @@
# -*- 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

+ 9
- 4
test/integration/v3000-py3/controls/pkgs_spec.rb 파일 보기

@@ -1,14 +1,19 @@
# frozen_string_literal: true

pkgs =
case platform[:family]
when 'windows'
%w[Salt\ Minion]
else
%w[salt-master salt-minion]
end

control 'salt packages' do
title 'should be installed'

version = '3000.3'

%w[
salt-master
salt-minion
].each do |p|
pkgs.each do |p|
describe package(p) do
it { should be_installed }
its('version') { should match(/^#{version}/) }

+ 9
- 4
test/integration/v3000-py3/controls/service_spec.rb 파일 보기

@@ -1,12 +1,17 @@
# frozen_string_literal: true

services =
case platform[:family]
when 'windows'
%w[salt-minion]
else
%w[salt-master salt-minion]
end

control 'salt services' do
title 'should be running'

%w[
salt-master
salt-minion
].each do |p|
services.each do |p|
describe service(p) do
it { should be_installed }
it { should be_enabled }

+ 1
- 0
test/integration/v3000-py3/inspec.yml 파일 보기

@@ -17,3 +17,4 @@ supports:
- platform-name: amazon
- platform-name: oracle
- platform-name: arch
- platform: windows

Loading…
취소
저장