@@ -14,15 +14,15 @@ class Fluent::Plugin::OtlpOutputTest < Test::Unit::TestCase
14
14
DEFAULT_LOGGER = ::WEBrick ::Log . new ( $stdout, ::WEBrick ::BasicLog ::FATAL )
15
15
16
16
def config
17
- <<~CONFIG
17
+ <<~" CONFIG"
18
18
<http>
19
- endpoint "http://127.0.0.1:24318 "
19
+ endpoint "http://127.0.0.1:#{ @port } "
20
20
</http>
21
21
CONFIG
22
22
end
23
23
24
24
def server_config
25
- config = { BindAddress : "127.0.0.1" , Port : "24318" }
25
+ config = { BindAddress : "127.0.0.1" , Port : @port }
26
26
# Suppress webrick logs
27
27
config [ :Logger ] = DEFAULT_LOGGER
28
28
config [ :AccessLog ] = [ ]
@@ -63,6 +63,8 @@ def run_http_server
63
63
def setup
64
64
Fluent ::Test . setup
65
65
66
+ @port = unused_tcp_port
67
+
66
68
@@server_request = nil
67
69
@@server_response_code = 200
68
70
@@http_server_thread = Thread . new do
@@ -71,8 +73,6 @@ def setup
71
73
end
72
74
73
75
def teardown
74
- p "!" * 80
75
- p @@http_server_thread
76
76
@@http_server_thread . kill
77
77
@@http_server_thread = nil
78
78
end
@@ -83,7 +83,7 @@ def create_driver(conf = config)
83
83
84
84
def test_configure
85
85
d = create_driver
86
- assert_equal "http://127.0.0.1:24318 " , d . instance . http_config . endpoint
86
+ assert_equal "http://127.0.0.1:#{ @port } " , d . instance . http_config . endpoint
87
87
end
88
88
89
89
def test_send_logs
@@ -133,7 +133,7 @@ def test_send_compressed_message
133
133
134
134
d = create_driver ( %[
135
135
<http>
136
- endpoint "http://127.0.0.1:24318 "
136
+ endpoint "http://127.0.0.1:#{ @port } "
137
137
compress gzip
138
138
</http>
139
139
] )
@@ -157,7 +157,7 @@ def test_unrecoverable_error
157
157
d . feed ( event )
158
158
end
159
159
160
- assert_match ( %r{got unrecoverable error response from 'http://127.0.0.1:24318 /v1/logs', response code is 500} ,
160
+ assert_match ( %r{got unrecoverable error response from 'http://127.0.0.1:#{ @port } /v1/logs', response code is 500} ,
161
161
d . instance . log . out . logs . join )
162
162
163
163
d . instance_shutdown
@@ -169,15 +169,15 @@ def test_error_with_disabled_unrecoverable
169
169
170
170
d = create_driver ( %[
171
171
<http>
172
- endpoint "http://127.0.0.1:24318 "
172
+ endpoint "http://127.0.0.1:#{ @port } "
173
173
error_response_as_unrecoverable false
174
174
</http>
175
175
] )
176
176
d . run ( default_tag : "otlp.test" , shutdown : false ) do
177
177
d . feed ( event )
178
178
end
179
179
180
- assert_match ( %r{got error response from 'http://127.0.0.1:24318 /v1/logs', response code is 500} ,
180
+ assert_match ( %r{got error response from 'http://127.0.0.1:#{ @port } /v1/logs', response code is 500} ,
181
181
d . instance . log . out . logs . join )
182
182
183
183
d . instance_shutdown
@@ -192,7 +192,7 @@ def test_write_with_retryable_response
192
192
193
193
d = create_driver ( %[
194
194
<http>
195
- endpoint "http://127.0.0.1:24318 "
195
+ endpoint "http://127.0.0.1:#{ @port } "
196
196
retryable_response_codes [503]
197
197
</http>
198
198
] )
@@ -211,7 +211,7 @@ def test_write_with_retryable_response
211
211
sub_test_case "HTTPS" do
212
212
def server_config
213
213
config = super
214
- config [ :Port ] = "24318 "
214
+ config [ :Port ] = "#{ @port } "
215
215
# WEBrick supports self-generated self-signed certificate
216
216
config [ :SSLEnable ] = true
217
217
config [ :SSLCertName ] = [ [ "CN" , WEBrick ::Utils . getservername ] ]
@@ -221,7 +221,7 @@ def server_config
221
221
def config
222
222
<<~"CONFIG"
223
223
<http>
224
- endpoint "https://127.0.0.1:24318 "
224
+ endpoint "https://127.0.0.1:#{ @port } "
225
225
</http>
226
226
<transport tls>
227
227
cert_path "#{ File . expand_path ( File . dirname ( __FILE__ ) + '/../resources/certs/ca.crt' ) } "
0 commit comments