Merge lp:~evarlast/charms/trusty/mongodb/fix-dump-actions into lp:charms/trusty/mongodb

Proposed by Jay R. Wren on 2015-11-10
Status: Merged
Merged at revision: 80
Proposed branch: lp:~evarlast/charms/trusty/mongodb/fix-dump-actions
Merge into: lp:charms/trusty/mongodb
Diff against target: 461 lines (+156/-59)
9 files modified
actions/backup.py (+5/-4)
config.yaml (+1/-1)
hooks/hooks.py (+1/-0)
metadata.yaml (+1/-1)
tests/01_deploy_single.py (+4/-1)
tests/02_deploy_shard_test.py (+47/-19)
tests/03_deploy_replicaset.py (+73/-19)
tests/04_deploy_with_storage.py (+18/-11)
tests/50_relate_ceilometer_test.py (+6/-3)
To merge this branch: bzr merge lp:~evarlast/charms/trusty/mongodb/fix-dump-actions
Reviewer Review Type Date Requested Status
Review Queue (community) automated testing Approve on 2015-12-17
Matt Bruzek (community) Approve on 2015-12-16
Jay R. Wren (community) Resubmit on 2015-12-10
Ryan Beisner Needs Fixing on 2015-11-23
Matthew Williams (community) Approve on 2015-11-12
Tim Van Steenburgh 2015-11-10 Needs Fixing on 2015-11-11
Review via email: mp+277191@code.launchpad.net

Description of the change

Dump wasn't working. Now it works and if args has spaces, they can be escaped with quotes.

e.g.

$ juju action do mongodb/0 dump args='-q "{a:1, b:2}"'
Action queued with id: 7b627526-8b0c-4f2e-8494-bdb13dabe23d
$ juju action fetch 7b
results:
  command: mongodump -q "{a:1, b:2}"

To post a comment you must log in.

charm_lint_check #13430 mongodb for evarlast mp277191
    LINT OK: passed

Build: http://10.245.162.77:8080/job/charm_lint_check/13430/

charm_unit_test #12564 mongodb for evarlast mp277191
    UNIT OK: passed

Build: http://10.245.162.77:8080/job/charm_unit_test/12564/

charm_amulet_test #7839 mongodb for evarlast mp277191
    AMULET OK: passed

Build: http://10.245.162.77:8080/job/charm_amulet_test/7839/

Tim Van Steenburgh (tvansteenburgh) wrote :

Charm CI tests failed due to hardcoded unit numbers in the tests. Jenkins log: http://juju-ci.vapour.ws:8080/job/charm-bundle-test-lxc/1432/console

