88-module (shovel_status_command_SUITE ).
99
1010-include_lib (" amqp_client/include/amqp_client.hrl" ).
11+ -include_lib (" eunit/include/eunit.hrl" ).
1112
1213-compile (export_all ).
1314
@@ -26,7 +27,8 @@ groups() ->
2627 run_starting ,
2728 output_starting ,
2829 run_running ,
29- output_running
30+ output_running ,
31+ e2e
3032 ]}
3133 ].
3234
@@ -95,8 +97,14 @@ output_starting(Config) ->
9597 [A ] = rabbit_ct_broker_helpers :get_node_configs (Config , nodename ),
9698 Opts = #{node => A },
9799 {stream , [#{vhost := <<" /" >>, name := <<" test" >>, type := dynamic ,
98- state := starting , last_changed := <<" 2016-11-17 10:00:00" >>}]}
100+ state := starting , last_changed := <<" 2016-11-17 10:00:00" >>,
101+ remaining := 10 , remaining_unacked := 8 ,
102+ pending := 5 , forwarded := 3 }]}
99103 = ? CMD :output ({stream , [{{<<" /" >>, <<" test" >>}, dynamic , starting ,
104+ #{remaining => 10 ,
105+ remaining_unacked => 8 ,
106+ pending => 5 ,
107+ forwarded => 3 },
100108 {{2016 , 11 , 17 }, {10 , 00 , 00 }}}]}, Opts ),
101109 shovel_test_utils :clear_param (Config , <<" test" >>).
102110
@@ -118,9 +126,43 @@ output_running(Config) ->
118126 state := running , source := <<" amqp://server-1" >>,
119127 destination := <<" amqp://server-2" >>,
120128 termination_reason := <<>>,
121- last_changed := <<" 2016-11-17 10:00:00" >>}]} =
129+ last_changed := <<" 2016-11-17 10:00:00" >>,
130+ remaining := 10 ,
131+ remaining_unacked := 8 ,
132+ pending := 5 ,
133+ forwarded := 3 }]} =
122134 ? CMD :output ({stream , [{{<<" /" >>, <<" test" >>}, dynamic ,
123135 {running , [{src_uri , <<" amqp://server-1" >>},
124136 {dest_uri , <<" amqp://server-2" >>}]},
137+ #{remaining => 10 ,
138+ remaining_unacked => 8 ,
139+ pending => 5 ,
140+ forwarded => 3 },
125141 {{2016 , 11 , 17 }, {10 , 00 , 00 }}}]}, Opts ),
126142 shovel_test_utils :clear_param (Config , <<" test" >>).
143+
144+ e2e (Config ) ->
145+ shovel_test_utils :set_param_nowait (
146+ Config ,
147+ <<" test" >>, [{<<" src-queue" >>, <<" src" >>},
148+ {<<" dest-queue" >>, <<" dest" >>}]),
149+ {ok , StdOut } = rabbit_ct_broker_helpers :rabbitmqctl (Config , 0 , [<<" shovel_status" >>]),
150+ [Msg , Headers0 , Shovel0 ] = re :split (StdOut , <<" \n " >>, [trim ]),
151+ ? assertMatch (match , re :run (Msg , " Shovel status on node" , [{capture , none }])),
152+ Headers = re :split (Headers0 , <<" \t " >>, [trim ]),
153+ ExpectedHeaders = [<<" name" >>, <<" vhost" >>, <<" type" >>, <<" state" >>,
154+ <<" source" >>, <<" destination" >>, <<" termination_reason" >>,
155+ <<" destination_protocol" >>, <<" source_protocol" >>,
156+ <<" last_changed" >>, <<" source_queue" >>, <<" destination_queue" >>,
157+ <<" remaining" >>, <<" remaining_unacked" >>,
158+ <<" pending" >>, <<" forwarded" >>],
159+ ? assert (lists :all (fun (H ) ->
160+ lists :member (H , Headers )
161+ end , ExpectedHeaders )),
162+ % % Check some values are there
163+ ExpectedValues = [<<" test" >>, <<" dynamic" >>, <<" running" >>],
164+ Shovel = re :split (Shovel0 , <<" \t " >>, [trim ]),
165+ ? assert (lists :all (fun (V ) ->
166+ lists :member (V , Shovel )
167+ end , ExpectedValues )),
168+ shovel_test_utils :clear_param (Config , <<" test" >>).
0 commit comments