Kaydet (Commit) 1f055796 authored tarafından Joffrey F's avatar Joffrey F

Add new init_swarm test with custom spec

Signed-off-by: 's avatarJoffrey F <joffrey@docker.com>
üst 07563cfe
...@@ -108,8 +108,8 @@ class SwarmSpec(DictType): ...@@ -108,8 +108,8 @@ class SwarmSpec(DictType):
self['Orchestration'] = { self['Orchestration'] = {
'TaskHistoryRetentionLimit': task_history_retention_limit 'TaskHistoryRetentionLimit': task_history_retention_limit
} }
if any(snapshot_interval, keep_old_snapshots, if any([snapshot_interval, keep_old_snapshots,
log_entries_for_slow_followers, heartbeat_tick, election_tick): log_entries_for_slow_followers, heartbeat_tick, election_tick]):
self['Raft'] = { self['Raft'] = {
'SnapshotInterval': snapshot_interval, 'SnapshotInterval': snapshot_interval,
'KeepOldSnapshots': keep_old_snapshots, 'KeepOldSnapshots': keep_old_snapshots,
......
...@@ -29,7 +29,7 @@ class SwarmTest(helpers.BaseTestCase): ...@@ -29,7 +29,7 @@ class SwarmTest(helpers.BaseTestCase):
@requires_api_version('1.24') @requires_api_version('1.24')
def test_init_swarm_force_new_cluster(self): 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') assert self.client.init_swarm('eth0')
version_1 = self.client.inspect_swarm()['Version']['Index'] version_1 = self.client.inspect_swarm()['Version']['Index']
...@@ -43,6 +43,18 @@ class SwarmTest(helpers.BaseTestCase): ...@@ -43,6 +43,18 @@ class SwarmTest(helpers.BaseTestCase):
with pytest.raises(docker.errors.APIError): with pytest.raises(docker.errors.APIError):
self.client.init_swarm('eth0') 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') @requires_api_version('1.24')
def test_leave_swarm(self): def test_leave_swarm(self):
assert self.client.init_swarm('eth0') assert self.client.init_swarm('eth0')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment