Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix][test] Fix test testAsyncFunctionMaxPending #22121

Merged

Conversation

liangyepianzhou
Copy link
Contributor

Motivation

The assert Assert.assertEquals(request.getProcessResult().get(), testString + "-lambda"); will wait for the function process completely, so the following ones are also processed completely. And the pending requests will be removed. Which will cause an NPE when doing the next verify.

2024-02-26T15:12:22,054 - INFO  - [main:JavaInstanceTest@195] - input string: ABC123
2024-02-26T15:12:22,062 - INFO  - [main:JavaInstanceTest@195] - input string: ABC123
2024-02-26T15:12:22,064 - INFO  - [main:JavaInstanceTest@195] - input string: ABC123

java.lang.NullPointerException: Cannot invoke "org.apache.pulsar.functions.instance.JavaInstance$AsyncFuncRequest.getProcessResult()" because "request" is null

	at org.apache.pulsar.functions.instance.JavaInstanceTest.testAsyncFunctionMaxPending(JavaInstanceTest.java:227)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at org.testng.internal.invokers.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:139)
	at org.testng.internal.invokers.TestInvoker.invokeMethod(TestInvoker.java:677)
	at org.testng.internal.invokers.TestInvoker.invokeTestMethod(TestInvoker.java:221)
	at org.testng.internal.invokers.MethodRunner.runInSequence(MethodRunner.java:50)
	at org.testng.internal.invokers.TestInvoker$MethodInvocationAgent.invoke(TestInvoker.java:969)
	at org.testng.internal.invokers.TestInvoker.invokeTestMethods(TestInvoker.java:194)
	at org.testng.internal.invokers.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:148)
	at org.testng.internal.invokers.TestMethodWorker.run(TestMethodWorker.java:128)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
	at org.testng.TestRunner.privateRun(TestRunner.java:829)
	at org.testng.TestRunner.run(TestRunner.java:602)
	at org.testng.SuiteRunner.runTest(SuiteRunner.java:437)
	at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:431)
	at org.testng.SuiteRunner.privateRun(SuiteRunner.java:391)
	at org.testng.SuiteRunner.run(SuiteRunner.java:330)
	at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
	at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:95)
	at org.testng.TestNG.runSuitesSequentially(TestNG.java:1256)
	at org.testng.TestNG.runSuitesLocally(TestNG.java:1176)
	at org.testng.TestNG.runSuites(TestNG.java:1099)
	at org.testng.TestNG.run(TestNG.java:1067)
	at com.intellij.rt.testng.IDEARemoteTestNG.run(IDEARemoteTestNG.java:65)
	at com.intellij.rt.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:105)

Modifications

Use CountDownLatch to replace sleep and cache requests before count.countDown();

Verifying this change

  • Make sure that the change passes the CI checks.

(Please pick either of the following options)

This change is a trivial rework / code cleanup without any test coverage.

(or)

This change is already covered by existing tests, such as (please describe tests).

(or)

This change added tests and can be verified as follows:

(example:)

  • Added integration tests for end-to-end deployment with large payloads (10MB)
  • Extended integration test for recovery after broker failure

Does this pull request potentially affect one of the following parts:

If the box was checked, please highlight the changes

  • Dependencies (add or upgrade a dependency)
  • The public API
  • The schema
  • The default values of configurations
  • The threading model
  • The binary protocol
  • The REST endpoints
  • The admin CLI options
  • The metrics
  • Anything that affects deployment

Documentation

  • doc
  • doc-required
  • doc-not-needed
  • doc-complete

Matching PR in forked repository

PR in forked repository:

@liangyepianzhou liangyepianzhou self-assigned this Feb 26, 2024
@github-actions github-actions bot added the doc-not-needed Your PR changes do not impact docs label Feb 26, 2024
@liangyepianzhou liangyepianzhou added this to the 3.3.0 milestone Feb 26, 2024
@github-actions github-actions bot added the doc-not-needed Your PR changes do not impact docs label Feb 26, 2024
@Technoboy- Technoboy- changed the title [fix][test] fix test testAsyncFunctionMaxPending [fix][test] Fix test testAsyncFunctionMaxPending Feb 27, 2024
@Technoboy-
Copy link
Contributor

Ping @freeznet @jiangpengcheng help review

@Technoboy- Technoboy- merged commit 91de98a into apache:master Feb 27, 2024
92 of 98 checks passed
heesung-sn pushed a commit that referenced this pull request Feb 27, 2024
gaoran10 pushed a commit to gaoran10/pulsar that referenced this pull request Mar 4, 2024
gaoran10 pushed a commit that referenced this pull request Mar 4, 2024
mukesh-ctds pushed a commit to datastax/pulsar that referenced this pull request Mar 4, 2024
(cherry picked from commit 91de98a)
(cherry picked from commit c9ecd52)
mukesh-ctds pushed a commit to datastax/pulsar that referenced this pull request Mar 6, 2024
(cherry picked from commit 91de98a)
(cherry picked from commit c9ecd52)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment