From 23aee89bebb42d4bd315f96f5e0299e006fae8b9 Mon Sep 17 00:00:00 2001 From: Matt Bruzek Date: Tue, 28 Oct 2014 18:02:23 -0500 Subject: [PATCH] Adding bundles test for trusty requirements. --- tests/00-setup | 13 +++++++++++++ tests/10-bundles-test.py | 33 +++++++++++++++++++++++++++++++++ tests/bundles.yaml | 15 +++++++++++++++ 3 files changed, 61 insertions(+) create mode 100755 tests/00-setup create mode 100755 tests/10-bundles-test.py create mode 100644 tests/bundles.yaml diff --git a/tests/00-setup b/tests/00-setup new file mode 100755 index 0000000..7866df7 --- /dev/null +++ b/tests/00-setup @@ -0,0 +1,13 @@ +#!/bin/bash + +set -ex + +# Check if amulet is installed before adding repository and updating apt-get. +dpkg -s amulet +if [ $? -ne 0 ]; then + sudo add-apt-repository -y ppa:juju/stable + sudo apt-get update + sudo apt-get install -y amulet +fi + +# Install any additional python packages or software here. diff --git a/tests/10-bundles-test.py b/tests/10-bundles-test.py new file mode 100755 index 0000000..cc3f317 --- /dev/null +++ b/tests/10-bundles-test.py @@ -0,0 +1,33 @@ +#!/usr/bin/env python3 + +# This amulet test deploys the bundles.yaml file in this directory. + +import os +import unittest +import yaml +import amulet + +seconds_to_wait = 600 + + +class BundleTest(unittest.TestCase): + """ Create a class for testing the charm in the unit test framework. """ + @classmethod + def setUpClass(cls): + """ Set up an amulet deployment using the bundle. """ + d = amulet.Deployment() + bundle_path = os.path.join(os.path.dirname(__file__), 'bundles.yaml') + with open(bundle_path, 'r') as bundle_file: + contents = yaml.safe_load(bundle_file) + d.load(contents) + d.setup(seconds_to_wait) + d.sentry.wait(seconds_to_wait) + cls.d = d + + def test_deployed(self): + """ Test to see if the bundle deployed successfully. """ + self.assertTrue(self.d.deployed) + + +if __name__ == '__main__': + unittest.main() \ No newline at end of file diff --git a/tests/bundles.yaml b/tests/bundles.yaml new file mode 100644 index 0000000..e10224d --- /dev/null +++ b/tests/bundles.yaml @@ -0,0 +1,15 @@ +hacluster-mysql: + series: trusty + services: + hacluster: + charm: hacluster + num_units: 0 + mysql: + charm: cs:trusty/mysql + num_units: 2 + options: + "dataset-size": 128M + vip: 192.168.21.1 + relations: + - - "mysql:ha" + - "hacluster:ha"