mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
start adding kitchen to test suites
This commit is contained in:
parent
d15de697f8
commit
b8c800e4a7
4 changed files with 116 additions and 8 deletions
5
.gitignore
vendored
5
.gitignore
vendored
|
@ -91,3 +91,8 @@ tests/integration/cloud/providers/pki/minions
|
|||
|
||||
# Ignore tox virtualenvs
|
||||
/.tox/
|
||||
|
||||
# Kitchen tests files
|
||||
.kitchen/
|
||||
.bundle/
|
||||
Gemfile.lock
|
||||
|
|
75
tests/kitchen/.kitchen.yml
Normal file
75
tests/kitchen/.kitchen.yml
Normal file
|
@ -0,0 +1,75 @@
|
|||
driver:
|
||||
name: docker
|
||||
use_sudo: false
|
||||
privileged: true
|
||||
<% if File.exists?('driver.yml') %>
|
||||
<% File.read('driver.yml').split(/\n/).each do |line| %>
|
||||
<%= line %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
provisioner:
|
||||
name: salt_solo
|
||||
salt_install: pip
|
||||
pip_pkg: <%= ENV['SALT_SDIST_PATH'] || 'salt' %>
|
||||
require_chef: false
|
||||
formula: states
|
||||
<% if File.exists?('dependencies.yml') %>
|
||||
<% File.read('dependencies.yml').split(/\n/).each do |line| %>
|
||||
<%= line %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% if File.exists?('state_top.yml') %>
|
||||
<% File.read('state_top.yml').split(/\n/).each do |line| %>
|
||||
<%= line %>
|
||||
<% end %>
|
||||
<% else %>
|
||||
state_top:
|
||||
base:
|
||||
'*':
|
||||
- states
|
||||
<% end %>
|
||||
<% if File.exists?('pillars.yml') %>
|
||||
<% File.read('pillars.yml').split(/\n/).each do |line| %>
|
||||
<%= line %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<% if File.exists?('platforms.yml') %>
|
||||
<%= File.read('platforms.yml') %>
|
||||
<% else %>
|
||||
platforms:
|
||||
- name: centos
|
||||
driver_config:
|
||||
run_command: /usr/lib/systemd/systemd
|
||||
provision_command:
|
||||
- yum install -y epel-release
|
||||
- yum install -y python-pip python-devel gcc git gcc-c++
|
||||
- name: opensuse
|
||||
driver_config:
|
||||
run_command: /usr/lib/systemd/systemd
|
||||
provision_command:
|
||||
- systemctl enable sshd.service
|
||||
- name: ubuntu
|
||||
driver_config:
|
||||
run_command: /lib/systemd/systemd
|
||||
- name: debian
|
||||
driver_config:
|
||||
run_command: /lib/systemd/systemd
|
||||
<% end %>
|
||||
|
||||
<% if File.exists?('suites.yml') %>
|
||||
<%= File.read('suites.yml') %>
|
||||
<% else %>
|
||||
suites:
|
||||
- name: salt
|
||||
<% end %>
|
||||
|
||||
<% if File.exists?('verifier.yml') %>
|
||||
<%= File.read('verifier.yml') %>
|
||||
<% else %>
|
||||
verifier:
|
||||
name: shell
|
||||
remote_exec: false
|
||||
command: pytest --junitxml= -v tests/integration/$KITCHEN_SUITE
|
||||
<% end %>
|
9
tests/kitchen/Gemfile
Normal file
9
tests/kitchen/Gemfile
Normal file
|
@ -0,0 +1,9 @@
|
|||
source "https://rubygems.org"
|
||||
|
||||
gem 'test-kitchen'
|
||||
gem 'kitchen-salt', :git => 'https://github.com/saltstack/kitchen-salt.git'
|
||||
gem 'kitchen-docker', :git => 'https://github.com/test-kitchen/kitchen-docker.git'
|
||||
gem 'vagrant-wrapper'
|
||||
gem 'kitchen-vagrant'
|
||||
gem 'winrm', '~>2.0'
|
||||
gem 'winrm-fs', '~>1.0'
|
|
@ -100,6 +100,9 @@ TEST_SUITES = {
|
|||
'unit':
|
||||
{'display_name': 'Unit',
|
||||
'path': 'unit'},
|
||||
'kitchen':
|
||||
{'display_name': 'Kitchen',
|
||||
'path': 'kitchen'},
|
||||
'module':
|
||||
{'display_name': 'Module',
|
||||
'path': 'integration/modules'},
|
||||
|
@ -169,7 +172,7 @@ class SaltTestsuiteParser(SaltCoverageTestingParser):
|
|||
source_code_basedir = SALT_ROOT
|
||||
|
||||
def _get_suites(self, include_unit=False, include_cloud_provider=False,
|
||||
include_proxy=False):
|
||||
include_proxy=False, include_kitchen=False):
|
||||
'''
|
||||
Return a set of all test suites except unit and cloud provider tests
|
||||
unless requested
|
||||
|
@ -181,28 +184,34 @@ class SaltTestsuiteParser(SaltCoverageTestingParser):
|
|||
suites -= set(['cloud_provider'])
|
||||
if not include_proxy:
|
||||
suites -= set(['proxy'])
|
||||
if not include_kitchen:
|
||||
suites -= set(['kitchen'])
|
||||
|
||||
return suites
|
||||
|
||||
def _check_enabled_suites(self, include_unit=False,
|
||||
include_cloud_provider=False, include_proxy=False):
|
||||
include_cloud_provider=False,
|
||||
include_proxy=False,
|
||||
include_kitchen=False):
|
||||
'''
|
||||
Query whether test suites have been enabled
|
||||
'''
|
||||
suites = self._get_suites(include_unit=include_unit,
|
||||
include_cloud_provider=include_cloud_provider,
|
||||
include_proxy=include_proxy)
|
||||
include_proxy=include_proxy,
|
||||
include_kitchen=include_kitchen)
|
||||
|
||||
return any([getattr(self.options, suite) for suite in suites])
|
||||
|
||||
def _enable_suites(self, include_unit=False, include_cloud_provider=False,
|
||||
include_proxy=False):
|
||||
include_proxy=False, include_kitchen=False):
|
||||
'''
|
||||
Enable test suites for current test run
|
||||
'''
|
||||
suites = self._get_suites(include_unit=include_unit,
|
||||
include_cloud_provider=include_cloud_provider,
|
||||
include_proxy=include_proxy)
|
||||
include_proxy=include_proxy,
|
||||
include_kitchen=include_kitchen)
|
||||
|
||||
for suite in suites:
|
||||
setattr(self.options, suite, True)
|
||||
|
@ -356,6 +365,15 @@ class SaltTestsuiteParser(SaltCoverageTestingParser):
|
|||
action='store_true',
|
||||
help='Run unit tests'
|
||||
)
|
||||
self.test_selection_group.add_option(
|
||||
'-k',
|
||||
'--kitchen',
|
||||
'--kitchen-tests',
|
||||
dest='kitchen',
|
||||
default=False,
|
||||
action='store_true',
|
||||
help='Run kitchen tests'
|
||||
)
|
||||
self.test_selection_group.add_option(
|
||||
'--fileserver',
|
||||
'--fileserver-tests',
|
||||
|
@ -465,7 +483,8 @@ class SaltTestsuiteParser(SaltCoverageTestingParser):
|
|||
if not self.options.name and not \
|
||||
self._check_enabled_suites(include_unit=True,
|
||||
include_cloud_provider=True,
|
||||
include_proxy=True):
|
||||
include_proxy=True,
|
||||
include_kitchen=True):
|
||||
self._enable_suites(include_unit=True)
|
||||
|
||||
self.start_coverage(
|
||||
|
@ -629,12 +648,12 @@ class SaltTestsuiteParser(SaltCoverageTestingParser):
|
|||
|
||||
if self.options.name:
|
||||
for test in self.options.name:
|
||||
if test.startswith(('tests.unit.', 'unit.')):
|
||||
if test.startswith(('tests.unit.', 'unit.', 'test.kitchen.', 'kitchen.')):
|
||||
named_unit_test.append(test)
|
||||
continue
|
||||
named_tests.append(test)
|
||||
|
||||
if (self.options.unit or named_unit_test) and not named_tests and not \
|
||||
if (self.options.unit or self.options.kitchen or named_unit_test) and not named_tests and not \
|
||||
self._check_enabled_suites(include_cloud_provider=True):
|
||||
# We're either not running any integration test suites, or we're
|
||||
# only running unit tests by passing --unit or by passing only
|
||||
|
|
Loading…
Add table
Reference in a new issue