From 48ac6c0651574649717f36b7ddff16764450bcfe Mon Sep 17 00:00:00 2001 From: emil Date: Mon, 4 Mar 2024 23:59:02 +0000 Subject: [PATCH] Automate the execution of all molecule scenarios (#17) # Context This PR implements the following [issue](https://git.theliberatededge.org/the-liberated-edge/test_linux_containers/issues/12). # Acceptance criteria - [ ] A Task task for running all Ansible Molecule scenarios has been introduced. - [ ] A Task task for running selected Ansible Molecule scenarios has been introduced. - [ ] `README.md` has been updated to provide correct guidance on executing Ansible Molecule scenarios. Co-authored-by: emo Reviewed-on: https://git.theliberatededge.org/the-liberated-edge/test_linux_containers/pulls/17 --- README.md | 20 +++++--------------- Taskfile.yml | 15 +++++++++++++++ 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 01646dc..8d62a98 100644 --- a/README.md +++ b/README.md @@ -217,22 +217,12 @@ Navigate to the root folder of the local copy of this git repository. cd test_linux_containers ``` -Install locally a snapshot version of `theliberatededge.test_linux_containers` -that will be used as the foundation for automated testing. +Run the following task to execute all of the Ansible Molecule test scenarios +in the project. ``` -LC_ALL=C.UTF-8 ansible-galaxy install -r requirements-test.yml --force +LTE_CONTAINER_ROOT_PWD= task test-all ``` -Execute all existing Ansible Molecule scenarios. - -``` -cd extensions -``` - -``` -LC_ALL=C.UTF-8 \ -LTE_CONTAINER_NAME= \ -LTE_CONTAINER_ROOT_PWD= \ - molecule test --all -``` +`LTE_CONTAINER_ROOT_PWD` is an environment variable denoting the password +of the `root` user in the testing container. diff --git a/Taskfile.yml b/Taskfile.yml index 3ff6bd1..c4fe596 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -13,3 +13,18 @@ tasks: lint-ansible: deps: [lint-yml] cmds: [LC_ALL=C.UTF-8 ansible-lint .] + init-tests: + cmds: + - LC_ALL=C.UTF-8 ansible-galaxy install -r requirements-test.yml --force + test-all: + deps: [init-tests] + dir: extensions + cmds: + - | + LC_ALL=C.UTF-8 \ + LTE_CONTAINER_NAME={{ .LTE_CONTAINER_NAME }} \ + LTE_CONTAINER_ROOT_PWD={{ .LTE_CONTAINER_ROOT_PWD }} \ + molecule test --all + vars: + LTE_CONTAINER_NAME: + sh: cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 8 | head -n 1