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 PlainOsgiTest #3097

Closed
wants to merge 1 commit into from
Closed

Conversation

krmahadevan
Copy link
Member

@krmahadevan krmahadevan commented Mar 21, 2024

This test has recently started failing after the PR #3089
got merged.

With the below exception

org.ops4j.pax.exam.TestContainerException: java.lang.IllegalArgumentException: Can not set java.util.List field org.testng.internal.NoOpTestClass.m_beforeTestMethods to [Lorg.testng.ITestNGMethod;

PR #3089 changed the type of a field which was previously an array to a list.

The PaxExam listener is making use of reflection to access the data member
m_beforeTestMethods instead of it just using
The “setter” that is part of NoOpTestClass.

Since this library is being used ONLY for test and Since the library in question seems to be something That is not updated for quite sometime, resorting to class path overriding wherein we duplicate the Same class into TestNG codebase and then fix the
Problem locally so that the tests will pass.

Summary by CodeRabbit

  • New Features
    • Introduced a TestNG driver for Pax Exam, enhancing integration and management of TestNG test classes with Pax Exam capabilities. This includes dependency injection, transaction management, and reactor staging for tests.

This test has recently started failing after the PR
testng-team#3089
got merged. 

With the below exception

org.ops4j.pax.exam.TestContainerException: java.lang.IllegalArgumentException: Can not set java.util.List field org.testng.internal.NoOpTestClass.m_beforeTestMethods to [Lorg.testng.ITestNGMethod;

This PR changes the type of a field
Which was previously an array to a list.

The PaxExam listener is making 
Use of reflection to access the data member 
“m_beforeTestMethods” instead of it just using
The “setter” that is part of NoOpTestClass.

Since this library is being used ONLY for test and 
Since the library in question seems to be something
That is not updated for quite sometime, resorting 
to class path overriding wherein we duplicate the 
Same class into TestNG codebase and then fix the 
Problem locally so that the tests will pass.
Copy link

coderabbitai bot commented Mar 21, 2024

Walkthrough

This update introduces a TestNG driver for Pax Exam, enhancing integration by implementing TestNG listener interfaces. It facilitates running TestNG tests with Pax Exam support, managing test methods, dependency injections, transactions, and reactor staging efficiently. The driver also includes improvements in configuration methods, probe invokers, and test method manipulation.

Changes

File Path Change Summary
.../testng/listener/PaxExam.java Introduced a TestNG driver for Pax Exam, implementing listener interfaces for enhanced test method management, dependency injection, and reactor staging.

Related issues

  • JPMS support #2727: The Pax Exam update could potentially address JPMS support challenges by enabling better integration and handling of Java modules within TestNG environments, considering it introduces new ways to manage test execution and dependencies.

Poem

In the land of code and byte,
A rabbit hopped into the light.
With a flick and a hop, it weaved a spell,
TestNG and Pax Exam, together they gel.
🌟 "Fear not the tests," the rabbit said,
"For I bring tools to ease your dread."
🐇 With every run, and every pass,
"Together, we shall ace the class!"

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share

Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit-tests for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit tests for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 69dc232 and cb0c311.
Files selected for processing (1)
  • testng-test-osgi/src/test/java/org/ops4j/pax/exam/testng/listener/PaxExam.java (1 hunks)
Additional comments: 1
testng-test-osgi/src/test/java/org/ops4j/pax/exam/testng/listener/PaxExam.java (1)
  • 494-497: The change to use a list instead of an array for m_beforeTestMethods and setAfterTestMethod in NoOpTestClass is a direct response to the issue described in the PR objectives. This modification ensures compatibility with the PaxExam library's reflection-based access patterns. However, it's crucial to ensure that this change does not inadvertently affect other parts of the TestNG framework that might rely on the original array type. It would be beneficial to verify that all internal usages within TestNG and external dependencies that might interact with these methods are compatible with this change.

@juherr
Copy link
Member

juherr commented Mar 21, 2024

Could you make a pull request of the fix here https://github.com/ops4j/org.ops4j.pax.exam2 ?
Once done, just skip the test with your pr as reference. It will be restore if a new version is released.

@krmahadevan
Copy link
Member Author

Could you make a pull request of the fix here https://github.com/ops4j/org.ops4j.pax.exam2 ? Once done, just skip the test with your pr as reference. It will be restore if a new version is released.

I didn't quite get you @juherr

Are you saying that we need to do the following :

  • This PR should NOT be merged.
  • Disable the test in question
  • Raise a PR with the changes in the original repository
  • Wait for the original PR to be merged and released
  • Upgrade testng to use the newly released version
  • Enable the disabled test

@juherr
Copy link
Member

juherr commented Mar 21, 2024

Yes, except the pr should be done before because we need the link 😉

@krmahadevan
Copy link
Member Author

Here's the PR: ops4j/org.ops4j.pax.exam2#1112

@juherr
Copy link
Member

juherr commented Mar 21, 2024

Perfect 👍 Just temporary disable the failing test.

@krmahadevan
Copy link
Member Author

The change is part of #3098

@krmahadevan krmahadevan deleted the fix_osgi_test branch March 21, 2024 09:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants