88 }
99 end
1010
11+ let ( :cloud_config ) do
12+ %{
13+ source_token abcd1234
14+ ingesting_host s1234.g1.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
@@ -29,7 +49,22 @@ def format(tag, time, record)
2949
3050 describe "#write" do
3151 it "should send a chunked request to the Logtail API" do
32- stub = stub_request ( :post , "https://in.logtail.com/" ) .
52+ stub = stub_request ( :post , "https://s1234.g1.betterstackdata.com/" ) .
53+ with (
54+ :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" ) ) ,
55+ :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' }
56+ ) .
57+ to_return ( :status => 202 , :body => "" , :headers => { } )
58+
59+ cloud_driver . emit ( record )
60+ cloud_driver . run
61+
62+ expect ( stub ) . to have_been_requested . times ( 1 )
63+ end
64+
65+ describe "#write to cloud" do
66+ it "should send a chunked request to the Logtail API" do
67+ stub = stub_request ( :post , "https://in.logs.betterstack.com/" ) .
3368 with (
3469 :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" ) ) ,
3570 :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 +78,7 @@ def format(tag, time, record)
4378 end
4479
4580 it "handles 500s" do
46- stub = stub_request ( :post , "https://in.logtail .com/" ) . to_return ( :status => 500 , :body => "" , :headers => { } )
81+ stub = stub_request ( :post , "https://in.logs.betterstack .com/" ) . to_return ( :status => 500 , :body => "" , :headers => { } )
4782
4883 driver . emit ( record )
4984 driver . run
@@ -52,7 +87,7 @@ def format(tag, time, record)
5287 end
5388
5489 it "handle auth failures" do
55- stub = stub_request ( :post , "https://in.logtail .com/" ) . to_return ( :status => 403 , :body => "" , :headers => { } )
90+ stub = stub_request ( :post , "https://in.logs.betterstack .com/" ) . to_return ( :status => 403 , :body => "" , :headers => { } )
5691
5792 driver . emit ( record )
5893 driver . run
0 commit comments