@@ -70,6 +70,20 @@ public void testInformationSchemaReceiversWithProtocolFilter() {
7070 "show_receivers_filter_pipe" );
7171 }
7272
73+ @ Test
74+ public void testShowReceiversAggregatesMultiplePipesFromSameSender () {
75+ final String pipeName1 = "show_receivers_aggregate_pipe_1" ;
76+ final String pipeName2 = "show_receivers_aggregate_pipe_2" ;
77+ createTwoWriteBackPipes ("root.show_receivers_aggregate" , pipeName1 , pipeName2 );
78+
79+ assertAggregatedShowReceivers ("show receivers" , BaseEnv .TREE_SQL_DIALECT , pipeName1 , pipeName2 );
80+ assertAggregatedShowReceivers (
81+ "select * from information_schema.receivers" ,
82+ BaseEnv .TABLE_SQL_DIALECT ,
83+ pipeName1 ,
84+ pipeName2 );
85+ }
86+
7387 @ Test
7488 public void testShowReceiversWithStoppedDataNode () throws Exception {
7589 Assert .assertTrue (env .getDataNodeWrapperList ().size () >= 3 );
@@ -152,6 +166,28 @@ private void createWriteBackPipe(final String database, final String pipeName) {
152166 null );
153167 }
154168
169+ private void createTwoWriteBackPipes (
170+ final String database , final String firstPipeName , final String secondPipeName ) {
171+ TestUtils .executeNonQueries (
172+ env ,
173+ Arrays .asList (
174+ "create database " + database ,
175+ "create timeseries " + database + ".d1.s1 with datatype=INT32, encoding=PLAIN" ,
176+ "create pipe "
177+ + firstPipeName
178+ + " with source ('pattern'='"
179+ + database
180+ + "') with sink ('sink'='write-back-sink')" ,
181+ "create pipe "
182+ + secondPipeName
183+ + " with source ('pattern'='"
184+ + database
185+ + "') with sink ('sink'='write-back-sink')" ,
186+ "insert into " + database + ".d1(time, s1) values (1, 1)" ,
187+ "flush" ),
188+ null );
189+ }
190+
155191 private void assertShowReceivers (final String sql , final String sqlDialect ) {
156192 assertShowReceivers (sql , sqlDialect , "show_receivers_pipe" );
157193 }
@@ -183,6 +219,22 @@ private void assertShowReceiversAsUser(
183219 hasExpectedReceiver (sql , sqlDialect , pipeName , userName , password )));
184220 }
185221
222+ private void assertAggregatedShowReceivers (
223+ final String sql ,
224+ final String sqlDialect ,
225+ final String firstPipeName ,
226+ final String secondPipeName ) {
227+ Awaitility .await ()
228+ .pollInSameThread ()
229+ .pollDelay (1L , TimeUnit .SECONDS )
230+ .pollInterval (1L , TimeUnit .SECONDS )
231+ .atMost (60L , TimeUnit .SECONDS )
232+ .untilAsserted (
233+ () ->
234+ Assert .assertTrue (
235+ hasAggregatedReceiver (sql , sqlDialect , firstPipeName , secondPipeName )));
236+ }
237+
186238 private void assertUserCannotSeeReceivers (
187239 final String sql , final String sqlDialect , final String userName , final String password ) {
188240 Awaitility .await ()
@@ -232,6 +284,33 @@ private boolean hasExpectedReceiver(
232284 }
233285 }
234286
287+ private boolean hasAggregatedReceiver (
288+ final String sql ,
289+ final String sqlDialect ,
290+ final String firstPipeName ,
291+ final String secondPipeName )
292+ throws SQLException {
293+ try (final Connection connection =
294+ env .getConnection (
295+ SessionConfig .DEFAULT_USER , SessionConfig .DEFAULT_PASSWORD , sqlDialect );
296+ final Statement statement = connection .createStatement ();
297+ final ResultSet resultSet = statement .executeQuery (sql )) {
298+ while (resultSet .next ()) {
299+ final String pipeIds = resultSet .getString (8 );
300+ if ("DataNode" .equals (resultSet .getString (1 ))
301+ && "thrift" .equals (resultSet .getString (3 ))
302+ && resultSet .getInt (6 ) >= 1
303+ && resultSet .getInt (7 ) >= 2
304+ && pipeIds != null
305+ && pipeIds .contains (firstPipeName + "@" )
306+ && pipeIds .contains (secondPipeName + "@" )) {
307+ return true ;
308+ }
309+ }
310+ return false ;
311+ }
312+ }
313+
235314 private boolean hasAnyReceiver (
236315 final String sql , final String sqlDialect , final String userName , final String password )
237316 throws SQLException {
0 commit comments