higgs 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,8 @@
1
1
  #!/usr/local/bin/ruby
2
2
 
3
3
  require 'fileutils'
4
+ require 'higgs/services'
5
+ require 'higgs/storage'
4
6
  require 'higgs/thread'
5
7
  require 'higgs/utils/bman'
6
8
  require 'logger'
@@ -11,7 +13,7 @@ module Higgs::Test
11
13
  include Higgs
12
14
 
13
15
  # for ident(1)
14
- CVS_ID = '$Id: test_utils_bman.rb 621 2007-10-08 13:10:08Z toki $'
16
+ CVS_ID = '$Id: test_utils_bman.rb 661 2007-10-30 15:37:54Z toki $'
15
17
 
16
18
  STORAGE_ITEMS = (ENV['STORAGE_ITEMS'] || '100').to_i
17
19
  WARM_START_ITEMS = (ENV['WARM_START_ITEMS'] || '1000').to_i
@@ -30,26 +32,28 @@ module Higgs::Test
30
32
  FileUtils.mkdir_p(@from_dir)
31
33
  FileUtils.rm_rf(@to_dir) # for debug
32
34
  FileUtils.mkdir_p(@to_dir)
33
- @jlog_rotate_service_uri = 'druby://localhost:17320'
35
+ @remote_services_uri = 'druby://localhost:17320'
34
36
  @from_st = Storage.new(@from,
35
37
  :jlog_rotate_max => 0,
36
- :jlog_rotate_service_uri => @jlog_rotate_service_uri,
37
38
  :logger => proc{|path|
38
39
  logger = Logger.new(path, 1)
39
40
  logger.level = Logger::DEBUG
40
41
  logger
41
42
  })
43
+ @services = RemoteServices.new(:remote_services_uri => @remote_services_uri,
44
+ :storage => @from_st)
42
45
  @bman = Utils::BackupManager.new(:from => @from,
43
46
  :to_dir => @to_dir,
44
47
  :to_name => @to_name,
45
- :jlog_rotate_service_uri => @jlog_rotate_service_uri,
48
+ :remote_services_uri => @remote_services_uri,
46
49
  :verbose => $DEBUG ? 2 : 0,
47
50
  :out => $DEBUG ? STDERR : '')
48
51
  end
49
52
 
50
53
  def teardown
51
54
  @from_st.shutdown unless @from_st.shutdown?
52
- DRb.stop_service # Why cannot each service be stopped?
55
+ @services.shutdown
56
+ DRb.stop_service
53
57
  FileUtils.rm_rf(@from_dir) unless $DEBUG
54
58
  FileUtils.rm_rf(@to_dir) unless $DEBUG
55
59
  end
@@ -61,47 +65,47 @@ module Higgs::Test
61
65
 
62
66
  def test_backup_data
63
67
  @bman.backup_data
64
- assert(FileUtils.cmp("#{@from}.tar", "#{@to}.tar"))
68
+ assert(FileUtils.cmp("#{@from}.tar", "#{@to}.tar"), 'DATA should be same.')
65
69
  end
66
70
 
67
71
  def test_rotate_jlog_0
68
- assert_equal(0, Storage.rotate_entries("#{@from}.jlog").length)
72
+ assert_equal(0, Storage.rotated_entries("#{@from}.jlog").length)
69
73
  end
70
74
 
71
75
  def test_rotate_jlog_1
72
76
  @bman.rotate_jlog
73
- assert_equal(1, Storage.rotate_entries("#{@from}.jlog").length)
77
+ assert_equal(1, Storage.rotated_entries("#{@from}.jlog").length)
74
78
  end
75
79
 
76
80
  def test_rotate_jlog_2
77
81
  @bman.rotate_jlog
78
82
  @bman.rotate_jlog
79
- assert_equal(2, Storage.rotate_entries("#{@from}.jlog").length)
83
+ assert_equal(2, Storage.rotated_entries("#{@from}.jlog").length)
80
84
  end
81
85
 
82
86
  def test_rotate_jlog_10
83
87
  10.times do
84
88
  @bman.rotate_jlog
85
89
  end
86
- assert_equal(10, Storage.rotate_entries("#{@from}.jlog").length)
90
+ assert_equal(10, Storage.rotated_entries("#{@from}.jlog").length)
87
91
  end
88
92
 
89
93
  def test_backup_jlog_0
90
94
  @bman.backup_jlog
91
- assert_equal(0, Storage.rotate_entries("#{@to}.jlog").length)
95
+ assert_equal(0, Storage.rotated_entries("#{@to}.jlog").length)
92
96
  end
93
97
 
94
98
  def test_backup_jlog_1
95
99
  @bman.rotate_jlog
96
100
  @bman.backup_jlog
97
- assert_equal(1, Storage.rotate_entries("#{@to}.jlog").length)
101
+ assert_equal(1, Storage.rotated_entries("#{@to}.jlog").length)
98
102
  end
99
103
 
100
104
  def test_backup_jlog_2
101
105
  @bman.rotate_jlog
102
106
  @bman.rotate_jlog
103
107
  @bman.backup_jlog
104
- assert_equal(2, Storage.rotate_entries("#{@to}.jlog").length)
108
+ assert_equal(2, Storage.rotated_entries("#{@to}.jlog").length)
105
109
  end
106
110
 
107
111
  def test_backup_jlog_10
@@ -109,7 +113,7 @@ module Higgs::Test
109
113
  @bman.rotate_jlog
110
114
  end
111
115
  @bman.backup_jlog
112
- assert_equal(10, Storage.rotate_entries("#{@to}.jlog").length)
116
+ assert_equal(10, Storage.rotated_entries("#{@to}.jlog").length)
113
117
  end
114
118
 
115
119
  def test_clean_jlog
@@ -118,16 +122,16 @@ module Higgs::Test
118
122
  @bman.rotate_jlog
119
123
  @bman.backup_jlog
120
124
 
121
- assert_equal(3, Storage.rotate_entries("#{@from}.jlog").length)
122
- assert_equal(3, Storage.rotate_entries("#{@to}.jlog").length)
125
+ assert_equal(3, Storage.rotated_entries("#{@from}.jlog").length)
126
+ assert_equal(3, Storage.rotated_entries("#{@to}.jlog").length)
123
127
 
124
128
  @bman.clean_jlog_from
125
- assert_equal(0, Storage.rotate_entries("#{@from}.jlog").length)
126
- assert_equal(3, Storage.rotate_entries("#{@to}.jlog").length)
129
+ assert_equal(0, Storage.rotated_entries("#{@from}.jlog").length)
130
+ assert_equal(3, Storage.rotated_entries("#{@to}.jlog").length)
127
131
 
128
132
  @bman.clean_jlog_to
129
- assert_equal(0, Storage.rotate_entries("#{@from}.jlog").length)
130
- assert_equal(0, Storage.rotate_entries("#{@to}.jlog").length)
133
+ assert_equal(0, Storage.rotated_entries("#{@from}.jlog").length)
134
+ assert_equal(0, Storage.rotated_entries("#{@to}.jlog").length)
131
135
  end
132
136
 
133
137
  def test_clean_jlog_delete_backup
@@ -137,16 +141,16 @@ module Higgs::Test
137
141
  @bman.backup_jlog
138
142
  @bman.rotate_jlog
139
143
 
140
- assert_equal(4, Storage.rotate_entries("#{@from}.jlog").length)
141
- assert_equal(3, Storage.rotate_entries("#{@to}.jlog").length)
144
+ assert_equal(4, Storage.rotated_entries("#{@from}.jlog").length)
145
+ assert_equal(3, Storage.rotated_entries("#{@to}.jlog").length)
142
146
 
143
147
  @bman.clean_jlog_from
144
- assert_equal(1, Storage.rotate_entries("#{@from}.jlog").length)
145
- assert_equal(3, Storage.rotate_entries("#{@to}.jlog").length)
148
+ assert_equal(1, Storage.rotated_entries("#{@from}.jlog").length)
149
+ assert_equal(3, Storage.rotated_entries("#{@to}.jlog").length)
146
150
 
147
151
  @bman.clean_jlog_to
148
- assert_equal(1, Storage.rotate_entries("#{@from}.jlog").length)
149
- assert_equal(0, Storage.rotate_entries("#{@to}.jlog").length)
152
+ assert_equal(1, Storage.rotated_entries("#{@from}.jlog").length)
153
+ assert_equal(0, Storage.rotated_entries("#{@to}.jlog").length)
150
154
  end
151
155
 
152
156
  def test_clean_jlog_no_backup_no_delete
@@ -154,16 +158,16 @@ module Higgs::Test
154
158
  @bman.rotate_jlog
155
159
  @bman.rotate_jlog
156
160
 
