[ 
https://issues.apache.org/jira/browse/HDDS-10311?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17825939#comment-17825939
 ] 

Attila Doroszlai commented on HDDS-10311:
-----------------------------------------

bq. any idea why getMetrics in two tests will be NullPointer

This is caused by {{cluster.restartOzoneManager()}} call near the end of test 
cases.  Stopping Ozone Manager unregisters {{OMMetrics}}, but 
{{OzoneManager.restart()}} does not re-register it.

This part of the test verifies that number of volumes/buckets/etc. is 
initialized upon startup from DB.  But {{OzoneManager.restart()}} is only used 
by tests, and it duplicates some code from {{start()}}.  So the test would not 
catch any problem with missing metrics init in {{start()}}, since it exercises 
another code path.

The test also injects some failures:

{code}
    // inject exception to test for Failure Metrics on the read path
    doThrow(exception).when(mockVm).getVolumeInfo(any());
    doThrow(exception).when(mockVm).listVolumes(any(), any(),
        any(), anyInt());


    HddsWhiteboxTestUtils.setInternalState(ozoneManager,
        "volumeManager", mockVm);
    // inject exception to test for Failure Metrics on the write path
    mockWritePathExceptions(OmVolumeArgs.class);
{code}

Without restarting Ozone Manager, these kinds of failures would cause problems 
for the other test cases.  We could fix that by restoring the original internal 
state.  However, I think injecting such failures is overkill.  For the read 
path, we can simply perform ops without creating the object in the first place.

Another problem with {{TestOmMetrics}} is that some of the expected metrics 
values are "magic".

If we can add assertions about each OM operation in more specific tests 
(preferably unit tests), then {{TestOmMetrics}} can be deleted and we don't 
need to work around the issues above (NPE, restoring state, etc.)

> Speed up TestOmMetrics
> ----------------------
>
>                 Key: HDDS-10311
>                 URL: https://issues.apache.org/jira/browse/HDDS-10311
>             Project: Apache Ozone
>          Issue Type: Sub-task
>          Components: test
>            Reporter: Attila Doroszlai
>            Assignee: Will Xiao
>            Priority: Major
>
> {code}
> Tests run: 8, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 115.365 s - 
> in org.apache.hadoop.ozone.om.TestOmMetrics
> {code}
> # assertions about metrics should be merged into functional tests (no need to 
> test e.g. {{listKeys}} and metrics for {{listKeys}} separately
> # no need to start new cluster for each test case



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to