rcbops/rpc-openstack-system-tests

Name: rpc-openstack-system-tests

Owner: rcbops

Description: null

Created: 2018-02-22 22:47:35.0

Updated: 2018-05-24 16:00:47.0

Pushed: 2018-05-24 20:29:12.0

Homepage: null

Size: 74

Language: Shell

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

System Tests for Rackspace Private Cloud - OpenStack

WIP This project is a work in progress and is subject to breaking changes and design changes.

The rcp-openstack-system-tests repository contains virtualenv requirements and constraints for installing the molecule framework for deploying system state via ansible and validating that state using the infratest test framework on the Deployment Host.

Tests are gathered as git submodules under the molecules directory. Molecule should be run against each of the submodules in turn.

This repository is meant to be run on the Deployment Host.

Gather Submodules

Since the molecule tests are included as git submodules, they must be initialized and updated in order to be accessible to the molecule test runner.

submodule init
submodule update --recursive --remote
Adding Submodules

The submodules for the tests should have branches that mirror the release branches for this repository (and the rpc-openstack repository). The submodules should be set to track the appropriate matching branch. For example, all submodules in the pike branch of this repo should be set to track the pike branch of their remote origin.

When adding a new submodule, the branch tracking will need to be performed for each of the release branches.

Add new submodule in master branch and set it to track master branch for its remote origin.

submodule add -b master [URL to Git repo] molecules/[name of Git repo]
submodule init

After this has been committed to the master branch, for each release branch, the commit associated with the submodule addition should be rebased or cherry-picked to the release branch and the tracking configuration for each submodule should be changed to reflect the release branch. The following command can be used to achieve this.

config -f .gitmodules submodule.<path>.branch <branch>
Virtualenv Deployment

On the Deployment Host, create a python virtualenv and populate it using the included requirements.txt and constraints.txt files. This will install molecule and ansible into the virtualenv.

Example

VENV_NAME=venv-molecule
CONSTRAINTS="constraints.txt"
REQUIREMENTS="requirements.txt"

eate virtualenv for molecule
ualenv --no-pip --no-setuptools --no-wheel ${SYS_VENV_NAME}

tivate virtualenv
ce ${SYS_VENV_NAME}/bin/activate

sure that correct pip version is installed
TARGET="$(awk -F= '/^pip==/ {print $3}' ${SYS_CONSTRAINTS})"
_PYTHON="${SYS_VENV_NAME}/bin/python"
_PIP="${SYS_VENV_NAME}/bin/pip"

[ "$(${VENV_PIP} --version)" != "pip ${PIP_TARGET}"* ]]; then
CURL_CMD="curl --silent --show-error --retry 5"
OUTPUT_FILE="get-pip.py"
${CURL_CMD} https://bootstrap.pypa.io/get-pip.py > ${OUTPUT_FILE}  \
    || ${CURL_CMD} https://raw.githubusercontent.com/pypa/get-pip/master/get-pip.py > ${OUTPUT_FILE}
GETPIP_OPTIONS="pip setuptools wheel --constraint ${SYS_CONSTRAINTS}"
${VENV_PYTHON} ${OUTPUT_FILE} ${GETPIP_OPTIONS} \
    || ${VENV_PYTHON} ${OUTPUT_FILE} --isolated ${GETPIP_OPTIONS}


stall test suite requirements
OPTIONS=-r ${SYS_REQUIREMENTS}"
NV_PIP} install ${PIP_OPTIONS} || ${VENV_PIP} install --isolated ${PIP_OPTIONS}
Generate Molecule Config from Ansible Dynamic Inventory

The moleculerize tool will build molecule config files from a RPC-O Ansible dynamic inventory file. As a prerequisite to using the moleculerize tool, a dynamic inventory must be generated from a RPC-O build:

 su -
opt/openstack-ansible/playbooks/inventory
namic_inventory.py > /path/to/dynamic_inventory.json

Now you can generate a molecule.yml config file using the moleculerize tool:

path/to/rpc-openstack-system-tests
culerize /path/to/dynamic_inventory.json

The above command assumes that moleculerize's built-in molecule.yml.j2 template will be used along with molecule.yml as the output file.

Execute Molecule Tests

For each of the submodules in the molecules directory, run the molecule converge command to execute any ansible playbook plays needed to set the system up for test validation. Then run the molecule verify command to validate that the system state conforms to the defined specifications.

The molecularize tool is used to transpose the Deploy Host's dynamic inventory JSON output into the yaml format used by molecule internally.

Example:

suming that the dynamic inventory script is located at the following location:
/openstack-ansible/playbooks/inventory/dynamic_inventory.py > /tmp/dynamic_inventory.json
TEST in $(ls molecules) ; do
moleculerize --output molecules/$TEST/molecule/default/molecule.yml /tmp/dynamic_inventory.json
pushd molecules/$TEST
molecule converge
molecule verify
popd


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.