From 8f43785d63dd1460987b9db3942e8c50d8d5276a Mon Sep 17 00:00:00 2001 From: Pete Vander Giessen Date: Mon, 24 Jul 2017 15:34:04 +0000 Subject: [PATCH] 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 --- tests/nova-hypervisor.sh | 27 +++++++++++++++++++++++++++ tests/snapstack_test.py | 26 ++++++++++++++++++++++++++ tox.ini | 14 +++++++++----- 3 files changed, 62 insertions(+), 5 deletions(-) create mode 100755 tests/nova-hypervisor.sh create mode 100644 tests/snapstack_test.py diff --git a/tests/nova-hypervisor.sh b/tests/nova-hypervisor.sh new file mode 100755 index 0000000..4768775 --- /dev/null +++ b/tests/nova-hypervisor.sh @@ -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 diff --git a/tests/snapstack_test.py b/tests/snapstack_test.py new file mode 100644 index 0000000..38b42fd --- /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 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() 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/