File tree 3 files changed +23
-3
lines changed
hello-gcs/src/test/java/functions
hello-http/src/test/java/functions
hello-pubsub/src/test/java/functions
3 files changed +23
-3
lines changed Original file line number Diff line number Diff line change @@ -55,7 +55,7 @@ public class ExampleIT {
55
55
@ BeforeClass
56
56
public static void setUp () throws IOException {
57
57
// Get the sample's base directory (the one containing a pom.xml file)
58
- String baseDir = System .getProperty ("basedir " );
58
+ String baseDir = System .getProperty ("user.dir " );
59
59
60
60
// Emulate the function locally by running the Functions Framework Maven plugin
61
61
emulatorProcess = new ProcessBuilder ()
@@ -93,6 +93,15 @@ public void helloGcs_shouldRunWithFunctionsFramework() throws Throwable {
93
93
RetryRegistry registry = RetryRegistry .of (RetryConfig .custom ()
94
94
.maxAttempts (8 )
95
95
.retryExceptions (HttpHostConnectException .class )
96
+ .retryOnResult (u -> {
97
+ // Retry if the Functions Framework process has no stdout content
98
+ // See `retryOnResultPredicate` here: https://resilience4j.readme.io/docs/retry
99
+ try {
100
+ return emulatorProcess .getErrorStream ().available () == 0 ;
101
+ } catch (IOException e ) {
102
+ return true ;
103
+ }
104
+ })
96
105
.intervalFunction (IntervalFunction .ofExponentialBackoff (200 , 2 ))
97
106
.build ());
98
107
Retry retry = registry .retry ("my" );
Original file line number Diff line number Diff line change @@ -49,7 +49,7 @@ public class ExampleIT {
49
49
@ BeforeClass
50
50
public static void setUp () throws IOException {
51
51
// Get the sample's base directory (the one containing a pom.xml file)
52
- String baseDir = System .getProperty ("basedir " );
52
+ String baseDir = System .getProperty ("user.dir " );
53
53
54
54
// Emulate the function locally by running the Functions Framework Maven plugin
55
55
emulatorProcess = new ProcessBuilder ()
@@ -72,10 +72,12 @@ public void helloHttp_shouldRunWithFunctionsFramework() throws Throwable {
72
72
73
73
// The Functions Framework Maven plugin process takes time to start up
74
74
// Use resilience4j to retry the test HTTP request until the plugin responds
75
+ // See `retryOnResultPredicate` here: https://resilience4j.readme.io/docs/retry
75
76
RetryRegistry registry = RetryRegistry .of (RetryConfig .custom ()
76
77
.maxAttempts (8 )
77
78
.intervalFunction (IntervalFunction .ofExponentialBackoff (200 , 2 ))
78
79
.retryExceptions (IOException .class )
80
+ .retryOnResult (body -> body .toString ().length () == 0 )
79
81
.build ());
80
82
Retry retry = registry .retry ("my" );
81
83
Original file line number Diff line number Diff line change @@ -56,7 +56,7 @@ public class ExampleIT {
56
56
@ BeforeClass
57
57
public static void setUp () throws IOException {
58
58
// Get the sample's base directory (the one containing a pom.xml file)
59
- String baseDir = System .getProperty ("basedir " );
59
+ String baseDir = System .getProperty ("user.dir " );
60
60
61
61
// Emulate the function locally by running the Functions Framework Maven plugin
62
62
emulatorProcess = new ProcessBuilder ()
@@ -91,6 +91,15 @@ public void helloPubSub_shouldRunWithFunctionsFramework() throws Throwable {
91
91
RetryRegistry registry = RetryRegistry .of (RetryConfig .custom ()
92
92
.maxAttempts (8 )
93
93
.retryExceptions (HttpHostConnectException .class )
94
+ .retryOnResult (u -> {
95
+ // Retry if the Functions Framework process has no stdout content
96
+ // See `retryOnResultPredicate` here: https://resilience4j.readme.io/docs/retry
97
+ try {
98
+ return emulatorProcess .getErrorStream ().available () == 0 ;
99
+ } catch (IOException e ) {
100
+ return true ;
101
+ }
102
+ })
94
103
.intervalFunction (IntervalFunction .ofExponentialBackoff (200 , 2 ))
95
104
.build ());
96
105
Retry retry = registry .retry ("my" );
You can’t perform that action at this time.
0 commit comments