Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TelemetryAPIJourney - Retrieving the telemetry payload (cached vs. fresh) #211

Merged
merged 4 commits into from
Feb 24, 2022
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
68 changes: 68 additions & 0 deletions src/test/scala/org/kibanaLoadTest/scenario/TelemetryAPI.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package org.kibanaLoadTest.scenario

import cats.implicits.catsSyntaxSemigroup

import io.gatling.core.Predef.{exec, _}
import io.gatling.http.Predef._

object TelemetryAPI {
def load(baseUrl: String, headers: Map[String, String]) = {
val defaultHeaders =
headers.combine(Map("Referer" -> s"$baseUrl/app/home"))

exec(
http("telemetry: /api/telemetry/v2/clusters/_stats")
.post("/api/telemetry/v2/clusters/_stats")
.body(StringBody("""{ "refreshCache": true }""")) // Request for fresh cache so we can measure the effect of generating the telemetry report multiple times
Bamieh marked this conversation as resolved.
Show resolved Hide resolved
.headers(defaultHeaders)
.check(status.is(200))
)
}

def getUnencryptedStats(baseUrl: String, headers: Map[String, String]) = {
val defaultHeaders =
headers.combine(Map("Referer" -> s"$baseUrl/app/home"))

exec(
http("telemetry: cached /api/telemetry/v2/clusters/_stats")
.post("/api/telemetry/v2/clusters/_stats")
.body(StringBody("""{ "unencrypted": true, "refreshCache": true }"""))
.asJson
.headers(defaultHeaders)
.check(status.is(200))
.check(jsonPath("$").count.is(1))
.check(
jsonPath("$[0].stats.stack_stats.kibana.plugins.usage_collector_stats")
.exists
)
.check(
jsonPath("$[0].stats.stack_stats.kibana.plugins.usage_collector_stats.failed.count")
.ofType[Int]
.is(0)
)
.check(
jsonPath("$[0].stats.stack_stats.kibana.plugins.usage_collector_stats.not_ready.count")
.ofType[Int]
.is(0)
)
.check(
jsonPath("$[0].stats.stack_stats.kibana.plugins.usage_collector_stats.not_ready_timeout.count")
.ofType[Int]
.is(0)
)
)
}

def cached(baseUrl: String, headers: Map[String, String]) = {
val defaultHeaders =
headers.combine(Map("Referer" -> s"$baseUrl/app/home"))

exec(
http("telemetry: cached /api/telemetry/v2/clusters/_stats")
.post("/api/telemetry/v2/clusters/_stats")
.body(StringBody("""{ "refreshCache": false }"""))
.headers(defaultHeaders)
.check(status.is(200))
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
package org.kibanaLoadTest.simulation.branch

import io.gatling.core.Predef._
import io.gatling.core.structure.ScenarioBuilder
import org.kibanaLoadTest.scenario.{Login, Home, TelemetryAPI}
import org.kibanaLoadTest.simulation.BaseSimulation

class TelemetryAPIJourney extends BaseSimulation {
def scenarioName(module: String): String = {
s"Branch telemetry journey $module ${appConfig.buildVersion}"
}

val scnTelemetry1: ScenarioBuilder = scenario(scenarioName("First hit - non-cached encrypted usage"))
.exec(
Login
.doLogin(
appConfig.isSecurityEnabled,
appConfig.loginPayload,
appConfig.loginStatusCode
)
.pause(5)
)
.exec(TelemetryAPI.load(appConfig.baseUrl, defaultHeaders).pause(1))

val scnTelemetry2: ScenarioBuilder = scenario(scenarioName("Second+ hit - cached encrypted usage"))
.exec(
Login
.doLogin(
appConfig.isSecurityEnabled,
appConfig.loginPayload,
appConfig.loginStatusCode
)
.pause(5)
)
.exec(TelemetryAPI.cached(appConfig.baseUrl, defaultHeaders).pause(1))

val scnTelemetry3: ScenarioBuilder = scenario(scenarioName("Example flyout - non-cached non-encrypted usage, check collectors status"))
.exec(
Login
.doLogin(
appConfig.isSecurityEnabled,
appConfig.loginPayload,
appConfig.loginStatusCode
)
.pause(5)
)
.exec(TelemetryAPI.getUnencryptedStats(appConfig.baseUrl, defaultHeaders).pause(1))

val cachedMaxUsers = 250
val nonCachedMaxUsers = 30
val duringDuration = 60 * 3

setUp(
scnTelemetry1.inject(
constantConcurrentUsers(20) during (duringDuration),
rampConcurrentUsers(20) to nonCachedMaxUsers during (duringDuration)
).andThen(
scnTelemetry2.inject(
constantConcurrentUsers(20) during (duringDuration),
rampConcurrentUsers(20) to cachedMaxUsers during (duringDuration)
)
).andThen(
scnTelemetry3.inject(
constantConcurrentUsers(20) during (duringDuration),
rampConcurrentUsers(20) to nonCachedMaxUsers during (duringDuration)
)
)
).protocols(httpProtocol).maxDuration(props.simulationTimeout * 2)
}