Adds /os-hosts api tests using gabbi

This patch adds /os-host api tests using gabbi. Tests for /leases
api will be added in a following patch.

Depends-On: https://review.openstack.org/581939
Depends-On: https://review.openstack.org/580538
Change-Id: Ic8dc7b1942f312d6dcbe5f2ad6a73289eaf7c838
This commit is contained in:
Tetsuro Nakamura 2018-07-05 16:29:43 +09:00
parent ebb9d53061
commit 8ece6590c9
6 changed files with 113 additions and 0 deletions

View File

@ -0,0 +1,30 @@
#
# 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.
import os
from gabbi import fixture
from tempest import clients as tempestclients
from tempest import test
class AuthenticationFixture(fixture.GabbiFixture, test.BaseTestCase):
def start_fixture(self):
cred_provider = self._get_credentials_provider()
creds = cred_provider.get_credentials('admin')
auth_prov = tempestclients.get_auth_provider(creds._credentials)
os.environ['OS_TOKEN'] = auth_prov.get_token()
def stop_fixture(self):
pass

View File

@ -0,0 +1,33 @@
fixtures:
- AuthenticationFixture
defaults:
request_headers:
accept: application/json
content-type: application/json
X-Auth-Token: $ENVIRON['OS_TOKEN']
tests:
- name: get host name
GET: compute/v2.1/os-hypervisors
status: 200
- name: post new host
POST: reservation/v1/os-hosts
data:
name: $HISTORY['get host name'].$RESPONSE['$.hypervisors[0].hypervisor_hostname']
status: 201
- name: get new host
GET: reservation/v1/os-hosts
response_json_paths:
$.hosts.`len`: 1
- name: delete new host
DELETE: reservation/v1/os-hosts/$HISTORY['get new host'].$RESPONSE['$.hosts[0].id']
status: 204
- name: get no host
GET: reservation/v1/os-hosts
response_json_paths:
$.hosts.`len`: 0

View File

@ -0,0 +1,30 @@
#
# 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.
"""A test module to exercise the Blazar API with gabbi."""
import os
from blazar_tempest_plugin.tests.api import fixtures
from gabbi import driver
TESTS_DIR = 'gabbits'
def load_tests(loader, tests, pattern):
"""Provide a TestSuite to the discovery process."""
test_dir = os.path.join(os.path.dirname(__file__), TESTS_DIR)
return driver.build_tests(test_dir, loader,
test_loader_name=__name__,
fixture_module=fixtures,
url='http://127.0.0.1/')

19
doc/source/usage.rst Normal file
View File

@ -0,0 +1,19 @@
=====
Usage
=====
The api tests are defined in .yaml files and should be executed
in the order in the file. To do this, set ``group_regex`` parameter
in ``.stestr.conf``::
group_regex=blazar_tempest_plugin\.tests\.api\.test_blazar_api
or, you can also save the test order by setting the number of test
workers to one via tempest run options::
$ tempest run --regex blazar_tempest_plugin --serial
or::
$ tempest run --regex blazar_tempest_plugin --concurrency=1

View File

@ -8,3 +8,4 @@ oslo.config>=5.2.0 # Apache-2.0
oslo.log>=3.36.0 # Apache-2.0
oslo.serialization!=2.19.1,>=2.18.0 # Apache-2.0
tempest>=17.1.0 # Apache-2.0
gabbi>=1.42.1 # Apache-2.0