Merge "Add fullstack test for share protectable plugin"
This commit is contained in:
commit
a6ded9bbc7
|
@ -33,14 +33,28 @@ s+=,cinder,g-api,g-reg
|
|||
s+=,c-api,c-vol,c-sch,c-bak,horizon
|
||||
s+=,s-proxy,s-object,s-container,s-account
|
||||
s+=,h-eng,h-api,h-api-cfn,h-api-cw
|
||||
s+=,manila,m-api,m-sch,m-shr,m-dat
|
||||
s+=,karbor,karbor-api,karbor-operationengine,karbor-protection
|
||||
ENABLED_SERVICES=$s
|
||||
export ENABLED_SERVICES
|
||||
|
||||
DEFAULT_EXTRA_SPECS="'snapshot_support=True create_share_from_snapshot_support=True'"
|
||||
|
||||
DEVSTACK_LOCAL_CONFIG+="API_WORKERS=4"
|
||||
DEVSTACK_LOCAL_CONFIG+=$'\n'"VOLUME_BACKING_FILE_SIZE=20490M"
|
||||
DEVSTACK_LOCAL_CONFIG+=$'\n'"enable_plugin karbor git://git.openstack.org/openstack/karbor"
|
||||
DEVSTACK_LOCAL_CONFIG+=$'\n'"enable_plugin heat git://git.openstack.org/openstack/heat"
|
||||
DEVSTACK_LOCAL_CONFIG+=$'\n'"enable_plugin manila git://git.openstack.org/openstack/manila"
|
||||
DEVSTACK_LOCAL_CONFIG+=$'\n'"MANILA_USE_SERVICE_INSTANCE_PASSWORD=True"
|
||||
DEVSTACK_LOCAL_CONFIG+=$'\n'"MANILA_DEFAULT_SHARE_TYPE_EXTRA_SPECS=$DEFAULT_EXTRA_SPECS"
|
||||
DEVSTACK_LOCAL_CONFIG+=$'\n'"Q_PLUGIN=ml2"
|
||||
DEVSTACK_LOCAL_CONFIG+=$'\n'"ENABLE_TENANT_VLANS=True"
|
||||
DEVSTACK_LOCAL_CONFIG+=$'\n'"ML2_VLAN_RANGES=physnet1:100:200"
|
||||
DEVSTACK_LOCAL_CONFIG+=$'\n'"PHYSICAL_NETWORK=physnet1"
|
||||
DEVSTACK_LOCAL_CONFIG+=$'\n'"OVS_PHYSICAL_BRIDGE=br-eth1"
|
||||
DEVSTACK_LOCAL_CONFIG+=$'\n'"Q_ML2_PLUGIN_MECHANISM_DRIVERS=openvswitch"
|
||||
DEVSTACK_LOCAL_CONFIG+=$'\n'"Q_ML2_PLUGIN_TYPE_DRIVERS=flat,vlan,vxlan"
|
||||
|
||||
DEVSTACK_LOCAL_CONFIG+=$'\n'"SWIFT_HASH=66a3d6b56c1f479c8b4e70ab5c2000f5"
|
||||
DEVSTACK_LOCAL_CONFIG+=$'\n'"SWIFT_REPLICAS=1"
|
||||
DEVSTACK_LOCAL_CONFIG+=$'\n'"SWIFT_DATA_DIR=$DEST/data"
|
||||
|
|
|
@ -18,6 +18,7 @@ ENABLED_SERVICES+=,neutron,q-svc,q-agt,q-dhcp,q-meta
|
|||
ENABLED_SERVICES+=,cinder,g-api,g-reg
|
||||
ENABLED_SERVICES+=,c-api,c-vol,c-sch,c-bak,horizon
|
||||
ENABLED_SERVICES+=,heat,h-api,h-api-cfn,h-api-cw,h-eng
|
||||
ENABLED_SERVICES+=,manila,m-api,m-sch,m-shr,m-dat
|
||||
|
||||
#Add the karbor services
|
||||
enable_service karbor-api
|
||||
|
@ -34,3 +35,18 @@ SWIFT_HASH=66a3d6b56c1f479c8b4e70ab5c2000f5
|
|||
SWIFT_REPLICAS=1
|
||||
SWIFT_DATA_DIR=$DEST/data
|
||||
enable_service s-proxy s-object s-container s-account
|
||||
|
||||
# Enable Manila
|
||||
|
||||
enable_plugin manila https://git.openstack.org/openstack/manila master
|
||||
|
||||
MANILA_USE_SERVICE_INSTANCE_PASSWORD=True
|
||||
MANILA_DEFAULT_SHARE_TYPE_EXTRA_SPECS="'snapshot_support=True create_share_from_snapshot_support=True'"
|
||||
|
||||
Q_PLUGIN=ml2
|
||||
ENABLE_TENANT_VLANS=True
|
||||
ML2_VLAN_RANGES=physnet1:100:200
|
||||
PHYSICAL_NETWORK=physnet1
|
||||
OVS_PHYSICAL_BRIDGE=br-eth1
|
||||
Q_ML2_PLUGIN_MECHANISM_DRIVERS=openvswitch
|
||||
Q_ML2_PLUGIN_TYPE_DRIVERS=flat,vlan,vxlan
|
|
@ -13,6 +13,7 @@
|
|||
from cinderclient import client as cinder_client
|
||||
from glanceclient import client as glance_client
|
||||
from karborclient import client as karbor_client
|
||||
from manilaclient import client as manilaclient
|
||||
from neutronclient.v2_0 import client as neutron_client
|
||||
from novaclient import client as nova_client
|
||||
|
||||
|
@ -78,6 +79,12 @@ def _get_cinder_client(api_version='3'):
|
|||
return client
|
||||
|
||||
|
||||
def _get_manila_client(api_version='2'):
|
||||
kwargs = _get_client_args('sharev2')
|
||||
client = manilaclient.Client(api_version, **kwargs)
|
||||
return client
|
||||
|
||||
|
||||
def _get_glance_client(api_version='2'):
|
||||
kwargs = _get_client_args('image')
|
||||
kwargs.pop('endpoint_type')
|
||||
|
@ -137,6 +144,7 @@ class KarborBaseTest(base.BaseTestCase):
|
|||
def setUp(self):
|
||||
super(KarborBaseTest, self).setUp()
|
||||
self.cinder_client = _get_cinder_client()
|
||||
self.manila_client = _get_manila_client()
|
||||
self.glance_client = _get_glance_client()
|
||||
self.nova_client = _get_nova_client()
|
||||
self.neutron_client = _get_neutron_client()
|
||||
|
|
|
@ -233,7 +233,8 @@ class Server(object):
|
|||
if not image:
|
||||
images = self.glance_client.images.list()
|
||||
for image_iter in images:
|
||||
if image_iter['disk_format'] not in ('aki', 'ari'):
|
||||
if image_iter['disk_format'] not in ('aki', 'ari') and (
|
||||
image_iter['name'].startswith('cirros')):
|
||||
image = image_iter['id']
|
||||
break
|
||||
assert image
|
||||
|
@ -340,7 +341,8 @@ class Volume(object):
|
|||
if create_from_image:
|
||||
images = self.glance_client.images.list()
|
||||
for image_iter in images:
|
||||
if image_iter['disk_format'] not in ('aki', 'ari'):
|
||||
if image_iter['disk_format'] not in ('aki', 'ari') and (
|
||||
image_iter['name'].startswith('cirros')):
|
||||
image = image_iter['id']
|
||||
break
|
||||
assert image
|
||||
|
@ -358,3 +360,62 @@ class Volume(object):
|
|||
return
|
||||
utils.wait_until_none(self._volume_status, timeout=timeout,
|
||||
sleep=MEDIUM_SLEEP)
|
||||
|
||||
|
||||
class Share(object):
|
||||
_name_id = 0
|
||||
|
||||
def __init__(self):
|
||||
self.id = None
|
||||
self._name = None
|
||||
self.manila_client = base._get_manila_client()
|
||||
self.neutron_client = base._get_neutron_client()
|
||||
|
||||
def _share_status(self, status=None):
|
||||
try:
|
||||
share = self.manila_client.shares.get(self.id)
|
||||
except Exception:
|
||||
return False
|
||||
|
||||
if status is None or status == share.status:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
def to_dict(self):
|
||||
return {
|
||||
"id": self.id,
|
||||
"type": constants.SHARE_RESOURCE_TYPE,
|
||||
"name": self._name,
|
||||
}
|
||||
|
||||
def create(self, share_proto, size, name=None, timeout=LONG_TIMEOUT):
|
||||
if name is None:
|
||||
name = "KarborFullstack-Share-{id}".format(id=self._name_id)
|
||||
self._name_id += 1
|
||||
|
||||
self._name = name
|
||||
networks = self.neutron_client.list_networks(name="private")
|
||||
assert len(networks['networks']) > 0
|
||||
network_id = networks['networks'][0]['id']
|
||||
|
||||
subnets = self.neutron_client.list_subnets(name="private-subnet")
|
||||
assert len(subnets['subnets']) > 0
|
||||
subnet_id = subnets['subnets'][0]['id']
|
||||
|
||||
share_network = self.manila_client.share_networks.create(
|
||||
neutron_net_id=network_id, neutron_subnet_id=subnet_id)
|
||||
share = self.manila_client.shares.create(share_proto, size, name=name,
|
||||
share_network=share_network)
|
||||
self.id = share.id
|
||||
utils.wait_until_true(partial(self._share_status, 'available'),
|
||||
timeout=timeout, sleep=MEDIUM_SLEEP)
|
||||
return self.id
|
||||
|
||||
def close(self, timeout=MEDIUM_TIMEOUT):
|
||||
try:
|
||||
self.manila_client.shares.delete(self.id)
|
||||
except Exception:
|
||||
return
|
||||
utils.wait_until_none(self._share_status, timeout=timeout,
|
||||
sleep=MEDIUM_SLEEP)
|
||||
|
|
|
@ -76,3 +76,14 @@ class ProtectablesTest(karbor_base.KarborBaseTest):
|
|||
ins_res.dependent_resources[0]["type"])
|
||||
self.assertEqual(volume.id,
|
||||
ins_res.dependent_resources[0]["id"])
|
||||
|
||||
def test_share_protectables_list_instances(self):
|
||||
res_list = self.karbor_client.protectables.list_instances(
|
||||
'OS::Manila::Share')
|
||||
before_num = len(res_list)
|
||||
share = self.store(objects.Share())
|
||||
share.create("NFS", 1)
|
||||
res_list = self.karbor_client.protectables.list_instances(
|
||||
'OS::Manila::Share')
|
||||
after_num = len(res_list)
|
||||
self.assertEqual(1, after_num - before_num)
|
||||
|
|
Loading…
Reference in New Issue