Skip to content

Commit

Permalink
feat(monkeys): Implement base actions - WPB-3355 (#1947) (#1965)
Browse files Browse the repository at this point in the history
  • Loading branch information
augustocdias authored Aug 8, 2023
1 parent 56387a4 commit 9692232
Show file tree
Hide file tree
Showing 26 changed files with 837 additions and 191 deletions.
10 changes: 6 additions & 4 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,18 @@ protobufCodegen = "0.9.1"
annotation = "1.2.0"
mordant = "2.0.0-beta13"
apache-tika = "2.8.0"
mockk = "1.13.5"

[plugins]
# Home-made convention plugins
kalium-library = { id = "kalium.library" }
android-library = { id = "com.android.library", version.ref = "agp" }
android-application = { id = "com.android.application", version.ref = "agp" }
completeKotlin = { id = "com.louiscad.complete-kotlin", version.ref = "completeKotlin"}
completeKotlin = { id = "com.louiscad.complete-kotlin", version.ref = "completeKotlin" }
kotlin-multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
kover = {id = "org.jetbrains.kotlinx.kover", version.ref = "kover" }
kover = { id = "org.jetbrains.kotlinx.kover", version.ref = "kover" }
ksp = { id = "com.google.devtools.ksp", version = "1.9.0-1.0.12" }
carthage = { id = "com.wire.carthage-gradle-plugin", version.ref = "carthage" }
sqldelight = { id = "app.cash.sqldelight", version.ref = "sqldelight" }
Expand All @@ -79,7 +80,7 @@ kotlin-plugin = { group = "org.jetbrains.kotlin", name = "kotlin-gradle-plugin",
kotlin-nativeUtils = { module = "org.jetbrains.kotlin:kotlin-native-utils", version.ref = "kotlin" }
ktxSerialization = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "ktx-serialization" }
ktxDateTime = { module = "org.jetbrains.kotlinx:kotlinx-datetime", version.ref = "ktx-datetime" }
ktx-atomicfu = { module = "org.jetbrains.kotlinx:atomicfu", version.ref = "ktx-atomicfu"}
ktx-atomicfu = { module = "org.jetbrains.kotlinx:atomicfu", version.ref = "ktx-atomicfu" }

# android dependencies
appCompat = { module = "androidx.appcompat:appcompat", version.ref = "app-compat" }
Expand Down Expand Up @@ -121,7 +122,7 @@ libsodiumBindingsMP = { module = "com.ionspin.kotlin:multiplatform-crypto-libsod
# cli
cliKt = { module = "com.github.ajalt.clikt:clikt", version.ref = "cli-kt" }
okhttp-loggingInterceptor = { module = "com.squareup.okhttp3:logging-interceptor", version.ref = "ok-http" }
mordant = { module = "com.github.ajalt.mordant:mordant", version.ref = "mordant"}
mordant = { module = "com.github.ajalt.mordant:mordant", version.ref = "mordant" }

# ktor
ktor-core = { module = "io.ktor:ktor-client-core", version.ref = "ktor" }
Expand Down Expand Up @@ -158,6 +159,7 @@ sqldelight-dialect = { module = "app.cash.sqldelight:sqlite-3-33-dialect", versi
mockative-runtime = { module = "io.mockative:mockative", version.ref = "mockative" }
mockative-processor = { module = "io.mockative:mockative-processor", version.ref = "mockative" }
turbine = { module = "app.cash.turbine:turbine", version.ref = "turbine" }
mockk = { module = "io.mockk:mockk", version.ref = "mockk" }

# detekt
detekt-cli = { module = "io.gitlab.arturbosch.detekt:detekt-cli", version.ref = "detekt" }
Expand Down
13 changes: 12 additions & 1 deletion monkeys/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,15 @@ To use, simply create a configuration and execute:
./gradlew :monkeys:run --args="config.json"
```

An [example](example.json) config is in this repo and the schema can be seen [here](schema.json)
An [example](example.json) config is in this repo and the schema can be seen [here](schema.json).

## Current Limitations (to be fixed in the future)

* It is assumed that all users under a backend belongs to a single team
* The application runs until it receives a `SIGINT` (Ctrl+C) signal. There should be a configuration
to finish the test run
* Tests need to be implemented
* Collecting metrics about the test execution
* Tracing and replaying a test run. For this the order is the important factor, so when replayed it
won't be executed in parallel.
* Multi-clients. Right now each user can have just one client within the application
16 changes: 16 additions & 0 deletions monkeys/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,22 @@ sourceSets {
}
}

val test by getting {
dependencies {
implementation(kotlin("test"))

// coroutines
implementation(libs.coroutines.test)
implementation(libs.turbine)

// mocking
implementation(libs.mockative.runtime)
implementation(libs.okio.test)
implementation(libs.settings.kmpTest)
implementation(libs.mockk)
}
}

tasks.withType<JavaExec> {
jvmArgs = listOf("-Djava.library.path=/usr/local/lib/:./native/libs")
}
Expand Down
169 changes: 94 additions & 75 deletions monkeys/example.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,40 +3,48 @@
{
"name": "Example Test Case",
"conversationDistribution": {
"group1": {
"groupPROTEUS": {
"userCount": {
"type": "PERCENTAGE",
"value": 100
"value": 50
},
"protocol": "PROTEUS",
"groupCount": 2
},
"groupMLS": {
"userCount": {
"type": "PERCENTAGE",
"value": 50
},
"protocol": "MLS",
"groupCount": 1
"groupCount": 2
}
},
"setup": [
{
"description": "Log everyone in",
"count": {
"type": "PERCENTAGE",
"value": 100
},
"config": {
"type": "LOGIN"
"type": "LOGIN",
"userCount": {
"type": "PERCENTAGE",
"value": 100
}
}
},
{
"description": "Connect teams",
"count": {
"type": "PERCENTAGE",
"value": 100
},
"config": {
"type": "SEND_REQUEST",
"userCount": {
"type": "PERCENTAGE",
"value": 100
},
"originDomain": "anta.wire.link",
"targetDomain": "bella.wire.link",
"targetUserCount": {
"type": "PERCENTAGE",
"value": 100
},
"originDomain": "pirates.dogfood.wire.link",
"targetDomain": "ninjas.dogfood.wire.link",
"delayResponse": 1000,
"shouldAccept": true
}
Expand All @@ -45,125 +53,136 @@
"actions": [
{
"description": "Send messages",
"count": {
"type": "PERCENTAGE",
"value": 100
},
"repeatInterval": 100,
"config": {
"type": "SEND_MESSAGE",
"count": 3,
"countGroups": 3,
"userCount": {
"type": "PERCENTAGE",
"value": 100
}
}
},
{
"description": "Send messages",
"count": 1,
"repeatInterval": 500,
"config": {
"type": "SEND_MESSAGE",
"count": 3,
"userCount": {
"type": "PERCENTAGE",
"value": 100
},
"targets": [
"group1"
"groupMLS",
"groupPROTEUS",
"One21"
]
}
},
{
"description": "Create groups",
"count": {
"type": "FIXED_COUNT",
"value": 3
},
"count": 3,
"repeatInterval": 10000,
"config": {
"type": "CREATE_CONVERSATION",
"userCount": {
"type": "FIXED_COUNT",
"value": 10
"value": 4
},
"protocol": "PROTEUS",
"domainOwner": "anta.wire.link"
"domainOwner": "ninjas.dogfood.wire.link"
}
},
{
"description": "Create groups",
"count": {
"type": "FIXED_COUNT",
"value": 3
},
"count": 3,
"repeatInterval": 10000,
"config": {
"type": "CREATE_CONVERSATION",
"userCount": {
"type": "FIXED_COUNT",
"value": 10
"value": 4
},
"protocol": "MLS",
"domainOwner": "anta.wire.link"
"domainOwner": "ninjas.dogfood.wire.link"
}
},
{
"description": "Create groups",
"count": 3,
"repeatInterval": 10000,
"config": {
"type": "CREATE_CONVERSATION",
"userCount": {
"type": "FIXED_COUNT",
"value": 10
},
"protocol": "PROTEUS",
"domainOwner": "pirates.dogfood.wire.link"
}
}
]
}
],
"backends": [
{
"api": "https://nginz-https.anta.wire.link",
"accounts": "https://account.anta.wire.link/",
"webSocket": "https://nginz-ssl.anta.wire.link/",
"api": "https://nginz-https.pirates.dogfood.wire.link",
"webSocket": "https://nginz-ssl.pirates.dogfood.wire.link",
"blackList": "https://clientblacklist.wire.com/staging",
"teams": "https://teams.anta.wire.link/",
"website": "https://example.org",
"title": "anta.wire.link",
"teams": "https://teams.pirates.dogfood.wire.link",
"accounts": "https://account.pirates.dogfood.wire.link",
"website": "https://wire.com",
"title": "pirates.dogfood.wire.link",
"passwordForUsers": "Aqa123456!",
"domain": "anta.wire.link",
"domain": "pirates.dogfood.wire.link",
"users": [
{
"email": "smoketester+65e02b3d42@wire.com",
"id": "a2baeed1-53f3-4a22-a161-7d61abf4456f"
"email": "augusto.c.dias+pirate@wire.com",
"id": "f979e74b-e43b-40f8-91ef-395f8eea026e"
},
{
"email": "smoketester+3cbe9db208@wire.com",
"id": "33ec2e20-9bed-44b2-b891-a1dbaf3da158"
}
]
},
{
"api": "https://nginz-https.bella.wire.link",
"webSocket": "https://nginz-ssl.bella.wire.link",
"blackList": "https://clientblacklist.wire.com/staging",
"teams": "https://teams.bella.wire.link",
"accounts": "https://account.bella.wire.link",
"website": "https://wire.com",
"title": "bella.wire.link",
"passwordForUsers": "Aqa123456!",
"domain": "bella.wire.link",
"users": [
{
"id": "37a27c29-398b-44c6-9334-79cf84024f74",
"email": "augusto.c.dias+test1@wire.com"
"email": "augusto.c.dias+pirate1@wire.com",
"id": "95900f96-56f1-4125-96ed-50ad0c45294e"
},
{
"id": "56f06ac1-69cb-43ab-96f1-816f6ddd6edb",
"email": "augusto.c.dias+test3@wire.com"
"email": "augusto.c.dias+pirate2@wire.com",
"id": "a6cb561d-82f4-4ede-a224-d2de0e7adbcf"
},
{
"id": "691e3c09-45e1-4845-89f4-121fef480ec8",
"email": "augusto.c.dias+test2@wire.com"
"email": "augusto.c.dias+pirate3@wire.com",
"id": "ad287c49-a1f1-47a1-9bb1-0eac11e240db"
}
]
},
{
"api": "https://nginz-https.chala.wire.link",
"webSocket": "https://nginz-ssl.chala.wire.link",
"api": "https://nginz-https.ninjas.dogfood.wire.link",
"webSocket": "https://nginz-ssl.ninjas.dogfood.wire.link",
"blackList": "https://clientblacklist.wire.com/staging",
"teams": "https://teams.chala.wire.link",
"accounts": "https://account.chala.wire.link",
"teams": "https://teams.ninjas.dogfood.wire.link",
"accounts": "https://account.ninjas.dogfood.wire.link",
"website": "https://wire.com",
"passwordForUsers": "Aqa123456!",
"domain": "chala.wire.link",
"title": "chala.wire.link",
"domain": "ninjas.dogfood.wire.link",
"title": "ninjas.dogfood.wire.link",
"users": [
{
"email": "vitor.schwaab+chala_team1@wire.com",
"id": "9f5a276d-f408-433e-81f6-812e69eb11bb"
"email": "augusto.c.dias+ninja@wire.com",
"id": "73b45628-1816-4777-95e7-8f449a559229"
},
{
"email": "augusto.c.dias+ninja1@wire.com",
"id": "4c5fda2a-a5fe-43fb-8b46-bcdb205ede10"
},
{
"email": "vitor.schwaab+chala_team2@wire.com",
"id": "47fb193a-540f-4fec-969a-868377b02d8e"
"email": "augusto.c.dias+ninja2@wire.com",
"id": "ea417610-3623-4d85-affc-dba6607182be"
},
{
"email": "vitor.schwaab+chala_team3@wire.com",
"id": "2342152d-3df8-4b50-81d8-950ca9105ab1"
"email": "augusto.c.dias+ninja3@wire.com",
"id": "151abef6-0a6f-4661-9f96-815a16b9342b"
}
]
}
Expand Down
Loading

0 comments on commit 9692232

Please sign in to comment.