content_server 1.5.0 → 1.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +15 -0
  2. data/bin/file_utils +118 -0
  3. data/lib/content_data/content_data.rb +114 -48
  4. data/lib/content_server/version.rb +1 -1
  5. data/lib/file_monitoring/file_monitoring.rb +94 -50
  6. data/lib/file_monitoring/monitor_path.rb +196 -113
  7. data/lib/file_utils/file_utils.rb +10 -49
  8. data/lib/networking/tcp.rb +4 -4
  9. data/spec/content_data/content_data_spec.rb +331 -0
  10. data/spec/content_data/validations_spec.rb +5 -0
  11. data/spec/content_server/content_server_spec.rb +5 -0
  12. data/spec/content_server/file_streamer_spec.rb +5 -0
  13. data/spec/file_copy/copy_spec.rb +5 -0
  14. data/spec/file_indexing/index_agent_spec.rb +5 -0
  15. data/spec/networking/tcp_spec.rb +5 -0
  16. data/spec/validations/index_validations_spec.rb +5 -0
  17. metadata +9 -89
  18. data/test/content_data/content_data_test.rb +0 -291
  19. data/test/file_generator/file_generator_spec.rb +0 -85
  20. data/test/file_monitoring/monitor_path_test.rb +0 -189
  21. data/test/file_monitoring/monitor_path_test/dir1000/test_file.1000 +0 -1000
  22. data/test/file_monitoring/monitor_path_test/dir1000/test_file.1000.0 +0 -1000
  23. data/test/file_monitoring/monitor_path_test/dir1000/test_file.1000.1 +0 -1000
  24. data/test/file_monitoring/monitor_path_test/dir1500/test_file.1500 +0 -1500
  25. data/test/file_monitoring/monitor_path_test/dir1500/test_file.1500.0 +0 -1500
  26. data/test/file_monitoring/monitor_path_test/dir1500/test_file.1500.1 +0 -1500
  27. data/test/file_monitoring/monitor_path_test/test_file.500 +0 -500
  28. data/test/file_monitoring/monitor_path_test/test_file.500.0 +0 -500
  29. data/test/file_monitoring/monitor_path_test/test_file.500.1 +0 -500
  30. data/test/file_utils/fileutil_mksymlink_test.rb +0 -134
  31. data/test/file_utils/fileutil_mksymlink_test/dir1000/dir1500/test_file.1500 +0 -1500
  32. data/test/file_utils/fileutil_mksymlink_test/dir1000/dir1500/test_file.1500.0 +0 -1500
  33. data/test/file_utils/fileutil_mksymlink_test/dir1000/dir1500/test_file.1500.1 +0 -1500
  34. data/test/file_utils/fileutil_mksymlink_test/dir1000/test_file.1000 +0 -1000
  35. data/test/file_utils/fileutil_mksymlink_test/dir1000/test_file.1000.0 +0 -1000
  36. data/test/file_utils/fileutil_mksymlink_test/dir1000/test_file.1000.1 +0 -1000
  37. data/test/file_utils/fileutil_mksymlink_test/test_file.500 +0 -500
  38. data/test/file_utils/fileutil_mksymlink_test/test_file.500.0 +0 -500
  39. data/test/file_utils/fileutil_mksymlink_test/test_file.500.1 +0 -500
  40. data/test/file_utils/time_modification_test.rb +0 -136
  41. data/test/params/params_spec.rb +0 -280
  42. data/test/params/params_test.rb +0 -43
  43. data/test/run_in_background/run_in_background_test.rb +0 -122
  44. data/test/run_in_background/test_app +0 -59
@@ -1,3 +1,8 @@
1
+ # NOTE Code Coverage block must be issued before any of your application code is required
2
+ if ENV['BBFS_COVERAGE']
3
+ require_relative '../spec_helper.rb'
4
+ SimpleCov.command_name 'content_server'
5
+ end
1
6
  require 'rspec'
2
7
 
3
8
  require_relative '../../lib/file_copy/copy.rb'
@@ -1,3 +1,8 @@
1
+ # NOTE Code Coverage block must be issued before any of your application code is required
2
+ if ENV['BBFS_COVERAGE']
3
+ require_relative '../spec_helper.rb'
4
+ SimpleCov.command_name 'content_server'
5
+ end
1
6
  require 'log'
2
7
  require 'rspec'
3
8
  require 'stringio'
@@ -1,3 +1,8 @@
1
+ # NOTE Code Coverage block must be issued before any of your application code is required
2
+ if ENV['BBFS_COVERAGE']
3
+ require_relative '../spec_helper.rb'
4
+ SimpleCov.command_name 'file_copy'
5
+ end
1
6
  require 'rspec'
2
7
 
3
8
  require_relative '../../lib/file_copy/copy.rb'
@@ -1,3 +1,8 @@
1
+ # NOTE Code Coverage block must be issued before any of your application code is required
2
+ if ENV['BBFS_COVERAGE']
3
+ require_relative '../spec_helper.rb'
4
+ SimpleCov.command_name 'file_indexing'
5
+ end
1
6
  require 'rspec'
2
7
  require 'tempfile'
3
8
 
@@ -1,3 +1,8 @@
1
+ # NOTE Code Coverage block must be issued before any of your application code is required
2
+ if ENV['BBFS_COVERAGE']
3
+ require_relative '../spec_helper.rb'
4
+ SimpleCov.command_name 'networking'
5
+ end
1
6
  require 'log'
2
7
  require 'rspec'
3
8
  require 'socket'
@@ -1,3 +1,8 @@
1
+ # NOTE Code Coverage block must be issued before any of your application code is required
2
+ if ENV['BBFS_COVERAGE']
3
+ require_relative '../spec_helper.rb'
4
+ SimpleCov.command_name 'validations'
5
+ end
1
6
  require 'rspec'
2
7
  require_relative '../../lib/validations.rb'
3
8
 
metadata CHANGED
@@ -1,20 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: content_server
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.0
5
- prerelease:
4
+ version: 1.6.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - BBFS Team
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2014-01-14 00:00:00.000000000 Z
11
+ date: 2014-03-15 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rake
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
17
  - - '='
20
18
  - !ruby/object:Gem::Version
@@ -22,7 +20,6 @@ dependencies:
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
24
  - - '='
28
25
  - !ruby/object:Gem::Version
@@ -30,7 +27,6 @@ dependencies:
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: algorithms
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
31
  - - ! '>='
36
32
  - !ruby/object:Gem::Version
@@ -38,7 +34,6 @@ dependencies:
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
38
  - - ! '>='
44
39
  - !ruby/object:Gem::Version
@@ -46,7 +41,6 @@ dependencies:
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: log4r
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
45
  - - ! '>='
52
46
  - !ruby/object:Gem::Version
@@ -54,7 +48,6 @@ dependencies:
54
48
  type: :runtime
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
52
  - - ! '>='
60
53
  - !ruby/object:Gem::Version
@@ -62,7 +55,6 @@ dependencies:
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: eventmachine
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
59
  - - ! '>='
68
60
  - !ruby/object:Gem::Version
@@ -70,7 +62,6 @@ dependencies:
70
62
  type: :runtime
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
66
  - - ! '>='
76
67
  - !ruby/object:Gem::Version
@@ -78,7 +69,6 @@ dependencies:
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: json
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
73
  - - ! '>='
84
74
  - !ruby/object:Gem::Version
@@ -86,7 +76,6 @@ dependencies:
86
76
  type: :runtime
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
80
  - - ! '>='
92
81
  - !ruby/object:Gem::Version
@@ -94,7 +83,6 @@ dependencies:
94
83
  - !ruby/object:Gem::Dependency
95
84
  name: sinatra
96
85
  requirement: !ruby/object:Gem::Requirement
97
- none: false
98
86
  requirements:
99
87
  - - ! '>='
100
88
  - !ruby/object:Gem::Version
@@ -102,7 +90,6 @@ dependencies:
102
90
  type: :runtime
103
91
  prerelease: false
104
92
  version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
93
  requirements:
107
94
  - - ! '>='
108
95
  - !ruby/object:Gem::Version
@@ -110,7 +97,6 @@ dependencies:
110
97
  - !ruby/object:Gem::Dependency
111
98
  name: thin
112
99
  requirement: !ruby/object:Gem::Requirement
113
- none: false
114
100
  requirements:
115
101
  - - ! '>='
116
102
  - !ruby/object:Gem::Version
@@ -118,7 +104,6 @@ dependencies:
118
104
  type: :runtime
119
105
  prerelease: false
120
106
  version_requirements: !ruby/object:Gem::Requirement
121
- none: false
122
107
  requirements:
123
108
  - - ! '>='
124
109
  - !ruby/object:Gem::Version
@@ -126,7 +111,6 @@ dependencies:
126
111
  - !ruby/object:Gem::Dependency
127
112
  name: rake
128
113
  requirement: !ruby/object:Gem::Requirement
129
- none: false
130
114
  requirements:
131
115
  - - '='
132
116
  - !ruby/object:Gem::Version
@@ -134,7 +118,6 @@ dependencies:
134
118
  type: :runtime
135
119
  prerelease: false
136
120
  version_requirements: !ruby/object:Gem::Requirement
137
- none: false
138
121
  requirements:
139
122
  - - '='
140
123
  - !ruby/object:Gem::Version
@@ -142,7 +125,6 @@ dependencies:
142
125
  - !ruby/object:Gem::Dependency
143
126
  name: algorithms
144
127
  requirement: !ruby/object:Gem::Requirement
145
- none: false
146
128
  requirements:
147
129
  - - ! '>='
148
130
  - !ruby/object:Gem::Version
@@ -150,7 +132,6 @@ dependencies:
150
132
  type: :runtime
151
133
  prerelease: false
152
134
  version_requirements: !ruby/object:Gem::Requirement
153
- none: false
154
135
  requirements:
155
136
  - - ! '>='
156
137
  - !ruby/object:Gem::Version
@@ -158,7 +139,6 @@ dependencies:
158
139
  - !ruby/object:Gem::Dependency
159
140
  name: log4r
160
141
  requirement: !ruby/object:Gem::Requirement
161
- none: false
162
142
  requirements:
163
143
  - - ! '>='
164
144
  - !ruby/object:Gem::Version
@@ -166,7 +146,6 @@ dependencies:
166
146
  type: :runtime
167
147
  prerelease: false
168
148
  version_requirements: !ruby/object:Gem::Requirement
169
- none: false
170
149
  requirements:
171
150
  - - ! '>='
172
151
  - !ruby/object:Gem::Version
@@ -174,7 +153,6 @@ dependencies:
174
153
  - !ruby/object:Gem::Dependency
175
154
  name: eventmachine
176
155
  requirement: !ruby/object:Gem::Requirement
177
- none: false
178
156
  requirements:
179
157
  - - ! '>='
180
158
  - !ruby/object:Gem::Version
@@ -182,7 +160,6 @@ dependencies:
182
160
  type: :runtime
183
161
  prerelease: false
184
162
  version_requirements: !ruby/object:Gem::Requirement
185
- none: false
186
163
  requirements:
187
164
  - - ! '>='
188
165
  - !ruby/object:Gem::Version
@@ -190,7 +167,6 @@ dependencies:
190
167
  - !ruby/object:Gem::Dependency
191
168
  name: json
192
169
  requirement: !ruby/object:Gem::Requirement
193
- none: false
194
170
  requirements:
195
171
  - - ! '>='
196
172
  - !ruby/object:Gem::Version
@@ -198,7 +174,6 @@ dependencies:
198
174
  type: :runtime
199
175
  prerelease: false
200
176
  version_requirements: !ruby/object:Gem::Requirement
201
- none: false
202
177
  requirements:
203
178
  - - ! '>='
204
179
  - !ruby/object:Gem::Version
@@ -206,7 +181,6 @@ dependencies:
206
181
  - !ruby/object:Gem::Dependency
207
182
  name: sinatra
208
183
  requirement: !ruby/object:Gem::Requirement
209
- none: false
210
184
  requirements:
211
185
  - - ! '>='
212
186
  - !ruby/object:Gem::Version
@@ -214,7 +188,6 @@ dependencies:
214
188
  type: :runtime
215
189
  prerelease: false
216
190
  version_requirements: !ruby/object:Gem::Requirement
217
- none: false
218
191
  requirements:
219
192
  - - ! '>='
220
193
  - !ruby/object:Gem::Version
@@ -222,7 +195,6 @@ dependencies:
222
195
  - !ruby/object:Gem::Dependency
223
196
  name: thin
224
197
  requirement: !ruby/object:Gem::Requirement
225
- none: false
226
198
  requirements:
227
199
  - - ! '>='
228
200
  - !ruby/object:Gem::Version
@@ -230,7 +202,6 @@ dependencies:
230
202
  type: :runtime
231
203
  prerelease: false
232
204
  version_requirements: !ruby/object:Gem::Requirement
233
- none: false
234
205
  requirements:
235
206
  - - ! '>='
236
207
  - !ruby/object:Gem::Version
@@ -240,6 +211,7 @@ email: bbfsdev@gmail.com
240
211
  executables:
241
212
  - content_server
242
213
  - backup_server
214
+ - file_utils
243
215
  - testing_server
244
216
  - testing_memory
245
217
  extensions:
@@ -299,33 +271,7 @@ files:
299
271
  - lib/validations.rb
300
272
  - lib/validations/index_validations.rb
