Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ class IntervalTestInfoSender(
}

override fun stopSendingTests() {
sendTests(collectTests())
messageSender.shutdown()
scheduledThreadPool.shutdown()
if (!scheduledThreadPool.awaitTermination(1, TimeUnit.SECONDS)) {
logger.error("Failed to send some tests prior to shutdown")
scheduledThreadPool.shutdownNow();
}
sendTests(collectTests())
messageSender.shutdown()
logger.info { "Test sending job is stopped." }
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
package com.epam.drill.agent.transport

import mu.KotlinLogging
import com.epam.drill.agent.common.transport.AgentMessage
import com.epam.drill.agent.common.transport.AgentMessageDestination
import com.epam.drill.agent.common.transport.AgentMessageSender
import kotlinx.serialization.KSerializer
Expand Down Expand Up @@ -52,7 +51,7 @@ open class QueuedAgentMessageSender(
}
}

override fun <T>send(destination: AgentMessageDestination, message: T, serializer: KSerializer<T>) {
override fun <T> send(destination: AgentMessageDestination, message: T, serializer: KSerializer<T>) {
val mappedDestination = destinationMapper.map(destination)
val serializedMessage = messageSerializer.serialize(message, serializer)
if (!isRunning.get()) {
Expand All @@ -69,10 +68,10 @@ open class QueuedAgentMessageSender(
}

override fun shutdown() {
isRunning.set(false)
if (!isRunning.compareAndSet(true, false)) return
executor.shutdown()
try {
if (!executor.awaitTermination(5, TimeUnit.SECONDS)) {
if (!executor.awaitTermination(1, TimeUnit.SECONDS)) {
executor.shutdownNow()
}
} catch (e: InterruptedException) {
Expand Down Expand Up @@ -144,6 +143,7 @@ open class QueuedAgentMessageSender(
tryToSend(destination, message) || handleUnsent(destination, message, reason)
}
} while (message != null)
logger.info { "Finished unloading a message queue." }
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,18 +180,18 @@ class QueuedAgentMessageSenderTest {
calls?.waitFor { verify(exactly = it) { messageSerializer.serialize(any(), TestAgentMessage.serializer()) } }
calls?.waitFor { verify(exactly = it) { destinationMapper.map(any()) } }
enqueued?.waitFor {
assertEquals(it, queueOffers.filter { o -> o }.size)
assertEquals(it, queueOffers.filter { o -> o }.size, "Expected $it messages to be enqueued, but was ${queueOffers.filter { o -> o }.size}")
}
dequeued?.waitFor {
assertEquals(it, queuePolls.filterNotNull().size)
assertEquals(it, queuePolls.filterNotNull().size, "Expected $it messages to be dequeued, but was ${queuePolls.filterNotNull().size}")
}

sendingAttempts?.waitFor { verify(exactly = it) { messageTransport.send(any(), any(), any()) } }
sent?.waitFor { verify(exactly = it) { messageSendingListener.onSent(any(), any()) } }
unsent?.waitFor { verify(exactly = it) { messageSendingListener.onUnsent(any(), any()) } }
}

private fun <T> T.waitFor(timeout: Long = 1000, block: (T) -> Unit) {
private fun <T> T.waitFor(timeout: Long = 2000, block: (T) -> Unit) {
val start = System.currentTimeMillis()
val timeIsOut = { System.currentTimeMillis() - start > timeout }
var error: Throwable? = null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,14 @@ class IntervalCoverageSender(
}

override fun stopSendingCoverage() {
sendProbes(collectReleasedProbes())
sendProbes(collectUnreleasedProbes())
sender.shutdown()
scheduledThreadPool.shutdown()
if (!scheduledThreadPool.awaitTermination(5, TimeUnit.SECONDS)) {
if (!scheduledThreadPool.awaitTermination(1, TimeUnit.SECONDS)) {
logger.error("Failed to send some coverage data prior to shutdown")
scheduledThreadPool.shutdownNow();
}
sendProbes(collectReleasedProbes())
sendProbes(collectUnreleasedProbes())
sender.shutdown()
logger.info { "Coverage sending job is stopped." }
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,10 @@ class ChecksumTest {

@Test
fun `changing lambda body should change it's checksum`() {
val methodSignatureBuild1 = "com/epam/drill/agent/fixture/ast/Build1:lambda\$null\$2:java.lang.String:java.lang.String"
val methodSignatureBuild2 = "com/epam/drill/agent/fixture/ast/Build2:lambda\$null\$2:java.lang.String:java.lang.String"
val methodSignatureBuild1 =
"com/epam/drill/agent/fixture/ast/Build1:lambda\$theSameMethodBody$0:java.lang.String:java.lang.String"
val methodSignatureBuild2 =
"com/epam/drill/agent/fixture/ast/Build2:lambda\$theSameMethodBody$0:java.lang.String:java.lang.String"
assertNotEquals(
checksumsBuild1[methodSignatureBuild1],
checksumsBuild2[methodSignatureBuild2]
Expand Down
Loading