2828import java .util .HashMap ;
2929import java .util .List ;
3030import java .util .Map ;
31+ import java .util .Random ;
3132import java .util .stream .Collectors ;
3233import java .util .stream .Stream ;
3334
3435import org .apache .arrow .flight .CallStatus ;
3536import org .apache .arrow .flight .FlightRuntimeException ;
37+ import org .apache .arrow .flight .FlightStatusCode ;
3638import org .apache .arrow .vector .VectorSchemaRoot ;
3739import org .assertj .core .api .Assertions ;
3840import org .jetbrains .annotations .NotNull ;
@@ -236,16 +238,15 @@ void pointValues() {
236238 @ Test
237239 public void handleFlightRuntimeException () throws IOException {
238240 Instant now = Instant .now ();
239- String measurement = String .format (
240- "/%d/test/com/influxdb/v3/client/ITQueryWrite/handleFlightRuntimeException" , now .toEpochMilli ()
241- );
241+ String measurement = "/influxdb3-java/test/ITQueryWrite/handleFlightRuntimeException" ;
242242
243243 client = getInstance ();
244244
245245 int extraTagLength = 512 ;
246246 Map <String , String > extraTags = new HashMap <String , String >();
247+ Random seededRandom = new Random (1 ); // use seeded random to generate always the same tags
247248 for (int i = 0 ; i < 22 ; i ++) {
248- extraTags .put (makeLengthyTag (extraTagLength , 64 , (byte ) '/' ), "extra-tag-" + i );
249+ extraTags .put (makeLengthyTag (extraTagLength , 64 , (byte ) '/' , seededRandom ), "extra-tag-" + i );
249250 }
250251
251252 Point p = Point .measurement (measurement )
@@ -275,17 +276,21 @@ public void handleFlightRuntimeException() throws IOException {
275276 });
276277 } catch (FlightRuntimeException fre ) {
277278 Assertions .assertThat (fre .getMessage ()).doesNotContain ("http2 exception" );
278- Assertions .assertThat (fre .status ().code ()).isNotEqualTo (CallStatus .INTERNAL .code ());
279- Assertions .assertThat (fre .status ().code ()).
279+ FlightStatusCode statusCode = fre .status ().code ();
280+ Assertions .assertThat (statusCode ).isNotEqualTo (CallStatus .INTERNAL .code ());
281+ Assertions .assertThat (statusCode ).
280282 as (String .format ("Flight runtime exception was UNAVAILABLE. "
281283 + "Target test case was not fully tested. "
282284 + "Check limits of test account and target database %s." ,
283285 System .getenv ("TESTING_INFLUXDB_DATABASE" )))
284286 .isNotEqualTo (CallStatus .UNAVAILABLE .code ());
285- Assertions .assertThat (fre . status (). code () ).
287+ Assertions .assertThat (statusCode ).
286288 as ("Flight runtime exception was UNAUTHENTICATED. "
287289 + "Target test case was not fully tested. Check test account token." )
288290 .isNotEqualTo (CallStatus .UNAUTHENTICATED .code ());
291+ Assertions .assertThat (statusCode ).
292+ as ("Flight runtime exception was not INVALID_ARGUMENT but: " + statusCode .toString ())
293+ .isEqualTo (CallStatus .INVALID_ARGUMENT .code ());
289294 return ;
290295 } catch (Exception e ) {
291296 Assertions .fail (String .format ("FlightRuntimeException should have been thrown. "
@@ -304,16 +309,17 @@ private static InfluxDBClient getInstance() {
304309 System .getenv ("TESTING_INFLUXDB_DATABASE" ));
305310 }
306311
307- private String makeLengthyTag (final int length , final int maxPartLength , final byte separator ) {
312+ private String makeLengthyTag (final int length , final int maxPartLength , final byte separator ,
313+ final Random random ) {
308314 final String legalVals = "0123456789abcdefghijklmnopqrstuvwxyz" ;
309315 byte [] bytes = new byte [length ];
310316 int nextPartAddress = 0 ;
311317 for (int i = 0 ; i < length ; i ++) {
312318 if (i == nextPartAddress ) {
313319 bytes [i ] = separator ;
314- nextPartAddress = i + (int ) (Math . random () * (maxPartLength - 3 ));
320+ nextPartAddress = i + (int ) (random . nextDouble () * (maxPartLength - 3 ));
315321 } else {
316- bytes [i ] = legalVals .getBytes ()[(int ) (Math . random () * legalVals .length ())];
322+ bytes [i ] = legalVals .getBytes ()[(int ) (random . nextDouble () * legalVals .length ())];
317323 }
318324 }
319325 return new String (bytes );
0 commit comments