You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by "Peter Lee (Jira)" <ji...@apache.org> on 2025/03/17 16:20:00 UTC

[jira] [Commented] (HDDS-12604) Reduce duplication in TestContainerStateMachine

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

Peter Lee commented on HDDS-12604:
----------------------------------

Hi [~chiacyu], if you are not working on this, may I take this? Thanks!

> Reduce duplication in TestContainerStateMachine
> -----------------------------------------------
>
>                 Key: HDDS-12604
>                 URL: https://issues.apache.org/jira/browse/HDDS-12604
>             Project: Apache Ozone
>          Issue Type: Sub-task
>          Components: test
>            Reporter: Attila Doroszlai
>            Assignee: Chia-Chuan Yu
>            Priority: Major
>
> Reduce code duplication in TestContainerStateMachine.  Examples:
> {code}
>     when(context.getRequestProto()).thenReturn(ContainerProtos.ContainerCommandRequestProto.newBuilder()
>         .setCmdType(ContainerProtos.Type.WriteChunk).setWriteChunk(
>             ContainerProtos.WriteChunkRequestProto.newBuilder().setData(ByteString.copyFromUtf8("Test Data"))
>                 .setBlockID(
>                     ContainerProtos.DatanodeBlockID.newBuilder().setContainerID(1).setLocalID(1).build()).build())
>         .setContainerID(1)
>         .setDatanodeUuid(UUID.randomUUID().toString()).build());
> {code}
> {code}
>     AtomicReference<Throwable> throwable = new AtomicReference<>(null);
>     Function<Throwable, ? extends Message> throwableSetter = t -> {
>       throwable.set(t);
>       return null;
>     };
> {code}
> {code}
>     if (failWithException) {
>       when(dispatcher.dispatch(any(), any())).thenThrow(new RuntimeException());
>     } else {
>       when(dispatcher.dispatch(any(), any())).thenReturn(ContainerProtos.ContainerCommandResponseProto
>           .newBuilder().setCmdType(ContainerProtos.Type.WriteChunk)
>           .setResult(ContainerProtos.Result.CONTAINER_INTERNAL_ERROR)
>           .build());
>     }
> {code}
> CC [~swamirishi], [~sumitagrawl]



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

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org