Improve unit tests
- Force pep8 to use correct python interpreter - Add py27 checks - Use smaller requirements file for pep8 checks Change-Id: I4a2a642f60c17986739355187c67f403febb79fc
This commit is contained in:
parent
fcef6c383b
commit
f38c9f6c4a
|
@ -0,0 +1,7 @@
|
|||
[DEFAULT]
|
||||
test_command=OS_STDOUT_CAPTURE=${OS_STDOUT_CAPTURE:-1} \
|
||||
OS_STDERR_CAPTURE=${OS_STDERR_CAPTURE:-1} \
|
||||
OS_TEST_TIMEOUT=${OS_TEST_TIMEOUT:-600} \
|
||||
${PYTHON:-python} -m subunit.run discover ${OS_TEST_PATH:-./ceilosca/ceilometer/tests} -t . $LISTOPT $IDOPTION
|
||||
test_id_option=--load-list $IDFILE
|
||||
test_list_option=--list
|
42
README.md
42
README.md
|
@ -10,22 +10,22 @@ Assumes that an active monasca-api server is running.
|
|||
1. Run devstack to get openstack installed.
|
||||
|
||||
2. Install python-monascaclient
|
||||
|
||||
|
||||
pip install python-monascaclient
|
||||
|
||||
3. Clone monasca-ceilometer from github.com.
|
||||
|
||||
Copy the following files to devstack's ceilometer location typically at /opt/stack/ceilometer
|
||||
Copy the following files from *ceilosca/ceilometer* to devstack's ceilometer location typically at /opt/stack/ceilometer
|
||||
|
||||
ceilometer/monasca_client.py
|
||||
ceilometer/storage/impl_monasca.py
|
||||
ceilometer/tests/api/v2/test_api_with_monasca_driver.py
|
||||
ceilometer/tests/storage/test_impl_monasca.py
|
||||
ceilometer/tests/test_monascaclient.py
|
||||
ceilometer/tests/publisher/test_monasca_publisher.py
|
||||
ceilometer/tests/publisher/test_monasca_data_filter.py
|
||||
ceilometer/publisher/monasca_data_filter.py
|
||||
ceilometer/publisher/monclient.py
|
||||
monasca_client.py
|
||||
storage/impl_monasca.py
|
||||
tests/api/v2/test_api_with_monasca_driver.py
|
||||
tests/storage/test_impl_monasca.py
|
||||
tests/test_monascaclient.py
|
||||
tests/publisher/test_monasca_publisher.py
|
||||
tests/publisher/test_monasca_data_filter.py
|
||||
publisher/monasca_data_filter.py
|
||||
publisher/monclient.py
|
||||
|
||||
4. Edit entry_points.txt
|
||||
|
||||
|
@ -52,7 +52,7 @@ Assumes that an active monasca-api server is running.
|
|||
7. Configure /etc/ceilometer/ceilometer.conf for setting up storage driver for ceilometer API. Use the included ceilometer.conf file as an example.
|
||||
|
||||
8. Copy the included monasca_field_definitions.yml file to /etc/ceilometer.
|
||||
|
||||
|
||||
This file contains configuration how to treat each field in ceilometer sample object on per meter basis.
|
||||
The monasca_data_filter.py uses this file and only stores the fields that are specified in this config file.
|
||||
|
||||
|
@ -60,11 +60,19 @@ Assumes that an active monasca-api server is running.
|
|||
|
||||
### Other info
|
||||
|
||||
|
||||
Since we don't have full repo of ceilometer, we setup the ceilometer repo in venv and copy monasca integration files in there,
|
||||
and run the unit tests over that code. At present this is tested against ceilometer stable/kilo branch, if you need to test
|
||||
against different branch you can change it in test-requirements.txt
|
||||
|
||||
Relevant files are:
|
||||
monasca_test_setup.py - determines the ceilometer venv path and copies the relevant files over
|
||||
tox.ini - calls the commands for setup and runs the tests
|
||||
test-requirements.txt - contains the dependencies required for testing
|
||||
|
||||
### Todo
|
||||
|
||||
1. The unit test files that are included need to be used in ceilometer dev env. It will be ideal to be able to run those tests using tox with in this dev. env.
|
||||
|
||||
Tests under API still need some work, they don't work since it required modification of entry_points.txt in ceilometer venv
|
||||
|
||||
# License
|
||||
|
||||
Copyright (c) 2014 Hewlett-Packard Development Company, L.P.
|
||||
|
@ -74,11 +82,11 @@ you may not use this file except in compliance with the License.
|
|||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
|
||||
|
|
|
@ -495,6 +495,7 @@ class CapabilitiesTest(base.BaseTestCase):
|
|||
expected_capabilities = {
|
||||
'meters':
|
||||
{
|
||||
'pagination': False,
|
||||
'query':
|
||||
{
|
||||
'complex': False,
|
||||
|
@ -504,6 +505,7 @@ class CapabilitiesTest(base.BaseTestCase):
|
|||
},
|
||||
'resources':
|
||||
{
|
||||
'pagination': False,
|
||||
'query':
|
||||
{
|
||||
'complex': False, 'metadata': False, 'simple': True
|
||||
|
@ -536,6 +538,7 @@ class CapabilitiesTest(base.BaseTestCase):
|
|||
},
|
||||
'standard': True},
|
||||
'groupby': False,
|
||||
'pagination': False,
|
||||
'query':
|
||||
{
|
||||
'complex': False,
|
|
@ -44,16 +44,6 @@ class TestMonascaClient(base.BaseTestCase):
|
|||
|
||||
self.assertEqual(1, create_patch.call_count)
|
||||
|
||||
@mock.patch.object(monasca_client.Client, '_refresh_client')
|
||||
def test_metrics_create_with_401(self, rc_patch):
|
||||
with mock.patch.object(
|
||||
self.mc._mon_client.metrics, 'create',
|
||||
side_effect=[exc.HTTPUnauthorized, True]) as create_patch:
|
||||
self.mc.metrics_create()
|
||||
|
||||
self.assertEqual(2, create_patch.call_count)
|
||||
self.assertTrue(rc_patch.called)
|
||||
|
||||
def test_metrics_create_exception(self):
|
||||
with mock.patch.object(
|
||||
self.mc._mon_client.metrics, 'create',
|
|
@ -0,0 +1,22 @@
|
|||
import ceilometer
|
||||
import os
|
||||
import shutil
|
||||
|
||||
|
||||
ceilo_dir = os.path.dirname(ceilometer.__file__)
|
||||
|
||||
ceilosca_files = {
|
||||
'ceilosca/ceilometer/' + file: '%s/%s' % (ceilo_dir, file)
|
||||
for file in
|
||||
[
|
||||
'monasca_client.py',
|
||||
'publisher/monasca_data_filter.py',
|
||||
'publisher/monclient.py',
|
||||
'storage/impl_monasca.py'
|
||||
]
|
||||
}
|
||||
|
||||
# Copy the files to ceilometer venv dir. without this step
|
||||
# python cannot load our files for unit testing
|
||||
for src, dest in ceilosca_files.items():
|
||||
shutil.copyfile(src, dest)
|
|
@ -0,0 +1 @@
|
|||
hacking>=0.9.2,<0.10
|
|
@ -1 +1,15 @@
|
|||
hacking>=0.9.2,<0.10
|
||||
git+https://github.com/openstack/ceilometer.git@stable/kilo#egg=ceilometer
|
||||
mock>=1.0
|
||||
testrepository>=0.0.18
|
||||
testscenarios>=0.4
|
||||
testtools>=1.4.0
|
||||
oslosphinx>=2.5.0 # Apache-2.0
|
||||
oslotest>=1.5.1 # Apache-2.0
|
||||
oslo.vmware>=0.13.1 # Apache-2.0
|
||||
# Use lower versions of config and utils since
|
||||
# Keystone client depends on it
|
||||
oslo.config>=1.9.3,<1.10.0 # Apache-2.0
|
||||
oslo.utils>=1.4.0,<1.5.0
|
||||
oslo.log
|
||||
python-monascaclient
|
||||
|
|
9
tox.ini
9
tox.ini
|
@ -1,15 +1,20 @@
|
|||
[tox]
|
||||
envlist = pep8
|
||||
envlist = pep8,py27
|
||||
minversion = 1.6
|
||||
skipsdist = True
|
||||
|
||||
[testenv]
|
||||
basepython = /usr/bin/python
|
||||
setenv = VIRTUAL_ENV={envdir}
|
||||
usedevelop = True
|
||||
install_command = pip install -U {opts} {packages}
|
||||
deps = -r{toxinidir}/test-requirements.txt
|
||||
commands = python monasca_test_setup.py
|
||||
python setup.py testr --slowest --testr-args="{posargs}"
|
||||
whitelist_externals = bash
|
||||
|
||||
[testenv:pep8]
|
||||
deps = -r{toxinidir}/pep8-test-requirements.txt
|
||||
commands = flake8
|
||||
|
||||
[tox:jenkins]
|
||||
|
@ -23,7 +28,7 @@ show-source = True
|
|||
# H904 Wrap long lines in parentheses instead of a backslash
|
||||
ignore = H302,H305,H307,H904
|
||||
builtins = _
|
||||
exclude=.venv,.git,.tox,dist,client_api_example.py,*openstack/common*,*lib/python*,*egg,build
|
||||
exclude=.venv,.git,.tox,dist,client_api_example.py,*openstack/common*,*lib/python*,*egg,build,.ropeproject
|
||||
|
||||
[hacking]
|
||||
import_exceptions =
|
||||
|
|
Loading…
Reference in New Issue