Skip to content

Commit

Permalink
test(service): add helper state to run service in containers
Browse files Browse the repository at this point in the history
Some distros do not start the service if virtualization is detected, so
we force the service to start to test the formula

* Semi-automated by myii/ssf-formula#333
  • Loading branch information
myii committed Jun 23, 2021
1 parent 28c27c1 commit 2bdc85c
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
5 changes: 5 additions & 0 deletions kitchen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -347,11 +347,16 @@ verifier:
suites:
- name: default
provisioner:
dependencies:
- name: states
path: ./test/salt
state_top:
base:
'*':
- ntp.ng._mapdata
- ntp.ng
'G@init:systemd and ( G@os:SUSE )':
- states.custom_systemd_service
pillars:
top.sls:
base:
Expand Down
27 changes: 27 additions & 0 deletions test/salt/states/custom_systemd_service.sls
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# This state is used to prepare environment for formula testing

# In distros that have a systemd unit, make sure the service is
# started even if running in a containerized environment

{%- set sls_config_file = 'ntp.ng.config.file' %}
{%- set service_file = {
'SUSE': '/usr/lib/systemd/system/ntpd.service',
}.get(grains.os, '') %}

test-salt-states-custom-systemd-service-file-replace:
file.replace:
- name: {{ service_file }}
- pattern: 'ConditionVirtualization=!container'
- repl: ''
- show_changes: True
- require:
- file: ntpd_conf

test-salt-states-custom-systemd-service-cmd-wait:
cmd.wait:
- name: systemctl daemon-reload
- runas: root
- watch:
- file: test-salt-states-custom-systemd-service-file-replace
- require_in:
- service: ntpd

0 comments on commit 2bdc85c

Please sign in to comment.