Gate functional job: assert volumes are correctly cleaned up

After OSPurge has ran on one project, this patch asserts that volumes
and volume backups in other projects have not been deleted.

Also, we must separate the case when cinder-backup is running and when
it is not. We know (for now) that c-bak is enabled in Gate runs.

Change-Id: I0064e43c7b8476943370aa365b6c0d3160d157b0
This commit is contained in:
Jordan Pittier 2017-02-28 18:10:02 +01:00
parent bddfe4f8cf
commit 7bf67dd293
2 changed files with 35 additions and 13 deletions

View File

@ -140,24 +140,25 @@ class TestOrderedMeta(unittest.TestCase):
class TestServiceResource(unittest.TestCase):
def test_init_without_order_attr(self):
class Foo(base.ServiceResource):
class Foo5(base.ServiceResource):
def list(self) -> Iterable:
pass
def delete(self, resource: Dict[str, Any]) -> None:
pass
@staticmethod
def to_str(resource: Dict[str, Any]) -> str:
pass
self.assertRaisesRegex(ValueError, 'Class .*ORDER.*',
Foo, mock.Mock())
Foo5, mock.Mock())
def test_instantiate_without_concrete_methods(self):
class Foo(base.ServiceResource):
class Foo6(base.ServiceResource):
ORDER = 1
self.assertRaises(TypeError, Foo)
self.assertRaises(TypeError, Foo6)
@mock.patch.multiple(base.ServiceResource, ORDER=12,
__abstractmethods__=set())

View File

@ -19,10 +19,16 @@ readonly PROGDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# Try to detect whether we run in the OpenStack Gate.
if [[ -d ~stack/devstack ]]; then
export DEVSTACK_DIR=~stack/devstack
GATE_RUN=1
else
export DEVSTACK_DIR=~/devstack
GATE_RUN=0
fi
#projectname_username
invisible_to_admin_demo_pass=$(cat $DEVSTACK_DIR/accrc/invisible_to_admin/demo | sed -nr 's/.*OS_PASSWORD="(.*)"/\1/p')
admin_admin_pass=$(cat $DEVSTACK_DIR/accrc/admin/admin | sed -nr 's/.*OS_PASSWORD="(.*)"/\1/p')
function assert_compute {
if [[ $(nova list | wc -l) -lt 5 ]]; then
echo "Less than one VM, someone cleaned our VM :("
@ -52,10 +58,17 @@ function assert_network {
}
function assert_volume {
exit 0
if [[ $(openstack volume backup list | wc -l) -lt 5 ]]; then
echo "Less than one volume backup, someone cleaned our backup:("
exit 1
if [[ ${GATE_RUN} == 1 ]]; then
# The Cinder backup service is enabled in the Gate.
if [[ $(openstack volume backup list | wc -l) -lt 5 ]]; then
echo "Less than one backup, someone cleaned our backup:("
exit 1
fi
else
if [[ $(openstack volume list | wc -l) -lt 5 ]]; then
echo "Less than one volume, someone cleaned our volume:("
exit 1
fi
fi
}
@ -112,14 +125,14 @@ tox -e run -- --os-cloud devstack --purge-own-project --verbose # purges demo/de
source $DEVSTACK_DIR/openrc demo invisible_to_admin
assert_compute && assert_network && assert_volume
tox -e run -- --os-auth-url http://localhost/identity_admin --os-username demo --os-project-name invisible_to_admin --os-password testtest --purge-own-project --verbose
tox -e run -- --os-auth-url http://localhost/identity_admin --os-username demo --os-project-name invisible_to_admin --os-password $invisible_to_admin_demo_pass --purge-own-project --verbose
source $DEVSTACK_DIR/openrc alt_demo alt_demo
assert_compute && assert_network && assert_volume
source $DEVSTACK_DIR/openrc admin admin
openstack project set --disable alt_demo
tox -e run -- --os-auth-url http://localhost/identity_admin --os-username admin --os-project-name admin --os-password testtest --purge-project alt_demo --verbose
tox -e run -- --os-auth-url http://localhost/identity_admin --os-username admin --os-project-name admin --os-password $admin_admin_pass --purge-project alt_demo --verbose
openstack project set --enable alt_demo
@ -137,7 +150,15 @@ if [[ $(neutron port-list | wc -l) -ne 1 ]]; then # This also checks FIP
exit 1
fi
if [[ $( cinder backup-list --all-tenants | wc -l) -ne 4 ]]; then
echo "Not all volume backups were cleaned up"
exit 1
if [[ ${GATE_RUN} == 1 ]]; then
# The Cinder backup service is enabled in the Gate.
if [[ $(cinder backup-list --all-tenants | wc -l) -ne 4 ]]; then
echo "Not all volume backups were cleaned up"
exit 1
fi
else
if [[ $(openstack volume list --all-projects | wc -l) -ne 1 ]]; then
echo "Not all volumes were cleaned up"
exit 1
fi
fi