Merge lp:~johnsca/charms/trusty/nagios/pagerduty-test-race into lp:~brad-marshall/charms/trusty/nagios/add-extra-config-options

Proposed by Cory Johns
Status: Needs review
Proposed branch: lp:~johnsca/charms/trusty/nagios/pagerduty-test-race
Merge into: lp:~brad-marshall/charms/trusty/nagios/add-extra-config-options
Diff against target: 49 lines (+18/-8)
1 file modified
tests/24-pagerduty-test (+18/-8)
To merge this branch: bzr merge lp:~johnsca/charms/trusty/nagios/pagerduty-test-race
Reviewer Review Type Date Requested Status
Brad Marshall Pending
Review via email: mp+269401@code.launchpad.net

Description of the change

Work-around for race condition in pagerduty test

To post a comment you must log in.

Unmerged revisions

49. By Cory Johns

Work-around for race condition in pagerduty test

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'tests/24-pagerduty-test'
--- tests/24-pagerduty-test 2015-07-22 06:19:11 +0000
+++ tests/24-pagerduty-test 2015-08-27 15:57:56 +0000
@@ -1,5 +1,6 @@
1#!/usr/bin/python31#!/usr/bin/python3
22
3from time import sleep
3import amulet4import amulet
4# import requests5# import requests
56
@@ -33,21 +34,30 @@
3334
3435
35def test_pagerduty_path_exists():36def test_pagerduty_path_exists():
36 pagerduty_path = nagios_unit.run('config-get pagerduty_path')37 for i in range(3): # try three times before failing
37 try:38 pagerduty_path = nagios_unit.run('config-get pagerduty_path')
38 pagerduty_file = nagios_unit.file(pagerduty_path[0])39 try:
39 except OSError:40 nagios_unit.file(pagerduty_path[0])
41 break
42 except OSError:
43 sleep(5)
44 else:
40 message = "Can't find pagerduty directory"45 message = "Can't find pagerduty directory"
41 amulet.raise_status(amulet.FAIL, msg=message)46 amulet.raise_status(amulet.FAIL, msg=message)
4247
4348
44def test_pagerduty_config():49def test_pagerduty_config():
45 pagerduty_cfg = '/etc/nagios3/conf.d/pagerduty_nagios.cfg'50 for i in range(3): # try three times before failing
46 try:51 pagerduty_cfg = '/etc/nagios3/conf.d/pagerduty_nagios.cfg'
47 pagerduty_cfg_file = nagios_unit.file(pagerduty_cfg)52 try:
48 except OSError:53 nagios_unit.file(pagerduty_cfg)
54 break
55 except OSError:
56 sleep(5)
57 else:
49 message = "Can't find pagerduty config file"58 message = "Can't find pagerduty config file"
50 amulet.raise_status(amulet.FAIL, msg=message)59 amulet.raise_status(amulet.FAIL, msg=message)
5160
61
52test_pagerduty_path_exists()62test_pagerduty_path_exists()
53test_pagerduty_config()63test_pagerduty_config()

Subscribers

People subscribed via source and target branches

to all changes: