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
@@ -5,6 +5,8 @@
5
5
  # Such as automatic file generation, symlink, etc.
6
6
  # Run from bbfs> ruby -Ilib bin/file_utils --command=generate_files --log_write_to_console=true --log_debug_level=3
7
7
 
8
+ # TODO this module is deprecated and should be revised
9
+
8
10
  require 'content_data'
9
11
  require 'file_indexing'
10
12
  require 'file_utils'
@@ -15,6 +17,7 @@ require 'params'
15
17
 
16
18
  module FileUtils
17
19
  Params.string 'command', nil ,'path'
20
+ Params.string 'help', nil ,'get a help'
18
21
  Params.string 'ref_cd', nil ,'reference path'
19
22
  Params.string 'base_cd', nil ,'base path'
20
23
  Params.string 'dest', nil ,'destination path'
@@ -28,7 +31,8 @@ module FileUtils
28
31
  Params.string 'exist_cd', nil, 'exist_path'
29
32
  #Params.string 'config_file', 'path' ,'configuration file path'
30
33
  class FileUtils
31
- def FileUtils.run
34
+
35
+ def self.run
32
36
  if Params['command'] == 'mksymlink'
33
37
  if Params['ref_cd'].nil?
34
38
  Log.error ("--ref_cd is not set")
@@ -59,45 +63,16 @@ module FileUtils
59
63
 
60
64
  not_found = nil
61
65
  begin
62
- not_found = FileUtil.mksymlink(ref_cd, base_cd, Params['dest'])
66
+ not_found = FileUtils.mksymlink(ref_cd, base_cd, Params['dest'])
63
67
  rescue NotImplementedError
64
68
  Log.error ("symlinks are unimplemented on this machine")
65
69
  return nil
66
70
  end
67
71
  return not_found
68
- elsif (Params['command'] == "merge" or
69
- Params['command'] == "intersect" or
70
- Params['command'] == "minus")
71
-
72
- if Params['cd_a'].nil?
73
- Log.error ("--cd_a is not set")
74
- return
75
- end
76
- cd_a = ContentData.new()
77
- cd_a.from_file(Params['cd_a'])
78
- if cd_a.nil?
79
- Log.error ("Error loading content data cd_a=%s" % Params['cd_a'])
80
- return
81
- end
82
-
83
- if Params['cd_b'].nil?
84
- Log.error ("--cd_b is not set")
85
- return
86
- end
87
- cd_b = ContentData.new()
88
- cd_b.from_file(Params['cd_b'])
89
- if cd_b.nil?
90
- Log.error ("Error loading content data cd_b=%s" % Params['cd_b'])
91
- return
92
- end
93
-
94
- if Params['cd_b'].nil?
95
- Log.error ("--dest is not set")
96
- return
97
- end
98
-
99
- output = FileUtil.contet_data_command(Params['command'], cd_a, cd_b, Params['dest'])
100
-
72
+ elsif (Params['command'] == "merge" ||
73
+ Params['command'] == "intersect" ||
74
+ Params['command'] == "minus")
75
+ content_data_command
101
76
  elsif Params['command'] == 'unify_time'
102
77
  if Params['cd'].nil?
103
78
  Log.error ("--cd is not set")
@@ -176,20 +151,6 @@ module FileUtils
176
151
  end
177
152
  end
178
153
 
179
- def self.contet_data_command(command, cd_a, cd_b, dest_path)
180
- dest = nil
181
- if command == "merge"
182
- dest = ContentData.merge(cd_a, cd_b)
183
- elsif command == "intersect"
184
- dest = ContentData.intersect(cd_a, cd_b)
185
- elsif command == "minus"
186
- dest = ContentData.remove(cd_b, cd_a)
187
- end
188
- if dest
189
- dest.to_file(dest_path)
190
- end
191
- end
192
-
193
154
  # Unify modification/first_appearance time according to input DB
194
155
  # Input: ContentData
195
156
  # Output: ContentData with unified times
@@ -135,14 +135,14 @@ module Networking
135
135
  @tcp_socket = nil
136
136
  @obj_clb = obj_clb
137
137
  @reconnected_clb = reconnected_clb
138
- Log.debug3("Start TCPClient initialize with @obj_clb: %s", @obj_clb)
138
+ # Variable to signal when remote server is ready.
139
+ @remote_server_available = ConditionVariable.new
140
+ @remote_server_available_mutex = Mutex.new
141
+ Log.debug3("Start TCPClient initialize with @obj_clb: %s", @obj_clb)
139
142
  if @obj_clb != nil
140
143
  @tcp_thread = start_reading
