From a46fe5c1b03b11c3e8d5389ae298ca0c5c3a5a7a Mon Sep 17 00:00:00 2001 From: Andrey Gubarev Date: Fri, 16 Jun 2023 20:24:33 +0400 Subject: [PATCH] increase tests suites number --- Makefile | 12 ++++++++- tests/.yamllint | 33 ++++++++++++++++++++++++ tests/molecule/default/molecule.yml | 25 ------------------ tests/molecule/user/converge.yml | 12 +++++++++ tests/molecule/user/molecule.yml | 20 ++++++++++++++ tests/molecule/user/prepare.yml | 15 +++++++++++ tests/molecule/user/verify.yml | 10 +++++++ tests/molecule/vmnet-shared/converge.yml | 12 +++++++++ tests/molecule/vmnet-shared/molecule.yml | 20 ++++++++++++++ tests/molecule/vmnet-shared/prepare.yml | 15 +++++++++++ tests/molecule/vmnet-shared/verify.yml | 10 +++++++ 11 files changed, 158 insertions(+), 26 deletions(-) create mode 100644 tests/.yamllint create mode 100644 tests/molecule/user/converge.yml create mode 100644 tests/molecule/user/molecule.yml create mode 100644 tests/molecule/user/prepare.yml create mode 100644 tests/molecule/user/verify.yml create mode 100644 tests/molecule/vmnet-shared/converge.yml create mode 100644 tests/molecule/vmnet-shared/molecule.yml create mode 100644 tests/molecule/vmnet-shared/prepare.yml create mode 100644 tests/molecule/vmnet-shared/verify.yml diff --git a/Makefile b/Makefile index 5262a70..c441a31 100644 --- a/Makefile +++ b/Makefile @@ -25,7 +25,17 @@ lint: virtualenv ## Lint .PHONY: test test: virtualenv ## Test $(VIRTUALENV_PIP) install -e . - cd tests && $(VIRTUALENV_MOLECULE) test + cd tests && $(VIRTUALENV_MOLECULE) test -s default + +.PHONY: test-all +test-all: virtualenv ## Test + $(VIRTUALENV_PIP) install -e . + cd tests && \ + $(VIRTUALENV_MOLECULE) destroy || true && \ + $(VIRTUALENV_MOLECULE) reset && \ + $(VIRTUALENV_MOLECULE) test -s default && \ + $(VIRTUALENV_MOLECULE) test -s user && \ + $(VIRTUALENV_MOLECULE) test -s vmnet-shared .PHONY: clean clean: ## Remove cache diff --git a/tests/.yamllint b/tests/.yamllint new file mode 100644 index 0000000..8827676 --- /dev/null +++ b/tests/.yamllint @@ -0,0 +1,33 @@ +--- +# Based on ansible-lint config +extends: default + +rules: + braces: + max-spaces-inside: 1 + level: error + brackets: + max-spaces-inside: 1 + level: error + colons: + max-spaces-after: -1 + level: error + commas: + max-spaces-after: -1 + level: error + comments: disable + comments-indentation: disable + document-start: disable + empty-lines: + max: 3 + level: error + hyphens: + level: error + indentation: disable + key-duplicates: enable + line-length: disable + new-line-at-end-of-file: disable + new-lines: + type: unix + trailing-spaces: disable + truthy: disable diff --git a/tests/molecule/default/molecule.yml b/tests/molecule/default/molecule.yml index dfda17d..7783194 100644 --- a/tests/molecule/default/molecule.yml +++ b/tests/molecule/default/molecule.yml @@ -9,31 +9,6 @@ platforms: image_checksum: sha512:https://cloud.debian.org/images/cloud/bullseye/latest/SHA512SUMS image_arch: aarch64 ssh_port: 10000 - - name: debian-bullseye-amd64 - image: https://cloud.debian.org/images/cloud/bullseye/latest/debian-11-genericcloud-amd64.qcow2 - image_checksum: sha512:https://cloud.debian.org/images/cloud/bullseye/latest/SHA512SUMS - image_arch: x86_64 - ssh_port: 10001 - - name: ubuntu-focal-arm64 - image: https://cloud-images.ubuntu.com/focal/current/focal-server-cloudimg-arm64.img - image_checksum: sha256:https://cloud-images.ubuntu.com/focal/current/SHA256SUMS - image_arch: aarch64 - ssh_port: 10002 - - name: ubuntu-focal-amd64 - image: https://cloud-images.ubuntu.com/focal/current/focal-server-cloudimg-amd64.img - image_checksum: sha256:https://cloud-images.ubuntu.com/focal/current/SHA256SUMS - image_arch: x86_64 - ssh_port: 10003 - - name: ubuntu-jammy-arm64 - image: https://cloud-images.ubuntu.com/jammy/current/jammy-server-cloudimg-arm64.img - image_checksum: sha256:https://cloud-images.ubuntu.com/jammy/current/SHA256SUMS - image_arch: aarch64 - ssh_port: 10004 - - name: ubuntu-jammy-amd64 - image: https://cloud-images.ubuntu.com/jammy/current/jammy-server-cloudimg-amd64.img - image_checksum: sha256:https://cloud-images.ubuntu.com/jammy/current/SHA256SUMS - image_arch: x86_64 - ssh_port: 10005 provisioner: name: ansible verifier: diff --git a/tests/molecule/user/converge.yml b/tests/molecule/user/converge.yml new file mode 100644 index 0000000..8d580ce --- /dev/null +++ b/tests/molecule/user/converge.yml @@ -0,0 +1,12 @@ +--- +- name: Converge + hosts: all + + environment: + http_proxy: "{{ lookup('ansible.builtin.env', 'http_proxy') | default(omit) }}" + https_proxy: "{{ lookup('ansible.builtin.env', 'https_proxy') | default(omit) }}" + + tasks: + - name: "Include tests" + ansible.builtin.include_role: + name: "tests" diff --git a/tests/molecule/user/molecule.yml b/tests/molecule/user/molecule.yml new file mode 100644 index 0000000..7d7dd4e --- /dev/null +++ b/tests/molecule/user/molecule.yml @@ -0,0 +1,20 @@ +--- +dependency: + name: galaxy +driver: + name: molecule-qemu +platforms: + - name: debian-bullseye-arm64 + image: https://cloud.debian.org/images/cloud/bullseye/latest/debian-11-genericcloud-arm64.qcow2 + image_checksum: sha512:https://cloud.debian.org/images/cloud/bullseye/latest/SHA512SUMS + image_arch: aarch64 + ssh_port: 10000 + - name: debian-bullseye-amd64 + image: https://cloud.debian.org/images/cloud/bullseye/latest/debian-11-genericcloud-amd64.qcow2 + image_checksum: sha512:https://cloud.debian.org/images/cloud/bullseye/latest/SHA512SUMS + image_arch: x86_64 + ssh_port: 10001 +provisioner: + name: ansible +verifier: + name: ansible diff --git a/tests/molecule/user/prepare.yml b/tests/molecule/user/prepare.yml new file mode 100644 index 0000000..9b26ccf --- /dev/null +++ b/tests/molecule/user/prepare.yml @@ -0,0 +1,15 @@ +--- +- name: Prepare + hosts: all + become: true + gather_facts: false + + environment: + http_proxy: "{{ lookup('ansible.builtin.env', 'http_proxy') | default(omit) }}" + https_proxy: "{{ lookup('ansible.builtin.env', 'https_proxy') | default(omit) }}" + + tasks: + - name: Wait for SSH to become available + ansible.builtin.wait_for_connection: + delay: 5 + timeout: 300 diff --git a/tests/molecule/user/verify.yml b/tests/molecule/user/verify.yml new file mode 100644 index 0000000..a5cfa75 --- /dev/null +++ b/tests/molecule/user/verify.yml @@ -0,0 +1,10 @@ +--- +# This is an example playbook to execute Ansible tests. + +- name: Verify + hosts: all + gather_facts: false + tasks: + - name: Example assertion + ansible.builtin.assert: + that: true diff --git a/tests/molecule/vmnet-shared/converge.yml b/tests/molecule/vmnet-shared/converge.yml new file mode 100644 index 0000000..8d580ce --- /dev/null +++ b/tests/molecule/vmnet-shared/converge.yml @@ -0,0 +1,12 @@ +--- +- name: Converge + hosts: all + + environment: + http_proxy: "{{ lookup('ansible.builtin.env', 'http_proxy') | default(omit) }}" + https_proxy: "{{ lookup('ansible.builtin.env', 'https_proxy') | default(omit) }}" + + tasks: + - name: "Include tests" + ansible.builtin.include_role: + name: "tests" diff --git a/tests/molecule/vmnet-shared/molecule.yml b/tests/molecule/vmnet-shared/molecule.yml new file mode 100644 index 0000000..74d5202 --- /dev/null +++ b/tests/molecule/vmnet-shared/molecule.yml @@ -0,0 +1,20 @@ +--- +dependency: + name: galaxy +driver: + name: molecule-qemu +platforms: + - name: debian-bullseye-arm64 + image: https://cloud.debian.org/images/cloud/bullseye/latest/debian-11-genericcloud-arm64.qcow2 + image_checksum: sha512:https://cloud.debian.org/images/cloud/bullseye/latest/SHA512SUMS + image_arch: aarch64 + vm_network: vmnet-shared + - name: debian-bullseye-amd64 + image: https://cloud.debian.org/images/cloud/bullseye/latest/debian-11-genericcloud-amd64.qcow2 + image_checksum: sha512:https://cloud.debian.org/images/cloud/bullseye/latest/SHA512SUMS + image_arch: x86_64 + vm_network: vmnet-shared +provisioner: + name: ansible +verifier: + name: ansible diff --git a/tests/molecule/vmnet-shared/prepare.yml b/tests/molecule/vmnet-shared/prepare.yml new file mode 100644 index 0000000..9b26ccf --- /dev/null +++ b/tests/molecule/vmnet-shared/prepare.yml @@ -0,0 +1,15 @@ +--- +- name: Prepare + hosts: all + become: true + gather_facts: false + + environment: + http_proxy: "{{ lookup('ansible.builtin.env', 'http_proxy') | default(omit) }}" + https_proxy: "{{ lookup('ansible.builtin.env', 'https_proxy') | default(omit) }}" + + tasks: + - name: Wait for SSH to become available + ansible.builtin.wait_for_connection: + delay: 5 + timeout: 300 diff --git a/tests/molecule/vmnet-shared/verify.yml b/tests/molecule/vmnet-shared/verify.yml new file mode 100644 index 0000000..a5cfa75 --- /dev/null +++ b/tests/molecule/vmnet-shared/verify.yml @@ -0,0 +1,10 @@ +--- +# This is an example playbook to execute Ansible tests. + +- name: Verify + hosts: all + gather_facts: false + tasks: + - name: Example assertion + ansible.builtin.assert: + that: true