Add initial compute functional tests to Shade
Also, modified tox.ini to add a 'functional' stanza and the testenv now runs only unit tests. Change-Id: Id8a1193c829f7f3ab764c334b1f796f19f447fdd Depends-On: I1cf58e6a4cf728c5d2a32d602d9dfae1d4dfd62c
This commit is contained in:
parent
0249fa1259
commit
738d215661
@ -2,6 +2,6 @@
|
||||
test_command=OS_STDOUT_CAPTURE=${OS_STDOUT_CAPTURE:-1} \
|
||||
OS_STDERR_CAPTURE=${OS_STDERR_CAPTURE:-1} \
|
||||
OS_TEST_TIMEOUT=${OS_TEST_TIMEOUT:-60} \
|
||||
${PYTHON:-python} -m subunit.run discover -t ./ . $LISTOPT $IDOPTION
|
||||
${PYTHON:-python} -m subunit.run discover -t ./ ${OS_TEST_PATH:-./shade/tests/unit} $LISTOPT $IDOPTION
|
||||
test_id_option=--load-list $IDFILE
|
||||
test_list_option=--list
|
||||
test_list_option=--list
|
||||
|
0
shade/tests/functional/__init__.py
Normal file
0
shade/tests/functional/__init__.py
Normal file
29
shade/tests/functional/hooks/post_test_hook.sh
Executable file
29
shade/tests/functional/hooks/post_test_hook.sh
Executable file
@ -0,0 +1,29 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); 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.
|
||||
|
||||
export SHADE_DIR="$BASE/new/shade"
|
||||
|
||||
cd $BASE/new/devstack
|
||||
source openrc admin admin
|
||||
unset OS_CACERT
|
||||
|
||||
cd $SHADE_DIR
|
||||
sudo chown -R jenkins:stack $SHADE_DIR
|
||||
echo "Running shade functional test suite"
|
||||
set +e
|
||||
sudo -E -H -u jenkins tox -efunctional
|
||||
EXIT_CODE=$?
|
||||
set -e
|
||||
|
||||
exit $EXIT_CODE
|
59
shade/tests/functional/test_compute.py
Normal file
59
shade/tests/functional/test_compute.py
Normal file
@ -0,0 +1,59 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); 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.
|
||||
|
||||
"""
|
||||
test_compute
|
||||
----------------------------------
|
||||
|
||||
Functional tests for `shade` compute methods.
|
||||
"""
|
||||
|
||||
from novaclient.v2.servers import Server
|
||||
from shade import openstack_cloud
|
||||
from shade.tests import base
|
||||
from shade.tests.functional.util import pick_flavor, pick_image
|
||||
|
||||
|
||||
class TestCompute(base.TestCase):
|
||||
def setUp(self):
|
||||
super(TestCompute, self).setUp()
|
||||
# Shell should have OS-* envvars from openrc, typically loaded by job
|
||||
self.cloud = openstack_cloud()
|
||||
self.nova = self.cloud.nova_client
|
||||
self.flavor = pick_flavor(self.nova.flavors.list())
|
||||
if self.flavor is None:
|
||||
self.addDetail('pick_flavor', 'no sensible flavor available')
|
||||
self.image = pick_image(self.nova.images.list())
|
||||
if self.image is None:
|
||||
self.addDetail('pick_image', 'no sensible image available')
|
||||
self.addCleanup(self._cleanup_servers)
|
||||
|
||||
def _cleanup_servers(self):
|
||||
for i in self.nova.servers.list():
|
||||
if i.name.startswith('test'):
|
||||
self.nova.servers.delete(i)
|
||||
|
||||
def test_create_server(self):
|
||||
server = self.cloud.create_server(name='test_create_server',
|
||||
image=self.image, flavor=self.flavor)
|
||||
self.assertIsInstance(server, Server)
|
||||
self.assertEquals(server.name, 'test_create_server')
|
||||
self.assertEquals(server.image['id'], self.image.id)
|
||||
self.assertEquals(server.flavor['id'], self.flavor.id)
|
||||
|
||||
def test_delete_server(self):
|
||||
self.cloud.create_server(name='test_delete_server',
|
||||
image=self.image, flavor=self.flavor)
|
||||
server_deleted = self.cloud.delete_server('test_delete_server')
|
||||
self.assertIsNone(server_deleted)
|
37
shade/tests/functional/util.py
Normal file
37
shade/tests/functional/util.py
Normal file
@ -0,0 +1,37 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); 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.
|
||||
|
||||
"""
|
||||
util
|
||||
--------------------------------
|
||||
|
||||
Util methods for functional tests
|
||||
"""
|
||||
|
||||
|
||||
def pick_flavor(flavors):
|
||||
"""Given a flavor list pick a reasonable one."""
|
||||
for flavor in flavors:
|
||||
if flavor.name == 'm1.tiny':
|
||||
return flavor
|
||||
|
||||
for flavor in flavors:
|
||||
if flavor.name == 'm1.small':
|
||||
return flavor
|
||||
|
||||
|
||||
def pick_image(images):
|
||||
for image in images:
|
||||
if image.name.startswith('cirros') and image.name.endswith('-uec'):
|
||||
return image
|
0
shade/tests/unit/__init__.py
Normal file
0
shade/tests/unit/__init__.py
Normal file
Loading…
Reference in New Issue
Block a user