Skip to content

Commit

Permalink
Remove maximum time testing from CRL (#2545)
Browse files Browse the repository at this point in the history
* Remove maximum testing as this is very dependent on pipeline behavior.

* Formatting

* Undo formatting to satisfy code cov
  • Loading branch information
Jeffery-Wasty authored Nov 22, 2024
1 parent edbc7fc commit fc0cfab
Showing 1 changed file with 4 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,8 @@ public void testConnectionRetry(String replacedDbName, String addedRetryParams)

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

timerStart = System.currentTimeMillis();
Expand All @@ -268,8 +266,6 @@ public void statementTimingTests() {
totalTime = System.currentTimeMillis() - timerStart;
assertTrue(totalTime > TimeUnit.SECONDS.toMillis(2),
"total time: " + totalTime + ", expected minimum time: " + TimeUnit.SECONDS.toMillis(8));
assertTrue(totalTime < TimeUnit.SECONDS.toMillis(18),
"total time: " + totalTime + ", expected maximum time: " + TimeUnit.SECONDS.toMillis(18));
}

timerStart = System.currentTimeMillis();
Expand All @@ -283,8 +279,6 @@ public void statementTimingTests() {
totalTime = System.currentTimeMillis() - timerStart;
assertTrue(totalTime > TimeUnit.SECONDS.toMillis(3),
"total time: " + totalTime + ", expected minimum time: " + TimeUnit.SECONDS.toMillis(10));
assertTrue(totalTime < TimeUnit.SECONDS.toMillis(20),
"total time: " + totalTime + ", expected maximum time: " + TimeUnit.SECONDS.toMillis(20));
}
}

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

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

// No retries since CRL rules override, expected time ~1 second
try {
Expand All @@ -517,18 +510,10 @@ public void connectionTimingTest() {
|| ((isSqlAzure() || isSqlAzureDW()) && e.getMessage().toLowerCase()
.contains(TestResource.getResource("R_connectTimedOut").toLowerCase())),
e.getMessage());

if (e.getMessage().toLowerCase().contains(TestResource.getResource("R_cannotOpenDatabase").toLowerCase())) {
// Only check the timing if the correct error, "cannot open database", is returned.
totalTime = System.currentTimeMillis() - timerStart;
assertTrue(totalTime < TimeUnit.SECONDS.toMillis(expectedMaxTime),
"total time: " + totalTime + ", expected time: " + TimeUnit.SECONDS.toMillis(expectedMaxTime));
}
}

timerStart = System.currentTimeMillis();
long expectedMinTime = 10;
expectedMaxTime = 35;

// (0s attempt + 0s attempt + 10s wait + 0s attempt) = expected 10s execution time
try {
Expand All @@ -546,8 +531,6 @@ public void connectionTimingTest() {
if (e.getMessage().toLowerCase().contains(TestResource.getResource("R_cannotOpenDatabase").toLowerCase())) {
// Only check the timing if the correct error, "cannot open database", is returned.
totalTime = System.currentTimeMillis() - timerStart;
assertTrue(totalTime < TimeUnit.SECONDS.toMillis(expectedMaxTime), "total time: " + totalTime
+ ", expected max time: " + TimeUnit.SECONDS.toMillis(expectedMaxTime));
assertTrue(totalTime > TimeUnit.SECONDS.toMillis(expectedMinTime), "total time: " + totalTime
+ ", expected min time: " + TimeUnit.SECONDS.toMillis(expectedMinTime));
}
Expand All @@ -571,8 +554,6 @@ public void connectionTimingTest() {
if (e.getMessage().toLowerCase().contains(TestResource.getResource("R_cannotOpenDatabase").toLowerCase())) {
// Only check the timing if the correct error, "cannot open database", is returned.
totalTime = System.currentTimeMillis() - timerStart;
assertTrue(totalTime < TimeUnit.SECONDS.toMillis(expectedMaxTime), "total time: " + totalTime
+ ", expected max time: " + TimeUnit.SECONDS.toMillis(expectedMaxTime));
assertTrue(totalTime > TimeUnit.SECONDS.toMillis(expectedMinTime), "total time: " + totalTime
+ ", expected min time: " + TimeUnit.SECONDS.toMillis(expectedMinTime));
}
Expand Down

0 comments on commit fc0cfab

Please sign in to comment.