diff --git a/tests/neutron.sh b/tests/neutron.sh new file mode 100755 index 0000000..ad7f4e6 --- /dev/null +++ b/tests/neutron.sh @@ -0,0 +1,38 @@ +#!/bin/bash + +set -ex + +source $BASE_DIR/admin-openrc + +openstack user show neutron || { + openstack user create --domain default --password neutron neutron + openstack role add --project service --user neutron admin +} + +openstack service show network || { + openstack service create --name neutron \ + --description "OpenStack Network" network + + for endpoint in public internal admin; do + openstack endpoint create --region RegionOne \ + network $endpoint http://localhost:9696 || : + done +} + +while sudo [ ! -d /var/snap/neutron/common/etc/neutron/ ]; do sleep 0.1; done; +sudo cp -r $BASE_DIR/etc/snap-neutron/* /var/snap/neutron/common/etc/ + +# Manually define alias if snap isn't installed from snap store. +# Otherwise, snap store defines this alias automatically. +snap aliases neutron | grep neutron-db-manage || sudo snap alias neutron.manage neutron-db-manage + +sudo neutron-db-manage upgrade head + +sudo systemctl restart snap.neutron.* + +while ! nc -z localhost 9696; do sleep 0.1; done; + +neutron net-show test || { + neutron net-create test + neutron subnet-create --name test_subnet test 192.168.222.0/24 +} diff --git a/tests/snapstack_test.py b/tests/snapstack_test.py new file mode 100644 index 0000000..0e67e17 --- /dev/null +++ b/tests/snapstack_test.py @@ -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 neutron. Override the 'neutron' + # step with a locally built snap. keystone, nova, etc. will still + # be installed as normal from the store. + setup = Setup() + setup.add_steps(('neutron', Step( + snap='neutron', + script_loc='./tests/', + scripts=['neutron.sh'], + snap_store=False))) + + # Execute the snapstack tests + plan = Plan(base_setup=setup.steps()) + plan.run() diff --git a/tox.ini b/tox.ini index 7360ffc..a6fe96f 100644 --- a/tox.ini +++ b/tox.ini @@ -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/