mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-19 04:51:24 +07:00
[perf_tests] Added more logs for event bus. Added timeout for WaitingForSubscribersTest
GitOrigin-RevId: 308c61a4a21e0af461454c348395ffb0f4f2a6e6
This commit is contained in:
committed by
intellij-monorepo-bot
parent
d566339d5e
commit
29cb138c76
@@ -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()
|
||||
}
|
||||
|
||||
|
||||
@@ -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()) }
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user