logstash-output-qingstor 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +2 -0
- data/README_zh_CN.md +4 -4
- data/lib/logstash/outputs/qingstor/rotation_policy.rb +9 -1
- data/lib/logstash/outputs/qingstor/temporary_file.rb +4 -6
- data/lib/logstash/outputs/qingstor.rb +2 -2
- data/logstash-output-qingstor.gemspec +1 -1
- data/spec/outputs/qingstor/temporary_file_spec.rb +11 -8
- data/spec/outputs/qingstor/uploader_spec.rb +13 -2
- data/spec/outputs/qingstor_spec.rb +14 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7cd73fbefc5156daf65ed1b5cbf65294847cafb9a36543ff2a33d2250ae8ee6c
|
4
|
+
data.tar.gz: 760d9f12c2facce1b5cf73eb309ff55a24c0857d110549d3166920477eef53a8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '08b89f4023ca52c4db4a2ab24e973b139b4ca8dd23b63b8cf0b7e68f406ecb504c871176015c3da23fc8d5879552c49620908603ae8b6315d617fd5296c0956e'
|
7
|
+
data.tar.gz: 7140d939f04a284fd1c7e65d310a4e6e0ed25780e15c3843e74c02f7d857b6021f47e453b8532eeca5a131906c00c297f46e94bc38aa0440f1b53524b1182bb0
|
data/CHANGELOG.md
CHANGED
data/README_zh_CN.md
CHANGED
@@ -58,11 +58,11 @@ output {
|
|
58
58
|
# 默认: "size_and_time". 可选枚举值["size_and_time", "size", "time"].
|
59
59
|
rotation_strategy => "size_and_time"
|
60
60
|
|
61
|
-
# 配合"size_and_time", "size"的可选配置型, 单位
|
62
|
-
# 默认:
|
63
|
-
size_file =>
|
61
|
+
# 配合"size_and_time", "size"的可选配置型, 单位 MB(megabyte)
|
62
|
+
# 默认: 5 (MB)
|
63
|
+
size_file => 5
|
64
64
|
|
65
|
-
# 配合"size_and_time", "time"的可选配置型, 单位minute
|
65
|
+
# 配合"size_and_time", "time"的可选配置型, 单位 minute
|
66
66
|
# 默认: 15 (minutes)
|
67
67
|
time_file => 15
|
68
68
|
|
@@ -73,7 +73,15 @@ module LogStash
|
|
73
73
|
end
|
74
74
|
|
75
75
|
def initialize(policy, file_size, file_time)
|
76
|
-
@policy = Policy(policy, file_size, file_time)
|
76
|
+
@policy = Policy(policy, to_bytes(file_size), to_seconds(file_time))
|
77
|
+
end
|
78
|
+
|
79
|
+
def to_seconds(file_time)
|
80
|
+
file_time * 60
|
81
|
+
end
|
82
|
+
|
83
|
+
def to_bytes(file_size)
|
84
|
+
file_size * 1024 * 1024
|
77
85
|
end
|
78
86
|
|
79
87
|
def rotate?(file)
|
@@ -14,12 +14,12 @@ module LogStash
|
|
14
14
|
|
15
15
|
def_delegators :@fd, :path, :write, :close, :fsync
|
16
16
|
|
17
|
-
attr_reader :fd
|
17
|
+
attr_reader :fd, :dir_path
|
18
18
|
|
19
|
-
def initialize(key, fd,
|
19
|
+
def initialize(key, fd, dir_path)
|
20
20
|
@key = key
|
21
21
|
@fd = fd
|
22
|
-
@
|
22
|
+
@dir_path = dir_path
|
23
23
|
@created_at = Time.now
|
24
24
|
end
|
25
25
|
|
@@ -27,8 +27,6 @@ module LogStash
|
|
27
27
|
@created_at
|
28
28
|
end
|
29
29
|
|
30
|
-
attr_reader :tmp_path
|
31
|
-
|
32
30
|
def size
|
33
31
|
@fd.size
|
34
32
|
rescue IOError
|
@@ -49,7 +47,7 @@ module LogStash
|
|
49
47
|
rescue
|
50
48
|
IOError
|
51
49
|
end
|
52
|
-
FileUtils.
|
50
|
+
FileUtils.rm_f(path)
|
53
51
|
end
|
54
52
|
|
55
53
|
def empty?
|
@@ -76,8 +76,8 @@ class LogStash::Outputs::Qingstor < LogStash::Outputs::Base
|
|
76
76
|
config :rotation_strategy, :validate => %w[size_and_time size time],
|
77
77
|
:default => 'size_and_time'
|
78
78
|
|
79
|
-
# Define the size requirement for each file to upload to QingStor. In
|
80
|
-
config :file_size, :validate => :number, :default =>
|
79
|
+
# Define the size requirement for each file to upload to QingStor. In megabyte(MB).
|
80
|
+
config :file_size, :validate => :number, :default => 5
|
81
81
|
|
82
82
|
# Define the time interval for each file to upload to QingStor. In minutes.
|
83
83
|
config :file_time, :validate => :number, :default => 15
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'logstash-output-qingstor'
|
3
|
-
s.version = '0.3.
|
3
|
+
s.version = '0.3.2'
|
4
4
|
s.licenses = ['Apache License (2.0)']
|
5
5
|
s.summary = 'logstash output plugin for qingstor'
|
6
6
|
s.description = 'Collect the outputs of logstash and store into QingStor'
|
@@ -6,16 +6,19 @@ require 'fileutils'
|
|
6
6
|
require 'tmpdir'
|
7
7
|
|
8
8
|
describe LogStash::Outputs::Qingstor::TemporaryFile do
|
9
|
+
def file_path
|
10
|
+
File.join(Dir.tmpdir, 'foo.log')
|
11
|
+
end
|
12
|
+
|
9
13
|
subject { described_class.new(key, io, Dir.tmpdir) }
|
10
14
|
|
11
15
|
let(:key) { 'foo.log' }
|
12
16
|
let(:content) { 'May the code be with you!' }
|
13
|
-
let(:tmp_path) { File.join(Dir.tmpdir, key) }
|
14
17
|
let(:file_mode) { 'w+' }
|
15
|
-
let(:io) { ::File.open(
|
18
|
+
let(:io) { ::File.open(file_path, file_mode) }
|
16
19
|
|
17
20
|
after(:all) do
|
18
|
-
FileUtils.rm(
|
21
|
+
FileUtils.rm(file_path) if File.exist?(file_path)
|
19
22
|
end
|
20
23
|
|
21
24
|
it 'return the key of the file' do
|
@@ -31,11 +34,11 @@ describe LogStash::Outputs::Qingstor::TemporaryFile do
|
|
31
34
|
it 'can return the correct file size' do
|
32
35
|
subject.write(content)
|
33
36
|
subject.close
|
34
|
-
expect(subject.size).to eq(File.size(
|
37
|
+
expect(subject.size).to eq(File.size(file_path))
|
35
38
|
end
|
36
39
|
|
37
|
-
it 'return the
|
38
|
-
expect(File.join(subject.
|
40
|
+
it 'return the file_path of the file' do
|
41
|
+
expect(File.join(subject.dir_path, subject.key)).to eq(file_path)
|
39
42
|
end
|
40
43
|
|
41
44
|
it 'return the creation time' do
|
@@ -43,9 +46,9 @@ describe LogStash::Outputs::Qingstor::TemporaryFile do
|
|
43
46
|
end
|
44
47
|
|
45
48
|
it 'can delete file correctly' do
|
46
|
-
expect(File.exist?(
|
49
|
+
expect(File.exist?(file_path)).to be_truthy
|
47
50
|
subject.delete!
|
48
|
-
expect(File.exist?(
|
51
|
+
expect(File.exist?(file_path)).to be_falsey
|
49
52
|
end
|
50
53
|
|
51
54
|
it 'return if the file is empty' do
|
@@ -5,7 +5,7 @@ require 'logstash/outputs/qingstor/uploader'
|
|
5
5
|
require 'logstash/outputs/qingstor/temporary_file'
|
6
6
|
require 'qingstor/sdk'
|
7
7
|
require 'stud/temporary'
|
8
|
-
|
8
|
+
require 'fileutils'
|
9
9
|
require_relative '../qs_access_helper'
|
10
10
|
|
11
11
|
describe LogStash::Outputs::Qingstor::Uploader do
|
@@ -31,8 +31,13 @@ describe LogStash::Outputs::Qingstor::Uploader do
|
|
31
31
|
f
|
32
32
|
end
|
33
33
|
|
34
|
-
|
34
|
+
before(:all) do
|
35
|
+
clean_remote_files
|
36
|
+
end
|
37
|
+
|
38
|
+
after(:each) do
|
35
39
|
delete_remote_file key
|
40
|
+
FileUtils.rm_r(tmp_file)
|
36
41
|
end
|
37
42
|
|
38
43
|
it 'upload file to the qingstor bucket' do
|
@@ -40,6 +45,12 @@ describe LogStash::Outputs::Qingstor::Uploader do
|
|
40
45
|
expect(list_remote_file.size).to eq(1)
|
41
46
|
end
|
42
47
|
|
48
|
+
it 'async upload file to qingstor' do
|
49
|
+
subject.upload_async(file)
|
50
|
+
sleep 2
|
51
|
+
expect(list_remote_file.size).to eq(1)
|
52
|
+
end
|
53
|
+
|
43
54
|
it 'execute a callback when the upload is complete' do
|
44
55
|
callback = proc { |f| }
|
45
56
|
expect(callback).to receive(:call).with(file)
|
@@ -9,10 +9,15 @@ require_relative './qs_access_helper'
|
|
9
9
|
require_relative './spec_helper'
|
10
10
|
|
11
11
|
describe LogStash::Outputs::Qingstor do
|
12
|
+
def tmp_dir_path
|
13
|
+
File.join(Dir.tmpdir, 'lg_qs_spec')
|
14
|
+
end
|
15
|
+
|
12
16
|
let(:prefix) { 'ss/%{server}' }
|
13
17
|
let(:event) { LogStash::Event.new('server' => 'overwatch') }
|
14
18
|
let(:event_encoded) { 'May the code be with you!' }
|
15
19
|
let(:events_and_encoded) { { event => event_encoded } }
|
20
|
+
let(:tmpdir) { tmp_dir_path }
|
16
21
|
let(:options) do
|
17
22
|
{
|
18
23
|
'access_key_id' => ENV['access_key_id'],
|
@@ -22,14 +27,17 @@ describe LogStash::Outputs::Qingstor do
|
|
22
27
|
'prefix' => prefix
|
23
28
|
}
|
24
29
|
end
|
25
|
-
|
30
|
+
|
31
|
+
before(:all) do
|
32
|
+
FileUtils.mkdir_p(tmp_dir_path) unless File.exist?(tmp_dir_path)
|
33
|
+
end
|
26
34
|
|
27
|
-
after do
|
35
|
+
after(:each) do
|
28
36
|
clean_remote_files
|
29
37
|
end
|
30
38
|
|
31
|
-
|
32
|
-
FileUtils.
|
39
|
+
after(:all) do
|
40
|
+
FileUtils.rm_rf(tmp_dir_path)
|
33
41
|
end
|
34
42
|
|
35
43
|
it 'done work with minimal options' do
|
@@ -37,7 +45,7 @@ describe LogStash::Outputs::Qingstor do
|
|
37
45
|
expect(list_remote_file.size).to eq(1)
|
38
46
|
end
|
39
47
|
|
40
|
-
it 'use aes256 to encrpytion in the server side' do
|
48
|
+
it 'use aes256 to encrpytion in the server side', :target => true do
|
41
49
|
cipher = OpenSSL::Cipher::AES256.new(:CBC)
|
42
50
|
cipher.encrypt
|
43
51
|
key = cipher.random_key
|
@@ -48,6 +56,7 @@ describe LogStash::Outputs::Qingstor do
|
|
48
56
|
end
|
49
57
|
|
50
58
|
it 'upload existing file if turn on restore function' do
|
59
|
+
binding.pry
|
51
60
|
non_empty_file = File.open(File.join(tmpdir, 'non-empty-file'), 'w')
|
52
61
|
non_empty_file.write(event_encoded * 10)
|
53
62
|
non_empty_file.close
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-output-qingstor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Evan Zhao
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-01-
|
11
|
+
date: 2018-01-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|