ralf 0.1.1 → 0.1.3
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.
- data/spec/ralf_spec.rb +54 -14
- metadata +12 -2
data/spec/ralf_spec.rb
CHANGED
@@ -5,7 +5,11 @@ require 'ralf'
|
|
5
5
|
describe Ralf do
|
6
6
|
|
7
7
|
before(:each) do
|
8
|
-
@default_params = {
|
8
|
+
@default_params = {
|
9
|
+
:config => File.dirname(__FILE__) + '/fixtures/config.yaml',
|
10
|
+
:out_seperator => ':year/:month/:day',
|
11
|
+
:date => '2010-02-10'
|
12
|
+
}
|
9
13
|
end
|
10
14
|
|
11
15
|
it "should initialize properly" do
|
@@ -62,7 +66,7 @@ describe Ralf do
|
|
62
66
|
describe "Date handling" do
|
63
67
|
|
64
68
|
it "should set the date to today" do
|
65
|
-
ralf = Ralf.new(
|
69
|
+
ralf = Ralf.new()
|
66
70
|
date = Date.today
|
67
71
|
ralf.date.should eql("%4d-%02d-%02d" % [date.year, date.month, date.day])
|
68
72
|
end
|
@@ -74,11 +78,21 @@ describe Ralf do
|
|
74
78
|
|
75
79
|
it "should raise error when invalid date given" do
|
76
80
|
lambda {
|
77
|
-
ralf = Ralf.new(@default_params.merge(:date => '
|
81
|
+
ralf = Ralf.new(@default_params.merge(:date => 'someday'))
|
78
82
|
ralf.date.should be_nil
|
79
83
|
}.should raise_error(ArgumentError, "invalid date")
|
80
84
|
end
|
81
85
|
|
86
|
+
xit "should accept a range of dates" do
|
87
|
+
ralf = Ralf.new(@default_params.merge(:date => 'now'))
|
88
|
+
ralf.date.should be_nil
|
89
|
+
end
|
90
|
+
|
91
|
+
xit "should accept a month and convert it to a date" do
|
92
|
+
ralf = Ralf.new(@default_params.merge(:date => 'januari'))
|
93
|
+
ralf.date.should be_nil
|
94
|
+
end
|
95
|
+
|
82
96
|
end
|
83
97
|
|
84
98
|
describe "Handle Buckets" do
|
@@ -86,10 +100,11 @@ describe Ralf do
|
|
86
100
|
before(:each) do
|
87
101
|
@ralf = Ralf.new(@default_params)
|
88
102
|
@bucket1 = {:name => 'bucket1'}
|
89
|
-
@bucket1.should_receive(:logging_info).any_number_of_times.and_return({ :enabled => true, :targetprefix => "log/" })
|
103
|
+
@bucket1.should_receive(:logging_info).any_number_of_times.and_return({ :enabled => true, :targetprefix => "log/access_log-" })
|
90
104
|
@bucket1.should_receive(:name).any_number_of_times.and_return('media.kerdienstgemist.nl')
|
91
105
|
@bucket2 = {:name => 'bucket2'}
|
92
106
|
@bucket2.should_receive(:logging_info).any_number_of_times.and_return({ :enabled => false, :targetprefix => "log/" })
|
107
|
+
@bucket2.should_receive(:name).any_number_of_times.and_return('media.kerdienstgemist.nl')
|
93
108
|
end
|
94
109
|
|
95
110
|
it "should find buckets with logging enabled" do
|
@@ -100,16 +115,17 @@ describe Ralf do
|
|
100
115
|
end
|
101
116
|
|
102
117
|
it "should save logging to disk" do
|
103
|
-
@key1 = {:name => 'log/2010-02-10-00-05-32-ZDRFGTCKUYVJCT', :data => 'This is content'}
|
104
|
-
@key2 = {:name => 'log/2010-02-10-00-07-28-EFREUTERGRSGDH', :data => 'This is content'}
|
118
|
+
@key1 = {:name => 'log/access_log-2010-02-10-00-05-32-ZDRFGTCKUYVJCT', :data => 'This is content'}
|
119
|
+
@key2 = {:name => 'log/access_log-2010-02-10-00-07-28-EFREUTERGRSGDH', :data => 'This is content'}
|
105
120
|
@bucket1.should_receive(:keys).any_number_of_times.and_return([@key1, @key2])
|
106
121
|
@key1.should_receive(:name).any_number_of_times.and_return(@key1[:name])
|
107
122
|
@key2.should_receive(:name).any_number_of_times.and_return(@key2[:name])
|
108
123
|
@key1.should_receive(:data).any_number_of_times.and_return(@key1[:data])
|
109
124
|
@key2.should_receive(:data).any_number_of_times.and_return(@key2[:data])
|
110
|
-
File.should_receive(:makedirs).twice.and_return(true)
|
111
|
-
File.should_receive(:exists?).
|
112
|
-
File.should_receive(:
|
125
|
+
File.should_receive(:makedirs).twice.with('/Users/berl/S3/media.kerdienstgemist.nl/log/2010/02/10').and_return(true)
|
126
|
+
File.should_receive(:exists?).once.with( '/Users/berl/S3/media.kerdienstgemist.nl/log/2010/02/10/access_log-2010-02-10-00-07-28-EFREUTERGRSGDH').and_return(true)
|
127
|
+
File.should_receive(:exists?).once.with( '/Users/berl/S3/media.kerdienstgemist.nl/log/2010/02/10/access_log-2010-02-10-00-05-32-ZDRFGTCKUYVJCT').and_return(false)
|
128
|
+
File.should_receive(:open).once.with( '/Users/berl/S3/media.kerdienstgemist.nl/log/2010/02/10/access_log-2010-02-10-00-05-32-ZDRFGTCKUYVJCT', "w").and_return(true)
|
113
129
|
|
114
130
|
@ralf.save_logging_to_disk(@bucket1).should eql([@key1, @key2])
|
115
131
|
end
|
@@ -117,16 +133,16 @@ describe Ralf do
|
|
117
133
|
it "should merge all logs" do
|
118
134
|
out_string = StringIO.new
|
119
135
|
|
120
|
-
Dir.should_receive(:glob).with('/Users/berl/S3/media.kerdienstgemist.nl/log/2010-02-10*').and_return(
|
121
|
-
['/Users/berl/S3/media.kerdienstgemist.nl/log/2010-02-10-00-05-32-ZDRFGTCKUYVJCT',
|
122
|
-
'/Users/berl/S3/media.kerdienstgemist.nl/log/2010-02-10-00-07-28-EFREUTERGRSGDH'])
|
136
|
+
Dir.should_receive(:glob).with('/Users/berl/S3/media.kerdienstgemist.nl/log/2010/02/10/access_log-2010-02-10*').and_return(
|
137
|
+
['/Users/berl/S3/media.kerdienstgemist.nl/log/2010/02/10/access_log-2010-02-10-00-05-32-ZDRFGTCKUYVJCT',
|
138
|
+
'/Users/berl/S3/media.kerdienstgemist.nl/log/2010/02/10/access_log-2010-02-10-00-07-28-EFREUTERGRSGDH'])
|
123
139
|
|
124
140
|
File.should_receive(:open).with('/Users/berl/S3/s3_combined_media.kerdienstgemist.nl_2010-02-10.alf', "w").and_yield(out_string)
|
125
141
|
|
126
142
|
LogMerge::Merger.should_receive(:merge).with(
|
127
143
|
out_string,
|
128
|
-
'/Users/berl/S3/media.kerdienstgemist.nl/log/2010-02-10-00-05-32-ZDRFGTCKUYVJCT',
|
129
|
-
'/Users/berl/S3/media.kerdienstgemist.nl/log/2010-02-10-00-07-28-EFREUTERGRSGDH'
|
144
|
+
'/Users/berl/S3/media.kerdienstgemist.nl/log/2010/02/10/access_log-2010-02-10-00-05-32-ZDRFGTCKUYVJCT',
|
145
|
+
'/Users/berl/S3/media.kerdienstgemist.nl/log/2010/02/10/access_log-2010-02-10-00-07-28-EFREUTERGRSGDH'
|
130
146
|
)
|
131
147
|
|
132
148
|
@ralf.merge_to_combined(@bucket1)
|
@@ -134,6 +150,30 @@ describe Ralf do
|
|
134
150
|
out_string.string.should eql('')
|
135
151
|
end
|
136
152
|
|
153
|
+
it "should save logs which have a targetprefix containing a '/'" do
|
154
|
+
@ralf.local_log_dirname(@bucket1).should eql('/Users/berl/S3/media.kerdienstgemist.nl/log/2010/02/10')
|
155
|
+
@ralf.local_log_dirname(@bucket2).should eql('/Users/berl/S3/media.kerdienstgemist.nl/log/2010/02/10')
|
156
|
+
end
|
157
|
+
|
158
|
+
it "should save to a subdir when a out_seperator is given" do
|
159
|
+
@ralf.local_log_dirname(@bucket1).should eql('/Users/berl/S3/media.kerdienstgemist.nl/log/2010/02/10')
|
160
|
+
|
161
|
+
@ralf.out_seperator = ':year/w:week'
|
162
|
+
@ralf.local_log_dirname(@bucket1).should eql('/Users/berl/S3/media.kerdienstgemist.nl/log/2010/w06')
|
163
|
+
end
|
164
|
+
|
165
|
+
it "should get the proper directories" do
|
166
|
+
@key.should_receive(:name).and_return('log/access_log-2010-02-10-00-05-32-ZDRFGTCKUYVJCT')
|
167
|
+
@ralf.local_log_file_basename_prefix(@bucket1).should eql('access_log-')
|
168
|
+
@ralf.local_log_file_basename(@bucket1, @key).should eql('access_log-2010-02-10-00-05-32-ZDRFGTCKUYVJCT')
|
169
|
+
@ralf.local_log_dirname(@bucket1).should eql('/Users/berl/S3/media.kerdienstgemist.nl/log/2010/02/10')
|
170
|
+
|
171
|
+
@key.should_receive(:name).and_return('log/2010-02-10-00-05-32-ZDRFGTCKUYVJCT')
|
172
|
+
@ralf.local_log_file_basename_prefix(@bucket2).should eql('')
|
173
|
+
@ralf.local_log_file_basename(@bucket2, @key).should eql('2010-02-10-00-05-32-ZDRFGTCKUYVJCT')
|
174
|
+
@ralf.local_log_dirname(@bucket2).should eql('/Users/berl/S3/media.kerdienstgemist.nl/log/2010/02/10')
|
175
|
+
end
|
176
|
+
|
137
177
|
end
|
138
178
|
|
139
179
|
describe "Conversion" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ralf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Klaas Jan Wierenga
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2010-02-
|
13
|
+
date: 2010-02-17 00:00:00 +01:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -33,6 +33,16 @@ dependencies:
|
|
33
33
|
- !ruby/object:Gem::Version
|
34
34
|
version: 1.0.0
|
35
35
|
version:
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: chronic
|
38
|
+
type: :runtime
|
39
|
+
version_requirement:
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
requirements:
|
42
|
+
- - ">="
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: 0.2.3
|
45
|
+
version:
|
36
46
|
description: " Download logfiles from Amazon S3 buckets to local disk and combine them in one Apache CLF per bucket\n"
|
37
47
|
email:
|
38
48
|
executables: []
|