tech:notes_tests_de_charge_http_avec_gatling
Différences
Ci-dessous, les différences entre deux révisions de la page.
| Prochaine révision | Révision précédente | ||
| tech:notes_tests_de_charge_http_avec_gatling [2025/03/24 15:06] – créée - modification externe 127.0.0.1 | tech:notes_tests_de_charge_http_avec_gatling [2026/06/29 14:02] (Version actuelle) – Jean-Baptiste | ||
|---|---|---|---|
| Ligne 1: | Ligne 1: | ||
| + | < | ||
| + | {{tag> | ||
| + | |||
| + | # Notes tests de charge HTTP avec Gatling | ||
| + | |||
| + | |||
| + | |||
| + | Voir aussi : | ||
| + | * [[Jmeter - notes|Apache JMeter]] | ||
| + | * [Serveur Web : tests de charge en Python avec Locust](https:// | ||
| + | |||
| + | |||
| + | ## Install IDE pour dev | ||
| + | |||
| + | Voir : | ||
| + | * https:// | ||
| + | * https:// | ||
| + | * https:// | ||
| + | * [Introduction à Gatling et Scala (obsolète mais intéressant)](http:// | ||
| + | * https:// | ||
| + | |||
| + | Install IDE Scala et tous le reste (pas nécessaire) | ||
| + | ~~~bash | ||
| + | apt install python-pip python3-pip snapd | ||
| + | apt-get install openjdk-11-jdk maven | ||
| + | wget https:// | ||
| + | dpkg -i scala-2.12.2.deb | ||
| + | |||
| + | snap install intellij-idea-community --classic | ||
| + | ~~~ | ||
| + | |||
| + | Lancement IDE | ||
| + | ~~~bash | ||
| + | / | ||
| + | ~~~ | ||
| + | |||
| + | |||
| + | ## getling recorder | ||
| + | |||
| + | ~~~bash | ||
| + | ./ | ||
| + | ~~~ | ||
| + | |||
| + | |||
| + | ## Lancement | ||
| + | |||
| + | `simulation/ | ||
| + | ~~~scala | ||
| + | package plop.hpplop.simulation.mainProfile | ||
| + | |||
| + | import scala.concurrent.duration._ | ||
| + | |||
| + | import io.gatling.core.Predef._ | ||
| + | import io.gatling.http.Predef._ | ||
| + | import io.gatling.jdbc.Predef._ | ||
| + | |||
| + | class ChargeHPO extends Simulation { | ||
| + | val durationTime = scala.util.Properties.envOrElse(" | ||
| + | val minUsers = scala.util.Properties.envOrElse(" | ||
| + | val maxUsers = scala.util.Properties.envOrElse(" | ||
| + | val baseUrl = scala.util.Properties.envOrElse(" | ||
| + | println(baseUrl.toString) | ||
| + | |||
| + | val httpProtocol = http.baseUrl(baseUrl.toString) | ||
| + | |||
| + | val headers_hpo = Map( | ||
| + | " | ||
| + | ) | ||
| + | |||
| + | val scn = scenario(" | ||
| + | .exec(http(" | ||
| + | .get("/" | ||
| + | .disableFollowRedirect | ||
| + | .check(status is (301)) | ||
| + | .headers(headers_hpo) | ||
| + | ) | ||
| + | |||
| + | setUp( | ||
| + | scn.inject( | ||
| + | nothingFor(10 seconds), | ||
| + | rampUsersPerSec(minUsers.toInt) to maxUsers.toInt during (durationTime.toInt minutes) | ||
| + | ).protocols(httpProtocol) | ||
| + | ) | ||
| + | } | ||
| + | ~~~ | ||
| + | |||
| + | ~~~bash | ||
| + | env BASEURL=http:// | ||
| + | ~~~ | ||
| + | |||
| + | |||
| + | ## Pb | ||
| + | |||
| + | Erreur avec l'IDE | ||
| + | |||
| + | ~~~ | ||
| + | gatling-tutorial/ | ||
| + | object gatling is not a member of package io | ||
| + | import io.gatling.app.Gatling | ||
| + | ~~~ | ||
| + | |||
| + | ## Notes Scala | ||
| + | |||
| + | Voir aussi : Kotlin | ||
| + | |||
| + | |||
| + | |||
| + | |||
