~ubuntu-branches/ubuntu/trusty/heat/trusty-security

« back to all changes in this revision

Viewing changes to heat/tests/functional/test_WordPress_Single_Instance_With_IHA.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short, Yolanda Robla, Chuck Short
  • Date: 2013-07-22 16:22:29 UTC
  • mfrom: (1.1.2)
  • Revision ID: package-import@ubuntu.com-20130722162229-zzvfu40id94ii0hc
Tags: 2013.2~b2-0ubuntu1
[ Yolanda Robla ]
* debian/tests: added autopkg tests

[ Chuck Short ]
* New upstream release
* debian/control:
  - Add python-pbr to build-depends.
  - Add python-d2to to build-depends.
  - Dropped python-argparse.
  - Add python-six to build-depends.
  - Dropped python-sendfile.
  - Dropped python-nose.
  - Added testrepository.
  - Added python-testtools.
* debian/rules: Run testrepository instead of nosetets.
* debian/patches/removes-lxml-version-limitation-from-pip-requires.patch: Dropped
  no longer needed.
* debian/patches/fix-package-version-detection-when-building-doc.patch: Dropped
  no longer needed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# vim: tabstop=4 shiftwidth=4 softtabstop=4
2
 
#
3
 
#    Licensed under the Apache License, Version 2.0 (the "License"); you may
4
 
#    not use this file except in compliance with the License. You may obtain
5
 
#    a copy of the License at
6
 
#
7
 
#         http://www.apache.org/licenses/LICENSE-2.0
8
 
#
9
 
#    Unless required by applicable law or agreed to in writing, software
10
 
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11
 
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12
 
#    License for the specific language governing permissions and limitations
13
 
#
14
 
 
15
 
import os
16
 
import util
17
 
import verify
18
 
from nose.plugins.attrib import attr
19
 
import unittest
20
 
import time
21
 
 
22
 
 
23
 
@attr(speed='slow')
24
 
@attr(tag=['func', 'wordpress', 'HA', 'F17',
25
 
      'WordPress_Single_Instance_With_IHA.template'])
26
 
class WordPressIHAFunctionalTest(unittest.TestCase):
27
 
    def setUp(self):
28
 
        template = 'WordPress_Single_Instance_With_IHA.template'
29
 
        stack_paramstr = ';'.join(['InstanceType=m1.xlarge',
30
 
                                   'DBUsername=dbuser',
31
 
                                   'DBPassword=' + os.environ['OS_PASSWORD']])
32
 
 
33
 
        self.stack = util.Stack(self, template, 'F17', 'x86_64', 'cfntools',
34
 
                                stack_paramstr)
35
 
        self.WikiDatabase = util.Instance(self, 'WikiDatabase')
36
 
 
37
 
    def tearDown(self):
38
 
        self.stack.cleanup()
39
 
 
40
 
    def test_instance(self):
41
 
        self.stack.create()
42
 
        self.WikiDatabase.wait_for_boot()
43
 
        self.WikiDatabase.check_cfntools()
44
 
        self.WikiDatabase.wait_for_provisioning()
45
 
 
46
 
        # ensure wordpress was installed by checking for expected
47
 
        # configuration file over ssh
48
 
        wp_file = '/usr/share/wordpress/wp-config.php'
49
 
        self.assertTrue(self.WikiDatabase.file_present(wp_file))
50
 
        print "Wordpress installation detected"
51
 
 
52
 
        # Verify the output URL parses as expected, ie check that
53
 
        # the wordpress installation is operational
54
 
        stack_url = self.stack.get_stack_output("WebsiteURL")
55
 
        print "Got stack output WebsiteURL=%s, verifying" % stack_url
56
 
        ver = verify.VerifyStack()
57
 
        self.assertTrue(ver.verify_wordpress(stack_url))
58
 
 
59
 
        # Save the instance physical resource ID
60
 
        phys_res_ids = self.stack.instance_phys_ids()
61
 
        self.assertEqual(len(phys_res_ids), 1)
62
 
        print "Shutting down instance ID = %s" % phys_res_ids[0]
63
 
 
64
 
        # Now shut down the instance via SSH, and wait for HA to reprovision
65
 
        # note it may not come back on the same IP
66
 
        stdin, stdout, stderr =\
67
 
            self.WikiDatabase.exec_sudo_command('/sbin/halt')
68
 
 
69
 
        # Now poll the stack events, as the current WikiDatabase instance
70
 
        # should be replaced with a new one
71
 
        # we can then prove the physical resource ID is different, and that
72
 
        # wordpress is accessible on the new WikiDatabase instance
73
 
        tries = 0
74
 
        while (tries <= 500):
75
 
                pollids = self.stack.instance_phys_ids()
76
 
                print "Waiting for Instance to be replaced %s/%s %s" %\
77
 
                      (tries, 500, pollids)
78
 
                if (len(pollids) == 2):
79
 
                    self.assertTrue(pollids[1] != phys_res_ids[0])
80
 
                    print "Instance replaced, new ID = %s" % pollids[1]
81
 
                    break
82
 
                time.sleep(10)
83
 
                tries += 1
84
 
 
85
 
        # Check we didn't timeout
86
 
        self.assertTrue(tries < 500)
87
 
 
88
 
        # Create a new Instance object and wait for boot
89
 
        # It seems to be necessary to close the old WikiDatabase
90
 
        # instance SSH transport, or paramiko throws an exception
91
 
        # when the SSH daemon starts on the new instance if it comes
92
 
        # up on the same IP address, suspect paramiko bug, TBC
93
 
        self.WikiDatabase.close_ssh_client()
94
 
        self.WikiDatabaseNew = util.Instance(self, 'WikiDatabase')
95
 
        self.WikiDatabaseNew.wait_for_boot()
96
 
        self.WikiDatabaseNew.check_cfntools()
97
 
        self.WikiDatabaseNew.wait_for_provisioning()
98
 
 
99
 
        # Re-check wordpress installation as for the first instance
100
 
        self.assertTrue(self.WikiDatabaseNew.file_present(wp_file))
101
 
        print "Wordpress installation detected on new instance"
102
 
 
103
 
        # Verify the output URL parses as expected, ie check that
104
 
        # the wordpress installation is operational
105
 
        stack_url = self.stack.get_stack_output("WebsiteURL")
106
 
        print "Got stack output WebsiteURL=%s, verifying" % stack_url
107
 
        self.assertTrue(ver.verify_wordpress(stack_url))