roma 1.2.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG +44 -1
- data/Gemfile.lock +18 -15
- data/README.md +15 -1
- data/bin/consistency_test +10 -0
- data/bin/data_accumulation +11 -0
- data/lib/roma/async_process.rb +39 -2
- data/lib/roma/command/sys_command_receiver.rb +80 -0
- data/lib/roma/command/vn_command_receiver.rb +1 -1
- data/lib/roma/config.rb +1 -1
- data/lib/roma/plugin/plugin_storage.rb +105 -1
- data/lib/roma/romad.rb +13 -1
- data/lib/roma/routing/cb_rttable.rb +1 -1
- data/lib/roma/tools/consistency_test.rb +77 -0
- data/lib/roma/tools/data_accumulation.rb +64 -0
- data/lib/roma/version.rb +1 -1
- data/lib/roma/write_behind.rb +138 -1
- data/test/config4mhash.rb +1 -1
- data/test/config4storage_error.rb +1 -1
- data/test/config4test.rb +1 -1
- data/test/cpdbtest/config4cpdb_base.rb +1 -1
- data/test/optional_test/t_mkroute_rich.rb +44 -0
- data/test/optional_test/t_other_cpdb.rb +45 -0
- data/test/optional_test/t_other_database.rb +59 -0
- data/test/{t_routing_logic.rb → optional_test/t_routing_logic.rb} +1 -0
- data/test/roma-test-storage.rb +685 -0
- data/test/roma-test-utils.rb +24 -0
- data/test/run-test.rb +9 -0
- data/test/t_command_definition.rb +2 -0
- data/test/t_cpdata.rb +1 -0
- data/test/t_cpdb.rb +22 -34
- data/test/t_eventmachine.rb +1 -0
- data/test/t_listplugin.rb +2 -0
- data/test/t_logshift.rb +2 -4
- data/test/t_mapcountplugin.rb +48 -37
- data/test/t_mapplugin.rb +2 -0
- data/test/t_mhash.rb +2 -1
- data/test/t_new_func.rb +386 -0
- data/test/t_protocol.rb +66 -1
- data/test/t_rclient.rb +2 -0
- data/test/t_replication.rb +299 -0
- data/test/t_routing_data.rb +6 -5
- data/test/t_storage.rb +5 -740
- data/test/t_storage_error.rb +1 -0
- data/test/t_writebehind.rb +11 -2
- metadata +31 -19
data/test/t_mapplugin.rb
CHANGED
@@ -113,10 +113,12 @@ module MapPluginTests
|
|
113
113
|
end # MapPluginTests
|
114
114
|
|
115
115
|
class MapPluginTest < Test::Unit::TestCase
|
116
|
+
self.test_order = :defined
|
116
117
|
include MapPluginTests
|
117
118
|
end
|
118
119
|
|
119
120
|
class MapPluginTestForceForward < Test::Unit::TestCase
|
121
|
+
self.test_order = :defined
|
120
122
|
include MapPluginTests
|
121
123
|
|
122
124
|
def setup
|
data/test/t_mhash.rb
CHANGED
@@ -9,6 +9,7 @@ Roma::Client::RomaClient.class_eval do
|
|
9
9
|
end
|
10
10
|
|
11
11
|
class MHashTest < Test::Unit::TestCase
|
12
|
+
self.test_order = :defined
|
12
13
|
include RomaTestUtils
|
13
14
|
|
14
15
|
def setup
|
@@ -99,7 +100,7 @@ class MHashTest < Test::Unit::TestCase
|
|
99
100
|
assert_equal('STORED', @rc.set('roma', 'hname=test'))
|
100
101
|
assert_equal('hname=test', @rc.get('roma'))
|
101
102
|
|
102
|
-
# stop
|
103
|
+
# stop roma
|
103
104
|
stop_roma
|
104
105
|
|
105
106
|
# restart roma
|
data/test/t_new_func.rb
ADDED
@@ -0,0 +1,386 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'socket'
|
4
|
+
|
5
|
+
class NewFuncTest < Test::Unit::TestCase
|
6
|
+
self.test_order = :defined
|
7
|
+
include RomaTestUtils
|
8
|
+
|
9
|
+
def setup
|
10
|
+
start_roma
|
11
|
+
@sock = TCPSocket.new("localhost", 11211)
|
12
|
+
end
|
13
|
+
|
14
|
+
def teardown
|
15
|
+
@sock.close if @sock
|
16
|
+
stop_roma
|
17
|
+
rescue => e
|
18
|
+
puts "#{e} #{$@}"
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_jaro_winkler
|
22
|
+
@sock.write("staat\r\n")
|
23
|
+
assert_equal("", @sock.gets.chomp)
|
24
|
+
assert_equal("ERROR: 'staat' is not roma command.", @sock.gets.chomp)
|
25
|
+
assert_equal("Did you mean this?", @sock.gets.chomp)
|
26
|
+
assert_equal("\tstat", @sock.gets.chomp)
|
27
|
+
|
28
|
+
@sock.write("outingdump yaml\r\n")
|
29
|
+
assert_equal("", @sock.gets.chomp)
|
30
|
+
assert_equal("ERROR: 'outingdump' is not roma command.", @sock.gets.chomp)
|
31
|
+
assert_equal("Did you mean this?", @sock.gets.chomp)
|
32
|
+
assert_equal("\troutingdump", @sock.gets.chomp)
|
33
|
+
|
34
|
+
@sock.write("hoge\r\n")
|
35
|
+
assert_equal("ERROR: 'hoge' is not roma command. Please check command.", @sock.gets.chomp)
|
36
|
+
assert_equal("(closing telnet connection command is 'quit')", @sock.gets.chomp)
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_stat_log_level
|
40
|
+
@sock.write("stat log_level\r\n")
|
41
|
+
assert_equal("stats.log_level debug", @sock.gets.chomp)
|
42
|
+
assert_equal("END", @sock.gets.chomp)
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_stat_failover
|
46
|
+
@sock.write("stat failover\r\n")
|
47
|
+
assert_equal("routing.enabled_failover false", @sock.gets.chomp)
|
48
|
+
assert_equal("END", @sock.gets.chomp)
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_stat_secondary
|
52
|
+
@sock.write("stat secondary\r\n")
|
53
|
+
sleep 1
|
54
|
+
column, param = @sock.gets.chomp.split("\s")
|
55
|
+
assert_equal("routing.secondary1", column)
|
56
|
+
assert_equal(true, param.to_i > 0)
|
57
|
+
assert_equal("END", @sock.gets.chomp)
|
58
|
+
end
|
59
|
+
|
60
|
+
def test_shutdown_self_no
|
61
|
+
@sock.write("shutdown_self\r\n")
|
62
|
+
assert_equal("", @sock.gets.chomp)
|
63
|
+
assert_equal("=================================================================", @sock.gets.chomp)
|
64
|
+
assert_equal("CAUTION!!: ", @sock.gets.chomp)
|
65
|
+
assert_equal("\tThis command kill the instance!", @sock.gets.chomp)
|
66
|
+
assert_equal("\tThere is some possibility of occuring redundancy down!", @sock.gets.chomp)
|
67
|
+
assert_equal("=================================================================", @sock.gets.chomp)
|
68
|
+
assert_equal("", @sock.gets.chomp)
|
69
|
+
assert_equal("Are you sure to shutdown this instance?(yes/no)", @sock.gets.chomp)
|
70
|
+
|
71
|
+
@sock.write("no\r\n")
|
72
|
+
assert_nil(@sock.gets)
|
73
|
+
end
|
74
|
+
|
75
|
+
def test_get_key_info
|
76
|
+
@sock.write("set key1 0 0 4\r\nval1\r\n")
|
77
|
+
assert_equal("STORED", @sock.gets.chomp)
|
78
|
+
|
79
|
+
@sock.write("get_key_info key1\r\n")
|
80
|
+
assert_match(/^d = \d+ 0x\h+$/, @sock.gets.chomp)
|
81
|
+
assert_match(/^vn = \d+ 0x\h+$/, @sock.gets.chomp)
|
82
|
+
assert_match(/^nodes = \["localhost_1121[1|2]", "localhost_1121[1|2]"\]$/, @sock.gets.chomp)
|
83
|
+
assert_equal('END', @sock.gets.chomp)
|
84
|
+
end
|
85
|
+
|
86
|
+
def test_enabled_repetition_in_routing
|
87
|
+
@sock.write("enabled_repetition_in_routing?\r\n")
|
88
|
+
assert_equal("true", @sock.gets.chomp)
|
89
|
+
end
|
90
|
+
|
91
|
+
def test_switch_dns_caching
|
92
|
+
@sock.write("stat dns\r\n")
|
93
|
+
assert_equal("dns_caching false", @sock.gets.chomp)
|
94
|
+
assert_equal("END", @sock.gets.chomp)
|
95
|
+
|
96
|
+
@sock.write("switch_dns_caching on \r\n")
|
97
|
+
assert_equal('{"localhost_11212"=>"ENABLED", "localhost_11211"=>"ENABLED"}', @sock.gets.chomp)
|
98
|
+
@sock.write("stat dns\r\n")
|
99
|
+
assert_equal("dns_caching true", @sock.gets.chomp)
|
100
|
+
assert_equal("END", @sock.gets.chomp)
|
101
|
+
|
102
|
+
@sock.write("switch_dns_caching off \r\n")
|
103
|
+
assert_equal('{"localhost_11212"=>"DISABLED", "localhost_11211"=>"DISABLED"}', @sock.gets.chomp)
|
104
|
+
@sock.write("stat dns\r\n")
|
105
|
+
assert_equal("dns_caching false", @sock.gets.chomp)
|
106
|
+
assert_equal("END", @sock.gets.chomp)
|
107
|
+
|
108
|
+
@sock.write("switch_dns_caching off \r\n")
|
109
|
+
assert_equal('{"localhost_11212"=>"DISABLED", "localhost_11211"=>"DISABLED"}', @sock.gets.chomp)
|
110
|
+
@sock.write("stat dns\r\n")
|
111
|
+
assert_equal("dns_caching false", @sock.gets.chomp)
|
112
|
+
assert_equal("END", @sock.gets.chomp)
|
113
|
+
end
|
114
|
+
|
115
|
+
def test_nid_brank
|
116
|
+
@sock.write("stat sub\r\n")
|
117
|
+
assert_equal('routing.sub_nid {}', @sock.gets.chomp)
|
118
|
+
assert_equal('END', @sock.gets.chomp)
|
119
|
+
@sock.write("routingdump yaml\r\n")
|
120
|
+
dump = []
|
121
|
+
while select [@sock], nil, nil, 0.5
|
122
|
+
dump << @sock.gets.chomp!
|
123
|
+
end
|
124
|
+
assert_equal(true, dump.grep(/vm/).empty?)
|
125
|
+
end
|
126
|
+
|
127
|
+
def test_add_rttable_sub_nid
|
128
|
+
@sock.write("stat sub\r\n")
|
129
|
+
assert_equal('routing.sub_nid {}', @sock.gets.chomp)
|
130
|
+
assert_equal('END', @sock.gets.chomp)
|
131
|
+
|
132
|
+
@sock.write("add_rttable_sub_nid 127.0.0.0/24 localhost vm\r\n")
|
133
|
+
assert_equal('{"localhost_11212"=>"ADDED", "localhost_11211"=>"ADDED"}', @sock.gets.chomp)
|
134
|
+
|
135
|
+
@sock.write("stat sub\r\n")
|
136
|
+
assert_equal('routing.sub_nid {"127.0.0.0/24"=>{:regexp=>"localhost", :replace=>"vm"}}', @sock.gets.chomp)
|
137
|
+
assert_equal('END', @sock.gets.chomp)
|
138
|
+
|
139
|
+
@sock.write("routingdump yaml\r\n")
|
140
|
+
dump = []
|
141
|
+
while select [@sock], nil, nil, 0.5
|
142
|
+
dump << @sock.gets.chomp!
|
143
|
+
end
|
144
|
+
assert_equal(false, dump.grep(/vm/).empty?)
|
145
|
+
end
|
146
|
+
|
147
|
+
def test_delete_rttable_sub_nid
|
148
|
+
@sock.write("add_rttable_sub_nid 127.0.0.0/24 localhost vm\r\n")
|
149
|
+
assert_equal('{"localhost_11212"=>"ADDED", "localhost_11211"=>"ADDED"}', @sock.gets.chomp)
|
150
|
+
|
151
|
+
@sock.write("delete_rttable_sub_nid 111.22.33.44/24\r\n")
|
152
|
+
assert_equal('{"localhost_11212"=>"NOT_FOUND", "localhost_11211"=>"NOT_FOUND"}', @sock.gets.chomp)
|
153
|
+
|
154
|
+
@sock.write("delete_rttable_sub_nid 127.0.0.0/24\r\n")
|
155
|
+
assert_equal('{"localhost_11212"=>"DELETED", "localhost_11211"=>"DELETED"}', @sock.gets.chomp)
|
156
|
+
|
157
|
+
@sock.write("stat sub\r\n")
|
158
|
+
assert_equal('routing.sub_nid {}', @sock.gets.chomp)
|
159
|
+
assert_equal('END', @sock.gets.chomp)
|
160
|
+
|
161
|
+
@sock.write("routingdump yaml\r\n")
|
162
|
+
dump = []
|
163
|
+
while select [@sock], nil, nil, 0.5
|
164
|
+
dump << @sock.gets.chomp!
|
165
|
+
end
|
166
|
+
assert_equal(true, dump.grep(/vm/).empty?)
|
167
|
+
end
|
168
|
+
|
169
|
+
def test_clear_rttable_sub_nid
|
170
|
+
@sock.write("add_rttable_sub_nid 127.0.0.0/24 localhost vm\r\n")
|
171
|
+
assert_equal('{"localhost_11212"=>"ADDED", "localhost_11211"=>"ADDED"}', @sock.gets.chomp)
|
172
|
+
|
173
|
+
@sock.write("clear_rttable_sub_nid\r\n")
|
174
|
+
assert_equal('{"localhost_11212"=>"CLEARED", "localhost_11211"=>"CLEARED"}', @sock.gets.chomp)
|
175
|
+
|
176
|
+
@sock.write("stat sub\r\n")
|
177
|
+
assert_equal('routing.sub_nid {}', @sock.gets.chomp)
|
178
|
+
assert_equal('END', @sock.gets.chomp)
|
179
|
+
|
180
|
+
@sock.write("routingdump yaml\r\n")
|
181
|
+
dump = []
|
182
|
+
while select [@sock], nil, nil, 0.5
|
183
|
+
dump << @sock.gets.chomp!
|
184
|
+
end
|
185
|
+
assert_equal(true, dump.grep(/vm/).empty?)
|
186
|
+
end
|
187
|
+
|
188
|
+
def test_stat_latency
|
189
|
+
@sock.write("stat latency\r\n")
|
190
|
+
assert_equal("stats.hilatency_warn_time 5.0", @sock.gets.chomp)
|
191
|
+
assert_equal("stats.latency_log false", @sock.gets.chomp)
|
192
|
+
assert_equal('stats.latency_check_cmd ["get", "set", "delete"]', @sock.gets.chomp)
|
193
|
+
assert_equal("stats.latency_check_time_count false", @sock.gets.chomp)
|
194
|
+
end
|
195
|
+
|
196
|
+
def test_del_latency_avg_calc_cmd
|
197
|
+
@sock.write("del_latency_avg_calc_cmd set delete\r\n")
|
198
|
+
assert_equal('{"localhost_11212"=>"DELETED", "localhost_11211"=>"DELETED"}', @sock.gets.chomp)
|
199
|
+
@sock.write("stat latency_check_cmd\r\n")
|
200
|
+
assert_equal('stats.latency_check_cmd ["get"]', @sock.gets.chomp)
|
201
|
+
assert_equal('END', @sock.gets.chomp)
|
202
|
+
end
|
203
|
+
|
204
|
+
def test_add_latency_avg_calc_cmd
|
205
|
+
@sock.write("add_latency_avg_calc_cmd add\r\n")
|
206
|
+
assert_equal('{"localhost_11212"=>"SET", "localhost_11211"=>"SET"}', @sock.gets.chomp)
|
207
|
+
@sock.write("stat latency_check_cmd\r\n")
|
208
|
+
assert_equal('stats.latency_check_cmd ["get", "set", "delete", "add"]', @sock.gets.chomp)
|
209
|
+
assert_equal('END', @sock.gets.chomp)
|
210
|
+
|
211
|
+
@sock.write("add_latency_avg_calc_cmd get\r\n")
|
212
|
+
assert_equal('ALREADY SET [get] command', @sock.gets.chomp)
|
213
|
+
@sock.write("stat latency_check_cmd\r\n")
|
214
|
+
assert_equal('stats.latency_check_cmd ["get", "set", "delete", "add"]', @sock.gets.chomp)
|
215
|
+
assert_equal('END', @sock.gets.chomp)
|
216
|
+
|
217
|
+
@sock.write("add_latency_avg_calc_cmd balse\r\n")
|
218
|
+
assert_equal('NOT SUPPORT [balse] command', @sock.gets.chomp)
|
219
|
+
@sock.write("stat latency_check_cmd\r\n")
|
220
|
+
assert_equal('stats.latency_check_cmd ["get", "set", "delete", "add"]', @sock.gets.chomp)
|
221
|
+
assert_equal('END', @sock.gets.chomp)
|
222
|
+
end
|
223
|
+
|
224
|
+
def test_chg_latency_avg_calc_time_count
|
225
|
+
@sock.write("chg_latency_avg_calc_time_count 60\r\n")
|
226
|
+
assert_equal('{"localhost_11212"=>"CHANGED", "localhost_11211"=>"CHANGED"}', @sock.gets.chomp)
|
227
|
+
@sock.write("stat latency_check_time_count\r\n")
|
228
|
+
assert_equal('stats.latency_check_time_count 60', @sock.gets.chomp)
|
229
|
+
assert_equal('END', @sock.gets.chomp)
|
230
|
+
|
231
|
+
@sock.write("chg_latency_avg_calc_time_count nil\r\n")
|
232
|
+
assert_equal('{"localhost_11212"=>"CHANGED", "localhost_11211"=>"CHANGED"}', @sock.gets.chomp)
|
233
|
+
@sock.write("stat latency_check_time_count\r\n")
|
234
|
+
assert_equal('stats.latency_check_time_count false', @sock.gets.chomp)
|
235
|
+
assert_equal('END', @sock.gets.chomp)
|
236
|
+
end
|
237
|
+
|
238
|
+
def test_set_latency_avg_calc_rule
|
239
|
+
@sock.write("set_latency_avg_calc_rule off\r\n")
|
240
|
+
assert_equal('{"localhost_11212"=>"DEACTIVATED", "localhost_11211"=>"DEACTIVATED"}', @sock.gets.chomp)
|
241
|
+
@sock.write("stat latency\r\n")
|
242
|
+
assert_equal("stats.hilatency_warn_time 5.0", @sock.gets.chomp)
|
243
|
+
assert_equal("stats.latency_log false", @sock.gets.chomp)
|
244
|
+
assert_equal('stats.latency_check_cmd []', @sock.gets.chomp)
|
245
|
+
assert_equal("stats.latency_check_time_count false", @sock.gets.chomp)
|
246
|
+
assert_equal("END", @sock.gets.chomp)
|
247
|
+
|
248
|
+
@sock.write("set_latency_avg_calc_rule on 30 get set\r\n")
|
249
|
+
assert_equal('{"localhost_11212"=>"ACTIVATED", "localhost_11211"=>"ACTIVATED"}', @sock.gets.chomp)
|
250
|
+
@sock.write("stat latency\r\n")
|
251
|
+
assert_equal("stats.hilatency_warn_time 5.0", @sock.gets.chomp)
|
252
|
+
assert_equal("stats.latency_log true", @sock.gets.chomp)
|
253
|
+
assert_equal('stats.latency_check_cmd ["get", "set"]', @sock.gets.chomp)
|
254
|
+
assert_equal("stats.latency_check_time_count 30", @sock.gets.chomp)
|
255
|
+
assert_equal("END", @sock.gets.chomp)
|
256
|
+
end
|
257
|
+
|
258
|
+
def test_auto_recover_stat
|
259
|
+
@sock.write("stat recover\r\n")
|
260
|
+
assert_equal("stats.run_recover false", @sock.gets.chomp)
|
261
|
+
assert_equal("routing.auto_recover false", @sock.gets.chomp)
|
262
|
+
assert_equal("routing.auto_recover_status waiting", @sock.gets.chomp)
|
263
|
+
assert_equal("routing.auto_recover_time 1800", @sock.gets.chomp)
|
264
|
+
assert_equal("END", @sock.gets.chomp)
|
265
|
+
end
|
266
|
+
|
267
|
+
def test_set_auto_recover
|
268
|
+
@sock.write("set_auto_recover true\r\n")
|
269
|
+
assert_equal('{"localhost_11212"=>"STORED", "localhost_11211"=>"STORED"}', @sock.gets.chomp)
|
270
|
+
|
271
|
+
@sock.write("stat auto_recover\r\n")
|
272
|
+
assert_equal("routing.auto_recover true", @sock.gets.chomp)
|
273
|
+
assert_equal("routing.auto_recover_status waiting", @sock.gets.chomp)
|
274
|
+
assert_equal("routing.auto_recover_time 1800", @sock.gets.chomp)
|
275
|
+
assert_equal("END", @sock.gets.chomp)
|
276
|
+
|
277
|
+
@sock.write("set_auto_recover true 180\r\n")
|
278
|
+
assert_equal('{"localhost_11212"=>"STORED", "localhost_11211"=>"STORED"}', @sock.gets.chomp)
|
279
|
+
|
280
|
+
@sock.write("stat auto_recover\r\n")
|
281
|
+
assert_equal("routing.auto_recover true", @sock.gets.chomp)
|
282
|
+
assert_equal("routing.auto_recover_status waiting", @sock.gets.chomp)
|
283
|
+
assert_equal("routing.auto_recover_time 180", @sock.gets.chomp)
|
284
|
+
assert_equal("END", @sock.gets.chomp)
|
285
|
+
|
286
|
+
@sock.write("set_auto_recover false\n")
|
287
|
+
assert_equal('{"localhost_11212"=>"STORED", "localhost_11211"=>"STORED"}', @sock.gets.chomp)
|
288
|
+
|
289
|
+
@sock.write("stat auto_recover\r\n")
|
290
|
+
assert_equal("routing.auto_recover false", @sock.gets.chomp)
|
291
|
+
assert_equal("routing.auto_recover_status waiting", @sock.gets.chomp)
|
292
|
+
assert_equal("routing.auto_recover_time 180", @sock.gets.chomp)
|
293
|
+
assert_equal("END", @sock.gets.chomp)
|
294
|
+
end
|
295
|
+
|
296
|
+
def test_stat_trans_timeout
|
297
|
+
@sock.write("stat trans\r\n")
|
298
|
+
assert_equal("stats.routing_trans_timeout 10800", @sock.gets.chomp)
|
299
|
+
assert_equal("END", @sock.gets.chomp)
|
300
|
+
end
|
301
|
+
|
302
|
+
def test_set_routing_trans_timeout
|
303
|
+
@sock.write("set_routing_trans_timeout 1\r\n")
|
304
|
+
assert_equal('{"localhost_11212"=>"STORED", "localhost_11211"=>"STORED"}', @sock.gets.chomp)
|
305
|
+
@sock.write("stat trans\r\n")
|
306
|
+
assert_equal("stats.routing_trans_timeout 1.0", @sock.gets.chomp)
|
307
|
+
assert_equal("END", @sock.gets.chomp)
|
308
|
+
end
|
309
|
+
|
310
|
+
def test_stat_routing_event
|
311
|
+
@sock.write("stat routing.event\r\n")
|
312
|
+
assert_equal('routing.event []', @sock.gets.chomp)
|
313
|
+
assert_equal('routing.event_limit_line 1000', @sock.gets.chomp)
|
314
|
+
assert_equal('END', @sock.gets.chomp)
|
315
|
+
end
|
316
|
+
|
317
|
+
def test_add_routing_event
|
318
|
+
@sock.write("switch_failover on\r\n")
|
319
|
+
assert_equal('{"localhost_11212"=>"ENABLED", "localhost_11211"=>"ENABLED"}', @sock.gets.chomp)
|
320
|
+
|
321
|
+
stop_roma_node('localhost_11212')
|
322
|
+
sleep 5 # wait failover
|
323
|
+
|
324
|
+
@sock.write("stat routing.event$\r\n")
|
325
|
+
assert_match(/routing\.event \["[-T\d:\.]+ leave localhost_11212"\]/, @sock.gets.chomp)
|
326
|
+
assert_equal('END', @sock.gets.chomp)
|
327
|
+
end
|
328
|
+
|
329
|
+
def test_adm_tool_sendcmd
|
330
|
+
res = `#{bin_dir}/roma-adm`
|
331
|
+
assert_equal('Argument Error: roma-adm [adm-command] [port No.]', res.chomp)
|
332
|
+
|
333
|
+
res = `#{bin_dir}/roma-adm -h`
|
334
|
+
assert_match(/usage:roma-adm \[command\] \[port No.\]\n\s+-h, --help\s+Show this message/, res.chomp)
|
335
|
+
|
336
|
+
res = `#{bin_dir}/roma-adm whoami 11211`
|
337
|
+
assert_equal(".\r\nROMA", res.chomp)
|
338
|
+
end
|
339
|
+
|
340
|
+
def test_romad_option
|
341
|
+
res = `#{bin_dir}/romad -h`
|
342
|
+
assert_equal("usage:romad [options] address
|
343
|
+
-d, --daemon
|
344
|
+
-j, --join [address:port]
|
345
|
+
-p, --port [PORT]
|
346
|
+
--verbose
|
347
|
+
-n, --name [name]
|
348
|
+
--enabled_repeathost Allow redundancy to same host
|
349
|
+
--replication_in_host Allow redundancy to same host
|
350
|
+
--disabled_cmd_protect Command protection disable while starting
|
351
|
+
--config [file path of the config.rb]
|
352
|
+
-h, --help Show this message
|
353
|
+
-v, --version Show version", res.chomp)
|
354
|
+
end
|
355
|
+
|
356
|
+
def test_check_tc_flag
|
357
|
+
stop_roma
|
358
|
+
res = `#{bin_dir}/check_tc_flag -h`
|
359
|
+
assert_equal("usage:check_tc_flag --path [directory path]
|
360
|
+
-h, --help Show this message
|
361
|
+
--storage <dir_path> Specify the TC Storage directory
|
362
|
+
Ex.)/roma/ds/localhost_10001/roma
|
363
|
+
--library <dir_path> Specify the TC library directory
|
364
|
+
Ex.)/roma/libexec", res.chomp)
|
365
|
+
|
366
|
+
start_roma 'cpdbtest/config4cpdb_tc.rb'
|
367
|
+
stop_roma
|
368
|
+
res = `#{bin_dir}/check_tc_flag --storage ./localhost_11211/roma --library /usr/local/roma/libexec`
|
369
|
+
assert_match(/\.\/localhost_11211\/roma\/\d\.tc : \(no flag\)
|
370
|
+
\.\/localhost_11211\/roma\/\d\.tc : \(no flag\)
|
371
|
+
\.\/localhost_11211\/roma\/\d\.tc : \(no flag\)
|
372
|
+
\.\/localhost_11211\/roma\/\d\.tc : \(no flag\)
|
373
|
+
\.\/localhost_11211\/roma\/\d\.tc : \(no flag\)
|
374
|
+
\.\/localhost_11211\/roma\/\d\.tc : \(no flag\)
|
375
|
+
\.\/localhost_11211\/roma\/\d\.tc : \(no flag\)
|
376
|
+
\.\/localhost_11211\/roma\/\d\.tc : \(no flag\)
|
377
|
+
\.\/localhost_11211\/roma\/\d\.tc : \(no flag\)
|
378
|
+
\.\/localhost_11211\/roma\/\d\.tc : \(no flag\)/, res.chomp)
|
379
|
+
end
|
380
|
+
|
381
|
+
def test_waiting_node
|
382
|
+
log = File.read("./localhost_11211.log")
|
383
|
+
assert_equal(true, log.include?("I'm waiting for booting the localhost_11211 instance"))
|
384
|
+
end
|
385
|
+
|
386
|
+
end
|
data/test/t_protocol.rb
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
require 'socket'
|
4
4
|
|
5
5
|
class ProtocolTest < Test::Unit::TestCase
|
6
|
+
self.test_order = :defined
|
6
7
|
include RomaTestUtils
|
7
8
|
|
8
9
|
def setup
|
@@ -17,33 +18,50 @@ class ProtocolTest < Test::Unit::TestCase
|
|
17
18
|
puts "#{e} #{$@}"
|
18
19
|
end
|
19
20
|
|
20
|
-
def
|
21
|
+
def test_set_get
|
22
|
+
sleep 10
|
23
|
+
|
21
24
|
# Set data
|
22
25
|
@sock.write("set key 0 0 5\r\nvalue\r\n")
|
26
|
+
sleep 1
|
23
27
|
assert_equal("STORED", @sock.gets.chomp)
|
24
28
|
|
25
29
|
# Get data
|
26
30
|
@sock.write("get key\r\n")
|
31
|
+
sleep 1
|
27
32
|
assert_equal("VALUE key 0 5", @sock.gets.chomp)
|
28
33
|
assert_equal("value", @sock.gets.chomp)
|
29
34
|
assert_equal("END", @sock.gets.chomp)
|
30
35
|
|
31
36
|
# Update data
|
32
37
|
@sock.write("set key 0 0 9\r\nnew_value\r\n")
|
38
|
+
sleep 1
|
33
39
|
assert_equal("STORED", @sock.gets.chomp)
|
34
40
|
|
35
41
|
# Confirm updated data
|
36
42
|
@sock.write("get key\r\n")
|
43
|
+
sleep 1
|
37
44
|
assert_equal("VALUE key 0 9", @sock.gets.chomp)
|
38
45
|
assert_equal("new_value", @sock.gets.chomp)
|
39
46
|
assert_equal("END", @sock.gets.chomp)
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_delete
|
50
|
+
sleep 1
|
51
|
+
|
52
|
+
# Set data
|
53
|
+
@sock.write("set key 0 0 5\r\nvalue\r\n")
|
54
|
+
sleep 1
|
55
|
+
assert_equal("STORED", @sock.gets.chomp)
|
40
56
|
|
41
57
|
# Delete data
|
42
58
|
@sock.write("delete key\r\n")
|
59
|
+
sleep 1
|
43
60
|
assert_equal("DELETED", @sock.gets.chomp)
|
44
61
|
|
45
62
|
# Confirm deleted data
|
46
63
|
@sock.write("get key\r\n")
|
64
|
+
sleep 1
|
47
65
|
assert_equal("END", @sock.gets.chomp)
|
48
66
|
end
|
49
67
|
|
@@ -128,4 +146,51 @@ class ProtocolTest < Test::Unit::TestCase
|
|
128
146
|
assert_equal("VALUE key 0 0", @sock.gets.chomp)
|
129
147
|
assert_equal("", @sock.gets.chomp)
|
130
148
|
end
|
149
|
+
|
150
|
+
def test_get_expt
|
151
|
+
# argument
|
152
|
+
@sock.write("get_expt\r\n")
|
153
|
+
assert_equal('CLIENT_ERROR Wrong number of arguments.', @sock.gets.chomp)
|
154
|
+
@sock.write("get_expt key1 true\r\n")
|
155
|
+
assert_equal('CLIENT_ERROR Wrong format of arguments.', @sock.gets.chomp)
|
156
|
+
@sock.write("get_expt key1 unix nil\r\n")
|
157
|
+
assert_equal('CLIENT_ERROR Wrong number of arguments.', @sock.gets.chomp)
|
158
|
+
|
159
|
+
# No data
|
160
|
+
@sock.write("get_expt key1\r\n")
|
161
|
+
assert_equal("END", @sock.gets.chomp)
|
162
|
+
|
163
|
+
# set 0
|
164
|
+
@sock.write("set key1 0 0 4\r\nval1\r\n")
|
165
|
+
assert_equal('STORED', @sock.gets.chomp )
|
166
|
+
@sock.write("get_expt key1\r\n")
|
167
|
+
t = Time.at(2147483647)
|
168
|
+
assert_equal(t.to_s, @sock.gets.chomp ) # 2038-01-19 03:14:07 +0000
|
169
|
+
assert_equal('END', @sock.gets.chomp )
|
170
|
+
@sock.write("get_expt key1 unix\r\n")
|
171
|
+
assert_equal("2147483647", @sock.gets.chomp )
|
172
|
+
assert_equal('END', @sock.gets.chomp )
|
173
|
+
|
174
|
+
# under 30days
|
175
|
+
now = Time.now.to_i
|
176
|
+
@sock.write("set_expt key1 600\r\n") # 10 min
|
177
|
+
assert_equal("STORED", @sock.gets.chomp )
|
178
|
+
@sock.write("get_expt key1\r\n")
|
179
|
+
assert_equal("#{Time.at(now+600)}", @sock.gets.chomp )
|
180
|
+
assert_equal("END", @sock.gets.chomp )
|
181
|
+
@sock.write("get_expt key1 unix\r\n")
|
182
|
+
assert_equal("#{now+600}", @sock.gets.chomp )
|
183
|
+
assert_equal("END", @sock.gets.chomp )
|
184
|
+
|
185
|
+
# over 30days
|
186
|
+
@sock.write("set_expt key1 #{t2 = Time.now.to_i+7776000}\r\n") # 90days
|
187
|
+
assert_equal("STORED", @sock.gets.chomp )
|
188
|
+
@sock.write("get_expt key1\r\n")
|
189
|
+
assert_equal("#{Time.at(t2)}", @sock.gets.chomp )
|
190
|
+
assert_equal("END", @sock.gets.chomp )
|
191
|
+
@sock.write("get_expt key1 unix\r\n")
|
192
|
+
assert_equal("#{t2}", @sock.gets.chomp )
|
193
|
+
assert_equal("END", @sock.gets.chomp )
|
194
|
+
end
|
195
|
+
|
131
196
|
end
|