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

Avoid implementing the OCI Monitoring interface. #8474

Conversation

klustria
Copy link
Member

@klustria klustria commented Mar 12, 2024

Description

The test in io.helidon.integrations.oci.metrics.cdi uses an implemented OCI Monitoring class. When an OCI SDK upgrade is made and the Monitoring class has changed (for example, a new method is added or a method is removed or a method's signature has changed), this will lead to a need to update the implementation which is quite cumbersome. The goal of this change is to avoid that issue by using Proxy to mock only the Monitoring class methods that are required by the test. The issue was filed via #8377.

This change also includes a resolution to #7739 that is caused by the Monitoring.postMetricData() being called before the test metrics are registered.

Solutions

  1. For Some mocked OCI interfaces need to be updated every time OCI makes a backwards-incompatible release #8377:
    • Remove the implementation of Monitoring interface.
    • Create an extension that simulates OciExtension but will only process Monitoring annotation and if the annotation is found, that it will inject a mocked Monitoring bean .
  2. For 4.x: intermittent io.helidon.integrations.oci.metrics.cdi.OciMetricsCdiExtensionTest.testEnableOciMetricsWithoutConfig #7739:
    • If the mocked Monitoring.postMetricData is invoked, check if the # of expected metrics is greater than 0. If it is, then a signal will be sent to the test to proceed with validation. If not, then that means that the metrics has not been registered yet, so just wait for next invocation and try again.

Documentation

No doc impact as this only affects the Unit Test.

@klustria klustria self-assigned this Mar 12, 2024
@oracle-contributor-agreement oracle-contributor-agreement bot added the OCA Verified All contributors have signed the Oracle Contributor Agreement. label Mar 12, 2024
…oring interface.

Additional Note:
This fix also includes a resolution to helidon-io#7739 that is caused by the Monitoring.postMetricData() to be called before the test metrics are registered.
…cs on the 1st invocation of Monitoring.postMetricData
@klustria klustria merged commit 03579c4 into helidon-io:main Mar 19, 2024
12 checks passed
romain-grecourt pushed a commit to hrstoyanov/helidon that referenced this pull request Mar 19, 2024
…to to mock it. (helidon-io#8474)

The goal of this test fix is to remove implementing Monitoring interface as a way to mock Monitoring client, as it is causing  updates to be made if that interface has changed during an upgrade to OCI SDK is made. Instead, the OCIExtension is now mocked and inside of it, a mocked Monitoring bean using Proxy is injected. With this approach, there is no need to  implement all the methods of Monitoring interface, but only mock those that are needed for the test.
@klustria klustria added this to the 4.0.7 milestone Mar 26, 2024
@klustria klustria changed the title Avoid implementing the OCI Monitoring interface and instead use Mockito to mock it. Avoid implementing the OCI Monitoring interface. Mar 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OCA Verified All contributors have signed the Oracle Contributor Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants