summaryrefslogtreecommitdiff
path: root/unit_tests
diff options
authorbilly.olsen@canonical.com <>2016-05-05 10:08:05 -0700
committerbilly.olsen@canonical.com <>2016-05-05 10:08:05 -0700
commita71bc020ec12f543e8aaa0671c16c9b96e0ae7ca (patch)
tree1118938cb5c3323894bf8d36b2b73acdcb6028be /unit_tests
parent87079a1babd0143bba4f5a5eca60470399061e89 (diff)
Move parameter logic from altering init conf file to the /etc/mongodb.conf
file. The mongdob service is already configured to read parameters from the /etc/mongodb.conf file and moving the configuration options inside the config file allows the systemd style service to start properly. Also, as of MongoDB 2.6, the specification of master/slave flags on startup is not allowed to be specified with the replicaset flags. This change allows for the master/slave flag to be specified in the /etc/mongodb.conf file only when the replica-set (peer) relation has not been established. Closes-Bug: #1513094
Diffstat (limited to 'unit_tests')
-rw-r--r--unit_tests/test_hooks.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/unit_tests/test_hooks.py b/unit_tests/test_hooks.py
index 4573b2c..85331f7 100644
--- a/unit_tests/test_hooks.py
+++ b/unit_tests/test_hooks.py
@@ -3,6 +3,7 @@ from mock import patch, call
import hooks
from test_utils import CharmTestCase
+from test_utils import mock_open
from pymongo.errors import OperationFailure
from subprocess import CalledProcessError
@@ -339,3 +340,20 @@ class MongoHooksTest(CharmTestCase):
call1 = call('juju-local:27017', 'juju-remote:27017')
mock_leave_replset.assert_has_calls([call1])
+
+ def test_get_current_mongo_config(self):
+ test_config = u"""
+ # Comment
+ key = value
+ one=two
+
+ three =four
+ """
+ expected = {
+ 'key': 'value',
+ 'one': 'two',
+ 'three': 'four'
+ }
+ with mock_open('/etc/mongodb.conf', test_config):
+ results = hooks.get_current_mongo_config()
+ self.assertEqual(results, expected)