[perf_tests] Added more logs for event bus. Added timeout for WaitingForSubscribersTest

GitOrigin-RevId: 308c61a4a21e0af461454c348395ffb0f4f2a6e6
This commit is contained in:
Nikita Barkov
2024-05-16 15:06:09 +02:00
committed by intellij-monorepo-bot
parent d566339d5e
commit 29cb138c76
3 changed files with 7 additions and 0 deletions

View File

@@ -41,6 +41,7 @@ class LocalEventBusServerClient(val server: LocalEventBusServer) : EventBusServe
}
}
println("LocalEventBusServerClient: send new request.\nUrl: $url\nMethod: $method\nBody: $requestBody")
connection.responseCode.also {
if (it != HttpURLConnection.HTTP_OK) {
throw ServerException("Code: $it. ${connection.responseMessage}")
@@ -68,6 +69,7 @@ class LocalEventBusServerClient(val server: LocalEventBusServer) : EventBusServe
eventClassesLock.writeLock().withLock {
eventClasses[simpleName] = eventClass.name
}
println("LocalEventBusServerClient: new subscriber $simpleName")
post("newSubscriber", objectMapper.writeValueAsString(SubscriberDto(simpleName, PROCESS_ID))).toBoolean()
}

View File

@@ -37,6 +37,7 @@ class EventsFlowService {
fun newSubscriber(subscriber: SubscriberDto) {
synchronized(subscriber.eventName) {
println("EventsFlowService: new subscriber $subscriber")
eventsPerProcessLock.writeLock().withLock {
eventsPerProcess
.computeIfAbsent(subscriber.processId) { HashMap() }
@@ -46,6 +47,7 @@ class EventsFlowService {
}
fun getEvents(processId: String): HashMap<String, MutableList<SharedEventDto>> {
println("EventsFlowService: getEvents for process $processId")
return eventsPerProcessLock.readLock().withLock { eventsPerProcess.getOrDefault(processId, HashMap()) }
}

View File

@@ -6,6 +6,8 @@ import kotlinx.coroutines.delay
import org.junit.jupiter.api.Assertions.assertFalse
import org.junit.jupiter.api.Assertions.assertTrue
import org.junit.jupiter.api.RepeatedTest
import org.junit.jupiter.api.Timeout
import java.util.concurrent.TimeUnit
import java.util.concurrent.atomic.AtomicBoolean
import kotlin.time.Duration.Companion.milliseconds
import kotlin.time.Duration.Companion.seconds
@@ -16,6 +18,7 @@ class WaitingForSubscribersTest : SharedEventsTest() {
class CustomSignal : SharedEvent()
@RepeatedTest(value = 10)
@Timeout(1, unit = TimeUnit.MINUTES)
fun `waiting till subscribers finish their work`() {
val firstSubscriberProcessedEvent = AtomicBoolean(false)
val secondSubscriberProcessedEvent = AtomicBoolean(false)