RESOLVED : Gatling Redis : Redis NOAUTH Authentication required

Hi There,

I am trying to connect redis server and if failed with error message Redis NOAUTH Authentication required.

Kindly help how to pass password on the below code.

“redis_cluster”: {
“servers”: [X.X.X.X:7000"],
“password”: “DummyPassword_1ZUc=”
},

import com.redis.*
import io.gatling.redis.Predef.*
import io.gatling.redis.feeder.RedisFeederBuilder
import io.gatling.core.Predef.*
import io.gatling.http.Predef.*
import io.gatling.core.scenario.Simulation
import io.gatling.core.structure.ScenarioBuilder

class redisFeederTest extends Simulation{

  // protocol

  //val httpProtocol = http.baseUrl("http://computer-database.gatling.io/")

  // use a list, so there's one single value per record, which is here named "foo"
  val dataFeederPool = new RedisClientPool("localhost", 6379)
  val myDataFeeder: RedisFeederBuilder =
    redisFeeder(dataFeederPool, "foo1", "foo1").RPOPLPUSH


  val Scn: ScenarioBuilder = scenario("Post an item")
    .exec { session =>
      println("myDataFeeder: " + myDataFeeder)
      println("redisPool: " + dataFeederPool)
      session
    }
    .pause(2)
    .feed(myDataFeeder)



  //setup

  setUp(Scn.inject(atOnceUsers(5)))

}

kindly help here.

Hi,
I can’t check it now but here you have example what properties can be used to create RedisClientPool:
Redis Feeder

I think the following will be important to you:

.withSecret(null)

and maybe

.withSSLContext(null)

Above is for JAVA.
Below you have code for Scala where Redis Secret is 1234qwer.
I’m not master in Scala but is working xD

import com.redis._
import io.gatling.core.Predef._
import io.gatling.http.Predef._
import io.gatling.redis.Predef._

class RedisFeederSimulationScala extends Simulation {

  val httpProtocol = http


  val redisPool = new RedisClientPool(host = "127.0.0.1", port = 6379, secret = Option("1234qwer"))

  val feeder = redisFeeder(redisPool, "mylist")

  val scn = scenario("BasicSimulationScala")
    .feed(feeder)
    .exec { session =>
      println(session)
      println("GeMi_RedisValue: " + session("mylist").as[String])
      session
    }

  setUp(
    scn.inject(atOnceUsers(1))
  ).protocols(httpProtocol)
}

@slandelle @sbrevet any better ScalaTip for that ? :slight_smile:
I wondering why syntax is not the same as for Java and Kotlin for this with with....

TIP: How to set Redis Secret:

# redis-cli
127.0.0.1:6379> config set requirepass 1234qwer

I wondering why syntax is not the same as for Java and Kotlin for this with with…

  1. Because the Gatling DSL for Redis was introduced/contributed a long time ago and directly depends on com.redis.RedisClientPool, not a Gatling API.
  2. Because you don’t need this in Scala with named parameters and default values like in here, or copy method for case classes

Do you have better tip for setting secret or my proposition of setting in constructor is ok?

No, that’s the correct way: named parameter and letting other parameters use their default value.

Thanks it worked.

Also how we can add more ips in redis pool. I have cluster of 6 node and want to add them in redisPool.

val redisPool = new RedisClientPool("localhost", 6379)

Please set topic as resolved and create another for this question - I will look at that later.