11import os
22
33import yaml
4- from integration .failover .utils import (get_etcd2_failover_info ,
5- get_eventual_failover_info ,
4+ from integration .failover .utils import (get_common_failover_info ,
5+ get_etcd2_failover_info ,
66 get_stateboard_failover_info )
77from utils import run_command_and_get_output
88
@@ -22,6 +22,8 @@ def test_default_app_stateboard_failover(cartridge_cmd, project_with_topology_an
2222 'failover_timeout' : 20 ,
2323 'fencing_pause' : 2 ,
2424 'fencing_timeout' : 10 ,
25+ 'autoreturn_delay' : 300 ,
26+ 'leader_autoreturn' : False ,
2527 'tarantool_params' : {
2628 'uri' : 'localhost:4401' , 'password' : '******'
2729 },
@@ -42,7 +44,7 @@ def test_setup_eventual_failover(cartridge_cmd, project_with_topology_and_vshard
4244 assert rc == 0
4345 assert "Failover configured successfully" in output
4446
45- failover_info = get_eventual_failover_info ()
47+ failover_info = get_common_failover_info ()
4648 assert failover_info == {
4749 # Because this parameter (fencing_enabled) suitable in
4850 # stateful mode only - and we don't check it
@@ -54,6 +56,33 @@ def test_setup_eventual_failover(cartridge_cmd, project_with_topology_and_vshard
5456 }
5557
5658
59+ def test_setup_raft_failover (cartridge_cmd , project_with_topology_and_vshard ):
60+ project = project_with_topology_and_vshard
61+
62+ cmd = [
63+ cartridge_cmd , "failover" , "set" , "raft" , "--params" ,
64+ "{\" fencing_enabled\" : true, \" failover_timeout\" : 30, \" fencing_pause\" : 140, \" fencing_timeout\" : 15}" ,
65+ ]
66+
67+ rc , output = run_command_and_get_output (cmd , cwd = project .path )
68+ if rc == 0 :
69+ assert "Failover configured successfully" in output
70+
71+ failover_info = get_common_failover_info ()
72+ assert failover_info == {
73+ # Because this parameter (fencing_enabled) suitable in
74+ # stateful mode only - and we don't check it
75+ 'fencing_enabled' : False ,
76+ 'failover_timeout' : 30 ,
77+ 'fencing_pause' : 140 ,
78+ 'fencing_timeout' : 15 ,
79+ 'mode' : 'raft' ,
80+ }
81+ else :
82+ assert "Your Tarantool version doesn't support raft failover mode, " + \
83+ "need Tarantool 2.10 or higher" in output
84+
85+
5786def test_setup_etcd2_failover (cartridge_cmd , project_with_topology_and_vshard ):
5887 project = project_with_topology_and_vshard
5988
@@ -76,6 +105,8 @@ def test_setup_etcd2_failover(cartridge_cmd, project_with_topology_and_vshard):
76105 'fencing_timeout' : 12 ,
77106 'mode' : 'stateful' ,
78107 'state_provider' : 'etcd2' ,
108+ 'autoreturn_delay' : 300 ,
109+ 'leader_autoreturn' : False ,
79110 'etcd2_params' : {
80111 'endpoints' : ['http://127.0.0.1:4001' , 'http://127.0.0.1:2379' ],
81112 'lock_delay' : 15 ,
@@ -97,7 +128,7 @@ def test_failover_disabled_command(cartridge_cmd, project_with_topology_and_vsha
97128 assert rc == 0
98129 assert "Failover disabled successfully" in output
99130
100- failover_info = get_eventual_failover_info ()["mode" ]
131+ failover_info = get_common_failover_info ()["mode" ]
101132 assert failover_info == "disabled"
102133
103134
@@ -113,7 +144,7 @@ def test_disable_failover_from_sub_command(cartridge_cmd, project_with_topology_
113144 assert rc == 0
114145 assert "Failover disabled successfully" in output
115146
116- failover_info = get_eventual_failover_info ()
147+ failover_info = get_common_failover_info ()
117148 assert failover_info == {
118149 'fencing_enabled' : False ,
119150 'failover_timeout' : 31 ,
@@ -130,7 +161,7 @@ def test_disable_failover_from_sub_command(cartridge_cmd, project_with_topology_
130161 assert rc == 0
131162 assert "Failover configured successfully" in output
132163
133- failover_info = get_eventual_failover_info ()
164+ failover_info = get_common_failover_info ()
134165 assert failover_info == {
135166 'fencing_enabled' : False ,
136167 'failover_timeout' : 31 ,
@@ -150,7 +181,7 @@ def test_set_invalid_mode(cartridge_cmd, project_without_dependencies):
150181
151182 rc , output = run_command_and_get_output (cmd , cwd = project .path )
152183 assert rc == 1
153- assert "Failover mode should be `stateful`, `eventual` or `disabled`" in output
184+ assert "Failover mode should be `stateful`, `eventual`, `raft` or `disabled`" in output
154185
155186
156187def test_set_invalid_provider (cartridge_cmd , project_without_dependencies ):
0 commit comments