1
0
Fork 0
mirror of https://github.com/JasonN3/build-container-installer.git synced 2025-12-25 10:57:55 +01:00

split make file

This commit is contained in:
Jason N. 2024-03-26 18:35:39 -04:00
parent 1de61a8083
commit ff74117fac
24 changed files with 249 additions and 172 deletions

47
test/vm/Makefile Normal file
View file

@ -0,0 +1,47 @@
VM_TESTS=$(filter-out README.md,$(shell ls))
# Get a list of tests for the feature
# $1 = test type
# $2 = feature
run_tests = \
tests="$(shell ls tests/$(1)/$(2)_*)"; \
if [ -n "$$tests" ]; \
then \
chmod +x $$tests; \
for test in $$tests; \
do \
$(foreach var,$(_VARS),$(var)=$($(var))) ./$${test}; \
RC=$$?; \
if [ $$RC != 0 ]; \
then \
exit $$RC; \
fi; \
done; \
fi
$(VM_TESTS):
$(eval _VARS = IMAGE_REPO IMAGE_NAME IMAGE_TAG)
ansible -i ansible_inventory -m ansible.builtin.wait_for_connection vm
# install tests
$(call run_tests,vm,install)
# flapak tests
if [ -n "$(FLATPAK_REMOTE_REFS)" ]; \
then \
$(call run_tests,vm,flatpak); \
fi
ansible_inventory:
echo "ungrouped:" > ansible_inventory
echo " hosts:" >> ansible_inventory
echo " vm:" >> ansible_inventory
echo " ansible_host: ${VM_IP}" >> ansible_inventory
echo " ansible_port: ${VM_PORT}" >> ansible_inventory
echo " ansible_user: ${VM_USER}" >> ansible_inventory
echo " ansible_password: ${VM_PASS}" >> ansible_inventory
echo " ansible_become_pass: ${VM_PASS}" >> ansible_inventory
echo " ansible_ssh_common_args: '-o StrictHostKeyChecking=no'" >> ansible_inventory
.PHONY: $(VM_TESTS)

1
test/vm/README.md Normal file
View file

@ -0,0 +1 @@
Place scripts that will test the VM. The VM will be available at ${VM_IP} using username ${VM_USER} and password ${VM_PASS}

View file

@ -0,0 +1,16 @@
#!/usr/bin/env -S ansible-playbook -i ./ansible_inventory
---
- name: Test for installed flatpaks
hosts: vm
gather_facts: no
tasks:
- name: Collect facts about system services
service_facts:
register: services_state
- name: Check that flatpak-add-fedora-repos is disabled
ansible.builtin.assert:
that:
- services_state['ansible_facts']['services']['flatpak-add-fedora-repos.service']['status'] == 'disabled'
fail_msg: 'flatpak-add-fedora-repos.service is not disabled'

View file

@ -0,0 +1,25 @@
#!/usr/bin/env -S ansible-playbook -i ./ansible_inventory
---
- name: Test for installed flatpaks
hosts: vm
gather_facts: no
tasks:
# Verifies that the flatpaks are installed
- name: Get list of installed Flatpaks
become: true
ansible.builtin.command:
cmd: /usr/bin/flatpak list
register: flatpaks
- name: Check that VLC is installed
ansible.builtin.assert:
that:
- "'VLC' in flatpaks.stdout"
fail_msg: 'VLC is not installed'
- name: Check that Firefox is installed
ansible.builtin.assert:
that:
- "'Firefox' in flatpaks.stdout"
fail_msg: 'Firefox is not installed'

View file

@ -0,0 +1,12 @@
#!/usr/bin/env -S ansible-playbook -i ./ansible_inventory
---
- name: Test for flatpaks
hosts: vm
gather_facts: no
tasks:
# Verifies that the GPG key is functional
- name: Test updating flatpak packages
become: true
ansible.builtin.command:
cmd: /usr/bin/flatpak update -y --noninteractive

View file

@ -0,0 +1,25 @@
#!/usr/bin/env -S ansible-playbook -i ./ansible_inventory
---
- name: Test Container Image source updates
hosts: vm
gather_facts: no
tasks:
# Get list of origins
- name: Get origin
become: true
ansible.builtin.command:
cmd: /bin/bash -c "cat /ostree/deploy/default/deploy/*.origin"
register: origin
- name: Get vars
ansible.builtin.set_fact:
image_repo: "{{ lookup('ansible.builtin.env', 'IMAGE_REPO') }}"
image_name: "{{ lookup('ansible.builtin.env', 'IMAGE_NAME') }}"
image_tag: "{{ lookup('ansible.builtin.env', 'IMAGE_TAG') }}"
- name: Tests
ansible.builtin.assert:
that:
- (image_repo + '/' + image_name + ':' + image_tag) in origin.stdout
fail_msg: 'Origin not configured'