Dmitriy Rabotyagov b4ffc12008 Replace functional tests with molecule
As effort to sunset tests repo, we replace functional test that were
running for the role with a molecule.
Due to docker limitations, I had to comment out swap tests, as while
it's possible to create a container with swap, I didn't find a way to
`swapon` from inside of the container.

Depends-On: https://review.opendev.org/c/openstack/openstack-ansible/+/938571
Change-Id: I8e021c76ba1c99d8be52269abd0aeebd05ec4fe7
2025-01-08 11:45:45 +01:00

89 lines
2.9 KiB
YAML

---
# Copyright 2015, Rackspace US, Inc.
# Copyright 2018, Logan Vig <logan2211@gmail.com>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
- name: Playbook for role testing
hosts: service_hosts
roles:
- role: "{{ playbook_dir | dirname | basename }}"
systemd_services:
- service_name: "test simple service0"
execstarts: "/bin/bash -c 'while true; do sleep 2 && echo test simple service; done'"
enabled: yes
- service_name: "test simple service0 with env vars"
execstarts: "/bin/bash -c 'while true; do sleep 2 && echo $ENV_VAR1; done'"
enabled: yes
environment:
ENV_VAR1: "testing"
- service_name: "test oneshot service1"
config_overrides:
Unit:
Description: Test oneshot service
After: network-online.target
Wants: network-online.target
Service:
RemainAfterExit: yes
service_type: oneshot
execstarts:
- "/bin/bash -c 'echo start1'"
- "/bin/bash -c 'echo start2'"
execstops:
- "/bin/bash -c 'echo stop1'"
- "/bin/bash -c 'echo stop2'"
enabled: yes
state: started
systemd_tempd_prefix: openstack
- service_name: "test timer service0"
execstarts:
- "/bin/bash -c 'echo start0'"
timer:
state: "started"
options:
OnBootSec: 30min
OnUnitActiveSec: 1h
Persistent: true
- service_name: "test timer service1"
execstarts:
- "/bin/bash -c 'echo start1'"
timer:
state: "started"
cron_minute: 30
cron_hour: 1
- service_name: "test_templated_service@"
service_type: oneshot
execstarts:
- "/bin/bash -c 'echo %i'"
template_arguments:
- 1
- 2
enabled: yes
post_tasks:
- name: Check Services
command: systemctl status "{{ item }}"
changed_when: false
with_items:
- test_simple_service0
- test_simple_service0_with_env_vars
- test_oneshot_service1
- test_timer_service0.timer
- test_timer_service1.timer
tags:
- skip_ansible_lint
- name: Notify tests passed
debug:
msg: All tests have passed