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

Initial integration testing environment #8

Merged
merged 14 commits into from
Mar 28, 2017
Merged
Show file tree
Hide file tree
Changes from 9 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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.vagrant/
__pycache__/
*.pyc
# Symlink to virtualenv
.venv
12 changes: 12 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[[source]]
url = "https://pypi.python.org/simple"
verify_ssl = true

[dev-packages]
behave = "*"
pylint = "*"
requests = "*"
PyHamcrest = "*"

[packages]
ansible = ">= 2.0"
150 changes: 150 additions & 0 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions integration-tests/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Symlink to virtualenv
.venv
61 changes: 61 additions & 0 deletions integration-tests/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Kernel modernization integration tests

This directory contains integration tests that check the expected results
of kernel modernization attempts given different starting scenarios.

* Test scenarios and expectations are defined using the Python
[behave](http://pythonhosted.org/behave/) framework
* Local virtual machines for test cases are defined and configured
using the
[Ansible Python API](http://docs.ansible.com/ansible/dev_guide/developing_api.html)
* The integration testing environment itself is configured using
[pipenv](https://pypi.python.org/pypi/pipenv)

## Setting up

Install `vagrant` and `vagrant-libvirt`:

$ sudo dnf install vagrant vagrant-libvirt

Install `pipenv` and the `pew` environment management tool:

$ pip install --user pipsi
$ pipsi install pew
$ pipsi install pipenv

The above commands do a user level install of the "pip script installer",
and then install `pew` and `pipenv` into isolated virtual environments
for reliability of later updates. (`pew` needs to be installed separately
so `pipenv` sees only the command line interface instead of the Python API)

Once `pipenv` is installed, run the following to install the
integration testing environment:

$ pipenv --three && pipenv install

Note that while `leapp` itself will run under Python 2.7, the integration
tests require Python 3.

## Running the tests

To get a local shell with the testing environment active, run:

$ pipenv shell

Once in the testing environment, the tests can be run by invoking
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had to cd integration-tests/ before calling behave.

`behave` test runner directly:

$ behave

The tests require passwordless `sudo` access to both `vagrant`
and `leapp-tool` (alternatively, they will require interactive
password entry during the test).

## Writing new tests

New feature definitions go in the ["features"](./features) subdirectory.

New step definitions go in the ["features/steps"](./features.steps)
subdirectory, and use the
["hamcrest"](https://pyhamcrest.readthedocs.io/en/latest/tutorial/)
library to define behavioural expectations.
7 changes: 7 additions & 0 deletions integration-tests/features/environment.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import contextlib

def before_scenario(context, scenario):
context.resource_manager = contextlib.ExitStack()

def after_scenario(context, scenario):
context.resource_manager.close()
9 changes: 9 additions & 0 deletions integration-tests/features/httpd-stateless.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Feature: Redeploy stateless HTTP services

Scenario: HTTP default server page
Given the local virtual machines:
| name | definition | ensure_fresh |
| app-source | centos6-guest-httpd | no |
| target | centos7-target | no |
When app-source is redeployed to target as a macrocontainer
Then the HTTP responses on port 80 should match within 90 seconds
Loading