Refactor to source charm

This is in line with the agreed conventions on where to put
files in a layered source package.

Essentially, just the final moving of things around and ensuring
that the dummy tests pass, along with lint.

Change-Id: I392568d6279f0a5876bdb2a3ad5e49fee03734aa
This commit is contained in:
Alex Kavanagh 2016-06-06 09:54:31 +00:00
parent d5e728e5af
commit f10d28e392
35 changed files with 159 additions and 90 deletions

View File

@ -1,28 +1,18 @@
# Overview # Overview
Tempest is a set of integration tests to be run against a live OpenStack cluster. Tempest has batteries of tests for OpenStack API validation, Scenarios, and other specific tests useful in validating an OpenStack deployment. This is a "source" charm, which is intended to be strictly the top
layer of a built charm. This structure declares that any included
layer assets are not intended to be consumed as a layer from a
functional or design standpoint.
The Tempest Charm can be deployed into a new or existing Juju model containing an OpenStack deployment to execute sets or subsets of Tempest tests. # Test and Build
# Building
``` ```
sudo apt-get install python-tox tox -e pep8
tox -e py34 # or py27 or py35
tox -e build tox -e build
``` ```
# Usage
At this time, the Tempest charm is in development and is in a proof-of-concept state. Development and related discussion occurs on the freenode #juju irc channel.
TLDR: Deploy the built charm and relate it to keystone and openstack-dashboard. See config.yaml as annotated.
More docs to come as this matures.
# Contact Information # Contact Information
Report bugs on [Launchpad](http://bugs.launchpad.net/charms/+source/tempest/+filebug) Freenode IRC: #openstack-charms

View File

@ -1,17 +1,13 @@
Format: http://dep.debian.net/deps/dep5/ Copyright 2016 Canonical Ltd.
Files: * Licensed under the Apache License, Version 2.0 (the "License");
Copyright: Copyright 2011, Canonical Ltd., All Rights Reserved. you may not use this file except in compliance with the License.
License: GPL-3 You may obtain a copy of the License at
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by http://www.apache.org/licenses/LICENSE-2.0
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. Unless required by applicable law or agreed to in writing, software
. distributed under the License is distributed on an "AS IS" BASIS,
This program is distributed in the hope that it will be useful, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
but WITHOUT ANY WARRANTY; without even the implied warranty of See the License for the specific language governing permissions and
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the limitations under the License.
GNU General Public License for more details.
.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.

View File

@ -1,18 +0,0 @@
import charms.reactive as reactive
import charm.openstack.tempest as tempest
import os
@reactive.hook('install')
def install_packages():
tempest.get_charm().install()
@reactive.when('identity-admin.available')
def render_tempest_config(keystone):
charm = tempest.TempestCharmFactory.charm(
interfaces=[keystone]
)
if not os.path.isdir(charm.TEMPEST_LOGDIR):
os.makedirs(charm.TEMPEST_LOGDIR)
charm.render_all_configs()

View File

@ -2,13 +2,4 @@
# of appearance. Changing the order has an impact on the overall integration # of appearance. Changing the order has an impact on the overall integration
# process, which may cause wedges in the gate later. # process, which may cause wedges in the gate later.
charm-tools>=2.0.0 charm-tools>=2.0.0
pbr>=1.8.0,<1.9.0
PyYAML>=3.1.0
simplejson>=2.2.0 simplejson>=2.2.0
netifaces>=0.10.4
netaddr>=0.7.12,!=0.7.16
Jinja2>=2.6 # BSD License (3 clause)
six>=1.9.0
dnspython>=1.12.0
psutil>=1.1.1,<2.0.0
python-neutronclient>=2.6.0

1
src/.testr.conf Symbolic link
View File

@ -0,0 +1 @@
../.testr.conf

21
src/README.md Normal file
View File

@ -0,0 +1,21 @@
# Overview
Tempest is a set of integration tests to be run against a live OpenStack cluster. Tempest has batteries of tests for OpenStack API validation, Scenarios, and other specific tests useful in validating an OpenStack deployment.
The Tempest Charm can be deployed into a new or existing Juju model containing an OpenStack deployment to execute sets or subsets of Tempest tests.
# Usage
At this time, the Tempest charm is in development and is in a proof-of-concept state. Development and related discussion occurs on the freenode #juju irc channel.
TLDR: Deploy the built charm and relate it to keystone and openstack-dashboard. See config.yaml as annotated.
More docs to come as this matures.
# Contact Information
Report bugs on [Launchpad](http://bugs.launchpad.net/charms/+source/tempest/+filebug)
Freenode IRC: #openstack-charms

1
src/copyright Symbolic link
View File

@ -0,0 +1 @@
../copyright

View File

Before

Width:  |  Height:  |  Size: 30 KiB

After

Width:  |  Height:  |  Size: 30 KiB

View File

@ -8,22 +8,26 @@ import neutronclient.v2_0.client as neutronclient
import novaclient.v2 as novaclient import novaclient.v2 as novaclient
import urllib import urllib
import charm.openstack.charm as charm import charms_openstack.charm as charm
import charm.openstack.adapters as adapters import charms_openstack.adapters as adapters
import charmhelpers.core.hookenv as hookenv import charmhelpers.core.hookenv as hookenv
import charmhelpers.fetch as fetch import charmhelpers.fetch as fetch
tempest_charm = None
def install():
def get_charm(): """Use the singleton from the BarbicanCharm to install the packages on the
""" Return a new instance of TempestCharm or existing global instance unit
@returns TempestCharm
""" """
global tempest_charm TempestCharm.singleton.install()
if tempest_charm is None:
tempest_charm = TempestCharmFactory.charm()
return tempest_charm def render_configs(interfaces_list):
"""Using a list of interfaces, render the configs and, if they have
changes, restart the services on the unit.
"""
if not os.path.isdir(TempestCharm.TEMPEST_LOGDIR):
os.makedirs(TempestCharm.TEMPEST_LOGDIR)
TempestCharm.singleton.render_with_interfaces(interfaces_list)
class TempestAdminAdapter(adapters.OpenStackRelationAdapter): class TempestAdminAdapter(adapters.OpenStackRelationAdapter):
@ -240,6 +244,9 @@ class TempestConfigurationAdapter(adapters.ConfigurationAdapter):
class TempestCharm(charm.OpenStackCharm): class TempestCharm(charm.OpenStackCharm):
release = 'liberty'
name = 'tempest'
"""Directories and files used for running tempest""" """Directories and files used for running tempest"""
TEMPEST_ROOT = '/var/lib/tempest/' TEMPEST_ROOT = '/var/lib/tempest/'
TEMPEST_LOGDIR = TEMPEST_ROOT + '/logs' TEMPEST_LOGDIR = TEMPEST_ROOT + '/logs'
@ -326,12 +333,3 @@ class TempestCharm(charm.OpenStackCharm):
self.setup_git(branch_name, git_dir) self.setup_git(branch_name, git_dir)
self.execute_tox(run_dir, logfile, tox_target) self.execute_tox(run_dir, logfile, tox_target)
hookenv.action_set(action_info) hookenv.action_set(action_info)
class TempestCharmFactory(charm.OpenStackCharmFactory):
releases = {
'liberty': TempestCharm
}
first_release = 'liberty'

13
src/reactive/handlers.py Normal file
View File

@ -0,0 +1,13 @@
import charms.reactive as reactive
import charm.openstack.tempest as tempest
@reactive.when_not('charm.installed')
def install_packages():
tempest.install()
reactive.set_state('charm.installed')
@reactive.when('identity-admin.available')
def render_tempest_config(keystone):
tempest.render_configs([keystone])

1
src/requirements.txt Symbolic link
View File

@ -0,0 +1 @@
../requirements.txt

1
src/test-requirements.txt Symbolic link
View File

@ -0,0 +1 @@
../test-requirements.txt

1
src/tests/writeme Normal file
View File

@ -0,0 +1 @@
Add amulet functional tests.

41
src/tox.ini Normal file
View File

@ -0,0 +1,41 @@
[tox]
skipsdist = True
envlist = pep8
[testenv]
sitepackages = False
setenv = VIRTUAL_ENV={envdir}
PYTHONHASHSEED=0
TERM=linux
INTERFACE_PATH={toxinidir}/interfaces
LAYER_PATH={toxinidir}/layers
JUJU_REPOSITORY={toxinidir}/build
passenv = http_proxy https_proxy
install_command =
pip install --allow-unverified python-apt {opts} {packages}
commands = ostestr {posargs}
[testenv:py27]
basepython = python2.7
deps = -r{toxinidir}/test-requirements.txt
[testenv:py34]
basepython = python3.4
deps = -r{toxinidir}/test-requirements.txt
[testenv:py35]
basepython = python3.5
deps = -r{toxinidir}/test-requirements.txt
[testenv:pep8]
basepython = python2.7
deps = -r{toxinidir}/requirements.txt
-r{toxinidir}/test-requirements.txt
commands = flake8 {posargs} hooks unit_tests tests actions
charm-proof
[testenv:venv]
commands = {posargs}
[flake8]
ignore = E402

View File

@ -0,0 +1,5 @@
# By design, this unit_tests dir is inside the src charm (layer),
# and it will be included in the resultant built charm asset.
#
# Include unit tests here which are intended to be executable
# from the built charm.

View File

@ -0,0 +1,13 @@
import unittest
class TestNoOp(unittest.TestCase):
"""Placeholder - Write Me!"""
# XXX (beisner): with the charm.openstack vs lib/charm/openstack/tempest
# module namespace collision, and with the hard requirement to have some
# sort of unit test passing, here is a temporary inert noop test. After
# charms_openstack module is completed, and this tempest charm is
# refactored to use it, revisit this and add actual unit tests.
def test_noop(self):
"""Test Nothing"""
pass

View File

@ -3,6 +3,6 @@
# process, which may cause wedges in the gate later. # process, which may cause wedges in the gate later.
coverage>=3.6 coverage>=3.6
mock>=1.2 mock>=1.2
pep8>=1.7.0
flake8>=2.2.4,<=2.4.1 flake8>=2.2.4,<=2.4.1
os-testr>=0.4.1 os-testr>=0.4.1
requests==2.6.0

View File

25
tox.ini
View File

@ -1,8 +1,10 @@
[tox] [tox]
skipsdist = True skipsdist = True
envlist = pep8 envlist = pep8
skip_missing_interpreters = True
[testenv] [testenv]
sitepackages = False
setenv = VIRTUAL_ENV={envdir} setenv = VIRTUAL_ENV={envdir}
PYTHONHASHSEED=0 PYTHONHASHSEED=0
TERM=linux TERM=linux
@ -17,24 +19,31 @@ commands = ostestr {posargs}
[testenv:build] [testenv:build]
basepython = python2.7 basepython = python2.7
commands = commands =
charm-build --log-level DEBUG -o {toxinidir}/build . charm-build --log-level DEBUG -o {toxinidir}/build src
deps = -r{toxinidir}/requirements.txt deps = -r{toxinidir}/requirements.txt
[testenv:py27] [testenv:py27]
basepython = python2.7 basepython = python2.7
deps = -r{toxinidir}/requirements.txt deps = -r{toxinidir}/test-requirements.txt
-r{toxinidir}/test-requirements.txt commands = ostestr {posargs}
[testenv:py34]
basepython = python3.4
deps = -r{toxinidir}/test-requirements.txt
commands = ostestr {posargs}
[testenv:py35]
basepython = python3.5
deps = -r{toxinidir}/test-requirements.txt
commands = ostestr {posargs}
[testenv:pep8] [testenv:pep8]
basepython = python2.7 basepython = python2.7
deps = -r{toxinidir}/requirements.txt deps = -r{toxinidir}/test-requirements.txt
-r{toxinidir}/test-requirements.txt commands = flake8 {posargs} src unit_tests
commands = flake8 {posargs} hooks unit_tests tests actions
charm-proof
[testenv:venv] [testenv:venv]
commands = {posargs} commands = {posargs}
[flake8] [flake8]
ignore = E402,E226 ignore = E402,E226
exclude = hooks/charmhelpers

View File

@ -0,0 +1,5 @@
# By design, this unit_tests dir is outside the src charm (layer),
# and it will not be included in the resultant built charm asset.
#
# Include unit tests here which are intended to be executable
# from the source charm but not the built charm.