Skip to content

Commit

Permalink
fix login issue
Browse files Browse the repository at this point in the history
  • Loading branch information
augustocdias committed Nov 21, 2023
1 parent 5e557dd commit acd2492
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import com.wire.kalium.logic.feature.publicuser.GetAllContactsResult
import com.wire.kalium.monkeys.importer.Backend
import com.wire.kalium.monkeys.importer.UserCount
import com.wire.kalium.monkeys.importer.UserData
import com.wire.kalium.monkeys.logger
import com.wire.kalium.monkeys.pool.ConversationPool
import com.wire.kalium.monkeys.pool.MonkeyPool
import com.wire.kalium.monkeys.pool.resolveUserCount
Expand Down Expand Up @@ -127,9 +128,24 @@ class Monkey(val monkeyType: MonkeyType) {
this.monkeyState = MonkeyState.NotReady
error("Failed registering client of monkey ${this.monkeyType.userData().email}: $registerResult")
}
sessionScope.observeSyncState().first { it is SyncState.Live }
this.monkeyState = MonkeyState.Ready(sessionScope)
callback(this)
var isFinished: Boolean
do {
val state = sessionScope.observeSyncState().first { it !is SyncState.Waiting && it !is SyncState.SlowSync }
when (state) {
is SyncState.Failed -> {
this.monkeyState = MonkeyState.NotReady
logger.w("Failed logging in: ${state.cause}")
isFinished = !state.cause.isRetryable
}
is SyncState.GatheringPendingEvents,
is SyncState.Live -> {
this.monkeyState = MonkeyState.Ready(sessionScope)
callback(this)
isFinished = true
}
else -> error("This should have been done")
}
} while (!isFinished)
}

private suspend fun connectedMonkeys(): List<UserId> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ import com.wire.kalium.monkeys.importer.Team
import com.wire.kalium.monkeys.importer.UserCount
import com.wire.kalium.monkeys.importer.UserData
import io.micrometer.core.instrument.Tag
import kotlinx.coroutines.coroutineScope
import kotlinx.coroutines.launch
import java.util.concurrent.ConcurrentHashMap
import kotlin.math.roundToInt

Expand Down Expand Up @@ -69,13 +67,11 @@ class MonkeyPool(users: List<UserData>, testCase: String) {
}
}

suspend fun warmUp(core: CoreLogic) = coroutineScope {
suspend fun warmUp(core: CoreLogic) {
// this is needed to create key packages for clients at least once
poolById.values.forEach {
launch {
it.login(core) {}
it.logout {}
}
it.login(core) {}
it.logout {}
}
}

Expand Down

0 comments on commit acd2492

Please sign in to comment.