4
4
import static org .hamcrest .Matchers .greaterThanOrEqualTo ;
5
5
import static org .junit .jupiter .api .Assertions .assertEquals ;
6
6
import static org .junit .jupiter .api .Assertions .assertTrue ;
7
- import static org .junit .jupiter .api .Assertions .fail ;
8
7
9
8
import java .time .Duration ;
10
- import java .time .OffsetDateTime ;
11
- import java .util .ArrayList ;
12
- import java .util .List ;
13
9
import java .util .concurrent .CountDownLatch ;
14
10
import java .util .concurrent .TimeUnit ;
15
- import java .util .concurrent .atomic .AtomicInteger ;
16
11
17
12
import org .eclipse .microprofile .config .inject .ConfigProperty ;
18
13
import org .junit .jupiter .api .BeforeAll ;
19
- import org .junit .jupiter .api .Disabled ;
20
14
import org .junit .jupiter .api .DisplayName ;
21
15
import org .junit .jupiter .api .MethodOrderer .OrderAnnotation ;
22
16
import org .junit .jupiter .api .Order ;
26
20
import io .quarkus .qe .vertx .sql .test .resources .PostgresqlTestProfile ;
27
21
import io .quarkus .test .junit .QuarkusTest ;
28
22
import io .quarkus .test .junit .TestProfile ;
29
- import io .smallrye .mutiny .Multi ;
30
23
import io .smallrye .mutiny .Uni ;
31
- import io .vertx .core .Handler ;
32
24
import io .vertx .core .impl .logging .Logger ;
33
25
import io .vertx .core .impl .logging .LoggerFactory ;
34
26
import io .vertx .core .json .JsonArray ;
38
30
import io .vertx .mutiny .ext .web .client .WebClient ;
39
31
import io .vertx .mutiny .ext .web .client .predicate .ResponsePredicate ;
40
32
import io .vertx .mutiny .pgclient .PgPool ;
41
- import io .vertx .mutiny .sqlclient .Row ;
42
33
import io .vertx .mutiny .sqlclient .RowSet ;
43
34
44
35
import jakarta .inject .Inject ;
@@ -135,47 +126,6 @@ public void checkIdleExpirationTime() throws InterruptedException {
135
126
assertEquals (doneIdleExpired .getCount (), 0 , "Missing doneIdleExpired query." );
136
127
}
137
128
138
- @ Test
139
- @ DisplayName ("Idle issue: Fail to read any response from the server, the underlying connection might get lost unexpectedly." )
140
- @ Order (3 )
141
- @ Disabled ("Takes too much time and is fixed by Vertx 4.1" )
142
- public void checkBorderConditionBetweenIdleAndGetConnection () {
143
- try {
144
- long idleMs = TimeUnit .SECONDS .toMillis (idle );
145
- latch = new CountDownLatch (1 ); // ignore, this test will run until Timeout or get an error occurs.
146
- AtomicInteger at = new AtomicInteger (0 );
147
- Handler <Long > handler = l -> {
148
- LOGGER .info ("###################################################: " );
149
- Multi .createFrom ().range (1 , 3 )
150
- .concatMap (n -> {
151
- LOGGER .info ("Connection #" + at .incrementAndGet ());
152
- return postgresql .preparedQuery ("SELECT CURRENT_TIMESTAMP" )
153
- .execute ().onFailure ().invoke (error -> {
154
- LOGGER .info ("Error: " + at .get ());
155
- LOGGER .error ("Error on query: '" + error .getMessage () + "'" );
156
- latch .countDown ();
157
- fail (error .getMessage ());
158
- }).map (RowSet ::iterator ).onItem ().transform (iterator -> {
159
- OffsetDateTime result = OffsetDateTime .now ();
160
- if (iterator .hasNext ()) {
161
- Row row = iterator .next ();
162
- LOGGER .info ("Result : " + at .get () + " : " + row .getOffsetDateTime (0 ));
163
- result = row .getOffsetDateTime (0 );
164
- }
165
- return result ;
166
- }).toMulti ();
167
- }).collect ().in (ArrayList ::new , List ::add ).subscribe ().with (re -> {
168
- LOGGER .info ("Subscribe success: -> " + re .get (0 ));
169
- }, Throwable ::printStackTrace );
170
- };
171
- Vertx .vertx ().setPeriodic (idleMs + 3 , l -> handler .handle (l ));
172
- await (5 , TimeUnit .MINUTES );
173
- } catch (IllegalStateException ex ) {
174
- } finally {
175
- assertEquals (1 , latch .getCount (), "An unexpected error was thrown." );
176
- }
177
- }
178
-
179
129
private Uni <Long > activeConnections () {
180
130
return postgresql .query (
181
131
"SELECT count(*) as active_con FROM pg_stat_activity where application_name like '%vertx%'" )
@@ -195,7 +145,7 @@ protected String getAppEndpoint() {
195
145
}
196
146
197
147
private boolean checkDbActiveConnections (long active ) {
198
- return active <= datasourceMaxSize + ( 7 ); // TODO: double check this condition ... this magical number is scary!.
148
+ return active <= datasourceMaxSize ;
199
149
}
200
150
201
151
}
0 commit comments