88 }
99 end
1010
11+ let ( :cloud_config ) do
12+ %{
13+ source_token abcd1234
14+ ingesting_host s1234.eu-nbg-2.betterstackdata.com
15+ }
16+ end
17+
1118 let ( :driver ) do
1219 tag = "test"
1320 Fluent ::Test ::BufferedOutputTestDriver . new ( Fluent ::LogtailOutput , tag ) {
@@ -19,6 +26,19 @@ def format(tag, time, record)
1926 end
2027 } . configure ( config )
2128 end
29+
30+ let ( :cloud_driver ) do
31+ tag = "test"
32+ Fluent ::Test ::BufferedOutputTestDriver . new ( Fluent ::LogtailOutput , tag ) {
33+ # v0.12's test driver assume format definition. This simulates ObjectBufferedOutput format
34+ if !defined? ( Fluent ::Plugin ::Output )
35+ def format ( tag , time , record )
36+ [ time , record ] . to_msgpack
37+ end
38+ end
39+ } . configure ( cloud_config )
40+ end
41+
2242 let ( :record ) do
2343 { 'age' => 26 , 'request_id' => '42' , 'parent_id' => 'parent' , 'routing_id' => 'routing' }
2444 end
@@ -28,8 +48,8 @@ def format(tag, time, record)
2848 end
2949
3050 describe "#write" do
31- it "should send a chunked request to the Logtail API" do
32- stub = stub_request ( :post , "https://in.logtail .com/" ) .
51+ it "should send a chunked request to the Logtail API using default host " do
52+ stub = stub_request ( :post , "https://in.logs.betterstack .com/" ) .
3353 with (
3454 :body => start_with ( "\xDD \x00 \x00 \x00 \x01 \x85 \xA3 age\x1A \xAA request_id\xA2 42\xA9 parent_id\xA6 parent\xAA routing_id\xA7 routing\xA2 dt\xB4 " . force_encoding ( "ASCII-8BIT" ) ) ,
3555 :headers => { 'Accept' => '*/*' , 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3' , 'Authorization' => 'Bearer abcd1234' , 'Content-Type' => 'application/msgpack' , 'User-Agent' => 'Logtail Fluentd/0.1.1' }
@@ -43,7 +63,7 @@ def format(tag, time, record)
4363 end
4464
4565 it "handles 500s" do
46- stub = stub_request ( :post , "https://in.logtail .com/" ) . to_return ( :status => 500 , :body => "" , :headers => { } )
66+ stub = stub_request ( :post , "https://in.logs.betterstack .com/" ) . to_return ( :status => 500 , :body => "" , :headers => { } )
4767
4868 driver . emit ( record )
4969 driver . run
@@ -52,12 +72,28 @@ def format(tag, time, record)
5272 end
5373
5474 it "handle auth failures" do
55- stub = stub_request ( :post , "https://in.logtail .com/" ) . to_return ( :status => 403 , :body => "" , :headers => { } )
75+ stub = stub_request ( :post , "https://in.logs.betterstack .com/" ) . to_return ( :status => 403 , :body => "" , :headers => { } )
5676
5777 driver . emit ( record )
5878 driver . run
5979
6080 expect ( stub ) . to have_been_requested . times ( 1 )
6181 end
6282 end
83+
84+ describe "#write to cloud" do
85+ it "should send a chunked request to the Logtail API" do
86+ stub = stub_request ( :post , "https://s1234.eu-nbg-2.betterstackdata.com/" ) .
87+ with (
88+ :body => start_with ( "\xDD \x00 \x00 \x00 \x01 \x85 \xA3 age\x1A \xAA request_id\xA2 42\xA9 parent_id\xA6 parent\xAA routing_id\xA7 routing\xA2 dt\xB4 " . force_encoding ( "ASCII-8BIT" ) ) ,
89+ :headers => { 'Accept' => '*/*' , 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3' , 'Authorization' => 'Bearer abcd1234' , 'Content-Type' => 'application/msgpack' , 'User-Agent' => 'Logtail Fluentd/0.1.1' }
90+ ) .
91+ to_return ( :status => 202 , :body => "" , :headers => { } )
92+
93+ cloud_driver . emit ( record )
94+ cloud_driver . run
95+
96+ expect ( stub ) . to have_been_requested . times ( 1 )
97+ end
98+ end
6399end
0 commit comments