16
16
import org .apache .http .HttpStatus ;
17
17
import org .eclipse .microprofile .config .inject .ConfigProperty ;
18
18
import org .junit .jupiter .api .Assertions ;
19
- import org .junit .jupiter .api .Disabled ;
20
19
import org .junit .jupiter .api .Test ;
21
20
22
21
import io .agroal .api .AgroalDataSource ;
41
40
public class AgroalPoolTest {
42
41
43
42
private final int CONCURRENCY_LEVEL = 20 ;
43
+ private final int SAFETY_INTERVAL = 200 ;
44
44
45
45
@ Inject
46
46
EntityManager em ;
@@ -54,17 +54,19 @@ public class AgroalPoolTest {
54
54
@ ConfigProperty (name = "quarkus.datasource.jdbc.idle-removal-interval" )
55
55
String idleSec ;
56
56
57
+ @ ConfigProperty (name = "quarkus.datasource.jdbc.background-validation-interval" )
58
+ String idleBackgroundValidationSec ;
59
+
57
60
@ ConfigProperty (name = "quarkus.datasource.jdbc.max-size" )
58
61
int datasourceMaxSize ;
59
62
60
63
@ ConfigProperty (name = "quarkus.datasource.jdbc.min-size" )
61
64
int datasourceMinSize ;
62
65
63
66
@ Test
64
- @ Disabled ("Pending Zulip conversation about quarkus.datasource.jdbc.idle-removal-interval" )
65
67
public void idleTimeoutTest () throws InterruptedException {
66
68
makeApplicationQuery ();
67
- Thread .sleep (Duration . ofMillis ( getIdleMs () + 1 ). toMillis () );
69
+ Thread .sleep (getIdleMs () + getIdleBackgroundValidationMs () + SAFETY_INTERVAL );
68
70
assertEquals (1 , activeConnections (), "agroalCheckIdleTimeout: Expected " + datasourceMinSize + " active connections" );
69
71
}
70
72
@@ -138,8 +140,13 @@ public void connectionConcurrencyTest() {
138
140
}
139
141
140
142
private long getIdleMs () {
141
- int idle = Integer .parseInt (idleSec .replaceAll ("[A-Z]" , "" ));
142
- return Duration .ofSeconds (idle ).toMillis ();
143
+ float idle = Float .parseFloat (idleSec .replaceAll ("[A-Z]" , "" ));
144
+ return Duration .ofMillis (Math .round (1000 * idle )).toMillis ();
145
+ }
146
+
147
+ private long getIdleBackgroundValidationMs () {
148
+ float idleBg = Float .parseFloat (idleBackgroundValidationSec .replaceAll ("[A-Z]" , "" ));
149
+ return Duration .ofMillis (Math .round (1000 * idleBg )).toMillis ();
143
150
}
144
151
145
152
private Multi <Long > activeConnectionsAsync (int events ) {
0 commit comments