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

[WIP]vdo_test : adding VDO testing files. #49

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
16 changes: 16 additions & 0 deletions roles/backend_setup/molecule/vdo/Dockerfile.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Molecule managed

{% if item.registry is defined %}
FROM {{ item.registry.url }}/{{ item.image }}
{% else %}
FROM {{ item.image }}
{% endif %}

RUN if [ $(command -v apt-get) ]; then apt-get update && apt-get install -y python sudo bash ca-certificates && apt-get clean; \
elif [ $(command -v dnf) ]; then dnf makecache && dnf --assumeyes install python sudo python-devel python2-dnf bash && dnf clean all; \
elif [ $(command -v yum) ]; then yum makecache fast && yum install -y python sudo yum-plugin-ovl bash && sed -i 's/plugins=0/plugins=1/g' /etc/yum.conf && yum clean all; \
elif [ $(command -v zypper) ]; then zypper refresh && zypper install -y python sudo bash python-xml && zypper clean -a; \
elif [ $(command -v apk) ]; then apk update && apk add --no-cache python sudo bash ca-certificates; \
elif [ $(command -v xbps-install) ]; then xbps-install -Syu && xbps-install -y python sudo bash ca-certificates && xbps-remove -O; fi

RUN yum install -y lvm2 util-linux libudev-devel libselinux-python gcc python-virtualenv xfsprogs policycoreutils-python PyYAML vdo kmod-kvdo
26 changes: 26 additions & 0 deletions roles/backend_setup/molecule/vdo/INSTALL.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
*******
Docker driver installation guide
*******

Requirements
============

* General molecule dependencies (see https://molecule.readthedocs.io/en/latest/installation.html)
* Docker Engine
* docker-py
* docker

Install
=======

Ansible < 2.6

.. code-block:: bash

$ sudo pip install docker-py

Ansible >= 2.6

.. code-block:: bash

$ sudo pip install docker
25 changes: 25 additions & 0 deletions roles/backend_setup/molecule/vdo/molecule.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
dependency:
name: galaxy
driver:
name: docker
lint:
name: yamllint
platforms:
- name: instance
image: centos/systemd
command: /sbin/init
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
- /dev:/dev:rw
privileged: true
provisioner:
name: ansible
lint:
name: ansible-lint
scenario:
name: vdo
verifier:
name: testinfra
lint:
name: flake8
39 changes: 39 additions & 0 deletions roles/backend_setup/molecule/vdo/playbook.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
- name: Converge
hosts: all
roles:
- role: backend_setup
vars:
# Set a disk type. Options: JBOD, RAID6, RAID10 - Default: JBOD
gluster_infra_disktype: RAID10
gluster_infra_dalign: 256K
gluster_infra_diskcount: 10
gluster_infra_stripe_unit_size: 128
gluster_infra_vdo:
- name: hc_vdo_1
device: /dev/loop0
slabsize: 128M
gluster_infra_volume_groups:
- vgname: vg_vdb
pvname: /dev/mapper/hc_vdo_1
gluster_infra_thick_lvs:
- vgname: vg_vdb
lvname: vg_vdb_thicklv1
size: 1G
gluster_infra_thinpools:
- vgname: vg_vdb
thinpoolname: foo_thinpool
thinpoolsize: 400M
poolmetadatasize: 200M
gluster_infra_lv_logicalvols:
- vgname: vg_vdb
thinpool: foo_thinpool
lvname: vg_vdb_thinlv
lvsize: 500M
gluster_infra_mount_devices:
- path: /mnt/thicklv
vgname: vg_vdb
lvname: vg_vdb_thicklv1
- path: /mnt/thinlv1
vgname: vg_vdb
lvname: vg_vdb_thinlv
18 changes: 18 additions & 0 deletions roles/backend_setup/molecule/vdo/prepare.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
- name: Prepare
hosts: all
tasks:
- name: Allocate space to a file
command: "fallocate -l 5G /var/{{item}}"
args:
creates: "/var/{{item}}"
with_items:
- data0
- data1
- name: Create loopback devices
command: "losetup -f /var/{{item.1}}"
with_together:
- ['loop0', 'loop1']
- ['data0', 'data1']
loop_control:
pause: 5
14 changes: 14 additions & 0 deletions roles/backend_setup/molecule/vdo/tests/test_default.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import os

import testinfra.utils.ansible_runner

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


def test_hosts_file(host):
f = host.file('/etc/hosts')

assert f.exists
assert f.user == 'root'
assert f.group == 'root'