adp-fluentd-plugin-gzip 0.0.3 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/adp-fluentd-plugin-gzip.gemspec +1 -1
- data/lib/fluent/plugin/parser_gzip.rb +22 -16
- data/test/adp/fluentd/plugin/gzip_test.rb +31 -7
- data/test/test_helper.rb +3 -4
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 035f43e830370693918be6653314292a027450a6eabf9fe3f7608cad2905b11f
|
4
|
+
data.tar.gz: d5583cff60b1220af5e04765531ed862bc5adee071d729520e040093609cf30b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c3913479f31d8b1c01afc99a7fb0dca966c730df3c1b08ec3fd6bacfe62f76ab5734a669c3f36992c4ae8998d07a40a87e2677cfd09be91485bcb402e59c18be
|
7
|
+
data.tar.gz: 9a787aace6432f99fada0ab66aad1899242d7eb5249ea9c6fc9ed0b16029bc583642d2bf87c79a8c4c990183e27bbe3a4f0c1ea5e529baca3d1a8eec6fe7ef8c
|
@@ -2,7 +2,7 @@ $:.push File.expand_path('../lib', __FILE__)
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |spec|
|
4
4
|
spec.name = "adp-fluentd-plugin-gzip"
|
5
|
-
spec.version = "0.0.
|
5
|
+
spec.version = "0.0.7"
|
6
6
|
spec.authors = ["Aleksander Dudek"]
|
7
7
|
spec.email = ["aleksander.dudek@ringieraxelspringer.pl"]
|
8
8
|
|
@@ -1,25 +1,31 @@
|
|
1
1
|
require 'fluent/plugin/parser'
|
2
2
|
require 'zlib'
|
3
|
+
require 'logger'
|
3
4
|
|
4
|
-
module Fluent
|
5
|
-
|
6
|
-
|
5
|
+
module Fluent
|
6
|
+
module Plugin
|
7
|
+
class GzipParser < Parser
|
8
|
+
Plugin.register_parser('gzip', self)
|
9
|
+
logger = Logger.new(STDOUT)
|
10
|
+
logger.level = Logger::INFO
|
7
11
|
|
8
|
-
|
9
|
-
|
10
|
-
|
12
|
+
def configure(conf)
|
13
|
+
super
|
14
|
+
end
|
11
15
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
+
def parse(text)
|
17
|
+
@logger.info("Text: #{text}")
|
18
|
+
@logger.info("After compression: #{compress(text)}")
|
19
|
+
text
|
20
|
+
end
|
16
21
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
22
|
+
def compress(string, level = Zlib::DEFAULT_COMPRESSION, strategy = Zlib::DEFAULT_STRATEGY)
|
23
|
+
output = Stream.new
|
24
|
+
gz = Zlib::GzipWriter.new(output, level, strategy)
|
25
|
+
gz.write(string)
|
26
|
+
gz.close
|
27
|
+
output.string
|
28
|
+
end
|
23
29
|
end
|
24
30
|
end
|
25
31
|
end
|
@@ -1,11 +1,35 @@
|
|
1
|
-
require
|
1
|
+
require 'test/unit'
|
2
|
+
require 'fluent/test/driver/parser'
|
3
|
+
require 'fluent/plugin/parser_gzip'
|
2
4
|
|
3
|
-
class
|
4
|
-
def
|
5
|
-
refute_nil ::Adp::Fluentd::Plugin::Gzip::VERSION
|
5
|
+
class ParserYourOwnTest < Test::Unit::TestCase
|
6
|
+
def setup
|
6
7
|
end
|
7
|
-
|
8
|
-
|
9
|
-
|
8
|
+
CONFIG = %[
|
9
|
+
pattern apache
|
10
|
+
]
|
11
|
+
def create_driver(conf = CONF)
|
12
|
+
Fluent::Test::Driver::Parser.new(Fluent::Plugin::GzipParser).configure(conf)
|
13
|
+
end
|
14
|
+
sub_test_case 'configured with invalid configurations' do
|
15
|
+
test 'empty' do
|
16
|
+
assert_raise(Fluent::ConfigError) do
|
17
|
+
create_driver('')
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
sub_test_case 'plugin will parse text' do
|
22
|
+
test 'record has a field' do
|
23
|
+
d = create_driver(CONFIG)
|
24
|
+
text = '192.168.0.1 - - [28/Feb/2013:12:00:00 +0900] "GET / HTTP/1.1" 200 777'
|
25
|
+
expected_time = event_time('28/Feb/2013:12:00:00 +0900', format: '%d/%b/%Y:%H:%M:%S %z')
|
26
|
+
expected_record = {
|
27
|
+
'method' => 'GET',
|
28
|
+
}
|
29
|
+
d.instance.parse(text) do |time, record|
|
30
|
+
assert_equal(expected_time, time)
|
31
|
+
assert_equal(expected_record, record)
|
32
|
+
end
|
33
|
+
end
|
10
34
|
end
|
11
35
|
end
|
data/test/test_helper.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
|
2
|
-
require
|
3
|
-
|
4
|
-
require "minitest/autorun"
|
1
|
+
require 'test/unit'
|
2
|
+
require 'fluent/test'
|
3
|
+
require "fluent/plugin/parser_gzip"
|