Added snapstack test.

Tweaked tox.ini to invoke snapstack, and added test_snapstack.py to
tests dir.

Also added glance.sh to glance/tests, as part of the plan to move
those scripts from snap-test to the individual snaps.

Change-Id: Ifbd53392c394ee36cf61d1a07dba825f7b7097b8
This commit is contained in:
Pete Vander Giessen 2017-07-24 15:00:41 +00:00
parent 9954765a70
commit 84668a42dc
3 changed files with 76 additions and 5 deletions

41
tests/glance.sh Executable file
View File

@ -0,0 +1,41 @@
#!/bin/bash
set -ex
source $BASE_DIR/admin-openrc
while sudo [ ! -d /var/snap/glance/common/etc/glance/ ]; do sleep 0.1; done;
sudo cp -r $BASE_DIR/etc/snap-glance/* /var/snap/glance/common/etc/
openstack user show glance || {
openstack user create --domain default --password glance glance
openstack role add --project service --user glance admin
}
openstack service show image || {
openstack service create --name glance --description "OpenStack Image" image
for endpoint in internal admin public; do
openstack endpoint create --region RegionOne \
image $endpoint http://localhost:9292 || :
done
}
# Manually define alias if snap isn't installed from snap store.
# Otherwise, snap store defines this alias automatically.
snap aliases glance | grep glance-manage || sudo snap alias glance.manage glance-manage
sudo glance-manage db_sync
sudo systemctl restart snap.glance.*
while ! nc -z localhost 9292; do sleep 0.1; done;
openstack image show xenial || {
[ -f $HOME/images/xenial-server-cloudimg-amd64-disk1.img ] || {
mkdir -p $HOME/images
wget http://cloud-images.ubuntu.com/xenial/current/xenial-server-cloudimg-amd64-disk1.img \
-O ${HOME}/images/xenial-server-cloudimg-amd64-disk1.img
}
openstack image create --file ${HOME}/images/xenial-server-cloudimg-amd64-disk1.img \
--public --container-format=bare --disk-format=qcow2 xenial
}

26
tests/snapstack_test.py Normal file
View File

@ -0,0 +1,26 @@
import unittest
from snapstack import Plan, Setup, Step
class SnapstackTest(unittest.TestCase):
def test_snapstack(self):
'''
_test_snapstack_
Run a basic smoke test, utilizing our snapstack testing harness.
'''
# snapstack already installs glance. Override the 'glance'
# step with a locally built snap. neutron, nova, etc. will still
# be installed as normal from the store.
setup = Setup()
setup.add_steps(('glance', Step(
snap='glance',
script_loc='./tests/',
scripts=['glance.sh'],
snap_store=False)))
# Execute the snapstack tests
plan = Plan(base_setup=setup.steps())
plan.run()

14
tox.ini
View File

@ -5,14 +5,18 @@ skipsdist = True
[testenv]
basepython = python3.5
install_command = pip install {opts} {packages}
passenv = HOME TERM
passenv =
HOME
TERM
SNAP_BUILD_PROXY
whitelist_externals =
sudo
snapcraft
[testenv:snap]
deps = -r{toxinidir}/requirements.txt
deps =
-r{toxinidir}/requirements.txt
git+https://github.com/openstack-snaps/snapstack
pytest
commands =
sudo snap install core
snapcraft clean
snapcraft snap
py.test -s tests/