Skip to content

Update tests for multiple eventlistener plugin changes #24755

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

Merged

Conversation

ScrapCodes
Copy link
Contributor

Description

A previous PR
#24456
added the needed changes to support Multiple event listener.
However it missed some changes in tests, query runners etc.
So here we fix the follow up, i.e. fix tests etc..

Motivation and Context

Impact

An API in QueryRunner to get EventListener is marked as Deprecated.

Test Plan

Existing tests.

Contributor checklist

  • Please make sure your submission complies with our contributing guide, in particular code style and commit standards.
  • PR description addresses the issue accurately and concisely. If the change is non-trivial, a GitHub Issue is referenced.
  • Documented new properties (with its default value), SQL syntax, functions, or other functionality.
  • If release notes are required, they follow the release notes guidelines.
  • Adequate tests were added if applicable.
  • CI passed.

Release Notes

Please follow release notes guidelines and fill in the release notes below.

== NO RELEASE NOTE ==

@ScrapCodes ScrapCodes requested a review from presto-oss March 19, 2025 12:18
@prestodb-ci prestodb-ci added the from:IBM PR from IBM label Mar 19, 2025
@prestodb-ci prestodb-ci requested review from a team, auden-woolfson and imsayari404 and removed request for a team March 19, 2025 12:19
@ScrapCodes
Copy link
Contributor Author

cc @zac, @aditi-pandit and @evanvdia

@ScrapCodes ScrapCodes force-pushed the followup_multiple_eventlistener branch from d846344 to d3c9ef0 Compare March 19, 2025 12:21
Copy link
Contributor

@auden-woolfson auden-woolfson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, just a couple small changes

List<EventListener> eventListener = getQueryRunner().getEventListeners();
assertFalse(eventListener.isEmpty());
assertTrue(eventListener.get(0) instanceof TestHiveEventListenerPlugin.TestingHiveEventListener, eventListener.get(0).getClass().getName());
return (TestHiveEventListenerPlugin.TestingHiveEventListener) eventListener.get(0);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

return Optional.of(getEventListeners().get(0));
}

List<EventListener> getEventListeners();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add a log here if there are multiple event listeners?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding a log message here, is not a good convention. What I could do is add an assert, that invoker of this method expects no more than one eventlistener. But that has consequences, if people are upgrading.

Copy link
Contributor

@aditi-pandit aditi-pandit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @ScrapCodes. Have a small nit, and also please address Auden's comments. Otherwise it looks good.

assertTrue(eventListener.isPresent());
assertTrue(eventListener.get() instanceof TestHiveEventListenerPlugin.TestingHiveEventListener, eventListener.get().getClass().getName());
return (TestHiveEventListenerPlugin.TestingHiveEventListener) eventListener.get();
List<EventListener> eventListener = getQueryRunner().getEventListeners();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit : Change variable name to eventListeners

A previous PR
added the needed changes to support Multiple event listener.
However it missed some changes in tests, query runners etc.
So here we fix the follow up, i.e. fix tests etc..
@ScrapCodes ScrapCodes force-pushed the followup_multiple_eventlistener branch from d3c9ef0 to 00ac731 Compare March 20, 2025 05:43
@ScrapCodes
Copy link
Contributor Author

Hi @aditi-pandit and @auden-woolfson , updated the PR. Please take a look again!

@@ -607,10 +607,10 @@ public StatsCalculator getStatsCalculator()
}

@Override
public Optional<EventListener> getEventListener()
public List<EventListener> getEventListeners()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be Optional<List

Copy link
Contributor Author

@ScrapCodes ScrapCodes Mar 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @jaystarshot for taking a look. I am not fully sure, I understand that. List can have zero elements (an List#isEmpty check similar to Optional#isPresent check), and if we are concerned about not breaking existing users, we added a default Optional<EventListener> in QueryRunner interface Link.

@ScrapCodes
Copy link
Contributor Author

Hi @aditi-pandit and @auden-woolfson , Thanks for taking a look !
Hopefully your comments are addressed, can you please take another look!

@aditi-pandit aditi-pandit changed the title Followup multiple eventlistener plugin changes (Fix tests). Update tests for multiple eventlistener plugin changes Mar 24, 2025
Copy link
Contributor

@aditi-pandit aditi-pandit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @ScrapCodes

Copy link
Contributor

@auden-woolfson auden-woolfson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@auden-woolfson auden-woolfson merged commit b175123 into prestodb:master Mar 24, 2025
98 checks passed
@ScrapCodes ScrapCodes deleted the followup_multiple_eventlistener branch March 25, 2025 09:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
from:IBM PR from IBM
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants