Skip to content

Commit

Permalink
tests: update stress test to not verify removed logic
Browse files Browse the repository at this point in the history
50 events batches are no longer a thing since we removed `QueueManager`
  • Loading branch information
wzieba committed Nov 8, 2023
1 parent 54e66a9 commit 52c7a43
Showing 1 changed file with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -122,29 +122,31 @@ class FunctionalTests {
*/
@Test
fun stressTest() {
val stressMultiplier = 10
val batchSize = 50
val eventsToSend = 500

ActivityScenario.launch(SampleActivity::class.java).use { scenario ->
scenario.onActivity { activity: Activity ->
beforeEach(activity)
server.enqueue(MockResponse().setResponseCode(200))
parselyTracker = initializeTracker(activity)

repeat(stressMultiplier * batchSize) {
repeat(eventsToSend) {
parselyTracker.trackPageview("url", null, null, null)
}
}

Thread.sleep((stressMultiplier * defaultFlushInterval).inWholeMilliseconds)
// Wait some time to give events chance to be saved in local data storage
Thread.sleep((defaultFlushInterval * 2).inWholeMilliseconds)

val requests = (1..stressMultiplier).mapNotNull {
runCatching { server.takeRequest(500, TimeUnit.MILLISECONDS) }.getOrNull()
// Catch up to 10 requests. We don't know how many requests the device we test on will
// perform. It's probably more like 1-2, but we're on safe (not flaky) side here.
val requests = (1..10).mapNotNull {
runCatching { server.takeRequest(100, TimeUnit.MILLISECONDS) }.getOrNull()
}.flatMap {
it.toMap()["events"]!!
}

assertThat(requests).hasSize(stressMultiplier * batchSize)
assertThat(requests).hasSize(eventsToSend)
}
}

Expand Down

0 comments on commit 52c7a43

Please sign in to comment.