Skip to content

Commit 91b6beb

Browse files
committed
Fix test failure only seen on CI
The failure was in GraphQlWebSocketHandlerTests for WebMvc. the subscriptionExists test checks that a second subscription with same id will close the connection with 4409. It also checks that 2 messages have arrived (connection_init) and one message from the first subscription. However, since message handling as async, handling of the two subscriptions is concurrent, and the connection may be closed before the first subscription is able to send. This commit adjusts the message checks to be more lenient and accept between 1 and 2 messages.
1 parent aa1ee77 commit 91b6beb

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

spring-graphql/src/test/java/org/springframework/graphql/server/webflux/GraphQlWebSocketHandlerTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2022 the original author or authors.
2+
* Copyright 2002-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -288,8 +288,8 @@ void subscriptionExists() {
288288
.verify(TIMEOUT);
289289

290290
assertThat(messages.size()).isEqualTo(2);
291+
assertThat(messages.size()).isGreaterThanOrEqualTo(1).isLessThan(3);
291292
assertThat(messages.get(0).resolvedType()).isEqualTo(GraphQlWebSocketMessageType.CONNECTION_ACK);
292-
assertThat(messages.get(1).resolvedType()).isEqualTo(GraphQlWebSocketMessageType.NEXT);
293293
}
294294

295295
@Test

spring-graphql/src/test/java/org/springframework/graphql/server/webmvc/GraphQlWebSocketHandlerTests.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2022 the original author or authors.
2+
* Copyright 2002-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -293,9 +293,8 @@ void subscriptionExists() throws Exception {
293293
.expectComplete()
294294
.verify(TIMEOUT);
295295

296-
assertThat(messages.size()).isEqualTo(2);
296+
assertThat(messages.size()).isGreaterThanOrEqualTo(1).isLessThan(3);
297297
assertThat(messages.get(0).resolvedType()).isEqualTo(GraphQlWebSocketMessageType.CONNECTION_ACK);
298-
assertThat(messages.get(1).resolvedType()).isEqualTo(GraphQlWebSocketMessageType.NEXT);
299298
}
300299

301300
@Test

0 commit comments

Comments
 (0)