fluent-plugin-sumologic-cloud-syslog 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,149 @@
1
+ # Copyright 2016 Acquia, Inc.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ require 'helper'
16
+ require 'date'
17
+ require 'sumologic_cloud_syslog/protocol'
18
+
19
+ class Protocol < Test::Unit::TestCase
20
+ def test_header_defaults
21
+ h = SumologicCloudSyslog::Header.new
22
+
23
+ # Check defaults
24
+ assert_equal h.severity, 'INFO'
25
+ assert_equal h.facility, 'LOCAL0'
26
+ assert_equal h.version, 1
27
+ assert_equal h.hostname, SumologicCloudSyslog::NIL_VALUE
28
+ assert_equal h.app_name, SumologicCloudSyslog::NIL_VALUE
29
+ assert_equal h.procid, SumologicCloudSyslog::NIL_VALUE
30
+ assert_equal h.msgid, SumologicCloudSyslog::NIL_VALUE
31
+
32
+ assert_equal h.to_s, "<#{h.pri}>1 #{h.timestamp.to_datetime.rfc3339} - - - -"
33
+ end
34
+
35
+ def test_header_facility_setter
36
+ h = SumologicCloudSyslog::Header.new
37
+ assert_raise do
38
+ h.facility = "NON_EXISTING"
39
+ end
40
+ SumologicCloudSyslog::Header::FACILITIES.each do |facility, _|
41
+ assert_nothing_raised do
42
+ h.facility = facility
43
+ end
44
+ end
45
+ end
46
+
47
+ def test_header_severity_setter
48
+ h = SumologicCloudSyslog::Header.new
49
+ assert_raise do
50
+ h.severity = "NON_EXISTING"
51
+ end
52
+ SumologicCloudSyslog::Header::SEVERITIES.each do |severity, _|
53
+ assert_nothing_raised do
54
+ h.severity = severity
55
+ end
56
+ end
57
+ end
58
+
59
+ def test_header_timestamp_setter
60
+ h = SumologicCloudSyslog::Header.new
61
+ assert_raise do
62
+ h.timestamp = Time.now.to_i
63
+ end
64
+ assert_nothing_raised do
65
+ h.timestamp = Time.now
66
+ end
67
+ end
68
+
69
+ def test_header_hostname
70
+ h = SumologicCloudSyslog::Header.new
71
+ h.hostname = "hostname"
72
+ assert_equal h.to_s, "<#{h.pri}>1 #{h.timestamp.to_datetime.rfc3339} hostname - - -"
73
+ end
74
+
75
+ def test_header_appname
76
+ h = SumologicCloudSyslog::Header.new
77
+ h.app_name = "appname"
78
+ assert_equal h.to_s, "<#{h.pri}>1 #{h.timestamp.to_datetime.rfc3339} - appname - -"
79
+ end
80
+
81
+ def test_header_procid
82
+ h = SumologicCloudSyslog::Header.new
83
+ h.procid = $$
84
+ assert_equal h.to_s, "<#{h.pri}>1 #{h.timestamp.to_datetime.rfc3339} - - #{$$} -"
85
+ end
86
+
87
+ def test_header_msgid
88
+ h = SumologicCloudSyslog::Header.new
89
+ h.msgid = "msgid"
90
+ assert_equal h.to_s, "<#{h.pri}>1 #{h.timestamp.to_datetime.rfc3339} - - - msgid"
91
+ end
92
+
93
+ def test_structured_data_defaults
94
+ id = "hash@IANA-ID"
95
+ sd = SumologicCloudSyslog::StructuredData.new(id)
96
+ assert_equal sd.to_s, "[#{id}]"
97
+ end
98
+
99
+ def test_structured_data_key
100
+ id = "hash@IANA-ID"
101
+ sd = SumologicCloudSyslog::StructuredData.new(id)
102
+ sd.data["key"] = "val"
103
+ assert_equal sd.to_s, "[#{id} key=\"val\"]"
104
+ end
105
+
106
+ def test_structured_data_escaping
107
+ id = "hash@IANA-ID"
108
+ sd = SumologicCloudSyslog::StructuredData.new(id)
109
+ sd.data["key"] = '\]"'
110
+ assert_equal sd.to_s, "[#{id} key=\"\\\\\\]\\\"\"]"
111
+ end
112
+
113
+ def test_messsage_defaults
114
+ m = SumologicCloudSyslog::Message.new
115
+ assert_not_nil m.header
116
+ assert_true m.structured_data.is_a? Array
117
+ assert_equal m.structured_data.length, 0
118
+ assert_equal m.msg, ""
119
+
120
+ assert_equal m.to_s, "<134>1 #{m.header.timestamp.to_datetime.rfc3339} - - - - -\n"
121
+ end
122
+
123
+ def test_message_msg
124
+ m = SumologicCloudSyslog::Message.new
125
+ m.msg = "TEST"
126
+ assert_equal m.to_s, "<134>1 #{m.header.timestamp.to_datetime.rfc3339} - - - - - TEST\n"
127
+ end
128
+
129
+ def test_message_sd
130
+ m = SumologicCloudSyslog::Message.new
131
+ m.structured_data << SumologicCloudSyslog::StructuredData.new("TEST_ID")
132
+ assert_equal m.to_s, "<134>1 #{m.header.timestamp.to_datetime.rfc3339} - - - - [TEST_ID]\n"
133
+ end
134
+
135
+ def test_message_multiple_sd
136
+ m = SumologicCloudSyslog::Message.new
137
+ m.structured_data << SumologicCloudSyslog::StructuredData.new("TEST_ID")
138
+ m.structured_data << SumologicCloudSyslog::StructuredData.new("TEST_ID2")
139
+ assert_equal m.to_s, "<134>1 #{m.header.timestamp.to_datetime.rfc3339} - - - - [TEST_ID][TEST_ID2]\n"
140
+ end
141
+
142
+ def test_message_multiple_sd_msg
143
+ m = SumologicCloudSyslog::Message.new
144
+ m.structured_data << SumologicCloudSyslog::StructuredData.new("TEST_ID")
145
+ m.structured_data << SumologicCloudSyslog::StructuredData.new("TEST_ID2")
146
+ m.msg = "MSG"
147
+ assert_equal m.to_s, "<134>1 #{m.header.timestamp.to_datetime.rfc3339} - - - - [TEST_ID][TEST_ID2] MSG\n"
148
+ end
149
+ end
metadata ADDED
@@ -0,0 +1,182 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fluent-plugin-sumologic-cloud-syslog
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.2
5
+ platform: ruby
6
+ authors:
7
+ - Acquia Engineering
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-05-02 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: fluentd
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.12'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.12'
27
+ - !ruby/object:Gem::Dependency
28
+ name: fluent-mixin-config-placeholders
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.3'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0.3'
41
+ - !ruby/object:Gem::Dependency
42
+ name: fluent-mixin-plaintextformatter
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '0.2'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '0.2'
55
+ - !ruby/object:Gem::Dependency
56
+ name: minitest
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '5.8'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '5.8'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '10.5'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '10.5'
83
+ - !ruby/object:Gem::Dependency
84
+ name: test-unit
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '3.1'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '3.1'
97
+ - !ruby/object:Gem::Dependency
98
+ name: webmock
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '2.0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '2.0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: simplecov
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '0.11'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '0.11'
125
+ description: Sumologic Cloud Syslog output plugin for Fluent event collector
126
+ email:
127
+ - engineering@acquia.com
128
+ executables: []
129
+ extensions: []
130
+ extra_rdoc_files: []
131
+ files:
132
+ - ".coveralls.yml"
133
+ - ".gitignore"
134
+ - ".travis.yml"
135
+ - CONTRIBUTING.md
136
+ - Gemfile
137
+ - LICENSE
138
+ - README.md
139
+ - Rakefile
140
+ - docs/configuration.md
141
+ - fluent-plugin-sumologic-cloud-syslog.gemspec
142
+ - lib/fluent/plugin/out_sumologic_cloud_syslog.rb
143
+ - lib/sumologic_cloud_syslog/facility.rb
144
+ - lib/sumologic_cloud_syslog/logger.rb
145
+ - lib/sumologic_cloud_syslog/lookup_from_const.rb
146
+ - lib/sumologic_cloud_syslog/protocol.rb
147
+ - lib/sumologic_cloud_syslog/severity.rb
148
+ - lib/sumologic_cloud_syslog/ssl_transport.rb
149
+ - lib/sumologic_cloud_syslog/version.rb
150
+ - test/fluent/test_out_sumologic_cloud_syslog.rb
151
+ - test/helper.rb
152
+ - test/sumologic_cloud_syslog/test_logger.rb
153
+ - test/sumologic_cloud_syslog/test_protocol.rb
154
+ homepage: https://github.com/acquia/fluent-plugin-sumologic-cloud-syslog
155
+ licenses:
156
+ - Apache v2
157
+ metadata: {}
158
+ post_install_message:
159
+ rdoc_options: []
160
+ require_paths:
161
+ - lib
162
+ required_ruby_version: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: 2.0.0
167
+ required_rubygems_version: !ruby/object:Gem::Requirement
168
+ requirements:
169
+ - - ">="
170
+ - !ruby/object:Gem::Version
171
+ version: '0'
172
+ requirements: []
173
+ rubyforge_project:
174
+ rubygems_version: 2.4.3
175
+ signing_key:
176
+ specification_version: 4
177
+ summary: Fluent Sumologic Cloud Syslog plugin
178
+ test_files:
179
+ - test/fluent/test_out_sumologic_cloud_syslog.rb
180
+ - test/helper.rb
181
+ - test/sumologic_cloud_syslog/test_logger.rb
182
+ - test/sumologic_cloud_syslog/test_protocol.rb