137
138
result = self.sql('SELECT TRUE')
138
139
self.assertEqual(result, [['t']])
141
# Confirm that the relation tears down without errors.
142
self.juju.do(['destroy-relation', 'postgresql:db', 'psql:db'])
143
self.juju.wait_until_ready()
140
145
def test_streaming_replication(self):
141
146
self.juju.deploy(
142
147
TEST_CHARM, 'postgresql', num_units=2, config=self.pg_config)
163
168
result = self.sql('SELECT TRUE', dbname='postgres')
164
169
self.assertEqual(result, [['t']])
171
# Confirm that the relation tears down without errors.
173
'destroy-relation', 'postgresql:db-admin', 'psql:db-admin'])
174
self.juju.wait_until_ready()
166
176
def is_master(self, postgres_unit, dbname=None):
167
177
is_master = self.sql(
168
178
'SELECT NOT pg_is_in_recovery()',
426
436
self.assertEqual(result, [['f', 'f', 'f']])
438
def test_syslog(self):
439
# Deploy 2 PostgreSQL units and 2 rsyslog units to ensure that
440
# log messages from every source reach every sink.
441
self.pg_config['log_min_duration_statement'] = 0 # Log all statements
443
TEST_CHARM, 'postgresql', num_units=2, config=self.pg_config)
444
self.juju.deploy(PSQL_CHARM, 'psql')
445
self.juju.do(['add-relation', 'postgresql:db', 'psql:db'])
446
self.juju.deploy('cs:rsyslog', 'rsyslog', num_units=2)
448
'add-relation', 'postgresql:syslog', 'rsyslog:aggregator'])
449
self.juju.wait_until_ready()
451
token = str(uuid.uuid1())
453
self.sql("SELECT 'master {}'".format(token), 'master')
454
self.sql("SELECT 'hot standby {}'".format(token), 'hot standby')
457
for runit in ['rsyslog/0', 'rsyslog/1']:
458
cmd = ['juju', 'ssh', runit, 'tail -100 /var/log/syslog']
460
self.failUnless('master {}'.format(token) in out)
461
self.failUnless('hot standby {}'.format(token) in out)
463
# Confirm that the relation tears down correctly.
465
'destroy-relation', 'postgresql:syslog', 'rsyslog:aggregator'])
466
self.juju.wait_until_ready()
430
470
PostgreSQLCharmBaseTestCase,