Added snapstack test.

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

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

Change-Id: Id39209ee1534670506f0d97bb3dcb34a173ebc92
This commit is contained in:
Pete Vander Giessen 2017-07-14 19:42:21 +00:00
parent 3067720cbb
commit aac40bec0e
3 changed files with 65 additions and 5 deletions

30
tests/keystone.sh Executable file
View File

@ -0,0 +1,30 @@
#!/bin/bash
set -ex
source $BASE_DIR/admin-openrc
while sudo [ ! -d /var/snap/keystone/common/etc/keystone/ ]; do sleep 0.1; done;
sudo cp -r $BASE_DIR/etc/snap-keystone/* /var/snap/keystone/common/etc/
# Manually define alias if snap isn't installed from snap store.
# Otherwise, snap store defines this alias automatically.
snap aliases keystone | grep keystone-manage || sudo snap alias keystone.manage keystone-manage
sudo keystone-manage fernet_setup --keystone-user root --keystone-group root
sudo keystone-manage db_sync
sudo systemctl restart snap.keystone.*
openstack user show admin || {
sudo keystone-manage bootstrap \
--bootstrap-password keystone \
--bootstrap-admin-url http://localhost:35357/v3/ \
--bootstrap-internal-url http://localhost:35357/v3/ \
--bootstrap-public-url http://localhost:5000/v3/ \
--bootstrap-region-id RegionOne
}
openstack project show service || {
openstack project create --domain default --description "Service Project" service
}

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 keystone. Override the 'keystone'
# step with a locally built snap. neutron, nova, etc. will still
# be installed as normal from the store.
setup = Setup()
setup.add_steps(('keystone', Step(
snap='keystone',
script_loc='./tests/',
scripts=['keystone.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/