General fixes and tests
This commit is contained in:
parent
03e1952419
commit
00ee31a214
1
.gitignore
vendored
1
.gitignore
vendored
@ -1 +1,2 @@
|
|||||||
lib
|
lib
|
||||||
|
.tox
|
||||||
|
14
src/charm.py
14
src/charm.py
@ -11,6 +11,10 @@ from ops.framework import (
|
|||||||
StoredState,
|
StoredState,
|
||||||
)
|
)
|
||||||
from ops.main import main
|
from ops.main import main
|
||||||
|
from ops.model import (
|
||||||
|
ActiveStatus,
|
||||||
|
WaitingStatus,
|
||||||
|
)
|
||||||
from charmhelpers.fetch import (
|
from charmhelpers.fetch import (
|
||||||
apt_install,
|
apt_install,
|
||||||
apt_update,
|
apt_update,
|
||||||
@ -31,7 +35,9 @@ class CephISCSIGatewayCharm(CharmBase):
|
|||||||
|
|
||||||
def __init__(self, framework, key):
|
def __init__(self, framework, key):
|
||||||
super().__init__(framework, key)
|
super().__init__(framework, key)
|
||||||
|
self.state.set_default(is_started=False)
|
||||||
self.framework.observe(self.on.install, self)
|
self.framework.observe(self.on.install, self)
|
||||||
|
self.framework.observe(self.on.update_status, self)
|
||||||
self.framework.observe(self.on.ceph_client_relation_joined, self)
|
self.framework.observe(self.on.ceph_client_relation_joined, self)
|
||||||
self.ceph_client = interface_ceph_client.CephClientRequires(
|
self.ceph_client = interface_ceph_client.CephClientRequires(
|
||||||
self,
|
self,
|
||||||
@ -42,6 +48,12 @@ class CephISCSIGatewayCharm(CharmBase):
|
|||||||
apt_update(fatal=True)
|
apt_update(fatal=True)
|
||||||
apt_install(self.PACKAGES, fatal=True)
|
apt_install(self.PACKAGES, fatal=True)
|
||||||
|
|
||||||
|
def on_update_status(self, event):
|
||||||
|
if self.state.is_started:
|
||||||
|
self.model.unit.status = ActiveStatus('Unit is ready')
|
||||||
|
else:
|
||||||
|
self.model.unit.status = WaitingStatus('not ready for reasons')
|
||||||
|
|
||||||
def on_ceph_client_relation_joined(self, event):
|
def on_ceph_client_relation_joined(self, event):
|
||||||
self.ceph_client.create_replicated_pool('rbd')
|
self.ceph_client.create_replicated_pool('rbd')
|
||||||
self.ceph_client.request_ceph_permissions(
|
self.ceph_client.request_ceph_permissions(
|
||||||
@ -77,6 +89,8 @@ class CephISCSIGatewayCharm(CharmBase):
|
|||||||
config_file,
|
config_file,
|
||||||
ceph_context)
|
ceph_context)
|
||||||
render_configs()
|
render_configs()
|
||||||
|
self.state.is_started = True
|
||||||
|
self.model.unit.status = ActiveStatus('Unit is ready')
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
# This file is managed centrally. If you find the need to modify this as a
|
# This file is managed centrally. If you find the need to modify this as a
|
||||||
# one-off, please don't. Intead, consult #openstack-charms and ask about
|
# one-off, please don't. Intead, consult #openstack-charms and ask about
|
||||||
# requirements management in charms via bot-control. Thank you.
|
# requirements management in charms via bot-control. Thank you.
|
||||||
#
|
charm-tools>=2.4.4
|
||||||
# Lint and unit test requirements
|
coverage>=3.6
|
||||||
|
mock>=1.2
|
||||||
flake8>=2.2.4,<=2.4.1
|
flake8>=2.2.4,<=2.4.1
|
||||||
stestr>=2.2.0
|
stestr>=2.2.0
|
||||||
requests>=2.18.4
|
requests>=2.18.4
|
||||||
charms.reactive
|
git+https://github.com/gnuoy/zaza.git@force-focal#egg=zaza
|
||||||
mock>=1.2
|
git+https://github.com/gnuoy/zaza-openstack-tests.git@ceph-iscsi-tests#egg=zaza.openstack
|
||||||
nose>=1.3.7
|
pytz # workaround for 14.04 pip/tox
|
||||||
coverage>=3.6
|
pyudev # for ceph-* charm unit tests (not mocked?)
|
||||||
git+https://github.com/openstack/charms.openstack.git#egg=charms.openstack
|
|
||||||
|
@ -1,7 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
client="ubuntu/0"
|
|
||||||
|
|
||||||
juju run --unit $client "apt install --yes open-iscsi multipath-tools"
|
|
||||||
juju run --unit $client "systemctl start iscsi"
|
|
||||||
juju run --unit $client "systemctl start iscsid"
|
|
@ -1,26 +0,0 @@
|
|||||||
#!/bin/bash -x
|
|
||||||
|
|
||||||
gw1="ceph-iscsi/0"
|
|
||||||
gw2="ceph-iscsi/1"
|
|
||||||
|
|
||||||
gw1_hostname=$(juju run --unit $gw1 "hostname -f")
|
|
||||||
gw2_hostname=$(juju run --unit $gw2 "hostname -f")
|
|
||||||
gw1_ip=$(juju status $gw1 --format=oneline | awk '{print $3}' | tr -d \\n )
|
|
||||||
gw2_ip=$(juju status $gw2 --format=oneline | awk '{print $3}' | tr -d \\n )
|
|
||||||
client_initiatorname=$(juju run --unit ubuntu/0 "grep -E '^InitiatorName' /etc/iscsi/initiatorname.iscsi")
|
|
||||||
client_initiatorname=$(echo $client_initiatorname | awk 'BEGIN {FS="="} {print $2}')
|
|
||||||
echo "!$gw1_hostname!"
|
|
||||||
echo "!$gw2_hostname!"
|
|
||||||
echo "!$gw1_ip!"
|
|
||||||
echo "!$gw2_ip!"
|
|
||||||
echo "!$client_initiatorname!"
|
|
||||||
|
|
||||||
gw_iqn="iqn.2003-01.com.canonical.iscsi-gw:iscsi-igw"
|
|
||||||
|
|
||||||
juju run --unit $gw1 "gwcli /iscsi-targets/ create $gw_iqn"
|
|
||||||
juju run --unit $gw1 "gwcli /iscsi-targets/${gw_iqn}/gateways create $gw1_hostname $gw1_ip skipchecks=true"
|
|
||||||
juju run --unit $gw1 "gwcli /iscsi-targets/${gw_iqn}/gateways create $gw2_hostname $gw2_ip skipchecks=true"
|
|
||||||
juju run --unit $gw1 "gwcli /disks create pool=rbd image=disk_1 size=1G"
|
|
||||||
juju run --unit $gw1 "gwcli /iscsi-targets/${gw_iqn}/hosts create ${client_initiatorname}"
|
|
||||||
juju run --unit $gw1 "gwcli /iscsi-targets/${gw_iqn}/hosts/${client_initiatorname} auth username=myiscsiusername password=myiscsipassword"
|
|
||||||
juju run --unit $gw1 "gwcli /iscsi-targets/${gw_iqn}/hosts/${client_initiatorname} disk add rbd/disk_1"
|
|
@ -1,18 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
client="ubuntu/0"
|
|
||||||
|
|
||||||
gw1="ceph-iscsi/0"
|
|
||||||
|
|
||||||
gw1_ip=$(juju status $gw1 --format=oneline | awk '{print $3}' | tr -d \\n )
|
|
||||||
|
|
||||||
juju run --unit $client "iscsiadm -m discovery -t st -p $gw1_ip"
|
|
||||||
|
|
||||||
target_name="iqn.2003-01.com.canonical.iscsi-gw:iscsi-igw"
|
|
||||||
|
|
||||||
juju run --unit $client "iscsiadm --mode node --targetname ${target_name} --op=update --name node.session.auth.authmethod --value=CHAP"
|
|
||||||
juju run --unit $client "iscsiadm --mode node --targetname ${target_name} --op=update --name node.session.auth.username --value=myiscsiusername"
|
|
||||||
juju run --unit $client "iscsiadm --mode node --targetname ${target_name} --op=update --name node.session.auth.password --value=myiscsipassword"
|
|
||||||
juju run --unit $client "iscsiadm --mode node --targetname ${target_name} --login"
|
|
||||||
sleep 5
|
|
||||||
juju ssh ubuntu/0 "ls -l /dev/dm-0"
|
|
@ -4,7 +4,7 @@ applications:
|
|||||||
charm: cs:ubuntu
|
charm: cs:ubuntu
|
||||||
num_units: 1
|
num_units: 1
|
||||||
ceph-iscsi:
|
ceph-iscsi:
|
||||||
charm: ../
|
charm: ../../
|
||||||
series: focal
|
series: focal
|
||||||
num_units: 2
|
num_units: 2
|
||||||
ceph-osd:
|
ceph-osd:
|
@ -1 +0,0 @@
|
|||||||
juju deploy --force ./focal.yaml
|
|
9
tests/tests.yaml
Normal file
9
tests/tests.yaml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
charm_name: ceph-iscsi
|
||||||
|
gate_bundles:
|
||||||
|
- focal
|
||||||
|
smoke_bundles:
|
||||||
|
- focal
|
||||||
|
configure:
|
||||||
|
- zaza.openstack.charm_tests.ceph.iscsi.setup.basic_guest_setup
|
||||||
|
tests:
|
||||||
|
- zaza.openstack.charm_tests.ceph.iscsi.tests.CephISCSIGatewayTest
|
13
todo.txt
Normal file
13
todo.txt
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
Confirm zaza tests are working
|
||||||
|
Remove hardcoded ceph pool name and expose as a config option
|
||||||
|
Write spec
|
||||||
|
Fix workload status so it reports missing relations
|
||||||
|
Implement pause/resume
|
||||||
|
Add iscsi target create action
|
||||||
|
Add series upgrade
|
||||||
|
Write README
|
||||||
|
Move to openstack-charmers
|
||||||
|
Refactor ceph broker code in charm helpers
|
||||||
|
Rewrite ceph-client interface to stop using any relation* commands via charmhelpers
|
||||||
|
implement source config option
|
||||||
|
Proper Update Status
|
90
tox.ini
90
tox.ini
@ -1,12 +1,12 @@
|
|||||||
# Source charm: ./tox.ini
|
# Source charm (with zaza): ./src/tox.ini
|
||||||
# This file is managed centrally by release-tools and should not be modified
|
# This file is managed centrally by release-tools and should not be modified
|
||||||
# within individual charm repos. See the 'global' dir contents for available
|
# within individual charm repos. See the 'global' dir contents for available
|
||||||
# choices of tox.ini for OpenStack Charms:
|
# choices of tox.ini for OpenStack Charms:
|
||||||
# https://github.com/openstack-charmers/release-tools
|
# https://github.com/openstack-charmers/release-tools
|
||||||
|
|
||||||
[tox]
|
[tox]
|
||||||
|
envlist = pep8
|
||||||
skipsdist = True
|
skipsdist = True
|
||||||
envlist = pep8,py3
|
|
||||||
# NOTE: Avoid build/test env pollution by not enabling sitepackages.
|
# NOTE: Avoid build/test env pollution by not enabling sitepackages.
|
||||||
sitepackages = False
|
sitepackages = False
|
||||||
# NOTE: Avoid false positives by not skipping missing interpreters.
|
# NOTE: Avoid false positives by not skipping missing interpreters.
|
||||||
@ -15,78 +15,36 @@ skip_missing_interpreters = False
|
|||||||
[testenv]
|
[testenv]
|
||||||
setenv = VIRTUAL_ENV={envdir}
|
setenv = VIRTUAL_ENV={envdir}
|
||||||
PYTHONHASHSEED=0
|
PYTHONHASHSEED=0
|
||||||
TERM=linux
|
whitelist_externals = juju
|
||||||
LAYER_PATH={toxinidir}/layers
|
passenv = HOME TERM CS_* OS_* TEST_*
|
||||||
INTERFACE_PATH={toxinidir}/interfaces
|
deps = -r{toxinidir}/test-requirements.txt
|
||||||
JUJU_REPOSITORY={toxinidir}/build
|
|
||||||
passenv = http_proxy https_proxy INTERFACE_PATH LAYER_PATH JUJU_REPOSITORY
|
|
||||||
install_command =
|
install_command =
|
||||||
pip install {opts} {packages}
|
pip install {opts} {packages}
|
||||||
deps =
|
|
||||||
-r{toxinidir}/requirements.txt
|
|
||||||
|
|
||||||
[testenv:build]
|
|
||||||
basepython = python3
|
|
||||||
commands =
|
|
||||||
charm-build --log-level DEBUG -o {toxinidir}/build src {posargs}
|
|
||||||
|
|
||||||
[testenv:py3]
|
|
||||||
basepython = python3
|
|
||||||
deps = -r{toxinidir}/test-requirements.txt
|
|
||||||
commands = stestr run --slowest {posargs}
|
|
||||||
|
|
||||||
[testenv:py35]
|
|
||||||
basepython = python3.5
|
|
||||||
deps = -r{toxinidir}/test-requirements.txt
|
|
||||||
commands = stestr run --slowest {posargs}
|
|
||||||
|
|
||||||
[testenv:py36]
|
|
||||||
basepython = python3.6
|
|
||||||
deps = -r{toxinidir}/test-requirements.txt
|
|
||||||
commands = stestr run --slowest {posargs}
|
|
||||||
|
|
||||||
[testenv:py37]
|
|
||||||
basepython = python3.7
|
|
||||||
deps = -r{toxinidir}/test-requirements.txt
|
|
||||||
commands = stestr run --slowest {posargs}
|
|
||||||
|
|
||||||
[testenv:pep8]
|
[testenv:pep8]
|
||||||
basepython = python3
|
basepython = python3
|
||||||
deps = -r{toxinidir}/test-requirements.txt
|
deps=charm-tools
|
||||||
commands = flake8 {posargs} src unit_tests
|
commands = charm-proof
|
||||||
|
|
||||||
[testenv:cover]
|
[testenv:func-noop]
|
||||||
# Technique based heavily upon
|
|
||||||
# https://github.com/openstack/nova/blob/master/tox.ini
|
|
||||||
basepython = python3
|
basepython = python3
|
||||||
deps = -r{toxinidir}/requirements.txt
|
|
||||||
-r{toxinidir}/test-requirements.txt
|
|
||||||
setenv =
|
|
||||||
{[testenv]setenv}
|
|
||||||
PYTHON=coverage run
|
|
||||||
commands =
|
commands =
|
||||||
coverage erase
|
functest-run-suite --help
|
||||||
stestr run --slowest {posargs}
|
|
||||||
coverage combine
|
|
||||||
coverage html -d cover
|
|
||||||
coverage xml -o cover/coverage.xml
|
|
||||||
coverage report
|
|
||||||
|
|
||||||
[coverage:run]
|
[testenv:func]
|
||||||
branch = True
|
basepython = python3
|
||||||
concurrency = multiprocessing
|
commands =
|
||||||
parallel = True
|
functest-run-suite --keep-model
|
||||||
source =
|
|
||||||
.
|
[testenv:func-smoke]
|
||||||
omit =
|
basepython = python3
|
||||||
.tox/*
|
commands =
|
||||||
*/charmhelpers/*
|
functest-run-suite --keep-model --smoke
|
||||||
unit_tests/*
|
|
||||||
|
[testenv:func-target]
|
||||||
|
basepython = python3
|
||||||
|
commands =
|
||||||
|
functest-run-suite --keep-model --bundle {posargs}
|
||||||
|
|
||||||
[testenv:venv]
|
[testenv:venv]
|
||||||
basepython = python3
|
commands = {posargs}
|
||||||
commands = {posargs}
|
|
||||||
|
|
||||||
[flake8]
|
|
||||||
# E402 ignore necessary for path append before sys module import in actions
|
|
||||||
ignore = E402,W504
|
|
Loading…
x
Reference in New Issue
Block a user