Skip to content

Commit fc0cfab

Browse files
Remove maximum time testing from CRL (#2545)
* Remove maximum testing as this is very dependent on pipeline behavior. * Formatting * Undo formatting to satisfy code cov
1 parent edbc7fc commit fc0cfab

File tree

1 file changed

+4
-23
lines changed

1 file changed

+4
-23
lines changed

src/test/java/com/microsoft/sqlserver/jdbc/configurableretry/ConfigurableRetryLogicTest.java

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,8 @@ public void testConnectionRetry(String replacedDbName, String addedRetryParams)
223223

224224
/**
225225
* Tests that the correct number of retries are happening for all statement scenarios. Tests are expected to take
226-
* a minimum of the sum of whatever has been defined for the waiting intervals, and maximum of the previous sum
227-
* plus some amount of time to account for test environment slowness.
226+
* a minimum of the sum of whatever has been defined for the waiting intervals. Maximum is not tested due to the
227+
* unpredictable factor of slowness that can be applied to these tests.
228228
*/
229229
@Test
230230
public void statementTimingTests() {
@@ -253,8 +253,6 @@ public void statementTimingTests() {
253253
totalTime = System.currentTimeMillis() - timerStart;
254254
assertTrue(totalTime > TimeUnit.SECONDS.toMillis(5),
255255
"total time: " + totalTime + ", expected minimum time: " + TimeUnit.SECONDS.toMillis(5));
256-
assertTrue(totalTime < TimeUnit.SECONDS.toMillis(15),
257-
"total time: " + totalTime + ", expected maximum time: " + TimeUnit.SECONDS.toMillis(15));
258256
}
259257

260258
timerStart = System.currentTimeMillis();
@@ -268,8 +266,6 @@ public void statementTimingTests() {
268266
totalTime = System.currentTimeMillis() - timerStart;
269267
assertTrue(totalTime > TimeUnit.SECONDS.toMillis(2),
270268
"total time: " + totalTime + ", expected minimum time: " + TimeUnit.SECONDS.toMillis(8));
271-
assertTrue(totalTime < TimeUnit.SECONDS.toMillis(18),
272-
"total time: " + totalTime + ", expected maximum time: " + TimeUnit.SECONDS.toMillis(18));
273269
}
274270

275271
timerStart = System.currentTimeMillis();
@@ -283,8 +279,6 @@ public void statementTimingTests() {
283279
totalTime = System.currentTimeMillis() - timerStart;
284280
assertTrue(totalTime > TimeUnit.SECONDS.toMillis(3),
285281
"total time: " + totalTime + ", expected minimum time: " + TimeUnit.SECONDS.toMillis(10));
286-
assertTrue(totalTime < TimeUnit.SECONDS.toMillis(20),
287-
"total time: " + totalTime + ", expected maximum time: " + TimeUnit.SECONDS.toMillis(20));
288282
}
289283
}
290284

@@ -496,14 +490,13 @@ public void testRetryChange() throws Exception {
496490

497491
/**
498492
* Tests that the correct number of retries are happening for all connection scenarios. Tests are expected to take
499-
* a minimum of the sum of whatever has been defined for the waiting intervals, and maximum of the previous sum
500-
* plus some amount of time to account for test environment slowness.
493+
* a minimum of the sum of whatever has been defined for the waiting intervals. Maximum is not tested due to the
494+
* unpredictable factor of slowness that can be applied to these tests.
501495
*/
502496
@Test
503497
public void connectionTimingTest() {
504498
long totalTime;
505499
long timerStart = System.currentTimeMillis();
506-
long expectedMaxTime = 10;
507500

508501
// No retries since CRL rules override, expected time ~1 second
509502
try {
@@ -517,18 +510,10 @@ public void connectionTimingTest() {
517510
|| ((isSqlAzure() || isSqlAzureDW()) && e.getMessage().toLowerCase()
518511
.contains(TestResource.getResource("R_connectTimedOut").toLowerCase())),
519512
e.getMessage());
520-
521-
if (e.getMessage().toLowerCase().contains(TestResource.getResource("R_cannotOpenDatabase").toLowerCase())) {
522-
// Only check the timing if the correct error, "cannot open database", is returned.
523-
totalTime = System.currentTimeMillis() - timerStart;
524-
assertTrue(totalTime < TimeUnit.SECONDS.toMillis(expectedMaxTime),
525-
"total time: " + totalTime + ", expected time: " + TimeUnit.SECONDS.toMillis(expectedMaxTime));
526-
}
527513
}
528514

529515
timerStart = System.currentTimeMillis();
530516
long expectedMinTime = 10;
531-
expectedMaxTime = 35;
532517

533518
// (0s attempt + 0s attempt + 10s wait + 0s attempt) = expected 10s execution time
534519
try {
@@ -546,8 +531,6 @@ public void connectionTimingTest() {
546531
if (e.getMessage().toLowerCase().contains(TestResource.getResource("R_cannotOpenDatabase").toLowerCase())) {
547532
// Only check the timing if the correct error, "cannot open database", is returned.
548533
totalTime = System.currentTimeMillis() - timerStart;
549-
assertTrue(totalTime < TimeUnit.SECONDS.toMillis(expectedMaxTime), "total time: " + totalTime
550-
+ ", expected max time: " + TimeUnit.SECONDS.toMillis(expectedMaxTime));
551534
assertTrue(totalTime > TimeUnit.SECONDS.toMillis(expectedMinTime), "total time: " + totalTime
552535
+ ", expected min time: " + TimeUnit.SECONDS.toMillis(expectedMinTime));
553536
}
@@ -571,8 +554,6 @@ public void connectionTimingTest() {
571554
if (e.getMessage().toLowerCase().contains(TestResource.getResource("R_cannotOpenDatabase").toLowerCase())) {
572555
// Only check the timing if the correct error, "cannot open database", is returned.
573556
totalTime = System.currentTimeMillis() - timerStart;
574-
assertTrue(totalTime < TimeUnit.SECONDS.toMillis(expectedMaxTime), "total time: " + totalTime
575-
+ ", expected max time: " + TimeUnit.SECONDS.toMillis(expectedMaxTime));
576557
assertTrue(totalTime > TimeUnit.SECONDS.toMillis(expectedMinTime), "total time: " + totalTime
577558
+ ", expected min time: " + TimeUnit.SECONDS.toMillis(expectedMinTime));
578559
}

0 commit comments

Comments
 (0)