]> review.fuel-infra Code Review - openstack-build/heat-build.git/commitdiff
heat tests : add functional test for Wordpress RDS
authorSteven Hardy <shardy@redhat.com>
Wed, 5 Sep 2012 15:26:27 +0000 (16:26 +0100)
committerSteven Hardy <shardy@redhat.com>
Wed, 5 Sep 2012 15:27:37 +0000 (16:27 +0100)
Add functional test for WordPress_With_RDS template

Fixes: #215
Change-Id: I0613c40e218acaab987a2b0e0df7737cb6f6b6b3
Signed-off-by: Steven Hardy <shardy@redhat.com>
heat/tests/functional/test_WordPress_With_RDS.py [new file with mode: 0644]

diff --git a/heat/tests/functional/test_WordPress_With_RDS.py b/heat/tests/functional/test_WordPress_With_RDS.py
new file mode 100644 (file)
index 0000000..a82eaf1
--- /dev/null
@@ -0,0 +1,66 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+#
+#    Licensed under the Apache License, Version 2.0 (the "License"); you may
+#    not use this file except in compliance with the License. You may obtain
+#    a copy of the License at
+#
+#         http://www.apache.org/licenses/LICENSE-2.0
+#
+#    Unless required by applicable law or agreed to in writing, software
+#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+#    License for the specific language governing permissions and limitations
+#
+
+import util
+import verify
+import nose
+from nose.plugins.attrib import attr
+import unittest
+
+
+@attr(speed='slow')
+@attr(tag=['func', 'wordpress', 'RDS'])
+class WordPressRDSFunctionalTest(unittest.TestCase):
+    def setUp(self):
+        template = 'WordPress_With_RDS.template'
+
+        self.func_utils = util.FuncUtils()
+
+        self.func_utils.prepare_jeos('F17', 'x86_64', 'cfntools')
+        self.func_utils.create_stack(template, 'F17')
+        self.func_utils.check_cfntools()
+        self.func_utils.wait_for_provisioning()
+        self.func_utils.check_user_data(template)
+
+        self.ssh = self.func_utils.get_ssh_client()
+
+    def test_instance(self):
+        # ensure wordpress was installed by checking for expected
+        # configuration file over ssh
+        wp_file = '/usr/share/wordpress/wp-config.php'
+        stdin, stdout, sterr = self.ssh.exec_command('ls ' + wp_file)
+        result = stdout.readlines().pop().rstrip()
+        self.assertTrue(result == wp_file)
+        print "Wordpress installation detected"
+
+        # Check the DB_HOST value in the wordpress config is sane
+        # ie not localhost, we don't have any way to get the IP of
+        # the RDS nested-stack instance so we can't do a proper verification
+        # Note there are two wp-config.php files, one under /etc and
+        # one under /usr/share, the template only seds the RDS instance
+        # IP into the /usr/share one, which seems to work but could be a
+        # template bug..
+        stdin, stdout, sterr = self.ssh.exec_command('grep DB_HOST ' + wp_file)
+        result = stdout.readlines().pop().rstrip().split('\'')
+        print "Checking wordpress DB_HOST, got %s" % result[3]
+        self.assertTrue("localhost" != result[3])
+
+        # Verify the output URL parses as expected, ie check that
+        # the wordpress installation is operational
+        stack_url = self.func_utils.get_stack_output("WebsiteURL")
+        print "Got stack output WebsiteURL=%s, verifying" % stack_url
+        ver = verify.VerifyStack()
+        self.assertTrue(ver.verify_wordpress(stack_url))
+
+        self.func_utils.cleanup()