Skip to content

Commit

Permalink
Faster tests (#2606)
Browse files Browse the repository at this point in the history
  • Loading branch information
trask authored Oct 20, 2022
1 parent 8e1b94a commit c44d4b2
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import static com.microsoft.applicationinsights.smoketest.WarEnvironmentValue.TOMCAT_8_JAVA_8_OPENJ9;
import static com.microsoft.applicationinsights.smoketest.WarEnvironmentValue.WILDFLY_13_JAVA_8;
import static com.microsoft.applicationinsights.smoketest.WarEnvironmentValue.WILDFLY_13_JAVA_8_OPENJ9;
import static java.util.concurrent.TimeUnit.SECONDS;
import static org.assertj.core.api.Assertions.assertThat;

import com.microsoft.applicationinsights.smoketest.schemav2.Data;
Expand Down Expand Up @@ -437,9 +438,9 @@ void testRequestSlowWithResponseTime() throws Exception {
}

@Test
@TargetUri("/slowLoop?responseTime=20")
@TargetUri("/slowLoop?responseTime=5")
void testSlowRequestUsingCpuBoundLoop() throws Exception {
validateSlowTest(20, "GET /CoreAndFilter2x/slowLoop");
validateSlowTest(5, "GET /CoreAndFilter2x/slowLoop");
}

@Test
Expand Down Expand Up @@ -505,8 +506,8 @@ private void validateSlowTest(int expectedDurationSeconds, String operationName)
RequestData rd = (RequestData) ((Data<?>) rdEnvelope.getData()).getBaseData();

long actual = rd.getDuration().getTotalMilliseconds();
long expected = (new Duration(0, 0, 0, expectedDurationSeconds, 0).getTotalMilliseconds());
long tolerance = 2 * 1000; // 2 seconds
long expected = SECONDS.toMillis(expectedDurationSeconds);
long tolerance = 2000; // 2 seconds

long min = expected - tolerance;
long max = expected + tolerance;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import static com.microsoft.applicationinsights.smoketest.WarEnvironmentValue.TOMCAT_8_JAVA_8_OPENJ9;
import static com.microsoft.applicationinsights.smoketest.WarEnvironmentValue.WILDFLY_13_JAVA_8;
import static com.microsoft.applicationinsights.smoketest.WarEnvironmentValue.WILDFLY_13_JAVA_8_OPENJ9;
import static java.util.concurrent.TimeUnit.SECONDS;
import static org.assertj.core.api.Assertions.assertThat;

import com.microsoft.applicationinsights.smoketest.schemav2.AvailabilityData;
Expand All @@ -29,7 +30,6 @@
import com.microsoft.applicationinsights.smoketest.schemav2.SeverityLevel;
import java.util.Comparator;
import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.function.Predicate;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
Expand Down Expand Up @@ -469,9 +469,9 @@ void testRequestSlowWithResponseTime() throws Exception {
}

@Test
@TargetUri("/slowLoop?responseTime=20")
@TargetUri("/slowLoop?responseTime=5")
void testSlowRequestUsingCpuBoundLoop() throws Exception {
validateSlowTest(20, "GET /CoreAndFilter3x/slowLoop");
validateSlowTest(5, "GET /CoreAndFilter3x/slowLoop");
}

@Test
Expand Down Expand Up @@ -499,7 +499,7 @@ public boolean test(Envelope input) {
},
1,
10,
TimeUnit.SECONDS);
SECONDS);

Envelope edEnvelope = edList.get(0);

Expand Down Expand Up @@ -537,8 +537,8 @@ private void validateSlowTest(int expectedDurationSeconds, String operationName)
RequestData rd = (RequestData) ((Data<?>) rdEnvelope.getData()).getBaseData();

long actual = rd.getDuration().getTotalMilliseconds();
long expected = (new Duration(0, 0, 0, expectedDurationSeconds, 0).getTotalMilliseconds());
long tolerance = 2 * 1000; // 2 seconds
long expected = SECONDS.toMillis(expectedDurationSeconds);
long tolerance = 2000; // 2 seconds

long min = expected - tolerance;
long max = expected + tolerance;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import static com.microsoft.applicationinsights.smoketest.WarEnvironmentValue.TOMCAT_8_JAVA_8_OPENJ9;
import static com.microsoft.applicationinsights.smoketest.WarEnvironmentValue.WILDFLY_13_JAVA_8;
import static com.microsoft.applicationinsights.smoketest.WarEnvironmentValue.WILDFLY_13_JAVA_8_OPENJ9;
import static java.util.concurrent.TimeUnit.SECONDS;
import static org.assertj.core.api.Assertions.assertThat;

import com.microsoft.applicationinsights.smoketest.schemav2.Data;
Expand Down Expand Up @@ -442,9 +443,9 @@ void testRequestSlowWithResponseTime() throws Exception {
}

@Test
@TargetUri("/slowLoop?responseTime=20")
@TargetUri("/slowLoop?responseTime=5")
void testSlowRequestUsingCpuBoundLoop() throws Exception {
validateSlowTest(20, "GET /CoreAndFilter3xUsingOld3xAgent/slowLoop");
validateSlowTest(5, "GET /CoreAndFilter3xUsingOld3xAgent/slowLoop");
}

@Test
Expand Down Expand Up @@ -510,8 +511,8 @@ private void validateSlowTest(int expectedDurationSeconds, String operationName)
RequestData rd = (RequestData) ((Data<?>) rdEnvelope.getData()).getBaseData();

long actual = rd.getDuration().getTotalMilliseconds();
long expected = (new Duration(0, 0, 0, expectedDurationSeconds, 0).getTotalMilliseconds());
long tolerance = 2 * 1000; // 2 seconds
long expected = SECONDS.toMillis(expectedDurationSeconds);
long tolerance = 2000; // 2 seconds

long min = expected - tolerance;
long max = expected + tolerance;
Expand Down

0 comments on commit c44d4b2

Please sign in to comment.