157
- assert_equal(3, Storage.rotate_entries("#{@from}.jlog").length)
158
- assert_equal(0, Storage.rotate_entries("#{@to}.jlog").length)
161
+ assert_equal(3, Storage.rotated_entries("#{@from}.jlog").length)
162
+ assert_equal(0, Storage.rotated_entries("#{@to}.jlog").length)
159
163
 
160
164
  @bman.clean_jlog_from
161
- assert_equal(3, Storage.rotate_entries("#{@from}.jlog").length)
162
- assert_equal(0, Storage.rotate_entries("#{@to}.jlog").length)
165
+ assert_equal(3, Storage.rotated_entries("#{@from}.jlog").length)
166
+ assert_equal(0, Storage.rotated_entries("#{@to}.jlog").length)
163
167
 
164
168
  @bman.clean_jlog_to
165
- assert_equal(3, Storage.rotate_entries("#{@from}.jlog").length)
166
- assert_equal(0, Storage.rotate_entries("#{@to}.jlog").length)
169
+ assert_equal(3, Storage.rotated_entries("#{@from}.jlog").length)
170
+ assert_equal(0, Storage.rotated_entries("#{@to}.jlog").length)
167
171
  end
168
172
 
169
173
  def update_storage(options)
@@ -184,7 +188,7 @@ module Higgs::Test
184
188
  write_list << [ ope, key, { 'string_only' => [ true, false ][rand(2)] } ]
185
189
  when :custom_properties
186
190
  next unless (@from_st.key? key)
187
- value = ITEM_CHARS[rand(ITEM_CHARS.size)] * rand(MAX_ITEM_BYTES)
191
+ value = ITEM_CHARS[rand(ITEM_CHARS.length)] * rand(MAX_ITEM_BYTES)
188
192
  write_list << [ ope, key, { 'foo' => value } ]
189
193
  when :delete
190
194
  next unless (@from_st.key? key)
@@ -217,11 +221,11 @@ module Higgs::Test
217
221
  @bman.clean_jlog_from
218
222
  @bman.clean_jlog_to
219
223
 
220
- assert(FileUtils.cmp("#{@from}.tar", "#{@to}.tar"))
224
+ assert(FileUtils.cmp("#{@from}.tar", "#{@to}.tar"), 'DATA should be same.')
221
225
  assert(Index.new.load("#{@from}.idx").to_h ==
222
- Index.new.load("#{@to}.idx").to_h)
223
- assert_equal(0, Storage.rotate_entries("#{@from}.jlog").length)
224
- assert_equal(0, Storage.rotate_entries("#{@to}.jlog").length)
226
+ Index.new.load("#{@to}.idx").to_h, 'INDEX should be same.')
227
+ assert_equal(0, Storage.rotated_entries("#{@from}.jlog").length)
228
+ assert_equal(0, Storage.rotated_entries("#{@to}.jlog").length)
225
229
  end
226
230
 
227
231
  def test_online_backup
@@ -238,7 +242,7 @@ module Higgs::Test
238
242
 
239
243
  assert((File.file? "#{@to}.tar"))
240
244
  assert((File.file? "#{@to}.idx"))
241
- assert_equal(0, Storage.rotate_entries("#{@to}.jlog").length)
245
+ assert_equal(0, Storage.rotated_entries("#{@to}.jlog").length)
242
246
  end
243
247
 
244
248
  def test_online_backup_with_latest_journal_log
@@ -258,18 +262,18 @@ module Higgs::Test
258
262
  @bman.recover
259
263
  @from_st.shutdown
260
264
 
261
- assert(FileUtils.cmp("#{@from}.tar", "#{@to}.tar"))
265
+ assert(FileUtils.cmp("#{@from}.tar", "#{@to}.tar"), 'DATA should be same.')
262
266
  assert(Index.new.load("#{@from}.idx").to_h ==
263
- Index.new.load("#{@to}.idx").to_h)
264
- assert(! FileUtils.cmp("#{@from}.jlog", "#{@to}.jlog"))
267
+ Index.new.load("#{@to}.idx").to_h, 'INDEX should be same.')
268
+ assert(! FileUtils.cmp("#{@from}.jlog", "#{@to}.jlog"), 'JOURNAL LOG should NOT be same.')
265
269
 
266
270
  st = Storage.new(@to)
267
271
  st.shutdown
268
272
 
