Skip to content

Commit ff0d0eb

Browse files
authored
[fix][test] Fix flaky PulsarFunctionsK8STest (apache#25108)
1 parent ab65faa commit ff0d0eb

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

tests/integration/src/test/java/org/apache/pulsar/tests/integration/functions/k8s/PulsarFunctionsK8STest.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,14 @@ public void testCreateFunctionInK8sWithSecrets()
119119
});
120120
log.info("Function created successfully");
121121

122+
log.info("Waiting for function to subscribe to input topic");
123+
Awaitility.await().ignoreExceptions().atMost(Duration.ofSeconds(30))
124+
.until(() -> {
125+
admin.topics().getSubscriptions(inputTopicName);
126+
return true;
127+
});
128+
log.info("Function subscribed to input topic");
129+
122130
// Validate that k8s secrets were provided as environment variables to the function pod
123131
String podName = "pf-%s-%s-%s-0".formatted(fnTenant, fnNamespace, fnName);
124132
Exec exec = new Exec(getApiClient());
@@ -157,12 +165,8 @@ public void testCreateFunctionInK8sWithSecrets()
157165
});
158166

159167
log.info("Starting function");
160-
// this seems to be flaky if the stopping of the function hasn't fully completed when it's started again.
161-
// one way to reproduce is to remove the delay before starting the function and also removing the pollDelay
162-
// from the await after stopFunction
163-
Thread.sleep(2000);
164168
admin.functions().startFunction(fnTenant, fnNamespace, fnName);
165-
Awaitility.await().ignoreExceptions().pollDelay(Duration.ofSeconds(1)).atMost(Duration.ofSeconds(30))
169+
Awaitility.await().ignoreExceptions().pollDelay(Duration.ofSeconds(1)).atMost(Duration.ofSeconds(40))
166170
.untilAsserted(() -> {
167171
FunctionStatus functionStatus = admin.functions().getFunctionStatus(fnTenant, fnNamespace, fnName);
168172
assertThat(functionStatus.getNumInstances()).isEqualTo(1);

0 commit comments

Comments
 (0)