Skip to content

Commit

Permalink
test: replace testinfra with ansible (#73)
Browse files Browse the repository at this point in the history
  • Loading branch information
jooola authored Jan 7, 2024
1 parent a68335c commit 5986d59
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 34 deletions.
6 changes: 6 additions & 0 deletions molecule/default/converge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@
name: [git, make, acl] # Is acl only required while testing ?
update_cache: true

- name: Link /usr/bin/sh to /bin/bash
ansible.builtin.file:
src: /bin/bash
dest: /usr/bin/sh
state: link

- name: Include libretime
ansible.builtin.include_role:
name: ansible-role-libretime
4 changes: 3 additions & 1 deletion molecule/default/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ provisioner:
inventory:
host_vars:
instance1:
libretime_checkout_version: main
libretime_public_url: http://localhost:{{ libretime_listen_port }}/
libretime_listen_port: 9001
libretime_api_key: hackme
Expand All @@ -35,11 +36,12 @@ provisioner:
Environment=LIBRETIME_LOG_LEVEL=debug
libretime_systemd_hardening: false
instance2:
libretime_checkout_version: main
libretime_public_url: http://localhost:{{ libretime_listen_port }}/
libretime_listen_port: 9002
libretime_api_key: hackme
libretime_secret_key: hackme
libretime_systemd_hardening: false

verifier:
name: testinfra
name: ansible
31 changes: 0 additions & 31 deletions molecule/default/test/test_default.py

This file was deleted.

56 changes: 56 additions & 0 deletions molecule/default/verify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
---
- name: Verify
hosts: all
gather_facts: true
become: true

vars:
services:
- libretime-analyzer.service
- libretime-api.service
- libretime-liquidsoap.service
- libretime-playout.service
- libretime-worker.service

tasks:
- name: Check that server is listening
ansible.builtin.wait_for:
port: "{{ libretime_listen_port }}"
timeout: 2

- name: Register /etc/libretime/config.yml
ansible.builtin.stat:
path: /etc/libretime/config.yml
register: result

- name: Check /etc/libretime/config.yml
ansible.builtin.assert:
that:
- result.stat.exists is true
- result.stat.pw_name == 'libretime'
- result.stat.gr_name == 'libretime'
- result.stat.mode == '0640'

- name: Register /usr/share/libretime/legacy/application/preload.php
ansible.builtin.stat:
path: /usr/share/libretime/legacy/application/preload.php
register: result

- name: Check /usr/share/libretime/legacy/application/preload.php
ansible.builtin.assert:
that:
- result.stat.exists is true
- result.stat.pw_name == 'libretime'
- result.stat.gr_name == 'libretime'
- result.stat.mode == '0644'

- name: Gather services facts
ansible.builtin.service_facts:
register: result

- name: Ensure that services are started and enabled
ansible.builtin.assert:
that:
- result.ansible_facts.services[item].state == 'running'
- result.ansible_facts.services[item].status == 'enabled'
loop: "{{ services }}"
2 changes: 0 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,3 @@ black>=23.1.0,<24.0
molecule>=6,<6.1
molecule-plugins[podman]>=23.0.0,<24.0
pylint>=3,<3.1
pytest>=7.2.2,<8.0
pytest-testinfra==10.0.0,<10.1
3 changes: 3 additions & 0 deletions templates/libretime/config.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,9 @@ stream:
- <<: *default_icecast_output
enabled: false
mount: extra
audio:
format: ogg
bitrate: 256

- # Whether the output is enabled.
# > default is false
Expand Down

0 comments on commit 5986d59

Please sign in to comment.