301
273
  - lib/validations/version.rb
302
- - test/content_data/content_data_test.rb
303
- - test/file_generator/file_generator_spec.rb
304
- - test/file_monitoring/monitor_path_test/test_file.500.0
305
- - test/file_monitoring/monitor_path_test/dir1000/test_file.1000.1
306
- - test/file_monitoring/monitor_path_test/dir1000/test_file.1000.0
307
- - test/file_monitoring/monitor_path_test/dir1000/test_file.1000
308
- - test/file_monitoring/monitor_path_test/test_file.500.1
309
- - test/file_monitoring/monitor_path_test/test_file.500
310
- - test/file_monitoring/monitor_path_test/dir1500/test_file.1500
311
- - test/file_monitoring/monitor_path_test/dir1500/test_file.1500.0
312
- - test/file_monitoring/monitor_path_test/dir1500/test_file.1500.1
313
- - test/file_monitoring/monitor_path_test.rb
314
- - test/file_utils/fileutil_mksymlink_test/test_file.500.0
315
- - test/file_utils/fileutil_mksymlink_test/dir1000/test_file.1000.1
316
- - test/file_utils/fileutil_mksymlink_test/dir1000/test_file.1000.0
317
- - test/file_utils/fileutil_mksymlink_test/dir1000/test_file.1000
318
- - test/file_utils/fileutil_mksymlink_test/dir1000/dir1500/test_file.1500
319
- - test/file_utils/fileutil_mksymlink_test/dir1000/dir1500/test_file.1500.0
320
- - test/file_utils/fileutil_mksymlink_test/dir1000/dir1500/test_file.1500.1
321
- - test/file_utils/fileutil_mksymlink_test/test_file.500.1
322
- - test/file_utils/fileutil_mksymlink_test/test_file.500
323
- - test/file_utils/fileutil_mksymlink_test.rb
324
- - test/file_utils/time_modification_test.rb
325
- - test/params/params_spec.rb
326
- - test/params/params_test.rb
327
- - test/run_in_background/test_app
328
- - test/run_in_background/run_in_background_test.rb
274
+ - spec/content_data/content_data_spec.rb
329
275
  - spec/content_data/validations_spec.rb
330
276
  - spec/content_server/content_server_spec.rb
331
277
  - spec/content_server/file_streamer_spec.rb
@@ -335,61 +281,35 @@ files:
335
281
  - spec/validations/index_validations_spec.rb
336
282
  - bin/content_server
337
283
  - bin/backup_server
284
+ - bin/file_utils
338
285
  - bin/testing_server
339
286
  - bin/testing_memory
340
287
  - ext/run_in_background/mkrf_conf.rb
341
288
  homepage: http://github.com/bbfsdev/bbfs
342
289
  licenses: []
290
+ metadata: {}
343
291
  post_install_message:
344
292
  rdoc_options: []
345
293
  require_paths:
346
294
  - lib
347
295
  required_ruby_version: !ruby/object:Gem::Requirement
348
- none: false
349
296
  requirements:
350
297
  - - ! '>='
351
298
  - !ruby/object:Gem::Version
352
299
  version: '0'
353
300
  required_rubygems_version: !ruby/object:Gem::Requirement
354
- none: false
355
301
  requirements:
356
302
  - - ! '>='
357
303
  - !ruby/object:Gem::Version
358
304
  version: '0'
359
305
  requirements: []
360
306
  rubyforge_project:
361
- rubygems_version: 1.8.24
307
+ rubygems_version: 2.1.11
362
308
  signing_key:
363
- specification_version: 3
309
+ specification_version: 4
364
310
  summary: Servers for backing up content.
365
311
  test_files:
