Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add molecule test for bootstrap-os #5845

Merged
merged 1 commit into from
Apr 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,4 @@ include:
- .gitlab-ci/shellcheck.yml
- .gitlab-ci/terraform.yml
- .gitlab-ci/packet.yml
- .gitlab-ci/vagrant.yml
16 changes: 16 additions & 0 deletions .gitlab-ci/vagrant.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---

molecule_tests:
tags: [vagrant]
only: [/^pr-.*$/]
except: ['triggers']
image: quay.io/miouge/kubespray-vagrant
services: []
stage: deploy-part1
before_script:
- tests/scripts/rebase.sh
- apt-get update && apt-get install -y python3-pip
- update-alternatives --install /usr/bin/python python /usr/bin/python3 10
- python -m pip install -r tests/requirements.txt
script:
- ./tests/scripts/molecule_run.sh
2 changes: 2 additions & 0 deletions roles/bootstrap-os/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,5 @@ fedora_coreos_packages:
## General
# Set the hostname to inventory_hostname
override_system_hostname: true

is_fedora_coreos: false
44 changes: 44 additions & 0 deletions roles/bootstrap-os/molecule/default/molecule.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---
scenario:
name: default
test_sequence:
- lint
- destroy
- dependency
- syntax
- create
- prepare
- converge
# - idempotence # skip
- side_effect
- verify
- destroy
dependency:
name: galaxy
lint:
name: yamllint
options:
config-file: ../../.yamllint
driver:
name: vagrant
provider:
name: libvirt
platforms:
- name: ubuntu18
box: generic/ubuntu1804
cpus: 2
memory: 2048
provisioner:
name: ansible
lint:
name: ansible-lint
inventory:
group_vars:
all:
user:
name: foo
comment: My test comment
verifier:
name: testinfra
lint:
name: flake8
6 changes: 6 additions & 0 deletions roles/bootstrap-os/molecule/default/playbook.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
- name: Converge
hosts: all
gather_facts: no
roles:
- role: bootstrap-os
11 changes: 11 additions & 0 deletions roles/bootstrap-os/molecule/default/tests/test_default.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import os

import testinfra.utils.ansible_runner

testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
os.environ['MOLECULE_INVENTORY_FILE']
).get_hosts('all')


def test_python(host):
assert host.exists('python3') or host.exists('python')
2 changes: 2 additions & 0 deletions tests/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ dopy==0.3.7
cryptography==2.8
ansible-lint==4.2.0
openshift==0.8.8
molecule==2.22
python-vagrant==0.5.15
12 changes: 12 additions & 0 deletions tests/scripts/molecule_run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash
set -euxo pipefail

export LC_ALL=C.UTF-8
export LANG=C.UTF-8

for d in $(find roles -name molecule -type d)
do
cd $(dirname $d)
molecule test --all
cd -
done