To fix, replace occurrences of `d.sentry.unit['mongodb/0']` with `d.sentry['mongodb'][0]` in the test files (tests/*).

review: Needs Fixing
80. By Jay R. Wren on 2015-11-12

fix hardcoded unit numbers in the tests

charm_unit_test #12615 mongodb for evarlast mp277191
    UNIT OK: passed

Build: http://10.245.162.77:8080/job/charm_unit_test/12615/

charm_lint_check #13484 mongodb for evarlast mp277191
    LINT OK: passed

Build: http://10.245.162.77:8080/job/charm_lint_check/13484/

Matthew Williams (mattyw) wrote :

LGTM

review: Approve

charm_amulet_test #7845 mongodb for evarlast mp277191
    AMULET FAIL: amulet-test failed

AMULET Results (max last 2 lines):
make: *** [functional_test] Error 1
ERROR:root:Make target returned non-zero.

Full amulet test output: http://paste.ubuntu.com/13240036/
Build: http://10.245.162.77:8080/job/charm_amulet_test/7845/

Review Queue (review-queue) wrote :

This item has failed automated testing! Results available here http://juju-ci.vapour.ws:8080/job/charm-bundle-test-aws/1421/

review: Needs Fixing (automated testing)
81. By Jay R. Wren on 2015-11-13

use sentry[service][N] instead of sentry.unit[unit]

82. By Jay R. Wren on 2015-11-13

categories is now tags.

config key now defaults to ""

charm_lint_check #13701 mongodb for evarlast mp277191
    LINT OK: passed

Build: http://10.245.162.77:8080/job/charm_lint_check/13701/

charm_unit_test #12771 mongodb for evarlast mp277191
    UNIT OK: passed

Build: http://10.245.162.77:8080/job/charm_unit_test/12771/

charm_amulet_test #7858 mongodb for evarlast mp277191
    AMULET FAIL: amulet-test failed

AMULET Results (max last 2 lines):
make: *** [functional_test] Error 1
ERROR:root:Make target returned non-zero.

Full amulet test output: http://paste.ubuntu.com/13249011/
Build: http://10.245.162.77:8080/job/charm_amulet_test/7858/

83. By Jay R. Wren on 2015-11-17

some ipv6 support

charm_lint_check #13928 mongodb for evarlast mp277191
    LINT FAIL: lint-test failed

LINT Results (max last 2 lines):
make: *** [lint] Error 1
ERROR:root:Make target returned non-zero.

Full lint test output: http://paste.ubuntu.com/13318610/
Build: http://10.245.162.77:8080/job/charm_lint_check/13928/

charm_unit_test #12984 mongodb for evarlast mp277191
    UNIT OK: passed

Build: http://10.245.162.77:8080/job/charm_unit_test/12984/

charm_amulet_test #7911 mongodb for evarlast mp277191
    AMULET FAIL: amulet-test failed

AMULET Results (max last 2 lines):
make: *** [functional_test] Error 1
ERROR:root:Make target returned non-zero.

Full amulet test output: http://paste.ubuntu.com/13318703/
Build: http://10.245.162.77:8080/job/charm_amulet_test/7911/

84. By Jay R. Wren on 2015-11-17

fix ipv6 url

85. By Jay R. Wren on 2015-11-17

fix ipv6 url

86. By Jay R. Wren on 2015-11-18

fix lint

charm_lint_check #14010 mongodb for evarlast mp277191
    LINT OK: passed

Build: http://10.245.162.77:8080/job/charm_lint_check/14010/

charm_unit_test #13061 mongodb for evarlast mp277191
    UNIT OK: passed

Build: http://10.245.162.77:8080/job/charm_unit_test/13061/

charm_amulet_test #7939 mongodb for evarlast mp277191
    AMULET OK: passed

Build: http://10.245.162.77:8080/job/charm_amulet_test/7939/

87. By Jay R. Wren on 2015-11-19

fix broken amulet tests

we do not know which is master, cannot assume it is /0, so try 0 and if it fails try /1.

enable ipv6 in mongodb. We cannot know which provider is being used and if the public-address may be ipv6, so we must enable ipv6

charm_lint_check #14066 mongodb for evarlast mp277191
    LINT FAIL: lint-test failed

LINT Results (max last 2 lines):
make: *** [lint] Error 1
ERROR:root:Make target returned non-zero.

Full lint test output: http://paste.ubuntu.com/13340748/
Build: http://10.245.162.77:8080/job/charm_lint_check/14066/

charm_unit_test #13112 mongodb for evarlast mp277191
    UNIT OK: passed

Build: http://10.245.162.77:8080/job/charm_unit_test/13112/

charm_amulet_test #7941 mongodb for evarlast mp277191
    AMULET FAIL: amulet-test failed

AMULET Results (max last 2 lines):
make: *** [functional_test] Error 1
ERROR:root:Make target returned non-zero.

Full amulet test output: http://paste.ubuntu.com/13341016/
Build: http://10.245.162.77:8080/job/charm_amulet_test/7941/

88. By Jay R. Wren on 2015-11-20

use sentry.wait() instead of time.sleep - much faster.

charm_lint_check #14136 mongodb for evarlast mp277191
    LINT FAIL: lint-test failed

LINT Results (max last 2 lines):
make: *** [lint] Error 1
ERROR:root:Make target returned non-zero.

Full lint test output: http://paste.ubuntu.com/13367320/
Build: http://10.245.162.77:8080/job/charm_lint_check/14136/

charm_unit_test #13176 mongodb for evarlast mp277191
    UNIT OK: passed

Build: http://10.245.162.77:8080/job/charm_unit_test/13176/

89. By Jay R. Wren on 2015-11-20

fix lint

charm_lint_check #14137 mongodb for evarlast mp277191
    LINT OK: passed

Build: http://10.245.162.77:8080/job/charm_lint_check/14137/

charm_unit_test #13177 mongodb for evarlast mp277191
    UNIT OK: passed

Build: http://10.245.162.77:8080/job/charm_unit_test/13177/

charm_amulet_test #7957 mongodb for evarlast mp277191
    AMULET FAIL: amulet-test failed

AMULET Results (max last 2 lines):
make: *** [functional_test] Error 1
ERROR:root:Make target returned non-zero.

Full amulet test output: http://paste.ubuntu.com/13368568/
Build: http://10.245.162.77:8080/job/charm_amulet_test/7957/

charm_amulet_test #7956 mongodb for evarlast mp277191
    AMULET OK: passed

Build: http://10.245.162.77:8080/job/charm_amulet_test/7956/

90. By Jay R. Wren on 2015-11-20

Use hostname used in relation.

Can't assume relation hostname is public-address. It isn't in many environments.

charm_lint_check #14138 mongodb for evarlast mp277191
    LINT OK: passed

Build: http://10.245.162.77:8080/job/charm_lint_check/14138/

charm_unit_test #13178 mongodb for evarlast mp277191
    UNIT OK: passed

Build: http://10.245.162.77:8080/job/charm_unit_test/13178/

91. By Jay R. Wren on 2015-11-20

use sentry.wait not time.sleep

charm_amulet_test #7958 mongodb for evarlast mp277191
    AMULET FAIL: amulet-test failed

AMULET Results (max last 2 lines):
make: *** [functional_test] Error 1
ERROR:root:Make target returned non-zero.

Full amulet test output: http://paste.ubuntu.com/13370168/
Build: http://10.245.162.77:8080/job/charm_amulet_test/7958/

charm_unit_test #13180 mongodb for evarlast mp277191
    UNIT OK: passed

Build: http://10.245.162.77:8080/job/charm_unit_test/13180/

charm_lint_check #14140 mongodb for evarlast mp277191
    LINT OK: passed

Build: http://10.245.162.77:8080/job/charm_lint_check/14140/

charm_amulet_test #7960 mongodb for evarlast mp277191
    AMULET FAIL: amulet-test failed

AMULET Results (max last 2 lines):
make: *** [functional_test] Error 1
ERROR:root:Make target returned non-zero.

Full amulet test output: http://paste.ubuntu.com/13370662/
Build: http://10.245.162.77:8080/job/charm_amulet_test/7960/

92. By Jay R. Wren on 2015-11-20

wait longer for replset

Don't retry on unit 1 when unit 0 is not primary.
Additional logging on fail.

charm_lint_check #14141 mongodb for evarlast mp277191
    LINT FAIL: lint-test failed

LINT Results (max last 2 lines):
make: *** [lint] Error 1
ERROR:root:Make target returned non-zero.

Full lint test output: http://paste.ubuntu.com/13372704/
Build: http://10.245.162.77:8080/job/charm_lint_check/14141/

charm_unit_test #13181 mongodb for evarlast mp277191
    UNIT OK: passed

Build: http://10.245.162.77:8080/job/charm_unit_test/13181/

charm_amulet_test #7961 mongodb for evarlast mp277191
    AMULET FAIL: amulet-test failed

AMULET Results (max last 2 lines):
make: *** [functional_test] Error 1
ERROR:root:Make target returned non-zero.

Full amulet test output: http://paste.ubuntu.com/13373290/
Build: http://10.245.162.77:8080/job/charm_amulet_test/7961/

93. By Jay R. Wren on 2015-11-20

fix lint

charm_unit_test #13182 mongodb for evarlast mp277191
    UNIT OK: passed

Build: http://10.245.162.77:8080/job/charm_unit_test/13182/

charm_lint_check #14142 mongodb for evarlast mp277191
    LINT OK: passed

Build: http://10.245.162.77:8080/job/charm_lint_check/14142/

charm_amulet_test #7962 mongodb for evarlast mp277191
    AMULET FAIL: amulet-test failed

AMULET Results (max last 2 lines):
make: *** [functional_test] Error 1
ERROR:root:Make target returned non-zero.

Full amulet test output: http://paste.ubuntu.com/13374149/
Build: http://10.245.162.77:8080/job/charm_amulet_test/7962/

94. By Jay R. Wren on 2015-11-23

increase wait time for CI

charm_lint_check #14253 mongodb for evarlast mp277191
    LINT OK: passed

Build: http://10.245.162.77:8080/job/charm_lint_check/14253/

charm_unit_test #13284 mongodb for evarlast mp277191
    UNIT OK: passed

Build: http://10.245.162.77:8080/job/charm_unit_test/13284/

charm_amulet_test #8016 mongodb for evarlast mp277191
    AMULET FAIL: amulet-test failed

AMULET Results (max last 2 lines):
make: *** [functional_test] Error 1
ERROR:root:Make target returned non-zero.

Full amulet test output: http://paste.ubuntu.com/13479215/
Build: http://10.245.162.77:8080/job/charm_amulet_test/8016/

95. By Jay R. Wren on 2015-11-23

increase wait time for CI

charm_lint_check #14254 mongodb for evarlast mp277191
    LINT OK: passed

Build: http://10.245.162.77:8080/job/charm_lint_check/14254/

charm_unit_test #13285 mongodb for evarlast mp277191
    UNIT OK: passed

Build: http://10.245.162.77:8080/job/charm_unit_test/13285/

charm_amulet_test #8017 mongodb for evarlast mp277191
    AMULET FAIL: amulet-test failed

AMULET Results (max last 2 lines):
make: *** [functional_test] Error 1
ERROR:root:Make target returned non-zero.

Full amulet test output: http://paste.ubuntu.com/13479787/
Build: http://10.245.162.77:8080/job/charm_amulet_test/8017/

Ryan Beisner (1chb1n) wrote :

Thank you for your work on this.

While I realize that the test race wasn't introduced by your proposed changes, please see:
https://bugs.launchpad.net/charms/+source/mongodb/+bug/1518468

It would be awesome to resolve that test issue along with this, as it's definitely presenting a pain point.

review: Needs Fixing
96. By Jay R. Wren on 2015-11-24

retry every 10s for replset validation

charm_lint_check #14310 mongodb for evarlast mp277191
    LINT OK: passed

Build: http://10.245.162.77:8080/job/charm_lint_check/14310/

charm_unit_test #13338 mongodb for evarlast mp277191
    UNIT OK: passed

Build: http://10.245.162.77:8080/job/charm_unit_test/13338/

charm_amulet_test #8028 mongodb for evarlast mp277191
    AMULET OK: passed

Build: http://10.245.162.77:8080/job/charm_amulet_test/8028/

Review Queue (review-queue) wrote :

This item has failed automated testing! Results available here http://juju-ci.vapour.ws:8080/job/charm-bundle-test-lxc/1534/

review: Needs Fixing (automated testing)
Review Queue (review-queue) wrote :

This item has failed automated testing! Results available here http://juju-ci.vapour.ws:8080/job/charm-bundle-test-aws/1517/

review: Needs Fixing (automated testing)
Review Queue (review-queue) wrote :

This item has failed automated testing! Results available here http://juju-ci.vapour.ws:8080/job/charm-bundle-test-lxc/1536/

review: Needs Fixing (automated testing)

charm_lint_check #14635 mongodb for evarlast mp277191
    LINT OK: passed

Build: http://10.245.162.77:8080/job/charm_lint_check/14635/

Review Queue (review-queue) wrote :

This item has failed automated testing! Results available here http://juju-ci.vapour.ws:8080/job/charm-bundle-test-lxc/1615/

review: Needs Fixing (automated testing)
97. By Jay R. Wren on 2015-12-02

retry replSetGetStatus and use minimum unit number for master

charm_lint_check #14756 mongodb for evarlast mp277191
    LINT FAIL: lint-test failed

LINT Results (max last 2 lines):
make: *** [lint] Error 1
ERROR:root:Make target returned non-zero.

Full lint test output: http://paste.ubuntu.com/13631511/
Build: http://10.245.162.77:8080/job/charm_lint_check/14756/

charm_unit_test #13759 mongodb for evarlast mp277191
    UNIT OK: passed

Build: http://10.245.162.77:8080/job/charm_unit_test/13759/

98. By Jay R. Wren on 2015-12-02

fix lint

charm_lint_check #14757 mongodb for evarlast mp277191
    LINT OK: passed

Build: http://10.245.162.77:8080/job/charm_lint_check/14757/

charm_unit_test #13761 mongodb for evarlast mp277191
    UNIT OK: passed

Build: http://10.245.162.77:8080/job/charm_unit_test/13761/

charm_amulet_test #8078 mongodb for evarlast mp277191
    AMULET OK: passed

Build: http://10.245.162.77:8080/job/charm_amulet_test/8078/

charm_amulet_test #8079 mongodb for evarlast mp277191
    AMULET FAIL: amulet-test failed

AMULET Results (max last 2 lines):
make: *** [functional_test] Error 124
ERROR:root:Make target returned non-zero.

Full amulet test output: http://paste.ubuntu.com/13632412/
Build: http://10.245.162.77:8080/job/charm_amulet_test/8079/

charm_amulet_test #8081 mongodb for evarlast mp277191
    AMULET OK: passed

Build: http://10.245.162.77:8080/job/charm_amulet_test/8081/

99. By Jay R. Wren on 2015-12-03

retry shard status interface test
sort units and use them based on order in 04_deploy_with_storage test

charm_lint_check #14813 mongodb for evarlast mp277191
    LINT OK: passed

Build: http://10.245.162.77:8080/job/charm_lint_check/14813/

charm_unit_test #13813 mongodb for evarlast mp277191
    UNIT OK: passed

Build: http://10.245.162.77:8080/job/charm_unit_test/13813/

Review Queue (review-queue) wrote :

This item has failed automated testing! Results available here http://juju-ci.vapour.ws:8080/job/charm-bundle-test-lxc/1652/

review: Needs Fixing (automated testing)

charm_amulet_test #8134 mongodb for evarlast mp277191
    AMULET FAIL: amulet-test failed

AMULET Results (max last 2 lines):
make: *** [functional_test] Error 1
ERROR:root:Make target returned non-zero.

Full amulet test output: http://paste.ubuntu.com/13658235/
Build: http://10.245.162.77:8080/job/charm_amulet_test/8134/

Review Queue (review-queue) wrote :

This item has failed automated testing! Results available here http://juju-ci.vapour.ws:8080/job/charm-bundle-test-lxc/1654/

review: Needs Fixing (automated testing)
Review Queue (review-queue) wrote :

This item has failed automated testing! Results available here http://juju-ci.vapour.ws:8080/job/charm-bundle-test-aws/1634/

review: Needs Fixing (automated testing)
Review Queue (review-queue) wrote :

This item has failed automated testing! Results available here http://juju-ci.vapour.ws:8080/job/charm-bundle-test-lxc/1666/

review: Needs Fixing (automated testing)
Review Queue (review-queue) wrote :

This item has failed automated testing! Results available here http://juju-ci.vapour.ws:8080/job/charm-bundle-test-aws/1646/

review: Needs Fixing (automated testing)
100. By Jay R. Wren on 2015-12-07

use constraints for storage test to prevent filling root volume

charm_lint_check #15041 mongodb for evarlast mp277191
    LINT OK: passed

Build: http://10.245.162.77:8080/job/charm_lint_check/15041/

charm_unit_test #14029 mongodb for evarlast mp277191
    UNIT OK: passed

Build: http://10.245.162.77:8080/job/charm_unit_test/14029/

charm_amulet_test #8205 mongodb for evarlast mp277191
    AMULET OK: passed

Build: http://10.245.162.77:8080/job/charm_amulet_test/8205/

Review Queue (review-queue) wrote :

This item has failed automated testing! Results available here http://juju-ci.vapour.ws:8080/job/charm-bundle-test-lxc/1716/

review: Needs Fixing (automated testing)
Review Queue (review-queue) wrote :

This item has failed automated testing! Results available here http://juju-ci.vapour.ws:8080/job/charm-bundle-test-aws/1694/

review: Needs Fixing (automated testing)
Review Queue (review-queue) wrote :

This item has failed automated testing! Results available here http://juju-ci.vapour.ws:8080/job/charm-bundle-test-lxc/1725/

review: Needs Fixing (automated testing)
Review Queue (review-queue) wrote :

This item has failed automated testing! Results available here http://juju-ci.vapour.ws:8080/job/charm-bundle-test-aws/1702/

review: Needs Fixing (automated testing)
Jay R. Wren (evarlast) wrote :

The only fail remaining is from a known bug, which I am not attempting to fix.

From the README:
Deploying three or more units at start can sometimes lead to unexpected race-conditions so it's best to start with two nodes.

http://review.juju.solutions/review/2357 Shows the AWS test passing and the LXC test fails because of the above known bug.

Please consider this for merging.

review: Resubmit
Matt Bruzek (mbruzek) wrote :

Hello Jay,

While reviewing the queue today and noticed more than one mongodb charm merge proposals. Since we review the oldest first this proposal did not get reviewed first.

As Ryan points out in a bug 1518468 ( https://bugs.launchpad.net/charms/+source/mongodb/+bug/1518468 ) using sleep funtions are not a deterministic way to build tests that run on multiple environments as the times can be very long on some (azure) and lower on others (aws). This merge proposal changes some sleep() calls to sentry.wait() but introduces several more time.sleep() commands and the latter seems to be the wrong way to go.

## 03_deploy_replicaset.py
The new code contains the comment “# We assume minimum unit number is master.” There should be a better way to get the master address in the test. Again you may be able to run commands on the units to determine their master relationship, or use a mongo python library to determine the master reliably.

The tests passed for me on AWS and I am going to merge this code. I would encourage you to change the test code to detect the state of the mongodb deployment from reliable sources that do not involve sleeping for arbitrary amounts of time. Such as running a command on the unit to tell when it is ready, or using `juju status-history unit/0` to determine ready states.

review: Approve
Review Queue (review-queue) wrote :

This item has failed automated testing! Results available here http://juju-ci.vapour.ws:8080/job/charm-bundle-test-lxc/1754/

review: Needs Fixing (automated testing)
Review Queue (review-queue) wrote :

The results (PASS) are in and available here: http://juju-ci.vapour.ws:8080/job/charm-bundle-test-aws/1731/

review: Approve (automated testing)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'actions/backup.py'
2--- actions/backup.py 2015-10-08 08:12:35 +0000
3+++ actions/backup.py 2015-12-07 22:34:32 +0000
4@@ -1,3 +1,4 @@
5+import shlex
6 import subprocess
7 import os
8 try:
9@@ -14,7 +15,7 @@
10
11 def execute(command, current_working_directory):
12 return subprocess.check_output(
13- " ".join(command),
14+ shlex.split(command),
15 cwd=current_working_directory,
16 )
17
18@@ -38,7 +39,7 @@
19 pass # Ignoring, the directory already exists
20 except Exception, e:
21 action_set({"directory creation exception": e})
22- action_fail(e)
23+ action_fail(str(e))
24 return
25
26 command = cmd + " " + args
27@@ -50,7 +51,7 @@
28 except subprocess.CalledProcessError, e:
29 action_set({"error_code": e.returncode,
30 "exception": e, "output": e.output})
31- action_fail(e)
32+ action_fail(str(e))
33 except Exception, e:
34 action_set({"exception": e})
35- action_fail(e)
36+ action_fail(str(e))
37
38=== modified file 'config.yaml'
39--- config.yaml 2015-02-25 00:24:56 +0000
40+++ config.yaml 2015-12-07 22:34:32 +0000
41@@ -211,7 +211,7 @@
42 option.
43 key:
44 type: string
45- default:
46+ default: ""
47 description: >
48 Key ID to import to the apt keyring to support use with arbitary source
49 configuration from outside of Launchpad archives or PPA's.
50
51=== modified file 'hooks/hooks.py'
52--- hooks/hooks.py 2015-09-09 12:59:18 +0000
53+++ hooks/hooks.py 2015-12-07 22:34:32 +0000
54@@ -254,6 +254,7 @@
55 subprocess.call(['chown', '-R', 'mongodb:mongodb', config_data['dbpath']])
56 config.append("dbpath=%s" % config_data['dbpath'])
57 config.append("")
58+ config.append("ipv6=true")
59
60 # logpath
61 # Create the directory if not there already
62
63=== modified file 'metadata.yaml'
64--- metadata.yaml 2015-05-19 13:21:16 +0000
65+++ metadata.yaml 2015-12-07 22:34:32 +0000
66@@ -18,7 +18,7 @@
67 - Auto-sharding for cloud-level scalability (Q209)
68 High performance, scalability, and reasonable depth of functionality
69 are the goals for the project.
70-categories:
71+tags:
72 - databases
73 provides:
74 nrpe-external-master:
75
76=== modified file 'tests/01_deploy_single.py'
77--- tests/01_deploy_single.py 2014-12-10 15:36:14 +0000
78+++ tests/01_deploy_single.py 2015-12-07 22:34:32 +0000
79@@ -24,7 +24,10 @@
80 # Validate connectivity from $WORLD
81 #############################################################
82 def validate_world_connectivity():
83- client = MongoClient(d.sentry.unit['mongodb/0'].info['public-address'])
84+ addy = d.sentry['mongodb'][0].info['public-address']
85+ if ":" in addy:
86+ addy = "[{}]".format(addy)
87+ client = MongoClient(addy)
88
89 db = client['test']
90 # Can we successfully insert?
91
92=== modified file 'tests/02_deploy_shard_test.py'
93--- tests/02_deploy_shard_test.py 2014-12-09 23:45:14 +0000
94+++ tests/02_deploy_shard_test.py 2015-12-07 22:34:32 +0000
95@@ -2,6 +2,9 @@
96
97 import amulet
98 import requests
99+import sys
100+import time
101+import traceback
102 from pymongo import MongoClient
103
104 #########################################################
105@@ -49,10 +52,10 @@
106 raise
107
108 sentry_dict = {
109- 'config-sentry': d.sentry.unit['configsvr/0'],
110- 'mongos-sentry': d.sentry.unit['mongos/0'],
111- 'shard1-sentry': d.sentry.unit['shard1/0'],
112- 'shard2-sentry': d.sentry.unit['shard2/0']
113+ 'config-sentry': d.sentry['configsvr'][0],
114+ 'mongos-sentry': d.sentry['mongos'][0],
115+ 'shard1-sentry': d.sentry['shard1'][0],
116+ 'shard2-sentry': d.sentry['shard2'][0]
117 }
118
119
120@@ -60,10 +63,27 @@
121 # Check presence of MongoDB GUI HEALTH Status
122 #############################################################
123 def validate_status_interface():
124- r = requests.get("http://{}:28017".format(
125- sentry_dict['config-sentry'].info['public-address']),
126- verify=False)
127- r.raise_for_status
128+ pubaddy = sentry_dict['config-sentry'].info['public-address']
129+ fmt = "http://{}:28017"
130+ if ":" in pubaddy:
131+ fmt = "http://[{}]:28017"
132+ time_between = 10
133+ tries = seconds / time_between
134+ try:
135+ r = requests.get(fmt.format(pubaddy), verify=False)
136+ r.raise_for_status()
137+ except requests.exception.ConnectionError as ex:
138+ sys.stderr.write(
139+ 'Connection error, sleep and retry... to {}: {}\n'.
140+ format(pubaddy, ex))
141+ tb_lines = traceback.format_exception(ex.__class__,
142+ ex, ex.__traceback__)
143+ tb_text = ''.join(tb_lines)
144+ sys.stderr.write(tb_text)
145+ tries = tries - 1
146+ if tries < 0:
147+ sys.stderr.write('retry limit caught, failing...\n')
148+ time.sleep(time_between)
149
150
151 #############################################################
152@@ -83,7 +103,10 @@
153 # Validate connectivity from $WORLD
154 #############################################################
155 def validate_world_connectivity():
156- client = MongoClient(d.sentry.unit['mongos/0'].info['public-address'])
157+ pubaddy = d.sentry['mongos'][0].info['public-address']
158+ if ":" in pubaddy:
159+ pubaddy = "[{}]".format(pubaddy)
160+ client = MongoClient(pubaddy)
161
162 db = client['test']
163 # Can we successfully insert?
164@@ -101,23 +124,28 @@
165 #############################################################
166 # broken pending 1273312
167 def validate_relationships():
168- d.sentry.unit['configsvr/0'].relation('configsvr', 'mongos:mongos-cfg')
169- d.sentry.unit['shard1/0'].relation('database', 'mongos:mongos')
170- d.sentry.unit['shard2/0'].relation('database', 'mongos:mongos')
171- print(d.sentry.unit['shard1/0'].relation('database', 'mongos:mongos'))
172+ d.sentry['configsvr'][0].relation('configsvr', 'mongos:mongos-cfg')
173+ d.sentry['shard1'][0].relation('database', 'mongos:mongos')
174+ d.sentry['shard2'][0].relation('database', 'mongos:mongos')
175+ print(d.sentry['shard1'][0].relation('database', 'mongos:mongos'))
176
177
178 def validate_manual_connection():
179- output, code = d.sentry.unit['shard1/0'].run("mongo {}".format(
180- d.sentry.unit['mongos/0'].info['public-address']))
181+ fmt = "mongo {}"
182+ addy = d.sentry['mongos'][0].info['public-address']
183+ if ":" in addy:
184+ fmt = "mongo --ipv6 {}:27017"
185+ jujuruncmd = fmt.format(addy)
186+ output, code = d.sentry['shard1'][0].run(jujuruncmd)
187 if code != 0:
188- message = "Manual Connection failed for unit shard1"
189+ message = ("Manual Connection failed for unit shard1:{} code:{} cmd:{}"
190+ .format(output, code, jujuruncmd))
191 amulet.raise_status(amulet.SKIP, msg=message)
192
193- output, code = d.sentry.unit['shard2/0'].run("mongo {}".format(
194- d.sentry.unit['mongos/0'].info['public-address']))
195+ output, code = d.sentry['shard2'][0].run(jujuruncmd)
196 if code != 0:
197- message = "Manual Connection failed for unit shard2"
198+ message = ("Manual Connection failed for unit shard2:{} code:{} cmd:{}"
199+ .format(output, code, jujuruncmd))
200 amulet.raise_status(amulet.SKIP, msg=message)
201
202
203
204=== modified file 'tests/03_deploy_replicaset.py'
205--- tests/03_deploy_replicaset.py 2015-02-25 01:49:08 +0000
206+++ tests/03_deploy_replicaset.py 2015-12-07 22:34:32 +0000
207@@ -1,8 +1,11 @@
208 #!/usr/bin/env python3
209
210 import amulet
211+import sys
212+import time
213+import traceback
214 import requests
215-import time
216+import pymongo
217 from pymongo import MongoClient
218 from collections import Counter
219
220@@ -13,9 +16,9 @@
221 scale = 3
222 seconds = 1800
223
224-# amount of time to wait before testing for replicaset
225+# max amount of time to wait before testing for replicaset
226 # status
227-wait_for_replicaset = 15
228+wait_for_replicaset = 600
229
230 #########################################################
231 # 3shard cluster configuration
232@@ -36,9 +39,9 @@
233 raise
234
235 sentry_dict = {
236- 'mongodb0-sentry': d.sentry.unit['mongodb/0'],
237- 'mongodb1-sentry': d.sentry.unit['mongodb/1'],
238- 'mongodb2-sentry': d.sentry.unit['mongodb/2'],
239+ 'mongodb0-sentry': d.sentry['mongodb'][0],
240+ 'mongodb1-sentry': d.sentry['mongodb'][1],
241+ 'mongodb2-sentry': d.sentry['mongodb'][2],
242 }
243
244
245@@ -46,9 +49,11 @@
246 # Check presence of MongoDB GUI HEALTH Status
247 #############################################################
248 def validate_status_interface():
249- r = requests.get("http://{}:28017".format(
250- d.sentry.unit['mongodb/0'].info['public-address']),
251- verify=False)
252+ pubaddy = d.sentry['mongodb'][0].info['public-address']
253+ fmt = "http://{}:28017"
254+ if ":" in pubaddy:
255+ fmt = "http://[{}]:28017"
256+ r = requests.get(fmt.format(pubaddy), verify=False)
257 r.raise_for_status
258
259
260@@ -70,24 +75,47 @@
261 #############################################################
262 def validate_replicaset_setup():
263
264- time.sleep(wait_for_replicaset)
265+ d.sentry.wait(seconds)
266
267 unit_status = []
268+ time_between = 10
269+ tries = wait_for_replicaset / time_between
270
271 for service in sentry_dict:
272- client = MongoClient(sentry_dict[service].info['public-address'])
273- r = client.admin.command('replSetGetStatus')
274+ addy = sentry_dict[service].info['public-address']
275+ if ":" in addy:
276+ addy = "[{}]".format(addy)
277+ while True:
278+ try:
279+ client = MongoClient(addy)
280+ r = client.admin.command('replSetGetStatus')
281+ break
282+ except pymongo.errors.OperationFailure as ex:
283+ sys.stderr.write(
284+ 'OperationFailure, sleep and retry... to {}: {}\n'.
285+ format(addy, ex))
286+ tb_lines = traceback.format_exception(ex.__class__,
287+ ex, ex.__traceback__)
288+ tb_text = ''.join(tb_lines)
289+ sys.stderr.write(tb_text)
290+ tries = tries - 1
291+ if tries < 0:
292+ sys.stderr.write('retry limit caught, failing...\n')
293+ break
294+ time.sleep(time_between)
295 unit_status.append(r['myState'])
296 client.close()
297
298 primaries = Counter(unit_status)[1]
299 if primaries != 1:
300- message = "Only one PRIMARY unit allowed! Found: %s" % (primaries)
301+ message = "Only one PRIMARY unit allowed! Found: %s %s" % (primaries,
302+ unit_status)
303 amulet.raise_status(amulet.FAIL, message)
304
305 secondrs = Counter(unit_status)[2]
306 if secondrs != 2:
307- message = "Only two SECONDARY units allowed! (Found %s)" % (secondrs)
308+ message = ("Only two SECONDARY units allowed! (Found %s) %s" %
309+ (secondrs, unit_status))
310 amulet.raise_status(amulet.FAIL, message)
311
312
313@@ -95,11 +123,37 @@
314 # Validate connectivity from $WORLD
315 #############################################################
316 def validate_world_connectivity():
317- client = MongoClient(d.sentry.unit['mongodb/0'].info['public-address'])
318-
319- db = client['test']
320- # Can we successfully insert?
321- insert_id = db.amulet.insert({'assert': True})
322+ d.sentry['mongodb']
323+ ordered_units = sorted(d.sentry['mongodb'], key=lambda u: u.info['unit'])
324+ # We assume minimum unit number is master.
325+ addy = ordered_units[0].info['public-address']
326+ if ":" in addy:
327+ addy = "[{}]".format(addy)
328+
329+ time_between = 10
330+ tries = wait_for_replicaset / time_between
331+ insert_id = None
332+ while True:
333+ try:
334+ client = MongoClient(addy)
335+ db = client.test
336+ # Can we successfully insert?
337+ insert_id = db.amulet.insert({'assert': True})
338+ break
339+ except pymongo.errors.AutoReconnect as ex:
340+ sys.stderr.write(
341+ 'AutoReconnect error, sleep and retry... to {}: {}\n'.
342+ format(addy, ex))
343+ tb_lines = traceback.format_exception(ex.__class__,
344+ ex, ex.__traceback__)
345+ tb_text = ''.join(tb_lines)
346+ sys.stderr.write(tb_text)
347+ tries = tries - 1
348+ if tries < 0:
349+ sys.stderr.write('retry limit caught, failing...\n')
350+ break
351+ time.sleep(time_between)
352+
353 if insert_id is None:
354 amulet.raise_status(amulet.FAIL, msg="Failed to insert test data")
355 # Can we delete from a shard using the Mongos hub?
356
357=== modified file 'tests/04_deploy_with_storage.py'
358--- tests/04_deploy_with_storage.py 2015-06-02 05:33:09 +0000
359+++ tests/04_deploy_with_storage.py 2015-12-07 22:34:32 +0000
360@@ -1,7 +1,6 @@
361 #!/usr/bin/env python3
362
363 import amulet
364-import time
365 from pymongo import MongoClient
366 from collections import Counter
367
368@@ -14,16 +13,17 @@
369
370 # amount of time to wait before testing for replicaset
371 # status
372-wait_for_replicaset = 30
373+wait_for_replicaset = 60*5
374 # amount of time to wait for the data relation
375-wait_for_relation = 60*2
376+wait_for_relation = 60*5
377
378 #########################################################
379 # 3shard cluster configuration
380 #########################################################
381 d = amulet.Deployment(series='trusty')
382
383-d.add('mongodb', units=scale, series='trusty')
384+d.add('mongodb', units=scale, series='trusty',
385+ constraints={'root-disk': '20480M'})
386 d.add('storage', charm='cs:~chris-gondolin/trusty/storage-5', series='trusty')
387 d.configure('storage', {'provider': 'local'})
388
389@@ -32,16 +32,17 @@
390 # Perform the setup for the deployment.
391 try:
392 d.setup(seconds)
393- d.sentry.wait(seconds)
394+ d.sentry.wait(wait_for_replicaset)
395 except amulet.helpers.TimeoutError:
396 message = 'The environment did not setup in %d seconds.', seconds
397 amulet.raise_status(amulet.SKIP, msg=message)
398 except:
399 raise
400
401+ordered_units = sorted(d.sentry['mongodb'], key=lambda u: u.info['unit'])
402 sentry_dict = {
403- 'mongodb0-sentry': d.sentry.unit['mongodb/0'],
404- 'mongodb1-sentry': d.sentry.unit['mongodb/1'],
405+ 'mongodb0-sentry': ordered_units[0],
406+ 'mongodb1-sentry': ordered_units[1]
407 }
408
409
410@@ -57,12 +58,15 @@
411 #############################################################
412 def validate_replicaset_setup():
413
414- time.sleep(wait_for_replicaset)
415+ d.sentry.wait(seconds)
416
417 unit_status = []
418
419 for service in sentry_dict:
420- client = MongoClient(sentry_dict[service].info['public-address'])
421+ addy = sentry_dict[service].info['public-address']
422+ if ":" in addy:
423+ addy = "[{}]".format(addy)
424+ client = MongoClient(addy)
425 r = client.admin.command('replSetGetStatus')
426 unit_status.append(r['myState'])
427 client.close()
428@@ -81,7 +85,10 @@
429 validate_status()
430 validate_replicaset_setup()
431 print("Adding storage relation, and sleeping for 2 min.")
432-d.relate('mongodb:data', 'storage:data')
433-time.sleep(wait_for_relation)
434+try:
435+ d.relate('mongodb:data', 'storage:data')
436+except OSError as e:
437+ print("ignoring error:{}", e)
438+d.sentry.wait(wait_for_relation)
439 validate_status()
440 validate_replicaset_setup()
441
442=== modified file 'tests/50_relate_ceilometer_test.py'
443--- tests/50_relate_ceilometer_test.py 2014-12-09 23:36:06 +0000
444+++ tests/50_relate_ceilometer_test.py 2015-12-07 22:34:32 +0000
445@@ -32,10 +32,13 @@
446 getattr(self, test)()
447
448 def test_mongo_relation(self):
449- unit = self.deploy.sentry.unit['ceilometer/0']
450- mongo = self.deploy.sentry.unit['mongodb/0'].info['public-address']
451+ unit = self.deploy.sentry['ceilometer'][0]
452+ mongo = self.deploy.sentry['mongodb'][0].info['public-address']
453+ mongo_reladdr = self.deploy.sentry['mongodb'][0].relation(
454+ 'database', 'ceilometer:shared-db')
455 cont = unit.file_contents('/etc/ceilometer/ceilometer.conf')
456- if mongo not in cont:
457+ if (mongo not in cont and mongo_reladdr.get(
458+ 'hostname', 'I SURE HOPE NOT') not in cont):
459 amulet.raise_status(amulet.FAIL, "Unable to verify ceilometer cfg")
460
461 if __name__ == '__main__':

Subscribers

People subscribed via source and target branches