Add local tests to validate share config
This commit is contained in:
@@ -15,7 +15,7 @@ options:
|
||||
provide a later version of OpenStack will trigger a software
|
||||
upgrade.
|
||||
rabbit-user:
|
||||
default: manila-ganesha
|
||||
default: manila
|
||||
type: string
|
||||
description: Username used to access rabbitmq queue
|
||||
rabbit-vhost:
|
||||
@@ -23,7 +23,7 @@ options:
|
||||
type: string
|
||||
description: Rabbitmq vhost
|
||||
database-user:
|
||||
default: manila-ganesha
|
||||
default: manila
|
||||
type: string
|
||||
description: Username for Manila database access
|
||||
database:
|
||||
|
@@ -16,7 +16,7 @@ import collections
|
||||
import json
|
||||
|
||||
# import socket
|
||||
# import subprocess
|
||||
import subprocess
|
||||
|
||||
# import charms.reactive as reactive
|
||||
|
||||
@@ -38,6 +38,7 @@ MANILA_CONF = MANILA_DIR + "manila.conf"
|
||||
MANILA_LOGGING_CONF = MANILA_DIR + "logging.conf"
|
||||
MANILA_API_PASTE_CONF = MANILA_DIR + "api-paste.ini"
|
||||
CEPH_CONF = '/etc/ceph/ceph.conf'
|
||||
|
||||
CEPH_CAPABILITIES = [
|
||||
"mds", "allow *",
|
||||
"osd", "allow rw",
|
||||
@@ -171,10 +172,10 @@ class ManilaGaneshaCharm(charms_openstack.charm.HAOpenStackCharm,
|
||||
@property
|
||||
def restart_map(self):
|
||||
return {
|
||||
MANILA_CONF: ['manila-share'],
|
||||
MANILA_API_PASTE_CONF: ['manila-share'],
|
||||
MANILA_LOGGING_CONF: ['manila-share'],
|
||||
CEPH_CONF: ['manila-share'],
|
||||
MANILA_CONF: ['manila-share', 'nfs-ganesha'],
|
||||
MANILA_API_PASTE_CONF: ['manila-share', 'nfs-ganesha'],
|
||||
MANILA_LOGGING_CONF: ['manila-share', 'nfs-ganesha'],
|
||||
CEPH_CONF: ['manila-share', 'nfs-ganesha'],
|
||||
}
|
||||
|
||||
@property
|
||||
@@ -227,4 +228,4 @@ class ManilaGaneshaCharm(charms_openstack.charm.HAOpenStackCharm,
|
||||
'permissions': CEPH_CAPABILITIES,
|
||||
'client': 'manila-ganesha'})
|
||||
ceph.set_local(key='broker_req', value=rq.request)
|
||||
send_request_if_needed(rq, relation='ceph')
|
||||
send_request_if_needed(rq, relation='ceph')
|
||||
|
0
src/local_tests/__init__.py
Normal file
0
src/local_tests/__init__.py
Normal file
0
src/local_tests/manila/__init__.py
Normal file
0
src/local_tests/manila/__init__.py
Normal file
18
src/local_tests/manila/setup.py
Normal file
18
src/local_tests/manila/setup.py
Normal file
@@ -0,0 +1,18 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# Copyright 2019 Canonical Ltd.
|
||||
#
|
||||
# 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.
|
||||
|
||||
"""Encapdulate manila setup tasks."""
|
||||
|
0
src/local_tests/manila_ganesha/__init__.py
Normal file
0
src/local_tests/manila_ganesha/__init__.py
Normal file
22
src/local_tests/manila_ganesha/setup.py
Normal file
22
src/local_tests/manila_ganesha/setup.py
Normal file
@@ -0,0 +1,22 @@
|
||||
import logging
|
||||
import zaza.openstack.utilities.openstack as openstack_utils
|
||||
|
||||
from manilaclient import client as manilaclient
|
||||
|
||||
def noop():
|
||||
"""Run setup."""
|
||||
logging.info('OK')
|
||||
|
||||
def setup_ganesha_share_type(manila_client=None):
|
||||
if manila_client is None:
|
||||
keystone_session = openstack_utils.get_overcloud_keystone_session()
|
||||
manila_client = manilaclient.Client(
|
||||
session=keystone_session, client_version='2')
|
||||
|
||||
manila_client.share_types.create(
|
||||
name="cephfsnfstype", spec_driver_handles_share_servers=False,
|
||||
extra_specs={
|
||||
'vendor_name': 'Ceph',
|
||||
'storage_protocol': 'NFS',
|
||||
'snapshot_support': False,
|
||||
})
|
126
src/local_tests/manila_ganesha/tests.py
Normal file
126
src/local_tests/manila_ganesha/tests.py
Normal file
@@ -0,0 +1,126 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# Copyright 2019 Canonical Ltd.
|
||||
#
|
||||
# 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.
|
||||
|
||||
"""Encapsulate Manila Ganesha testing."""
|
||||
|
||||
import logging
|
||||
|
||||
from manilaclient import client as manilaclient
|
||||
|
||||
import zaza.model
|
||||
import zaza.openstack.charm_tests.glance.setup as glance_setup
|
||||
import zaza.openstack.charm_tests.neutron.tests as neutron_tests
|
||||
import zaza.openstack.charm_tests.nova.utils as nova_utils
|
||||
import zaza.openstack.charm_tests.test_utils as test_utils
|
||||
import zaza.openstack.configure.guest as guest
|
||||
import zaza.openstack.utilities.openstack as openstack_utils
|
||||
|
||||
|
||||
class ManilaGaneshaTests(test_utils.OpenStackBaseTest):
|
||||
"""Encapsulate Manila Ganesha tests."""
|
||||
RESOURCE_PREFIX = 'zaza-manilatests'
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
"""Run class setup for running tests."""
|
||||
super(ManilaGaneshaTests, cls).setUpClass()
|
||||
cls.nova_client = (
|
||||
openstack_utils.get_nova_session_client(cls.keystone_session))
|
||||
cls.manila_client = manilaclient.Client(
|
||||
session=cls.keystone_session, client_version='2')
|
||||
|
||||
|
||||
def test_manila_share(self):
|
||||
"""Test that Manila + Ganesha shares can be accessed on two instances.
|
||||
|
||||
1. create a share
|
||||
2. Spawn two servers
|
||||
3. mount it on both
|
||||
4. write a file on one
|
||||
5. read it on the other
|
||||
6. profit
|
||||
"""
|
||||
|
||||
# Create Share
|
||||
share = self.manila_client.shares.create(
|
||||
share_type='cephfsnfstype', name='cephnfsshare1',
|
||||
share_proto="nfs", size=1)
|
||||
|
||||
# Spawn Servers
|
||||
guest.launch_instance(
|
||||
glance_setup.LTS_IMAGE_NAME,
|
||||
vm_name='{}-ins-1'.format(self.RESOURCE_PREFIX))
|
||||
guest.launch_instance(
|
||||
glance_setup.LTS_IMAGE_NAME,
|
||||
vm_name='{}-ins-2'.format(self.RESOURCE_PREFIX))
|
||||
|
||||
instance_1 = self.nova_client.servers.find(
|
||||
name='{}-ins-1'.format(self.RESOURCE_PREFIX))
|
||||
fip_1 = neutron_tests.floating_ips_from_instance(instance_1)[0]
|
||||
instance_2 = self.nova_client.servers.find(
|
||||
name='{}-ins-2'.format(self.RESOURCE_PREFIX))
|
||||
fip_2 = neutron_tests.floating_ips_from_instance(instance_2)[0]
|
||||
|
||||
share.allow(access_type='ip', access=fip_1, access_level='rw')
|
||||
share.allow(access_type='ip', access=fip_2, access_level='rw')
|
||||
|
||||
# Mount Share
|
||||
|
||||
username = guest.boot_tests['bionic']['username']
|
||||
password = guest.boot_tests['bionic'].get('password')
|
||||
privkey = openstack_utils.get_private_key(nova_utils.KEYPAIR_NAME)
|
||||
mount_path = share.export_locations[0]
|
||||
|
||||
# Write a file on instance_1
|
||||
|
||||
def verify_setup(stdin, stdout, stderr):
|
||||
status = stdout.channel.recv_exit_status()
|
||||
self.assertEqual(status, 0)
|
||||
|
||||
openstack_utils.ssh_command(
|
||||
username, fip_1, 'instance-1',
|
||||
'sudo apt install -yq nfs-common && '
|
||||
'sudo mkdir -p /mnt/ceph && '
|
||||
'sudo mount -t nfs -o nfsvers=4.1,proto=tcp {} /mnt/ceph && '
|
||||
'echo "test" | sudo tee /mnt/ceph/test'.format(
|
||||
mount_path),
|
||||
password=password, privkey=privkey, verify=verify_setup)
|
||||
|
||||
openstack_utils.ssh_command(
|
||||
username, fip_2, 'instance-2',
|
||||
'sudo apt install -yq nfs-common && '
|
||||
'sudo /bin/mkdir -p /mnt/ceph && '
|
||||
'sudo /bin/mount -t nfs -o nfsvers=4.1,proto=tcp {} /mnt/ceph'
|
||||
.format(mount_path),
|
||||
password=password, privkey=privkey, verify=verify_setup)
|
||||
|
||||
def verify(stdin, stdout, stderr):
|
||||
status = stdout.channel.recv_exit_status()
|
||||
out = ""
|
||||
print("[{}] Stdout:".format(status))
|
||||
for line in iter(stdout.readline, ""):
|
||||
out += line
|
||||
self.assertEqual(out, "test\n")
|
||||
|
||||
# Read that file on instance_2
|
||||
|
||||
openstack_utils.ssh_command(
|
||||
username, fip_2, 'instance-2',
|
||||
'sudo cat /mnt/ceph/test'.format(
|
||||
mount_path),
|
||||
password=password, privkey=privkey, verify=verify)
|
||||
|
||||
|
@@ -1,3 +1,5 @@
|
||||
import subprocess
|
||||
|
||||
import charms.reactive as reactive
|
||||
|
||||
import charms_openstack.bus
|
||||
@@ -74,3 +76,18 @@ def render_things(*args):
|
||||
ch_core.host.service('start', service)
|
||||
reactive.set_flag('config.rendered')
|
||||
charm_instance.assess_status()
|
||||
|
||||
|
||||
@reactive.when_all('config.rendered',
|
||||
'ceph.pools.available')
|
||||
@reactive.when_not('ganesha_pool_configured')
|
||||
def configure_ganesha(*args):
|
||||
cmd = [
|
||||
'rados', '-p', 'manila-ganesha', '--id', 'manila-ganesha',
|
||||
'put', 'ganesha-export-index', '/dev/null'
|
||||
]
|
||||
try:
|
||||
subprocess.check_call(cmd)
|
||||
reactive.set_flag('ganesha_pool_configured')
|
||||
except subprocess.CalledProcessError:
|
||||
log("Failed to setup ganesha index object")
|
@@ -7,5 +7,6 @@ mock>=1.2
|
||||
flake8>=2.2.4,<=2.4.1
|
||||
stestr>=2.2.0
|
||||
requests>=2.18.4
|
||||
python-manilaclient
|
||||
git+https://github.com/openstack-charmers/zaza.git#egg=zaza
|
||||
git+https://github.com/openstack-charmers/zaza-openstack-tests.git#egg=zaza.openstack
|
@@ -9,7 +9,7 @@ services:
|
||||
options:
|
||||
openstack-origin: *source
|
||||
ceph-mon:
|
||||
charm: cs:~openstack-charmers-next/ceph-mon
|
||||
charm: /home/ubuntu/ceph-mon
|
||||
num_units: 3
|
||||
options:
|
||||
source: *source
|
||||
@@ -26,12 +26,49 @@ services:
|
||||
options:
|
||||
source: *source
|
||||
manila:
|
||||
charm: cs:~openstack-charmers-next/manila
|
||||
# charm: cs:~openstack-charmers-next/manila
|
||||
charm: /home/ubuntu/manila/build/builds/manila
|
||||
num_units: 1
|
||||
options:
|
||||
openstack-origin: *source
|
||||
default-share-backend: cephfsnfs1
|
||||
share-protocols: NFS
|
||||
nova-cloud-controller:
|
||||
charm: cs:~openstack-charmers-next/nova-cloud-controller
|
||||
num_units: 1
|
||||
options:
|
||||
network-manager: Neutron
|
||||
openstack-origin: *source
|
||||
nova-compute:
|
||||
charm: cs:~openstack-charmers-next/nova-compute
|
||||
num_units: 2
|
||||
constraints: mem=8G
|
||||
options:
|
||||
config-flags: default_ephemeral_format=ext4
|
||||
enable-live-migration: true
|
||||
enable-resize: true
|
||||
migration-auth-type: ssh
|
||||
openstack-origin: *source
|
||||
glance:
|
||||
charm: cs:~openstack-charmers-next/glance
|
||||
num_units: 1
|
||||
options:
|
||||
openstack-origin: *source
|
||||
neutron-api:
|
||||
charm: cs:~openstack-charmers-next/neutron-api
|
||||
num_units: 1
|
||||
options:
|
||||
flat-network-providers: physnet1
|
||||
neutron-security-groups: true
|
||||
openstack-origin: *source
|
||||
neutron-openvswitch:
|
||||
charm: cs:~openstack-charmers-next/neutron-openvswitch
|
||||
neutron-gateway:
|
||||
charm: cs:~openstack-charmers-next/neutron-gateway
|
||||
num_units: 1
|
||||
options:
|
||||
bridge-mappings: physnet1:br-ex
|
||||
openstack-origin: *source
|
||||
rabbitmq-server:
|
||||
charm: cs:~openstack-charmers-next/rabbitmq-server
|
||||
num_units: 1
|
||||
@@ -71,3 +108,41 @@ relations:
|
||||
- percona-cluster
|
||||
- - manila
|
||||
- percona-cluster
|
||||
- - 'neutron-api:shared-db'
|
||||
- 'percona-cluster:shared-db'
|
||||
- - 'neutron-api:amqp'
|
||||
- 'rabbitmq-server:amqp'
|
||||
- - 'neutron-api:neutron-api'
|
||||
- 'nova-cloud-controller:neutron-api'
|
||||
- - 'neutron-api:neutron-plugin-api'
|
||||
- 'neutron-gateway:neutron-plugin-api'
|
||||
- - 'neutron-api:identity-service'
|
||||
- 'keystone:identity-service'
|
||||
- - 'nova-compute:neutron-plugin'
|
||||
- 'neutron-openvswitch:neutron-plugin'
|
||||
- - 'nova-cloud-controller:shared-db'
|
||||
- 'percona-cluster:shared-db'
|
||||
- - 'neutron-gateway:amqp'
|
||||
- 'rabbitmq-server:amqp'
|
||||
- - 'nova-cloud-controller:amqp'
|
||||
- 'rabbitmq-server:amqp'
|
||||
- - 'nova-compute:amqp'
|
||||
- 'rabbitmq-server:amqp'
|
||||
- - 'neutron-openvswitch:amqp'
|
||||
- 'rabbitmq-server:amqp'
|
||||
- - 'nova-cloud-controller:identity-service'
|
||||
- 'keystone:identity-service'
|
||||
- - 'nova-cloud-controller:cloud-compute'
|
||||
- 'nova-compute:cloud-compute'
|
||||
- - 'glance:identity-service'
|
||||
- 'keystone:identity-service'
|
||||
- - 'glance:shared-db'
|
||||
- 'percona-cluster:shared-db'
|
||||
- - 'glance:amqp'
|
||||
- 'rabbitmq-server:amqp'
|
||||
- - 'nova-compute:image-service'
|
||||
- 'glance:image-service'
|
||||
- - 'nova-cloud-controller:image-service'
|
||||
- 'glance:image-service'
|
||||
- - 'nova-cloud-controller:quantum-network-service'
|
||||
- 'neutron-gateway:quantum-network-service'
|
||||
|
@@ -33,7 +33,42 @@ services:
|
||||
openstack-origin: *source
|
||||
default-share-backend: cephfsnfs1
|
||||
share-protocols: NFS
|
||||
# default-share-type:
|
||||
nova-cloud-controller:
|
||||
charm: cs:~openstack-charmers-next/nova-cloud-controller
|
||||
num_units: 1
|
||||
options:
|
||||
network-manager: Neutron
|
||||
openstack-origin: *source
|
||||
nova-compute:
|
||||
charm: cs:~openstack-charmers-next/nova-compute
|
||||
num_units: 2
|
||||
constraints: mem=8G
|
||||
options:
|
||||
config-flags: default_ephemeral_format=ext4
|
||||
enable-live-migration: true
|
||||
enable-resize: true
|
||||
migration-auth-type: ssh
|
||||
openstack-origin: *source
|
||||
glance:
|
||||
charm: cs:~openstack-charmers-next/glance
|
||||
num_units: 1
|
||||
options:
|
||||
openstack-origin: *source
|
||||
neutron-api:
|
||||
charm: cs:~openstack-charmers-next/neutron-api
|
||||
num_units: 1
|
||||
options:
|
||||
flat-network-providers: physnet1
|
||||
neutron-security-groups: true
|
||||
openstack-origin: *source
|
||||
neutron-openvswitch:
|
||||
charm: cs:~openstack-charmers-next/neutron-openvswitch
|
||||
neutron-gateway:
|
||||
charm: cs:~openstack-charmers-next/neutron-gateway
|
||||
num_units: 1
|
||||
options:
|
||||
bridge-mappings: physnet1:br-ex
|
||||
openstack-origin: *source
|
||||
rabbitmq-server:
|
||||
charm: cs:~openstack-charmers-next/rabbitmq-server
|
||||
num_units: 1
|
||||
@@ -73,3 +108,41 @@ relations:
|
||||
- percona-cluster
|
||||
- - manila
|
||||
- percona-cluster
|
||||
- - 'neutron-api:shared-db'
|
||||
- 'percona-cluster:shared-db'
|
||||
- - 'neutron-api:amqp'
|
||||
- 'rabbitmq-server:amqp'
|
||||
- - 'neutron-api:neutron-api'
|
||||
- 'nova-cloud-controller:neutron-api'
|
||||
- - 'neutron-api:neutron-plugin-api'
|
||||
- 'neutron-gateway:neutron-plugin-api'
|
||||
- - 'neutron-api:identity-service'
|
||||
- 'keystone:identity-service'
|
||||
- - 'nova-compute:neutron-plugin'
|
||||
- 'neutron-openvswitch:neutron-plugin'
|
||||
- - 'nova-cloud-controller:shared-db'
|
||||
- 'percona-cluster:shared-db'
|
||||
- - 'neutron-gateway:amqp'
|
||||
- 'rabbitmq-server:amqp'
|
||||
- - 'nova-cloud-controller:amqp'
|
||||
- 'rabbitmq-server:amqp'
|
||||
- - 'nova-compute:amqp'
|
||||
- 'rabbitmq-server:amqp'
|
||||
- - 'neutron-openvswitch:amqp'
|
||||
- 'rabbitmq-server:amqp'
|
||||
- - 'nova-cloud-controller:identity-service'
|
||||
- 'keystone:identity-service'
|
||||
- - 'nova-cloud-controller:cloud-compute'
|
||||
- 'nova-compute:cloud-compute'
|
||||
- - 'glance:identity-service'
|
||||
- 'keystone:identity-service'
|
||||
- - 'glance:shared-db'
|
||||
- 'percona-cluster:shared-db'
|
||||
- - 'glance:amqp'
|
||||
- 'rabbitmq-server:amqp'
|
||||
- - 'nova-compute:image-service'
|
||||
- 'glance:image-service'
|
||||
- - 'nova-cloud-controller:image-service'
|
||||
- 'glance:image-service'
|
||||
- - 'nova-cloud-controller:quantum-network-service'
|
||||
- 'neutron-gateway:quantum-network-service'
|
||||
|
@@ -1,5 +1,4 @@
|
||||
charm_name: manila-ganesha
|
||||
configure: []
|
||||
dev_bundles:
|
||||
- bionic
|
||||
gate_bundles:
|
||||
@@ -9,4 +8,12 @@ gate_bundles:
|
||||
smoke_bundles:
|
||||
- bionic-stein
|
||||
target_deploy_status: {}
|
||||
tests: []
|
||||
tests:
|
||||
- local_tests.manila_ganesha.tests.ManilaGaneshaTests
|
||||
configure:
|
||||
- zaza.openstack.charm_tests.glance.setup.add_lts_image
|
||||
- zaza.openstack.charm_tests.neutron.setup.basic_overcloud_network
|
||||
- zaza.openstack.charm_tests.nova.setup.create_flavors
|
||||
- zaza.openstack.charm_tests.nova.setup.manage_ssh_key
|
||||
- zaza.openstack.charm_tests.keystone.setup.add_demo_user
|
||||
- local_tests.manila_ganesha.setup.setup_ganesha_share_type
|
||||
|
@@ -14,7 +14,7 @@ install_command =
|
||||
pip install {opts} {packages}
|
||||
commands = stestr run {posargs}
|
||||
whitelist_externals = juju
|
||||
passenv = HOME TERM AMULET_* CS_API_*
|
||||
passenv = HOME TERM AMULET_* CS_API_* OS_*
|
||||
deps = -r{toxinidir}/test-requirements.txt
|
||||
|
||||
[testenv:py27]
|
||||
|
@@ -7,9 +7,6 @@ mock>=1.2
|
||||
nose>=1.3.7
|
||||
coverage>=3.6
|
||||
git+https://github.com/openstack/charms.openstack.git#egg=charms-openstack
|
||||
netifaces # vault
|
||||
hvac<0.7.0 # vault
|
||||
psycopg2-binary # vault
|
||||
tenacity # vault
|
||||
pbr # vault
|
||||
cryptography # vault
|
||||
|
||||
# TODO: Migrate to zaza-openstack-charms
|
||||
python-manilaclient
|
||||
|
Reference in New Issue
Block a user