File tree Expand file tree Collapse file tree 2 files changed +45
-0
lines changed
framework/testCore/src/main/java/com/microsoft/applicationinsights/smoketest
testApps/WebFlux/src/smokeTest/java/com/microsoft/applicationinsights/smoketest Expand file tree Collapse file tree 2 files changed +45
-0
lines changed Original file line number Diff line number Diff line change 1+ package com .microsoft .applicationinsights .smoketest ;
2+
3+ import org .junit .rules .TestRule ;
4+ import org .junit .runner .Description ;
5+ import org .junit .runners .model .Statement ;
6+
7+ public class Retry implements TestRule {
8+
9+ private final int retryCount ;
10+
11+ public Retry (int retryCount ) {
12+ this .retryCount = retryCount ;
13+ }
14+
15+ @ Override
16+ public Statement apply (Statement base , Description description ) {
17+ return statement (base , description );
18+ }
19+
20+ private Statement statement (Statement base , Description description ) {
21+ return new Statement () {
22+ @ Override
23+ public void evaluate () throws Throwable {
24+ Throwable caughtThrowable = null ;
25+ for (int i = 0 ; i < retryCount ; i ++) {
26+ try {
27+ base .evaluate (); // this will invoke test method, when the test fails, it will throw an AssertionError.
28+ return ;
29+ } catch (Throwable t ) {
30+ caughtThrowable = t ;
31+ System .err .println (description .getDisplayName () + ": run " + (i +1 ) + " failed" );
32+ }
33+ }
34+ System .err .println (description .getDisplayName () + ": giving up after " + retryCount + " failures" );
35+ caughtThrowable .printStackTrace ();
36+ throw caughtThrowable ;
37+ }
38+ };
39+ }
40+ }
Original file line number Diff line number Diff line change 33import com .microsoft .applicationinsights .internal .schemav2 .Data ;
44import com .microsoft .applicationinsights .internal .schemav2 .Envelope ;
55import com .microsoft .applicationinsights .internal .schemav2 .RequestData ;
6+ import org .junit .Rule ;
67import org .junit .Test ;
78
89import java .util .List ;
1213@ UseAgent
1314public class WebFluxTest extends AiSmokeTest {
1415
16+ // TODO revisit and try to get to the bottom of this sporadic failure
17+ @ Rule
18+ public Retry retry = new Retry (5 );
19+
1520 @ Test
1621 @ TargetUri ("/test" )
1722 public void doMostBasicTest () throws Exception {
You can’t perform that action at this time.
0 commit comments