Add Freezer API Version Test

Add a simple Tempest test to see if tests will hit the freezer api.

Change-Id: I794599752e1fea3eb884e238805565cced368ff5
This commit is contained in:
Deklan Dieterly 2016-03-09 12:51:54 -07:00
parent 541baee572
commit 13f0b7b2d1
11 changed files with 152 additions and 9 deletions

View File

@ -44,7 +44,7 @@ symbols=no
# --enable=similarities". If you want to run only the classes checker, but have
# no Warning level messages displayed, use"--disable=all --enable=classes
# --disable=W"
disable=W,C,R
disable=W,C,R,E1002
[REPORTS]

View File

@ -18,4 +18,5 @@ set -ex
# Install freezer devstack integration
export DEVSTACK_LOCAL_CONFIG="enable_plugin freezer-api https://git.openstack.org/openstack/freezer-api"
# Invoke default behavior.
$BASE/new/devstack-gate/devstack-vm-gate.sh

View File

@ -1,6 +1,6 @@
===============================================
Tempest Integration of Sample
Tempest Integration of Freezer API
===============================================
This directory contains Tempest tests to cover the Sample project.
This directory contains Tempest tests to cover the freezer-api project.

View File

@ -0,0 +1,25 @@
# (C) Copyright 2016 Hewlett Packard Enterprise Development Company LP
#
# 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.
from tempest import clients
from freezer_api.tests.freezer_api_tempest_plugin.services import \
freezer_api_client
class Manager(clients.Manager):
def __init__(self, credentials=None, service=None):
super(Manager, self).__init__(credentials, service)
self.freezer_api_client = freezer_api_client.FreezerApiClient(
self.auth_provider)

View File

@ -23,4 +23,24 @@ ServiceAvailableGroup = [
cfg.BoolOpt("freezer-api",
default=True,
help="Whether or not Freezer API is expected to be available"),
]
freezer_api_group = cfg.OptGroup(name="backup",
title="Freezer API Service Options")
FreezerApiGroup = [
cfg.StrOpt("region",
default="",
help="The freezer api region name to use. If empty, the value "
"of identity.region is used instead. If no such region "
"is found in the service catalog, the first found one is "
"used."),
cfg.StrOpt("catalog_type",
default="backup",
help="Catalog type of the freezer-api service."),
cfg.StrOpt('endpoint_type',
default='publicURL',
choices=['public', 'admin', 'internal',
'publicURL', 'adminURL', 'internalURL'],
help="The endpoint type to use for the freezer-api service.")
]

View File

@ -33,6 +33,9 @@ class FreezerApiTempestPlugin(plugins.TempestPlugin):
config.register_opt_group(
conf, freezer_api_config.service_available_group,
freezer_api_config.ServiceAvailableGroup)
config.register_opt_group(conf, freezer_api_config.freezer_api_group,
freezer_api_config.FreezerApiGroup)
def get_opt_lists(self):
pass
return [(freezer_api_config.frezer_api_group.name,
freezer_api_config.FreezerApiGroup)]

View File

@ -0,0 +1,34 @@
# (C) Copyright 2016 Hewlett Packard Enterprise Development Company LP
#
# 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.
from oslo_serialization import jsonutils as json
from tempest import config
from tempest_lib.common import rest_client
CONF = config.CONF
class FreezerApiClient(rest_client.RestClient):
def __init__(self, auth_provider):
super(FreezerApiClient, self).__init__(
auth_provider,
CONF.backup.catalog_type,
CONF.backup.region or CONF.identity.region,
endpoint_type=CONF.backup.endpoint_type
)
def get_version(self):
resp, response_body = self.get('/')
return resp, response_body

View File

@ -11,8 +11,35 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from tempest import config
from tempest.common import credentials_factory
import tempest.test
from freezer_api.tests.freezer_api_tempest_plugin import clients
CONF = config.CONF
class BaseFreezerApiTest(tempest.test.BaseTestCase):
pass
"""Base test case class for all Freezer API tests."""
@classmethod
def skip_checks(cls):
super(BaseFreezerApiTest, cls).skip_checks()
@classmethod
def resource_setup(cls):
super(BaseFreezerApiTest, cls).resource_setup()
auth_version = CONF.identity.auth_version
cls.cred_provider = credentials_factory.get_credentials_provider(
cls.__name__,
force_tenant_isolation=True,
identity_version=auth_version)
credentials = cls.cred_provider.get_creds_by_roles(
['admin', 'service'])
cls.os = clients.Manager(credentials=credentials)
cls.freezer_api_client = cls.os.freezer_api_client
@classmethod
def resource_cleanup(cls):
super(BaseFreezerApiTest, cls).resource_cleanup()

View File

@ -17,7 +17,16 @@ from tempest import test
class TestFreezerApiVersion(base.BaseFreezerApiTest):
@classmethod
def resource_setup(cls):
super(TestFreezerApiVersion, cls).resource_setup()
@classmethod
def resource_cleanup(cls):
super(TestFreezerApiVersion, cls).resource_cleanup()
@test.attr(type="gate")
def test_api_version(self):
# See if tempest plugin tests run.
self.assertEqual(1, 1, 'First test case')
resp, response_body = self.freezer_api_client.get_version()
self.assertEqual(300, resp.status)

View File

@ -13,12 +13,15 @@
# License for the specific language governing permissions and limitations
# under the License.
# Called by gate-freezer-api-devstack-dsvm job.
# This script is executed inside post_test_hook function in devstack gate.
echo 'Running freezer-api post_test_hook'
# Install packages from test-requirements.txt
sudo pip install -r /opt/stack/new/freezer-api/test-requirements.txt
cd /opt/stack/new/freezer-api/freezer_api/tests
echo 'Running freezer-api integration tests'
# Here it goes the command to execute integration tests
#sudo ./run_tests.sh

View File

@ -0,0 +1,21 @@
#!/bin/bash -xe
# (C) Copyright 2016 Hewlett Packard Enterprise Development Company LP
#
# 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.
# Called by gate-freezer-api-devstack-dsvm job.
echo 'Running freezer-api pre_test_hook'
# Nothing to do. Can be used when needed.