Reputation: 1316
I have basic Gatling script in which I try to login to the app and that's it.
For some reason I get the error:
j.l.IllegalArgumentException: "https://my-site.com/"login could not be parsed into a proper Uri, missing scheme
It looks to me like it has appended at the end of the baseUrl quotation mark.
This is my simulation class:
package simulations.stage
import io.ecx.steps.{Config, Login}
import io.gatling.core.Predef._
import io.gatling.http.Predef._
import scala.concurrent.duration._
class RampUsersLoadSimulations extends Simulation{
val httpConf = http.baseUrl(Config.baseUrl)
.header("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9")
.userAgentHeader("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.190 Safari/537.36")
.inferHtmlResources()
.acceptEncodingHeader("gzip, deflate, br")
before {
println(s"Running for: ${Config.baseUrl}")
}
val login = scenario("Scenario: Login to the storefront")
.exec(Login.login(Config.accounts))
setUp(
login.inject(
nothingFor(5 seconds),
atOnceUsers(Config.userCount),
rampUsers(Config.userCount) during(Config.rampDuration seconds)
).protocols(httpConf)
).maxDuration(Config.testDuration seconds)
}
This is my login step implementation:
package io.ecx.steps
import io.gatling.core.Predef._
import io.gatling.http.Predef._
object Login {
def login(accountsPath: String) = {
val accounts = csv(accountsPath).random
feed(accounts)
.exec(http("Open login page")
.get("login")
.check(status.is(200)))
.pause(2)
.exec(http("Log in with credentials to the storefront")
.post("j_spring_security_check")
.formParam("email", "${username}")
.formParam("password", "${password}"))
.pause(5)
}
}
This is my Config step implementation:
package io.ecx.steps
import com.typesafe.config.ConfigFactory
object Config {
private def getProperty(propertyName: String, defaultValue: String) = {
Option(System.getenv(propertyName))
.orElse(Option(System.getProperty(propertyName)))
.getOrElse(defaultValue)
}
def userCount: Int = getProperty("USERS", "5").toInt
def rampDuration: Int = getProperty("RAMP_DURATION", "10").toInt
def testDuration: Int = getProperty("DURATION", "12").toInt
def environment:String = getProperty("ENVIRONMENT", "STAGE")
val conf = ConfigFactory.load()
val accounts = conf.getString("accounts")
val baseUrl = if (environment == "STAGE") conf.getString("baseUrlStage") else conf.getString("baseUrlProd")
}
And in my properties file I have:
#COMMON
accounts=data/stage/accounts.csv
#STAGE
baseUrlStage="https://my-site.com/"
#PROD
baseUrlProd="TBD"
Can anybody help please :)
Thanks!
Upvotes: 0
Views: 3482
Reputation: 6623
Error is explicit: "https://my-site.com/"login
could not be parsed into a proper Uri, missing scheme.
Indeed, the value in your property file is broken.
Instead of baseUrlStage="https://my-site.com/"
, you should have baseUrlStage=https://my-site.com/
.
Upvotes: 1