~stub/charms/precise/postgresql/bug-1179847

« back to all changes in this revision

Viewing changes to test.py

  • Committer: Stuart Bishop
  • Date: 2013-06-13 11:00:36 UTC
  • mfrom: (47.1.6 tests)
  • Revision ID: stuart.bishop@canonical.com-20130613110036-l0jsbafdex5gydg9
Merged tests into bug-1179847.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
SERIES = 'precise'
18
18
TEST_CHARM = 'local:postgresql'
19
 
PSQL_CHARM = 'local:postgresql-psql'
 
19
PSQL_CHARM = 'cs:postgresql-psql'
20
20
 
21
21
 
22
22
def DEBUG(msg):
79
79
            self.refresh_status()
80
80
            ready = True
81
81
            for service in self.status['services']:
82
 
                for unit in self.status['services'][service]['units']:
83
 
                    agent_state = (
84
 
                        self.status['services'][service][
85
 
                            'units'][unit]['agent-state'])
 
82
                if self.status['services'][service].get('life', '') == 'dying':
 
83
                    ready = False
 
84
                units = self.status['services'][service].get('units', {})
 
85
                for unit in units.keys():
 
86
                    agent_state = units[unit].get('agent-state', '')
86
87
                    if agent_state != 'started':
87
88
                        ready = False
88
89
 
97
98
        # Tear down any services left running.
98
99
        self.refresh_status()
99
100
        for service in self.status['services']:
100
 
            self.do(['destroy-service', service])
101
 
        # We unfortunately cannot reuse machines, as we have no
102
 
        # guarantee they are still in a usable state. Tear them down
103
 
        # too.
104
 
        ## But it is sloooow... so lets see what happens for now.
105
 
        ## dirty_machines = [
106
 
        ##     m for m in self.status['machines'].keys() if m != '0']
107
 
        ## if dirty_machines:
108
 
        ##     self.do(['terminate-machine'] + dirty_machines)
 
101
            # It is an error to destroy a dying service.
 
102
            if self.status['services'][service].get('life', '') != 'dying':
 
103
                self.do(['destroy-service', service])
 
104
 
 
105
        self.wait_until_ready()  # Required due to Bug #1190250
 
106
 
 
107
        # We shouldn't reuse machines, as we have no guarantee they are
 
108
        # still in a usable state, so tear them down too. It would be a
 
109
        # nice to make this optional, but Bug #1190492 prevents this
 
110
        # optimization.
 
111
        dirty_machines = [
 
112
            m for m in self.status['machines'].keys() if m != '0']
 
113
        if dirty_machines:
 
114
            self.do(['destroy-machine'] + dirty_machines)
109
115
 
110
116
 
111
117
class LocalCharmRepositoryFixture(fixtures.Fixture):
148
154
        cls.juju.do(['deploy', '--upgrade', TEST_CHARM, 'postgresql'])
149
155
        cls.juju.do(['destroy-service', 'postgresql'])
150
156
 
 
157
        cls.juju.wait_until_ready()  # Required due to Bug #1190250
 
158
 
151
159
    @classmethod
152
160
    def tearDownClass(cls):
153
161
        cls.juju.cleanUp()