summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoffrey F <joffrey@docker.com>2016-08-03 18:00:29 -0700
committerJoffrey F <joffrey@docker.com>2016-08-03 18:00:29 -0700
commit1f055796a8992da041280401025792cc8fb22336 (patch)
tree123fb2872bc5622128522988d3154c67f1b60659
parent07563cfe3f565b57b955455d2ce2b350ed34883b (diff)
downloaddocker-py-1f055796a8992da041280401025792cc8fb22336.tar.gz
Add new init_swarm test with custom spec
Signed-off-by: Joffrey F <joffrey@docker.com>
-rw-r--r--docker/utils/types.py4
-rw-r--r--tests/integration/swarm_test.py14
2 files changed, 15 insertions, 3 deletions
diff --git a/docker/utils/types.py b/docker/utils/types.py
index b970114..725c8c8 100644
--- a/docker/utils/types.py
+++ b/docker/utils/types.py
@@ -108,8 +108,8 @@ class SwarmSpec(DictType):
self['Orchestration'] = {
'TaskHistoryRetentionLimit': task_history_retention_limit
}
- if any(snapshot_interval, keep_old_snapshots,
- log_entries_for_slow_followers, heartbeat_tick, election_tick):
+ if any([snapshot_interval, keep_old_snapshots,
+ log_entries_for_slow_followers, heartbeat_tick, election_tick]):
self['Raft'] = {
'SnapshotInterval': snapshot_interval,
'KeepOldSnapshots': keep_old_snapshots,
diff --git a/tests/integration/swarm_test.py b/tests/integration/swarm_test.py
index 734d470..969e05e 100644
--- a/tests/integration/swarm_test.py
+++ b/tests/integration/swarm_test.py
@@ -29,7 +29,7 @@ class SwarmTest(helpers.BaseTestCase):
@requires_api_version('1.24')
def test_init_swarm_force_new_cluster(self):
- pytest.skip('Test stalls the engine on 1.12')
+ pytest.skip('Test stalls the engine on 1.12.0')
assert self.client.init_swarm('eth0')
version_1 = self.client.inspect_swarm()['Version']['Index']
@@ -44,6 +44,18 @@ class SwarmTest(helpers.BaseTestCase):
self.client.init_swarm('eth0')
@requires_api_version('1.24')
+ def test_init_swarm_custom_raft_spec(self):
+ spec = self.client.create_swarm_spec(
+ snapshot_interval=5000, log_entries_for_slow_followers=1200
+ )
+ assert self.client.init_swarm(
+ advertise_addr='eth0', swarm_spec=spec
+ )
+ swarm_info = self.client.inspect_swarm()
+ assert swarm_info['Spec']['Raft']['SnapshotInterval'] == 5000
+ assert swarm_info['Spec']['Raft']['LogEntriesForSlowFollowers'] == 1200
+
+ @requires_api_version('1.24')
def test_leave_swarm(self):
assert self.client.init_swarm('eth0')
with pytest.raises(docker.errors.APIError) as exc_info: