-
Notifications
You must be signed in to change notification settings - Fork 0
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
[TS-1928] Support keepOpen
option for searchMessageGroups
gRPC r…
#86
Draft
Nikita-Smirnov-Exactpro
wants to merge
8
commits into
dev-version-2
Choose a base branch
from
TH2-1928
base: dev-version-2
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+620
−39
Draft
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
a621ce0
[TH2-1928] Support `keepOpen` option for `searchMessageGroups` gRPC r…
Nikita-Smirnov-Exactpro b8021f0
bump th2 plugin version
purplegen 52176ec
[th2-1928] corrected readme
Nikita-Smirnov-Exactpro 274a8be
Make sure that Backpreassure provider is closed on RST_STREAM
purplegen 4d65fda
Merge branch 'dev-version-2' into TH2-1928
purplegen 0a02c00
Remove isCancelled
purplegen f46103f
Add test to verify cancellation on RST_STREAM
purplegen 61b35e0
Add new configuration parameter: keepOpenPullingTimeout
purplegen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
kotlin.code.style=official | ||
release_version=2.12.0 | ||
release_version=2.12.1 | ||
description='th2 Lightweight data provider component' | ||
kapt.include.compile.classpath=false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
114 changes: 114 additions & 0 deletions
114
app/src/test/kotlin/com/exactpro/th2/lwdataprovider/grpc/GRPCBaseTests.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
/* | ||
* Copyright 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. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.exactpro.th2.lwdataprovider.grpc | ||
|
||
import com.exactpro.cradle.messages.StoredMessage | ||
import com.exactpro.th2.common.message.toTimestamp | ||
import com.exactpro.th2.dataprovider.lw.grpc.MessageGroupsSearchRequest | ||
import com.exactpro.th2.lwdataprovider.entities.internal.ResponseFormat | ||
import com.exactpro.th2.lwdataprovider.util.ImmutableListCradleResult | ||
import com.exactpro.th2.lwdataprovider.util.createBatches | ||
import com.exactpro.th2.lwdataprovider.util.validateMessagesOrderGrpc | ||
import org.junit.jupiter.api.Assertions.assertEquals | ||
import org.mockito.kotlin.argThat | ||
import org.mockito.kotlin.whenever | ||
import java.time.Instant | ||
import java.time.temporal.ChronoUnit | ||
|
||
abstract class GRPCBaseTests : GrpcImplTestBase() { | ||
|
||
protected fun stopsPullingDataWhenOutOfRangeExists(offsetNewData: Boolean) { | ||
val startTimestamp = Instant.now() | ||
val firstEndTimestamp = startTimestamp.plus(10L, ChronoUnit.MINUTES) | ||
val endTimestamp = firstEndTimestamp.plus(10L, ChronoUnit.MINUTES) | ||
val aliasesCount = 5 | ||
val increase = 5L | ||
val firstBatchMessagesCount = (firstEndTimestamp.epochSecond - startTimestamp.epochSecond) / increase | ||
val firstMessagesPerAlias = firstBatchMessagesCount / aliasesCount | ||
|
||
val lastBatchMessagesCount = (endTimestamp.epochSecond - firstEndTimestamp.epochSecond) / increase | ||
val lastMessagesPerAlias = lastBatchMessagesCount / aliasesCount | ||
|
||
val firstBatches = createBatches( | ||
firstMessagesPerAlias, | ||
aliasesCount, | ||
overlapCount = 0, | ||
increase, | ||
startTimestamp, | ||
firstEndTimestamp, | ||
) | ||
val lastBatches = createBatches( | ||
lastMessagesPerAlias, | ||
aliasesCount, | ||
overlapCount = 0, | ||
increase, | ||
firstEndTimestamp, | ||
endTimestamp, | ||
aliasIndexOffset = if (offsetNewData) aliasesCount else 0 | ||
) | ||
val outsideBatches = createBatches( | ||
10, | ||
1, | ||
0, | ||
increase, | ||
endTimestamp.plusNanos(1), | ||
endTimestamp.plus(5, ChronoUnit.MINUTES), | ||
) | ||
val group = "test" | ||
val firstRequestMessagesCount = firstBatches.sumOf { it.messageCount } | ||
val secondRequestMessagesCount = lastBatches.sumOf { it.messageCount } | ||
val messagesCount = firstRequestMessagesCount + secondRequestMessagesCount | ||
|
||
whenever(storage.getGroupedMessageBatches(argThat { | ||
groupName == group && from.value == startTimestamp && to.value == endTimestamp | ||
})).thenReturn(ImmutableListCradleResult(firstBatches)) | ||
whenever(storage.getGroupedMessageBatches(argThat { | ||
groupName == group && from.value == firstBatches.maxOf { it.lastTimestamp } && to.value == endTimestamp | ||
})).thenReturn(ImmutableListCradleResult(lastBatches)) | ||
whenever(storage.getGroupedMessageBatches(argThat { | ||
limit == 1 && groupName == group | ||
})).thenReturn(ImmutableListCradleResult(outsideBatches)) | ||
|
||
val request = MessageGroupsSearchRequest.newBuilder().apply { | ||
addMessageGroupBuilder().setName("test") | ||
addResponseFormats(ResponseFormat.BASE_64.name) | ||
bookIdBuilder.setName("test") | ||
this.startTimestamp = startTimestamp.toTimestamp() | ||
this.endTimestamp = endTimestamp.toTimestamp() | ||
this.keepOpen = true | ||
}.build() | ||
|
||
val grpcDataProvider = createGrpcDataProvider() | ||
GrpcTestHolder(grpcDataProvider).use { (stub) -> | ||
val responses = stub.searchMessageGroups(request).asSequence().toList() | ||
|
||
assertEquals(messagesCount + 1, responses.size) { | ||
val missing: List<StoredMessage> = | ||
(firstBatches.asSequence() + lastBatches.asSequence()).flatMap { it.messages }.filter { stored -> | ||
responses.none { | ||
val messageId = it.message.messageId | ||
messageId.connectionId.sessionAlias == stored.sessionAlias | ||
&& messageId.sequence == stored.sequence | ||
&& messageId.direction.toCradleDirection() == stored.direction | ||
} | ||
}.toList() | ||
"Missing ${missing.size} message(s): $missing" | ||
} | ||
|
||
validateMessagesOrderGrpc(responses, messagesCount) | ||
} | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note: please check if we should keep pulling before calling
sleep
method. As an alternative, I think you can call sleep method before callingpullUpdates
. I think it would make sense to wait a bit before first pull attempt as well