269
- assert(FileUtils.cmp("#{@from}.tar", "#{@to}.tar"))
273
+ assert(FileUtils.cmp("#{@from}.tar", "#{@to}.tar"), 'DATA should be same.')
270
274
  assert(Index.new.load("#{@from}.idx").to_h ==
271
- Index.new.load("#{@to}.idx").to_h)
272
- assert(FileUtils.cmp("#{@from}.jlog", "#{@to}.jlog"))
275
+ Index.new.load("#{@to}.idx").to_h, 'INDEX should be same.')
276
+ assert(FileUtils.cmp("#{@from}.jlog", "#{@to}.jlog"), 'JOURNAL LOG should be same.')
273
277
  end
274
278
 
275
279
  def test_online_backup_with_incompleted_journal_log
@@ -290,18 +294,18 @@ module Higgs::Test
290
294
  @bman.recover
291
295
  @from_st.shutdown
292
296
 
293
- assert(FileUtils.cmp("#{@from}.tar", "#{@to}.tar"))
297
+ assert(FileUtils.cmp("#{@from}.tar", "#{@to}.tar"), 'DATA should be same.')
294
298
  assert(Index.new.load("#{@from}.idx").to_h ==
295
- Index.new.load("#{@to}.idx").to_h)
296
- assert(! FileUtils.cmp("#{@from}.jlog", "#{@to}.jlog"))
299
+ Index.new.load("#{@to}.idx").to_h, 'INDEX should be same.')
300
+ assert(! FileUtils.cmp("#{@from}.jlog", "#{@to}.jlog"), 'JOURNAL LOG should NOT be same.')
297
301
 
298
302
  st = Storage.new(@to)
299
303
  st.shutdown
300
304
 
301
- assert(FileUtils.cmp("#{@from}.tar", "#{@to}.tar"))
305
+ assert(FileUtils.cmp("#{@from}.tar", "#{@to}.tar"), 'DATA should be same.')
302
306
  assert(Index.new.load("#{@from}.idx").to_h ==
303
- Index.new.load("#{@to}.idx").to_h)
304
- assert(FileUtils.cmp("#{@from}.jlog", "#{@to}.jlog"))
307
+ Index.new.load("#{@to}.idx").to_h, 'INDEX should be same.')
308
+ assert(FileUtils.cmp("#{@from}.jlog", "#{@to}.jlog"), 'JOURNAL LOG should be same.')
305
309
  end
306
310
 
307
311
  def test_restore_files
@@ -318,15 +322,15 @@ module Higgs::Test
318
322
 
319
323
  @from_st.shutdown
320
324
 
321
- assert(! FileUtils.cmp("#{@from}.tar", "#{@to}.tar"))
325
+ assert(! FileUtils.cmp("#{@from}.tar", "#{@to}.tar"), 'DATA should NOT be same.')
322
326
  assert(Index.new.load("#{@from}.idx").to_h !=
323
- Index.new.load("#{@to}.idx").to_h)
327
+ Index.new.load("#{@to}.idx").to_h, 'INDEX should NOT be same.')
324
328
 
325
329
  @bman.restore_files
326
330
 
327
- assert(FileUtils.cmp("#{@from}.tar", "#{@to}.tar"))
331
+ assert(FileUtils.cmp("#{@from}.tar", "#{@to}.tar"), 'DATA should be same.')
328
332
  assert(Index.new.load("#{@from}.idx").to_h ==
329
- Index.new.load("#{@to}.idx").to_h)
333
+ Index.new.load("#{@to}.idx").to_h, 'INDEX should be same.')
330
334
  end
331
335
 
332
336
  def test_restore_recover_and_verify
@@ -349,9 +353,9 @@ module Higgs::Test
349
353
  @bman.restore_recover
350
354
  @bman.restore_verify
351
355
 
352
- assert(FileUtils.cmp("#{@from}.tar", "#{@from}.tar.orig"))
356
+ assert(FileUtils.cmp("#{@from}.tar", "#{@from}.tar.orig"), 'DATA should be same.')
353
357
  assert(Index.new.load("#{@from}.idx").to_h ==
354
- Index.new.load("#{@from}.idx.orig").to_h)
358
+ Index.new.load("#{@from}.idx.orig").to_h, 'INDEX should be same.')
355
359
  end
356
360
 
357
361
  def test_restore
@@ -372,9 +376,9 @@ module Higgs::Test
372
376
 
373
377
  @bman.restore
374
378
 
