You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by "Attila Doroszlai (Jira)" <ji...@apache.org> on 2025/03/25 12:14:00 UTC
[jira] [Resolved] (HDDS-12604) Reduce duplication in TestContainerStateMachine
[ https://issues.apache.org/jira/browse/HDDS-12604?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Attila Doroszlai resolved HDDS-12604.
-------------------------------------
Fix Version/s: 2.1.0
Resolution: Implemented
> 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
> Labels: pull-request-available
> Fix For: 2.1.0
>
>
> 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