7
seconds_to_wait = 20000
10
class TestDeploy(unittest.TestCase):
12
Deployment test for the IBM DB2 charm.
15
self.d = amulet.Deployment(series='xenial')
16
self.d.add('ibm-db2', '/root/charms/xenial/ibm-db2')
17
self.d.setup(seconds_to_wait)
18
self.d.sentry.wait(seconds_to_wait)
20
def test_deploy_with_placeholder_resource(self):
21
# The status message when using placeholder resources will include the
22
# string "ibm_db2_installer resource". If we see that, the test is
24
sentry_re = re.compile('ibm_db2_installer resource')
25
self.d.sentry.wait_for_messages({"ibm-db2": sentry_re})
27
def test_deployed(self):
28
""" Test to see if the bundle deployed successfully. """
29
self.assertTrue(self.d.deployed)
31
db2_unit = self.d.sentry['ibm-db2'][0]
32
# Get the port num where db2 is running and check for netstat
33
output, code = db2_unit.run("su - db2inst1 -c 'db2 get dbm cfg'"
34
" | grep -i svce | cut -d'=' -f2")
36
message = 'Unable to get the port number where DB2 is running.'
37
' Exiting before completing'
38
'rest of the verification tests.'
39
amulet.raise_status(amulet.FAIL, msg=message)
40
print('DB2 running in port num : %s' % output)
41
print('Checking netstat command')
42
cmd = "su - db2inst1 -c 'netstat -an' | grep LISTEN | grep %s" % output
43
output, code = db2_unit.run(cmd)
45
message = 'Unable to get the port number where DB2 is running.'\
46
' Exiting before completing rest of the verification tests.'
47
amulet.raise_status(amulet.FAIL, msg=message)
48
print('Output of netstat command id %s' % output)
51
if __name__ == '__main__':