375
- assert(FileUtils.cmp("#{@from}.tar", "#{@from}.tar.orig"))
379
+ assert(FileUtils.cmp("#{@from}.tar", "#{@from}.tar.orig"), 'DATA should be same.')
376
380
  assert(Index.new.load("#{@from}.idx").to_h ==
377
- Index.new.load("#{@from}.idx.orig").to_h)
381
+ Index.new.load("#{@from}.idx.orig").to_h, 'INDEX should be same.')
378
382
  end
379
383
 
380
384
  def test_incremental_backup_with_recovery_and_restore
@@ -407,9 +411,9 @@ module Higgs::Test
407
411
 
408
412
  @bman.restore
409
413
 
410
- assert(FileUtils.cmp("#{@from}.tar", "#{@from}.tar.orig"))
414
+ assert(FileUtils.cmp("#{@from}.tar", "#{@from}.tar.orig"), 'DATA should be same.')
411
415
  assert(Index.new.load("#{@from}.idx").to_h ==
412
- Index.new.load("#{@from}.idx.orig").to_h)
416
+ Index.new.load("#{@from}.idx.orig").to_h, 'INDEX should be same.')
413
417
  end
414
418
 
415
419
  def test_incremental_backup_without_recovery_and_restore
@@ -439,9 +443,9 @@ module Higgs::Test
439
443
 
440
444
  @bman.restore
441
445
 
442
- assert(FileUtils.cmp("#{@from}.tar", "#{@from}.tar.orig"))
446
+ assert(FileUtils.cmp("#{@from}.tar", "#{@from}.tar.orig"), 'DATA should be same.')
443
447
  assert(Index.new.load("#{@from}.idx").to_h ==
444
- Index.new.load("#{@from}.idx.orig").to_h)
448
+ Index.new.load("#{@from}.idx.orig").to_h, 'INDEX should be same.')
445
449
  end
446
450
  end
447
451
  end
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.4
3
3
  specification_version: 1
4
4
  name: higgs
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.1.2
7
- date: 2007-10-12 00:00:00 +09:00
6
+ version: 0.1.3
7
+ date: 2007-11-11 00:00:00 +09:00
8
8
  summary: pure ruby transactional storage compatible with unix TAR format
9
9
  require_paths:
10
10
  - lib
@@ -38,6 +38,7 @@ files:
38
38
  - lib/higgs/utils/bman.rb
39
39
  - lib/higgs/exceptions.rb
40
40
  - lib/higgs/cache.rb
41
+ - lib/higgs/sman.rb
41
42
  - lib/higgs/lock.rb
42
43
  - lib/higgs/thread.rb
43
44
  - lib/higgs/block.rb
@@ -46,6 +47,7 @@ files:
46
47
  - lib/higgs/storage.rb
47
48
  - lib/higgs/tar.rb
48
49
  - lib/higgs/index.rb
50
+ - lib/higgs/services.rb
49
51
  - lib/higgs/flock.rb
50
52
  - lib/higgs/store.rb
51
53
  - lib/higgs/version.rb
@@ -73,12 +75,14 @@ files:
73
75
  - test/test_block.rb
74
76
  - test/test_dbm.rb
75
77
  - test/test_storage_conf.rb
78
+ - test/test_services.rb
76
79
  - test/test_tar.rb
77
80
  - test/run.rb
78
81
  - test/test_storage.rb
79
82
  - test/test_index.rb
80
83
  - test/test_tman_init_opts.rb
81
84
  - test/test_flock.rb
85
+ - test/test_replication.rb
82
86
  - test/test_store.rb
83
87
  - test/test_jlog.rb
84
88
  - test/test_online_backup.rb
@@ -86,9 +90,11 @@ files:
86
90
  - sample/count.rb
87
91
  - sample/dbmtest.rb
88
92
  - rdoc.yml
93
+ - bin/higgs_apply_jlog
89
94
  - bin/higgs_backup
90
95
  - bin/higgs_dump_index
91
96
  - bin/higgs_dump_jlog
97
+ - bin/higgs_ping
92
98
  - bin/higgs_verify
93
99
  - ChangeLog
94
100
  - LICENSE
@@ -104,9 +110,11 @@ rdoc_options:
104
110
  extra_rdoc_files: []
105
111
 
106
112
  executables:
113
+ - higgs_apply_jlog
107
114
  - higgs_backup
108
115
  - higgs_dump_index
109
116
  - higgs_dump_jlog
117
+ - higgs_ping
110
118
  - higgs_verify
111
119
  extensions: []
112
120