366
- - test/content_data/content_data_test.rb
367
- - test/file_generator/file_generator_spec.rb
368
- - test/file_monitoring/monitor_path_test/test_file.500.0
369
- - test/file_monitoring/monitor_path_test/dir1000/test_file.1000.1
370
- - test/file_monitoring/monitor_path_test/dir1000/test_file.1000.0
371
- - test/file_monitoring/monitor_path_test/dir1000/test_file.1000
372
- - test/file_monitoring/monitor_path_test/test_file.500.1
373
- - test/file_monitoring/monitor_path_test/test_file.500
374
- - test/file_monitoring/monitor_path_test/dir1500/test_file.1500
375
- - test/file_monitoring/monitor_path_test/dir1500/test_file.1500.0
376
- - test/file_monitoring/monitor_path_test/dir1500/test_file.1500.1
377
- - test/file_monitoring/monitor_path_test.rb
378
- - test/file_utils/fileutil_mksymlink_test/test_file.500.0
379
- - test/file_utils/fileutil_mksymlink_test/dir1000/test_file.1000.1
380
- - test/file_utils/fileutil_mksymlink_test/dir1000/test_file.1000.0
381
- - test/file_utils/fileutil_mksymlink_test/dir1000/test_file.1000
382
- - test/file_utils/fileutil_mksymlink_test/dir1000/dir1500/test_file.1500
383
- - test/file_utils/fileutil_mksymlink_test/dir1000/dir1500/test_file.1500.0
384
- - test/file_utils/fileutil_mksymlink_test/dir1000/dir1500/test_file.1500.1
385
- - test/file_utils/fileutil_mksymlink_test/test_file.500.1
386
- - test/file_utils/fileutil_mksymlink_test/test_file.500
387
- - test/file_utils/fileutil_mksymlink_test.rb
388
- - test/file_utils/time_modification_test.rb
389
- - test/params/params_spec.rb
390
- - test/params/params_test.rb
391
- - test/run_in_background/test_app
392
- - test/run_in_background/run_in_background_test.rb
312
+ - spec/content_data/content_data_spec.rb
393
313
  - spec/content_data/validations_spec.rb
394
314
  - spec/content_server/content_server_spec.rb
395
315
  - spec/content_server/file_streamer_spec.rb
@@ -1,291 +0,0 @@
1
- require 'time.rb'
2
- require 'test/unit'
3
- require 'content_server/server'
4
- require_relative '../../lib/content_data/content_data.rb'
5
-
6
- class TestContentData < Test::Unit::TestCase
7
-
8
- def setup
9
- Params.init Array.new
10
- # must preced Log.init, otherwise log containing default values will be created
11
- Params['log_write_to_file'] = false
12
- Log.init
13
- end
14
-
15
- def test_cloning_db_1
16
- content_data = ContentData::ContentData.new
17
- content_data.add_instance("A1", 1242, "server_1",
18
- "/home/file_1", 2222222222)
19
-
20
- content_data_cloned = ContentData::ContentData.new(content_data)
21
- #check that DBs are equal
22
- assert_equal(content_data, content_data_cloned)
23
-
24
- content_data_cloned.add_instance("A1", 1242, "server_1",
25
- "/home/file_2", 3333333333)
26
- #change orig DB - size
27
- assert_not_equal(content_data, content_data_cloned)
28
- end
29
-
30
- def test_cloning_db_2
31
- content_data = ContentData::ContentData.new
32
- content_data.add_instance("A1", 1242, "server_1",
33
- "/home/file_1", 2222222222)
34
-
35
- content_data_cloned = ContentData::ContentData.new(content_data)
36
- #check that DBs are equal
37
- assert_equal(content_data, content_data_cloned)
38
-
39
- content_data_cloned.add_instance("A2", 1243, "server_1",
40
- "/home/file_2", 3333333333)
41
- #change orig DB - size
42
- assert_not_equal(content_data, content_data_cloned)
43
- end
44
-
45
-
46
- def test_add_instance
47
- #create first content with instance
48
- content_data = ContentData::ContentData.new
49
- content_data.add_instance("A1", 50, "server_1",
50
- "/home/file_1", 2222222222)
51
-
52
- #Add new instance - different size
53
- # size would be overriden should not be added
54
- content_data.add_instance("A1", 60, "server_1",
55
- "/home/file_2", 2222222222)
56
- assert_equal("1\nA1,60,2222222222\n2\nA1,60,server_1,/home/file_1,2222222222\nA1,60,server_1,/home/file_2,2222222222\n", content_data.to_s)
57
-
58
- #Add new instance - new content
59
- #both new content and new instances are created in DB
60
- content_data.add_instance("A2", 60, "server_1",
61
- "/home/file_2", 3333333333)
62
- assert_equal("2\nA1,60,2222222222\nA2,60,3333333333\n2\n" +
63
- "A1,60,server_1,/home/file_1,2222222222\n" +
64
- "A2,60,server_1,/home/file_2,3333333333\n", content_data.to_s)
65
-
66
- #Add new instance - same content
67
- content_data.add_instance("A2", 60, "server_1",
68
- "/home/file_3", 4444444444)
69
- assert_equal("2\nA1,60,2222222222\nA2,60,3333333333\n3\n" +
70
- "A1,60,server_1,/home/file_1,2222222222\n" +
71
- "A2,60,server_1,/home/file_2,3333333333\n" +
72
- "A2,60,server_1,/home/file_3,4444444444\n", content_data.to_s)
73
- end
74
-
75
- def test_instance_exists
76
- content_data = ContentData::ContentData.new
77
- content_data.add_instance("A129", 50, "server_1",
78
- "/home/file_1", 2222222222)
79
- assert_equal(true, content_data.instance_exists('/home/file_1', 'server_1'))
80
- assert_equal(false, content_data.instance_exists('/home/file_1', 'stum'))
81
- end
82
-
83
- def test_remove_instance
84
- #remove instance also removes content
85
- content_data = ContentData::ContentData.new
86
- content_data.add_instance("A1", 50, "server_1",
87
- "/home/file_1", 2222222222)
88
- assert_equal(true, content_data.content_exists('A1'))
89
- assert_equal(true, content_data.instance_exists('/home/file_1', 'server_1'))
90
- content_data.remove_instance('server_1', '/home/file_1')
91
- assert_equal(false, content_data.instance_exists('/home/file_1', 'server_1'))
92
- assert_equal(false, content_data.content_exists('A1'))
93
-
94
- #remove instance does not remove content
95
- content_data.add_instance("A1", 50, "server_1",
96
- "/home/file_1", 2222222222)
97
- content_data.add_instance("A1", 50, "server_1",
98
- "/home/file_2", 3333333333)
99
- assert_equal(true, content_data.content_exists('A1'))
100
- assert_equal(true, content_data.instance_exists('/home/file_1', 'server_1'))
101
- content_data.remove_instance('server_1', '/home/file_1')
102
- assert_equal(false, content_data.instance_exists('/home/file_1', 'server_1'))
103
- assert_equal(true, content_data.content_exists('A1'))
104
-
105
- #remove also removes content
106
- content_data.remove_instance('server_1', '/home/file_2')
107
- assert_equal(false, content_data.instance_exists('/home/file_1', 'server_1'))
108
- assert_equal(false, content_data.content_exists('A1'))
109
- end
110
-
111
- def test_to_file_from_file
112
- content_data = ContentData::ContentData.new
113
- content_data.add_instance("A1", 50, "server_1",
114
- "/home/file_1", 22222222222)
115
- content_data.add_instance("B1", 60, "server_1",
116
- "/home/file_2", 44444444444)
117
- content_data.add_instance("B1", 60, "server_1",
118
- "/home/file_3", 55555555555)
119
- file_moc_object = StringIO.new
120
- file_moc_object.write(content_data.to_s)
121
- test_file = __FILE__ + 'test'
122
- content_data.to_file(test_file)
123
- content_data_2 = ContentData::ContentData.new
124
- content_data_2.from_file(test_file)
125
- assert_equal(true, content_data == content_data_2)
126
- end
127
-
128
- def test_merge
129
- content_data_a = ContentData::ContentData.new
130
- content_data_a.add_instance("A1", 50, "server_1",
131
- "/home/file_1", 22222222222)
132
-
133
- content_data_b = ContentData::ContentData.new
134
- content_data_b.add_instance("B1", 60, "server_1",
135
- "/home/file_2", 44444444444)
136
- content_data_b.add_instance("B1", 60, "server_1",
137
- "/home/file_3", 55555555555)
138
- content_data_merged = ContentData.merge(content_data_a, content_data_b)
139
- assert_equal(content_data_merged.to_s, "2\nB1,60,44444444444\nA1,50,22222222222\n3\nB1,60,server_1,/home/file_2,44444444444\nB1,60,server_1,/home/file_3,55555555555\nA1,50,server_1,/home/file_1,22222222222\n")
140
- content_data_a.remove_instance('server_1', '/home/file_1')
141
- assert_equal(content_data_merged.to_s, "2\nB1,60,44444444444\nA1,50,22222222222\n3\nB1,60,server_1,/home/file_2,44444444444\nB1,60,server_1,/home/file_3,55555555555\nA1,50,server_1,/home/file_1,22222222222\n")
142
- content_data_b.remove_instance('server_1', '/home/file_2')
143
- assert_equal(content_data_merged.to_s, "2\nB1,60,44444444444\nA1,50,22222222222\n3\nB1,60,server_1,/home/file_2,44444444444\nB1,60,server_1,/home/file_3,55555555555\nA1,50,server_1,/home/file_1,22222222222\n")
144
-
145
- end
146
-
147
- def test_merge_override_b
148
- content_data_a = ContentData::ContentData.new
149
- content_data_a.add_instance("A1", 50, "server_1",
150
- "/home/file_1", 22222222222)
151
-
152
- content_data_b = ContentData::ContentData.new
153
- content_data_b.add_instance("A1", 50, "server_1",
154
- "/home/file_1", 22222222222)
155
- content_data_b.add_instance("B1", 60, "server_1",
156
- "/home/file_2", 44444444444)
157
- content_data_b.add_instance("B1", 60, "server_1",
158
- "/home/file_3", 55555555555)
159
- content_data_merged = ContentData.merge_override_b(content_data_a, content_data_b)
160
- assert_equal("2\nA1,50,22222222222\nB1,60,44444444444\n3\nA1,50,server_1,/home/file_1,22222222222\nB1,60,server_1,/home/file_2,44444444444\nB1,60,server_1,/home/file_3,55555555555\n",
161
- content_data_merged.to_s)
162
-
163
- content_data_a.remove_instance('server_1', '/home/file_1')
164
- assert_equal("2\nA1,50,22222222222\nB1,60,44444444444\n3\nA1,50,server_1,/home/file_1,22222222222\nB1,60,server_1,/home/file_2,44444444444\nB1,60,server_1,/home/file_3,55555555555\n",
165
- content_data_merged.to_s)
166
- content_data_b.remove_instance('server_1', '/home/file_2')
167
- assert_equal("2\nA1,50,22222222222\nB1,60,44444444444\n2\nA1,50,server_1,/home/file_1,22222222222\nB1,60,server_1,/home/file_3,55555555555\n",
168
- content_data_b.to_s)
169
-
170
- assert_equal(true, content_data_merged == content_data_b)
171
- end
172
-
173
- def test_remove
174
- content_data_a = ContentData::ContentData.new
175
- content_data_a.add_instance("A1", 50, "server_1",
176
- "/home/file_1", 22222222222)
177
-
178
- content_data_b = ContentData::ContentData.new
179
- content_data_b.add_instance("A1", 50, "server_1",
180
- "/home/file_1", 22222222222)
181
- content_data_b.add_instance("A1", 50, "server_1",
182
- "extra_inst", 66666666666)
183
- content_data_b.add_instance("B1", 60, "server_1",
184
- "/home/file_2", 44444444444)
185
- content_data_b.add_instance("B1", 60, "server_1",
186
- "/home/file_3", 55555555555)
187
- content_data_removed = ContentData.remove(content_data_a, content_data_b)
188
- assert_equal(content_data_removed.to_s, "1\nB1,60,44444444444\n2\nB1,60,server_1,/home/file_2,44444444444\nB1,60,server_1,/home/file_3,55555555555\n")
189
- content_data_a.remove_instance('server_1', '/home/file_1')
190
- assert_equal(content_data_removed.to_s, "1\nB1,60,44444444444\n2\nB1,60,server_1,/home/file_2,44444444444\nB1,60,server_1,/home/file_3,55555555555\n")
191
- content_data_b.remove_instance('server_1', '/home/file_2')
192
- assert_equal(content_data_removed.to_s, "1\nB1,60,44444444444\n2\nB1,60,server_1,/home/file_2,44444444444\nB1,60,server_1,/home/file_3,55555555555\n")
193
-
194
- #check nil
195
- content_data_removed = ContentData.remove(nil, content_data_b)
196
- assert_equal(content_data_removed.to_s, content_data_b.to_s)
197
- content_data_removed = ContentData.remove(content_data_b, nil)
198
- assert_equal(content_data_removed, nil)
199
- end
200
-
201
- def test_remove_instances
202
- content_data_a = ContentData::ContentData.new
203
- content_data_a.add_instance("A1", 50, "server_1",
204
- "/home/file_1", 22222222222)
205
-
206
- content_data_b = ContentData::ContentData.new
207
- content_data_b.add_instance("A1", 50, "server_1",
208
- "/home/file_1", 22222222222)
209
- content_data_b.add_instance("A1", 50, "server_1",
210
- "extra_inst", 66666666666)
211
- content_data_b.add_instance("B1", 60, "server_1",
212
- "/home/file_2", 44444444444)
213
- content_data_b.add_instance("B1", 60, "server_1",
214
- "/home/file_3", 55555555555)
215
- content_data_removed = ContentData.remove_instances(content_data_a, content_data_b)
216
- assert_equal(content_data_removed.to_s,"2\nA1,50,22222222222\nB1,60,44444444444\n3\nA1,50,server_1,extra_inst,66666666666\nB1,60,server_1,/home/file_2,44444444444\nB1,60,server_1,/home/file_3,55555555555\n")
217
- content_data_a.remove_instance('server_1', '/home/file_1')
218
- assert_equal(content_data_removed.to_s,"2\nA1,50,22222222222\nB1,60,44444444444\n3\nA1,50,server_1,extra_inst,66666666666\nB1,60,server_1,/home/file_2,44444444444\nB1,60,server_1,/home/file_3,55555555555\n")
219
- content_data_b.remove_instance('server_1', '/home/file_2')
220
- assert_equal(content_data_removed.to_s,"2\nA1,50,22222222222\nB1,60,44444444444\n3\nA1,50,server_1,extra_inst,66666666666\nB1,60,server_1,/home/file_2,44444444444\nB1,60,server_1,/home/file_3,55555555555\n")
221
-
222
- #assert_equal(content_data_b, nil)
223
-
224
- #check nil
225
- content_data_removed = ContentData.remove_instances(nil, content_data_b)
226
- assert_equal(content_data_removed.to_s, content_data_b.to_s)
227
- content_data_removed = ContentData.remove_instances(content_data_b, nil)
228
- assert_equal(content_data_removed, nil)
229
- end
230
-
231
- def test_remove_directory
232
-
233
- content_data_b = ContentData::ContentData.new
234
- content_data_b.add_instance("A1", 50, "server_1",
235
- "/home/file_1", 22222222222)
236
- content_data_b.add_instance("A1", 50, "server_1",
237
- "extra_inst", 66666666666)
238
- content_data_b.add_instance("B1", 60, "server_1",
239
- "/home/file_2", 44444444444)
240
- content_data_b.add_instance("B1", 60, "server_1",
241
- "/home/file_3", 55555555555)
242
- content_data_removed = ContentData.remove_directory(content_data_b, 'home', "server_1")
243
- assert_equal("1\nA1,50,22222222222\n1\nA1,50,server_1,extra_inst,66666666666\n",
244
- content_data_removed.to_s)
245
-
246
- content_data_b.remove_instance('server_1', '/home/file_2')
247
- assert_equal("1\nA1,50,22222222222\n1\nA1,50,server_1,extra_inst,66666666666\n",
248
- content_data_removed.to_s)
249
-
250
- assert_equal("2\nA1,50,22222222222\nB1,60,44444444444\n3\nA1,50,server_1,/home/file_1,22222222222\nA1,50,server_1,extra_inst,66666666666\nB1,60,server_1,/home/file_3,55555555555\n",
251
- content_data_b.to_s)
252
-
253
- content_data_b = ContentData::ContentData.new
254
- content_data_removed = ContentData.remove_directory(content_data_b, 'home', "server_1")
255
- assert_equal(0, content_data_removed.contents_size)
256
- content_data_removed = ContentData.remove_directory(nil, 'home', "server_1")
257
- assert_equal(content_data_removed, nil)
258
- end
259
-
260
- def test_intersect
261
- content_data_a = ContentData::ContentData.new
262
- content_data_a.add_instance("A1", 50, "server_1",
263
- "/home/file_1", 22222222222)
264
- content_data_a.add_instance("C1", 70, "server_1",
265
- "/home/file_4", 77777777777)
266
- content_data_b = ContentData::ContentData.new
267
- content_data_b.add_instance("A1", 50, "server_1",
268
- "/home/file_1", 22222222222)
269
- content_data_b.add_instance("A1", 50, "server_1",
270
- "/home/file_5", 55555555555)
271
- content_data_b.add_instance("B1", 60, "server_1",
272
- "/home/file_2", 44444444444)
273
-
274
- content_data_intersect = ContentData.intersect(content_data_a, content_data_b)
275
- assert_equal(content_data_intersect.to_s, "1\nA1,50,22222222222\n2\nA1,50,server_1,/home/file_1,22222222222\nA1,50,server_1,/home/file_5,55555555555\n")
276
- end
277
-
278
- def test_unify_time
279
- content_data_a = ContentData::ContentData.new
280
- content_data_a.add_instance("A1", 50, "server_1",
281
- "/home/file_1", 22222222222)
282
- content_data_a.add_instance("C1", 70, "server_1",
283
- "/home/file_4", 77777777777)
284
- content_data_a.add_instance("C1", 70, "server_1",
285
- "/home/file_5", 33333333333)
286
- content_data_a.unify_time
287
- assert_equal(content_data_a.to_s, "2\nA1,50,22222222222\nC1,70,33333333333\n3\nA1,50,server_1,/home/file_1,22222222222\nC1,70,server_1,/home/file_4,33333333333\nC1,70,server_1,/home/file_5,33333333333\n")
288
- end
289
- end
290
-
291
-