diff --git a/.github/workflows/ci-unwelcome-words.yml b/.github/workflows/ci-unwelcome-words.yml index b23bb56..5e4c440 100644 --- a/.github/workflows/ci-unwelcome-words.yml +++ b/.github/workflows/ci-unwelcome-words.yml @@ -7,17 +7,17 @@ jobs: test: runs-on: ubuntu-20.04 steps: - - uses: actions/checkout@v4 - with: - ref: ${{ github.sha }} - - name: Checkout tool - uses: actions/checkout@v4 - with: - repository: exactpro-th2/ci-github-action - ref: master - token: ${{ secrets.PAT_CI_ACTION }} - path: ci-github-action - - name: Run CI action - uses: ./ci-github-action - with: - ref: ${{ github.sha }} \ No newline at end of file + - uses: actions/checkout@v4 + with: + ref: ${{ github.sha }} + - name: Checkout tool + uses: actions/checkout@v4 + with: + repository: exactpro-th2/ci-github-action + ref: master + token: ${{ secrets.PAT_CI_ACTION }} + path: ci-github-action + - name: Run CI action + uses: ./ci-github-action + with: + ref: ${{ github.sha }} \ No newline at end of file diff --git a/README.md b/README.md index 4bb7626..0a4de2c 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# th2-conn-dirty-fix (1.3.0) +# th2-conn-dirty-fix (1.4.0) This microservice allows sending and receiving messages via FIX protocol @@ -333,6 +333,12 @@ spec: memory: 100Mi cpu: 20m ``` +# Changelog + +## 1.4.0 + +* Merged changes from [th2-conn-dirty-fix:1.7.0](https://github.com/th2-net/th2-conn-dirty-fix) + ## 1.3.0 * Migrated to th2 gradle plugin `0.1.1` @@ -422,4 +428,4 @@ spec: ## 0.0.2 -* Supported the password encryption via `RSA` algorithm. +* Supported the password encryption via `RSA` algorithm. \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index c3996f9..83f8cd0 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1 +1 @@ -release_version=1.3.0 \ No newline at end of file +release_version=1.4.0 \ No newline at end of file diff --git a/src/test/java/com/exactpro/th2/FixHandlerSendTimeoutTest.java b/src/test/java/com/exactpro/th2/FixHandlerSendTimeoutTest.java index 93eec24..89d268f 100644 --- a/src/test/java/com/exactpro/th2/FixHandlerSendTimeoutTest.java +++ b/src/test/java/com/exactpro/th2/FixHandlerSendTimeoutTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Exactpro (Exactpro Systems Limited) + * Copyright 2023-2024 Exactpro (Exactpro Systems Limited) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,6 +22,7 @@ import com.exactpro.th2.conn.dirty.tcp.core.api.IChannel; import com.exactpro.th2.conn.dirty.tcp.core.api.IHandlerContext; import kotlin.Unit; +import org.jetbrains.annotations.NotNull; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.mockito.Mockito; @@ -48,36 +49,32 @@ void sendTimeoutOnConnectionOpen() { any(), anyBoolean(), anyLong(), - anyInt() + anyInt(), + any(String[].class) )) .thenReturn(channelMock); Mockito.when(channelMock.open()) .thenReturn(new CompletableFuture<>()); // future never completes - var settings = new FixHandlerSettings(); - settings.setPort(42); - settings.setSenderCompID("test"); - settings.setPassword("test"); - settings.setHost("localhost"); - settings.setConnectionTimeoutOnSend(300); // 300 millis - settings.setMinConnectionTimeoutOnSend(100); + var settings = createSettings(); Mockito.when(contextMock.getSettings()) .thenReturn(settings); - var fixHandler = new FixHandler(contextMock); - fixHandler.onStart(); - var exception = Assertions.assertThrows(TimeoutException.class, () -> - fixHandler.send(RawMessage.builder() - .setId(MessageId.builder() - .setDirection(Direction.OUTGOING) - .setSessionAlias("test") - .setSequence(1) - .setTimestamp(Instant.now()) - .build()) - .build())); - Assertions.assertEquals( - "could not open connection before timeout 300 mls elapsed", - exception.getMessage(), - "unexpected message" - ); + try(var fixHandler = new FixHandler(contextMock)) { + fixHandler.onStart(); + var exception = Assertions.assertThrows(TimeoutException.class, () -> + fixHandler.send(RawMessage.builder() + .setId(MessageId.builder() + .setDirection(Direction.OUTGOING) + .setSessionAlias("test") + .setSequence(1) + .setTimestamp(Instant.now()) + .build()) + .build())); + Assertions.assertEquals( + "could not open connection before timeout 300 mls elapsed", + exception.getMessage(), + "unexpected message" + ); + } } @Test @@ -90,12 +87,37 @@ void sendTimeoutOnSessionEnabled() { any(), anyBoolean(), anyLong(), - anyInt() + anyInt(), + any(String[].class) )) .thenReturn(channelMock); Mockito.when(channelMock.open()) .thenReturn(CompletableFuture.completedFuture(Unit.INSTANCE)); // completed immediately Mockito.when(channelMock.isOpen()).thenReturn(true); + var settings = createSettings(); + Mockito.when(contextMock.getSettings()) + .thenReturn(settings); + try(var fixHandler = new FixHandler(contextMock)) { + fixHandler.onStart(); + var exception = Assertions.assertThrows(TimeoutException.class, () -> + fixHandler.send(RawMessage.builder() + .setId(MessageId.builder() + .setDirection(Direction.OUTGOING) + .setSessionAlias("test") + .setSequence(1) + .setTimestamp(Instant.now()) + .build()) + .build())); + Assertions.assertEquals( + "session was not established within 300 mls", + exception.getMessage(), + "unexpected message" + ); + } + } + + @NotNull + private static FixHandlerSettings createSettings() { var settings = new FixHandlerSettings(); settings.setPort(42); settings.setHost("localhost"); @@ -114,23 +136,6 @@ void sendTimeoutOnSessionEnabled() { settings.setSessionStartTime(currentTime.plusMinutes(deltaMinutes * 2)); settings.setSessionEndTime(currentTime.plusMinutes(deltaMinutes)); } - Mockito.when(contextMock.getSettings()) - .thenReturn(settings); - var fixHandler = new FixHandler(contextMock); - fixHandler.onStart(); - var exception = Assertions.assertThrows(TimeoutException.class, () -> - fixHandler.send(RawMessage.builder() - .setId(MessageId.builder() - .setDirection(Direction.OUTGOING) - .setSessionAlias("test") - .setSequence(1) - .setTimestamp(Instant.now()) - .build()) - .build())); - Assertions.assertEquals( - "session was not established within 300 mls", - exception.getMessage(), - "unexpected message" - ); + return settings; } } diff --git a/src/test/java/com/exactpro/th2/RecoveryTest.java b/src/test/java/com/exactpro/th2/RecoveryTest.java index 1b12109..d40100b 100644 --- a/src/test/java/com/exactpro/th2/RecoveryTest.java +++ b/src/test/java/com/exactpro/th2/RecoveryTest.java @@ -204,7 +204,7 @@ void testSequenceResetAdminMessages() { ByteBuf resendRequest = Unpooled.wrappedBuffer("8=FIXT.1.1\u00019=73\u000135=2\u000134=2\u000149=client\u000156=server\u000150=trader\u000152=2014-12-22T10:15:30Z\u00017=1\u000116=5\u000110=226\u0001".getBytes(StandardCharsets.UTF_8)); fixHandler.onIncoming(channel, resendRequest, MessageID.getDefaultInstance()); - // sequence reset for meesages from 1 to 3 ( 1, 2 - missing, 3 - admin ) + // sequence reset for messages from 1 to 3 ( 1, 2 - missing, 3 - admin ) ByteBuf seqReset1 = channel.getQueue().get(1); assertEquals(findField(seqReset1, MSG_TYPE_TAG).getValue(), MSG_TYPE_SEQUENCE_RESET); assertEquals(Integer.parseInt(findField(seqReset1, MSG_SEQ_NUM_TAG).getValue()), 1); @@ -215,7 +215,7 @@ void testSequenceResetAdminMessages() { assertEquals(Integer.parseInt(findField(message, MSG_SEQ_NUM_TAG).getValue()), 4); assertEquals(findField(message, POSS_DUP_TAG).getValue(), "Y"); - // sequence reset for meesages from 1 to 3 ( 1, 2 - missing, 3 - admin ) + // sequence reset for messages from 1 to 3 ( 1, 2 - missing, 3 - admin ) ByteBuf seqReset2 = channel.getQueue().get(3); assertEquals(findField(seqReset2, MSG_TYPE_TAG).getValue(), MSG_TYPE_SEQUENCE_RESET); assertEquals(Integer.parseInt(findField(seqReset2, MSG_SEQ_NUM_TAG).getValue()), 5); @@ -245,7 +245,7 @@ void allMessagesMissed() { ByteBuf resendRequest = Unpooled.wrappedBuffer("8=FIXT.1.1\u00019=73\u000135=2\u000134=2\u000149=client\u000156=server\u000150=trader\u000152=2014-12-22T10:15:30Z\u00017=1\u000116=5\u000110=226\u0001".getBytes(StandardCharsets.UTF_8)); fixHandler.onIncoming(channel, resendRequest, MessageID.getDefaultInstance()); - // sequence reset for meesages from 1 to 3 ( 1, 2 - missing, 3 - admin ) + // sequence reset for messages from 1 to 3 ( 1, 2 - missing, 3 - admin ) ByteBuf seqReset = channel.getQueue().get(1); assertEquals(findField(seqReset, MSG_TYPE_TAG).getValue(), MSG_TYPE_SEQUENCE_RESET); assertEquals(Integer.parseInt(findField(seqReset, MSG_SEQ_NUM_TAG).getValue()), 1);