141
144
  @tcp_thread.abort_on_exception = true
142
145
  end
143
- # Variable to signal when remote server is ready.
144
- @remote_server_available = ConditionVariable.new
145
- @remote_server_available_mutex = Mutex.new
146
146
  open_socket unless socket_good?
147
147
  Log.debug3("End TCPClient initialize.")
148
148
  end
@@ -0,0 +1,331 @@
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_data'
5
+ end
6
+ require 'rspec'
7
+ require 'tempfile'
8
+ require 'time.rb'
9
+ require 'content_server/server'
10
+ require_relative '../../lib/content_data/content_data.rb'
11
+
12
+ describe 'Content Data Test' do
13
+
14
+ before :all do
15
+ Params.init Array.new
16
+ # must preced Log.init, otherwise log containing default values will be created
17
+ Params['log_write_to_file'] = false
18
+ Log.init
19
+ end
20
+
21
+ it 'test cloning db 1' do
22
+ content_data = ContentData::ContentData.new
23
+ content_data.add_instance("A1", 1242, "server_1",
24
+ "/home/file_1", 2222222222)
25
+
26
+ content_data_cloned = ContentData::ContentData.new(content_data)
27
+ #check that DBs are equal
28
+ content_data_cloned.should == content_data
29
+
30
+ content_data_cloned.add_instance("A1", 1242, "server_1",
31
+ "/home/file_2", 3333333333)
32
+ #change orig DB - size
33
+ content_data_cloned.should_not == content_data
34
+ end
35
+
36
+ it 'test cloning db 2' do
37
+ content_data = ContentData::ContentData.new
38
+ content_data.add_instance("A1", 1242, "server_1",
39
+ "/home/file_1", 2222222222)
40
+
41
+ content_data_cloned = ContentData::ContentData.new(content_data)
42
+ #check that DBs are equal
43
+ content_data_cloned.should == content_data
44
+
45
+ content_data_cloned.add_instance("A2", 1243, "server_1",
46
+ "/home/file_2", 3333333333)
47
+ #change orig DB - size
48
+ content_data_cloned.should_not == content_data
49
+ end
50
+
51
+
52
+ it 'test add instance' do
53
+ #create first content with instance
54
+ content_data = ContentData::ContentData.new
55
+ content_data.add_instance("A1", 50, "server_1",
56
+ "/home/file_1", 2222222222)
57
+
58
+ #Add new instance - different size
59
+ # size would be overriden should not be added
60
+ content_data.add_instance("A1", 60, "server_1",
61
+ "/home/file_2", 2222222222)
62
+ expected = "1\nA1,60,2222222222\n2\nA1,60,server_1,/home/file_1,2222222222\nA1,60,server_1,/home/file_2,2222222222\n"
63
+ content_data.to_s.should == expected
64
+
65
+ #Add new instance - new content
66
+ #both new content and new instances are created in DB
67
+ content_data.add_instance("A2", 60, "server_1",
68
+ "/home/file_2", 3333333333)
69
+ expected = "2\nA1,60,2222222222\nA2,60,3333333333\n2\n" +
70
+ "A1,60,server_1,/home/file_1,2222222222\n" +
71
+ "A2,60,server_1,/home/file_2,3333333333\n"
72
+ content_data.to_s.should == expected
73
+
74
+ #Add new instance - same content
75
+ content_data.add_instance("A2", 60, "server_1",
76
+ "/home/file_3", 4444444444)
77
+ expected = "2\nA1,60,2222222222\nA2,60,3333333333\n3\n" +
78
+ "A1,60,server_1,/home/file_1,2222222222\n" +
79
+ "A2,60,server_1,/home/file_2,3333333333\n" +
80
+ "A2,60,server_1,/home/file_3,4444444444\n"
81
+ content_data.to_s.should == expected
82
+ end
83
+
84
+ it 'test instance exists' do
85
+ content_data = ContentData::ContentData.new
86
+ content_data.add_instance("A129", 50, "server_1",
87
+ "/home/file_1", 2222222222)
88
+ content_data.instance_exists('/home/file_1', 'server_1').should == true
89
+ content_data.instance_exists('/home/file_1', 'stum').should == false
90
+ end
91
+
92
+ it 'test remove instance' do
93
+ #remove instance also removes content
94
+ content_data = ContentData::ContentData.new
95
+ content_data.add_instance("A1", 50, "server_1",
96
+ "/home/file_1", 2222222222)
97
+ content_data.content_exists('A1').should == true
98
+ content_data.instance_exists('/home/file_1', 'server_1').should == true
99
+ content_data.remove_instance('server_1', '/home/file_1')
100
+ content_data.instance_exists('/home/file_1', 'server_1').should == false
101
+ content_data.content_exists('A1').should == false
102
+
103
+ #remove instance does not remove content
104
+ content_data.add_instance("A1", 50, "server_1",
105
+ "/home/file_1", 2222222222)
106
+ content_data.add_instance("A1", 50, "server_1",
107
+ "/home/file_2", 3333333333)
108
+ content_data.content_exists('A1').should == true
109
+ content_data.instance_exists('/home/file_1', 'server_1').should == true
110
+ content_data.remove_instance('server_1', '/home/file_1')
111
+ content_data.instance_exists('/home/file_1', 'server_1').should == false
112
+ content_data.content_exists('A1').should == true
113
+
114
+ #remove also removes content
115
+ content_data.remove_instance('server_1', '/home/file_2')
116
+ content_data.instance_exists('/home/file_1', 'server_1').should == false
117
+ content_data.content_exists('A1').should == false
118
+ end
119
+
120
+ it 'test to file from file' do
121
+ content_data = ContentData::ContentData.new
122
+ content_data.add_instance("A1", 50, "server_1",
123
+ "/home/file_1", 22222222222)
124
+ content_data.add_instance("B1", 60, "server_1",
125
+ "/home/file_2", 44444444444)
126
+ content_data.add_instance("B1", 60, "server_1",
127
+ "/home/file_3", 55555555555)
128
+ file_moc_object = StringIO.new
129
+ file_moc_object.write(content_data.to_s)
130
+ test_file = Tempfile.new('content_data_spec.test')
131
+ content_data.to_file(test_file)
132
+ content_data_2 = ContentData::ContentData.new
133
+ content_data_2.from_file(test_file)
134
+ (content_data == content_data_2).should == true
135
+ end
136
+
137
+ it 'test merge' do
138
+ content_data_a = ContentData::ContentData.new
139
+ content_data_a.add_instance("A1", 50, "server_1",
140
+ "/home/file_1", 22222222222)
141
+
142
+ content_data_b = ContentData::ContentData.new
143
+ content_data_b.add_instance("B1", 60, "server_1",
144
+ "/home/file_2", 44444444444)
145
+ content_data_b.add_instance("B1", 60, "server_1",
146
+ "/home/file_3", 55555555555)
147
+ content_data_merged = ContentData.merge(content_data_a, content_data_b)
148
+ expected = "2\nB1,60,44444444444\nA1,50,22222222222\n" +
149
+ "3\nB1,60,server_1,/home/file_2,44444444444\nB1,60,server_1,/home/file_3,55555555555\n" +
150
+ "A1,50,server_1,/home/file_1,22222222222\n"
151
+ content_data_merged.to_s.should == expected
152
+ content_data_a.remove_instance('server_1', '/home/file_1')
153
+ expected = "2\nB1,60,44444444444\nA1,50,22222222222\n" +
154
+ "3\nB1,60,server_1,/home/file_2,44444444444\nB1,60,server_1,/home/file_3,55555555555\n" +
155
+ "A1,50,server_1,/home/file_1,22222222222\n"
156
+ content_data_merged.to_s.should == expected
157
+ content_data_b.remove_instance('server_1', '/home/file_2')
158
+ expected = "2\nB1,60,44444444444\nA1,50,22222222222\n" +
159
+ "3\nB1,60,server_1,/home/file_2,44444444444\nB1,60,server_1,/home/file_3,55555555555\n" +
160
+ "A1,50,server_1,/home/file_1,22222222222\n"
161
+ content_data_merged.to_s.should == expected
162
+ end
163
+
164
+ it 'test merge override b' do
165
+ content_data_a = ContentData::ContentData.new
166
+ content_data_a.add_instance("A1", 50, "server_1",
167
+ "/home/file_1", 22222222222)
168
+
169
+ content_data_b = ContentData::ContentData.new
170
+ content_data_b.add_instance("A1", 50, "server_1",
171
+ "/home/file_1", 22222222222)
172
+ content_data_b.add_instance("B1", 60, "server_1",
173
+ "/home/file_2", 44444444444)
174
+ content_data_b.add_instance("B1", 60, "server_1",
175
+ "/home/file_3", 55555555555)
176
+ content_data_merged = ContentData.merge_override_b(content_data_a, content_data_b)
177
+ expected = "2\nA1,50,22222222222\nB1,60,44444444444\n" +
178
+ "3\nA1,50,server_1,/home/file_1,22222222222\nB1,60,server_1,/home/file_2,44444444444\n" +
179
+ "B1,60,server_1,/home/file_3,55555555555\n"
180
+ content_data_merged.to_s.should == expected
181
+
182
+ content_data_a.remove_instance('server_1', '/home/file_1')
183
+ expected = "2\nA1,50,22222222222\nB1,60,44444444444\n" +
184
+ "3\nA1,50,server_1,/home/file_1,22222222222\n" +
185
+ "B1,60,server_1,/home/file_2,44444444444\nB1,60,server_1,/home/file_3,55555555555\n"
186
+ content_data_merged.to_s.should == expected
187
+ content_data_b.remove_instance('server_1', '/home/file_2')
188
+ expected = "2\nA1,50,22222222222\nB1,60,44444444444\n" +
189
+ "2\nA1,50,server_1,/home/file_1,22222222222\nB1,60,server_1,/home/file_3,55555555555\n"
190
+ content_data_b.to_s.should == expected
191
+
192
+ (content_data_merged == content_data_b).should == true
193
+ end
194
+
195
+ it 'test remove' do
196
+ content_data_a = ContentData::ContentData.new
197
+ content_data_a.add_instance("A1", 50, "server_1",
198
+ "/home/file_1", 22222222222)
199
+
200
+ content_data_b = ContentData::ContentData.new
201
+ content_data_b.add_instance("A1", 50, "server_1",
202
+ "/home/file_1", 22222222222)
203
+ content_data_b.add_instance("A1", 50, "server_1",
204
+ "extra_inst", 66666666666)
205
+ content_data_b.add_instance("B1", 60, "server_1",
206
+ "/home/file_2", 44444444444)
207
+ content_data_b.add_instance("B1", 60, "server_1",
208
+ "/home/file_3", 55555555555)
209
+ content_data_removed = ContentData.remove(content_data_a, content_data_b)
210
+ expected = "1\nB1,60,44444444444\n2\nB1,60,server_1,/home/file_2,44444444444\nB1,60,server_1,/home/file_3,55555555555\n"
211
+ content_data_removed.to_s.should == expected
212
+ content_data_a.remove_instance('server_1', '/home/file_1')
213
+ expected = "1\nB1,60,44444444444\n2\nB1,60,server_1,/home/file_2,44444444444\nB1,60,server_1,/home/file_3,55555555555\n"
214
+ content_data_removed.to_s.should == expected
215
+ content_data_b.remove_instance('server_1', '/home/file_2')
216
+ expected = "1\nB1,60,44444444444\n2\nB1,60,server_1,/home/file_2,44444444444\nB1,60,server_1,/home/file_3,55555555555\n"
217
+ content_data_removed.to_s.should == expected
218
+
219
+ #check nil
220
+ content_data_removed = ContentData.remove(nil, content_data_b)
221
+ content_data_b.to_s.should == content_data_removed.to_s
222
+ content_data_removed = ContentData.remove(content_data_b, nil)
223
+ nil.should == content_data_removed
224
+ end
225
+
226
+ it 'test remove instances' do
227
+ content_data_a = ContentData::ContentData.new
228
+ content_data_a.add_instance("A1", 50, "server_1",
229
+ "/home/file_1", 22222222222)
230
+
231
+ content_data_b = ContentData::ContentData.new
232
+ content_data_b.add_instance("A1", 50, "server_1",
233
+ "/home/file_1", 22222222222)
234
+ content_data_b.add_instance("A1", 50, "server_1",
235
+ "extra_inst", 66666666666)
236
+ content_data_b.add_instance("B1", 60, "server_1",
237
+ "/home/file_2", 44444444444)
238
+ content_data_b.add_instance("B1", 60, "server_1",
239
+ "/home/file_3", 55555555555)
240
+ content_data_removed = ContentData.remove_instances(content_data_a, content_data_b)
241
+ expected = "2\nA1,50,22222222222\nB1,60,44444444444\n" +
242
+ "3\nA1,50,server_1,extra_inst,66666666666\nB1,60,server_1,/home/file_2,44444444444\n" +
243
+ "B1,60,server_1,/home/file_3,55555555555\n"
244
+ content_data_removed.to_s.should == expected
245
+ content_data_a.remove_instance('server_1', '/home/file_1')
246
+ expected = "2\nA1,50,22222222222\nB1,60,44444444444\n" +
247
+ "3\nA1,50,server_1,extra_inst,66666666666\nB1,60,server_1,/home/file_2,44444444444\n" +
248
+ "B1,60,server_1,/home/file_3,55555555555\n"
249
+ content_data_removed.to_s.should == expected
250
+ content_data_b.remove_instance('server_1', '/home/file_2')
251
+ expected = "2\nA1,50,22222222222\nB1,60,44444444444\n" +
252
+ "3\nA1,50,server_1,extra_inst,66666666666\nB1,60,server_1,/home/file_2,44444444444\n" +
253
+ "B1,60,server_1,/home/file_3,55555555555\n"
254
+ content_data_removed.to_s.should == expected
255
+
256
+ #nil.should == content_data_b
257
+
258
+ #check nil
259
+ content_data_removed = ContentData.remove_instances(nil, content_data_b)
260
+ content_data_b.to_s.should == content_data_removed.to_s
261
+ content_data_removed = ContentData.remove_instances(content_data_b, nil)
262
+ content_data_removed.should == nil
263
+ end
264
+
265
+ it 'test remove directory' do
266
+
267
+ content_data_b = ContentData::ContentData.new
268
+ content_data_b.add_instance("A1", 50, "server_1",
269
+ "/home/file_1", 22222222222)
270
+ content_data_b.add_instance("A1", 50, "server_1",
271
+ "extra_inst", 66666666666)
272
+ content_data_b.add_instance("B1", 60, "server_1",
273
+ "/home/file_2", 44444444444)
274
+ content_data_b.add_instance("B1", 60, "server_1",
275
+ "/home/file_3", 55555555555)
276
+ content_data_removed = ContentData.remove_directory(content_data_b, 'home', "server_1")
277
+ expected = "1\nA1,50,22222222222\n1\nA1,50,server_1,extra_inst,66666666666\n"
278
+ content_data_removed.to_s.should == expected
279
+
280
+ content_data_b.remove_instance('server_1', '/home/file_2')
281
+ expected = "1\nA1,50,22222222222\n1\nA1,50,server_1,extra_inst,66666666666\n"
282
+ content_data_removed.to_s.should == expected
283
+
284
+ expected = "2\nA1,50,22222222222\nB1,60,44444444444\n" +
285
+ "3\nA1,50,server_1,/home/file_1,22222222222\nA1,50,server_1,extra_inst,66666666666\n" +
286
+ "B1,60,server_1,/home/file_3,55555555555\n"
287
+ content_data_b.to_s.should == expected
288
+
289
+ content_data_b = ContentData::ContentData.new
290
+ content_data_removed = ContentData.remove_directory(content_data_b, 'home', "server_1")
291
+ content_data_removed.contents_size.should == 0
292
+ content_data_removed = ContentData.remove_directory(nil, 'home', "server_1")
293
+ content_data_removed.should == nil
294
+ end
295
+
296
+ it 'test intersect' do
297
+ content_data_a = ContentData::ContentData.new
298
+ content_data_a.add_instance("A1", 50, "server_1",
299
+ "/home/file_1", 22222222222)
300
+ content_data_a.add_instance("C1", 70, "server_1",
301
+ "/home/file_4", 77777777777)
302
+ content_data_b = ContentData::ContentData.new
303
+ content_data_b.add_instance("A1", 50, "server_1",
304
+ "/home/file_1", 22222222222)
305
+ content_data_b.add_instance("A1", 50, "server_1",
306
+ "/home/file_5", 55555555555)
307
+ content_data_b.add_instance("B1", 60, "server_1",
308
+ "/home/file_2", 44444444444)
309
+
310
+ content_data_intersect = ContentData.intersect(content_data_a, content_data_b)
311
+ expected = "1\nA1,50,22222222222\n" +
312
+ "2\nA1,50,server_1,/home/file_1,22222222222\nA1,50,server_1,/home/file_5,55555555555\n"
313
+ content_data_intersect.to_s.should == expected
314
+ end
315
+
316
+ it 'test unify time' do
317
+ content_data_a = ContentData::ContentData.new
318
+ content_data_a.add_instance("A1", 50, "server_1",
319
+ "/home/file_1", 22222222222)
320
+ content_data_a.add_instance("C1", 70, "server_1",
321
+ "/home/file_4", 77777777777)
322
+ content_data_a.add_instance("C1", 70, "server_1",
323
+ "/home/file_5", 33333333333)
324
+ content_data_a.unify_time
325
+ expected = "2\nA1,50,22222222222\nC1,70,33333333333\n" +
326
+ "3\nA1,50,server_1,/home/file_1,22222222222\nC1,70,server_1,/home/file_4,33333333333\n" +
327
+ "C1,70,server_1,/home/file_5,33333333333\n"
328
+ content_data_a.to_s.should == expected
329
+ end
330
+ end
331
+
@@ -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_data'
5
+ end
1
6
  require 'rspec'
2
7
  require 'file_indexing/index_agent'
3
8
  require 'params'