Add functional tests for masakari

This patch adds minimal functional tests to check the
behavior of supported APIs for Segment and Host by masakari.
Also added new CI job to run these newly added functional
test cases.

Note: Functional test cases related to ``POST/GET /notifications``
APIs will be added in Masakari.

Change-Id: I55fed23a1ceb259e9a13f3ed9e4b6d462330bcb4
This commit is contained in:
Pooja Jadhav 2018-08-11 18:49:54 +05:30 committed by shilpa.devharakar
parent 16fbe99df0
commit 7b14c1e6fd
4 changed files with 137 additions and 0 deletions

View File

@ -345,6 +345,25 @@
test_matrix_branch: master
tox_install_siblings: true
- job:
name: openstacksdk-functional-devstack-masakari
parent: openstacksdk-functional-devstack-minimum
description: |
Run openstacksdk functional tests against a master devstack with masakari
required-projects:
- openstack/masakari
vars:
devstack_plugins:
masakari: https://git.openstack.org/openstack/masakari
devstack_services:
masakari-api: true
masakari-engine: true
tox_environment:
OPENSTACKSDK_HAS_MASAKARI: 1
OPENSTACKSDK_TESTS_SUBDIR: instance_ha
zuul_copy_output:
'{{ devstack_base_dir }}/masakari-logs': logs
- project-template:
name: openstacksdk-functional-tips
check:
@ -379,6 +398,8 @@
- openstacksdk-functional-devstack-senlin
- openstacksdk-functional-devstack-magnum:
voting: false
- openstacksdk-functional-devstack-masakari:
voting: false
- openstacksdk-functional-devstack-ironic:
voting: false
- openstacksdk-functional-devstack-python2

View File

@ -0,0 +1,73 @@
# Copyright (C) 2018 NTT DATA
# All Rights Reserved.
#
# 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 unittest
from openstack import connection
from openstack.cloud.openstackcloud import _OpenStackCloudMixin
from openstack.tests.functional import base
HYPERVISORS = []
def hypervisors():
global HYPERVISORS
if HYPERVISORS:
return True
HYPERVISORS = _OpenStackCloudMixin.list_hypervisors(
connection.from_config(cloud_name=base.TEST_CLOUD_NAME))
return bool(HYPERVISORS)
class TestHost(base.BaseFunctionalTest):
def setUp(self):
super(TestHost, self).setUp()
self.require_service('instance-ha')
self.NAME = self.getUniqueString()
if not hypervisors():
self.skipTest("Skip TestHost as there are no hypervisors "
"configured in nova")
# Create segment
self.segment = self.conn.ha.create_segment(
name=self.NAME, recovery_method='auto',
service_type='COMPUTE')
# Create valid host
self.NAME = HYPERVISORS[0]['hypervisor_hostname']
self.host = self.conn.ha.create_host(
segment_id=self.segment.uuid, name=self.NAME, type='COMPUTE',
control_attributes='SSH')
# Delete host
self.addCleanup(self.conn.ha.delete_host, self.segment.uuid,
self.host.uuid)
# Delete segment
self.addCleanup(self.conn.ha.delete_segment, self.segment.uuid)
def test_list(self):
names = [o.name for o in self.conn.ha.hosts(
self.segment.uuid, failover_segment_id=self.segment.uuid,
type='COMPUTE')]
self.assertIn(self.NAME, names)
def test_update(self):
updated_host = self.conn.ha.update_host(self.host['uuid'],
segment_id=self.segment.uuid,
on_maintenance='True')
get_host = self.conn.ha.get_host(updated_host.uuid,
updated_host.segment_id)
self.assertEqual(True, get_host.on_maintenance)

View File

@ -0,0 +1,43 @@
# Copyright (C) 2018 NTT DATA
# All Rights Reserved.
#
# 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 openstack.tests.functional import base
class TestSegment(base.BaseFunctionalTest):
def setUp(self):
super(TestSegment, self).setUp()
self.require_service('instance-ha')
self.NAME = self.getUniqueString()
# Create segment
self.segment = self.conn.ha.create_segment(
name=self.NAME, recovery_method='auto',
service_type='COMPUTE')
# Delete segment
self.addCleanup(self.conn.ha.delete_segment, self.segment['uuid'])
def test_list(self):
names = [o.name for o in self.conn.ha.segments(
recovery_method='auto')]
self.assertIn(self.NAME, names)
def test_update(self):
updated_segment = self.conn.ha.update_segment(self.segment['uuid'],
name='UPDATED-NAME')
get_updated_segment = self.conn.ha.get_segment(updated_segment.uuid)
self.assertEqual('UPDATED-NAME', get_updated_segment.name)