Added snapstack test.

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

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

Change-Id: I2e0363d361893a899b6cd4e4683e6d14bac1a0ed
This commit is contained in:
Pete Vander Giessen 2017-07-24 15:34:04 +00:00
parent 3f0b92da64
commit 8f43785d63
3 changed files with 62 additions and 5 deletions

27
tests/nova-hypervisor.sh Executable file
View File

@ -0,0 +1,27 @@
#!/bin/bash
set -ex
source $BASE_DIR/admin-openrc
# Manually connect interfaces if snap isn't installed from snap store.
# Otherwise, snap store automatically connects these interfaces.
interfaces=( firewall-control hardware-observe libvirt network-control
network-observe openvswitch process-control system-observe )
for interface in "${interfaces[@]}"; do
snap interfaces -i ${interface} nova-hypervisor | grep nova-hypervisor:${interface} && \
sudo snap connect nova-hypervisor:${interface} core:${interface}
done
while sudo [ ! -d /var/snap/nova-hypervisor/common/etc/neutron/ ]; do sleep 0.1; done;
while sudo [ ! -d /var/snap/nova-hypervisor/common/etc/nova/ ]; do sleep 0.1; done;
sudo cp -r $BASE_DIR/etc/snap-nova-hypervisor/* /var/snap/nova-hypervisor/common/etc/
sudo systemctl restart snap.nova-hypervisor.*
sudo systemctl restart snap.nova-hypervisor.nova-compute
# Manually define alias if snap isn't installed from snap store.
# Otherwise, snap store defines this alias automatically.
snap aliases nova | grep nova-manage || sudo snap alias nova.manage nova-manage
sudo nova-manage cell_v2 discover_hosts --verbose

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