4848import java .util .HashMap ;
4949import java .util .List ;
5050import java .util .Map ;
51+ import java .util .function .Consumer ;
5152
5253import static org .junit .Assert .fail ;
5354
@@ -131,6 +132,12 @@ private void doTest(
131132 ? receiverDataNode .getPipeAirGapReceiverPort ()
132133 : receiverDataNode .getPort ();
133134
135+ final Consumer <String > handleFailure =
136+ o -> {
137+ TestUtils .executeNonQueryWithRetry (senderEnv , "flush" );
138+ TestUtils .executeNonQueryWithRetry (receiverEnv , "flush" );
139+ };
140+
134141 try (final SyncConfigNodeIServiceClient client =
135142 (SyncConfigNodeIServiceClient ) senderEnv .getLeaderConfigNodeConnection ()) {
136143 if (!TestUtils .tryExecuteNonQueriesWithRetry (
@@ -173,7 +180,8 @@ private void doTest(
173180 receiverEnv ,
174181 "select count(*) from root.db.**" ,
175182 "count(root.db.d1.s1)," ,
176- Collections .singleton ("2," ));
183+ Collections .singleton ("2," ),
184+ handleFailure );
177185
178186 if (!TestUtils .tryExecuteNonQueriesWithRetry (
179187 senderEnv ,
@@ -193,7 +201,8 @@ private void doTest(
193201 receiverEnv ,
194202 "select count(*) from root.db.**" ,
195203 "count(root.db.d1.s1)," ,
196- Collections .singleton ("8," ));
204+ Collections .singleton ("8," ),
205+ handleFailure );
197206 }
198207 }
199208
@@ -204,6 +213,12 @@ public void testZstdCompressorLevel() throws Exception {
204213 final String receiverIp = receiverDataNode .getIp ();
205214 final int receiverPort = receiverDataNode .getPort ();
206215
216+ final Consumer <String > handleFailure =
217+ o -> {
218+ TestUtils .executeNonQueryWithRetry (senderEnv , "flush" );
219+ TestUtils .executeNonQueryWithRetry (receiverEnv , "flush" );
220+ };
221+
207222 try (final SyncConfigNodeIServiceClient client =
208223 (SyncConfigNodeIServiceClient ) senderEnv .getLeaderConfigNodeConnection ()) {
209224 if (!TestUtils .tryExecuteNonQueriesWithRetry (
@@ -320,7 +335,8 @@ public void testZstdCompressorLevel() throws Exception {
320335 receiverEnv ,
321336 "count timeseries root.db.**" ,
322337 "count(timeseries)," ,
323- Collections .singleton ("3," ));
338+ Collections .singleton ("3," ),
339+ handleFailure );
324340 }
325341 }
326342}
0 commit comments