Closed jsrikrishna closed 9 years ago
Any more info?
Which embedded-redis version?
Does underlying redis-server process exited? embedded-redis 0.4 should log error stream to System.out. Anything there?
This error occurred when i am using embedded-redis for Unit tests. Scenario goes like this : 1) I have two test cases in 2 different files. 2) Each test case adds data to the embedded-redis and Each test case will start and stop the embedded-redis server at the start and end of test respectively. 3) When each test is run in individual this ERROR DOES NOT OCCUR 4) But when i run the tests in sequential, one of the two test cases fails with the above error.
All the redis process are exited before starting the tests alone and also in sequential.
yes the error is logged out System.out
What does the System.out says?
Provided description suggests that two redis instances are run with a race condition on the bind port. Can you provide RedisService(int port) with different port for these two tests?
Which embedded-redis version do you use?
Can you provide your exact test code?
working on with embedded-redis version 0.6
I had tried Thread.sleep(20000) at the end of one of the test cases and stilll that doesn't work
I can't start server on a different PORT(other than 6379) because i need to test the same scenario which i was explaining in the previous post
test case 1 private val redisServerInst = new RedisServer(6379) redisServerInst.start() //add some data to embedded -redis redisServerInst.stop()
test case 2 private val redisServerInst = new RedisServer(6379) redisServerInst.start() add some data embedded -redis redisServerInst.stop()
On system.out i was presented with the following error
at redis.clients.util.RedisInputStream.ensureFill(RedisInputStream.java:198) [info] at redis.clients.util.RedisInputStream.readByte(RedisInputStream.java:40) [info] at redis.clients.jedis.Protocol.process(Protocol.java:128) [info] at redis.clients.jedis.Protocol.read(Protocol.java:192) [info] at redis.clients.jedis.Connection.readProtocolWithCheckingBroken(Connection.java:282) [info] at redis.clients.jedis.Connection.getStatusCodeReply(Connection.java:181) [info] at redis.clients.jedis.Jedis.watch(Jedis.java:1449)
Hmmm, first of all: this embedded-redis latest version is 0.4. Dunno which one do you use if you say 0.6 ;>
I guess you probably use: http://mvnrepository.com/artifact/com.orange.redis-embedded/embedded-redis Which is a long-time fork of this repo. If you want to use my embedded-redis then use: https://clojars.org/redis.embedded/embedded-redis
<repository>
<id>clojars.org</id>
<url>http://clojars.org/repo</url>
</repository>
<dependency>
<groupId>redis.embedded</groupId>
<artifactId>embedded-redis</artifactId>
<version>0.4</version>
</dependency>
yeah i am using version 0.6 from com.orange.redis-embedded
will try with version 0.4 and clojars repo will update about it
hey, i am still getting the same error after changing the version to 0.4 and repo to clojars one.
I want to test the scenario where both start on the same port itself.
Is there any way to overcome this error
A process cannot bind to port in parallel with other process that already did. You're just using embedded-redis in the wrong way and I can't help you unless you share your exact code for me to reproduce your issue.
However, what redis print now on System.out as you are using version 0.4?
Unexpected end of stream. at redis.clients.util.RedisInputStream.ensureFill(RedisInputStream.java:198) ~[jedis-2.6.2.jar:na] at redis.clients.util.RedisInputStream.readByte(RedisInputStream.java:40) ~[jedis-2.6.2.jar:na] at redis.clients.jedis.Protocol.process(Protocol.java:128) ~[jedis-2.6.2.jar:na] at redis.clients.jedis.Protocol.read(Protocol.java:192) ~[jedis-2.6.2.jar:na] at redis.clients.jedis.Connection.readProtocolWithCheckingBroken(Connection.java:282) ~[jedis-2.6.2.jar:na] at redis.clients.jedis.Connection.getBinaryMultiBulkReply(Connection.java:218) ~[jedis-2.6.2.jar:na] at redis.clients.jedis.Connection.getMultiBulkReply(Connection.java:211) ~[jedis-2.6.2.jar:na] at redis.clients.jedis.Jedis.smembers(Jedis.java:1050) ~[jedis-2.6.2.jar:na]
this is being printed to when i started the reds server on the same port and start reading the data from reds
redis started only after stopping the running redis instances
following are the codes
test-1 private val redisServerInst = new RedisServer(6379) override def beforeAll = { redisServerInst.start() } override def afterAll = { redisServerInst.stop() }
test("Perform Add transaction : ") { val operationList = List( SetAddMultipleOp("p10", Seq("q10", "q11")), SetAddOp("q10", "p10"), SetAddOp("q11", "p10")) assert(expectedResult == readSetMembers("q10")) //readSetMembers is a method defined to read data from redis }
test -2 private val redisServerInst = new RedisServer(6379) override def beforeAll = { redisServerInst.start()
val operationList = List( SetAddMultipleOp("q10", Seq("p10","p11")), SetAddOp("q11", "p11") transact(operationList) ) }
override def afterAll = { redisServerInst.stop() }
test("Perform read transaction : ") { assert(expectedResult == readSetMembers("q10")) //readSetMembers is a method defined to read data from redis }
I'm sorry, but I've spinned out example project as close to yours as possible, but I'm unable to reproduce the issue. Please create example project in github and point me there with an instruction what should I run (preferably mvn/sbt).
Any update on that?
I was having a similar problem. After a while I realize that I have a Singleton which builds the configuration once and provides it to a suite of tests. That group of tests have a initialization where I start all redis that the tests use and an after method where stops the servers. Once I have changed that singleton to a regular class that instanciate the configuration in every test the problem disappeared. Hope this help.
I'm not an english-speaker so, deal with it =P
@lgiorcelli I've made exactly the same experience. I used a jedis configuration, which was a spring bean (singleton). further i started and stopped the embedded-redis server in each integration test. one test was fine while running several tests lead to the problem above. I fixed it by moving the jedis configuration into the integration tests each.
As suggested, I tried moving the RedisConfig into each individual test case, but still this issue persisits. The only work around I've found is to instantiate embedded redis with a different port number for each unit test, which isn't robust.
Since I am using an Apache Spark redislabs library, rather than strictly jedis, I've opened a new issue here since this issue was closed with a working solution for its specific jedis implementation:https://github.com/kstyrc/embedded-redis/issues/78
at redis.clients.util.RedisInputStream.ensureFill(RedisInputStream.java:198) [info] at redis.clients.util.RedisInputStream.readByte(RedisInputStream.java:40) [info] at redis.clients.jedis.Protocol.process(Protocol.java:128) [info] at redis.clients.jedis.Protocol.read(Protocol.java:192) [info] at redis.clients.jedis.Connection.readProtocolWithCheckingBroken(Connection.java:282) [info] at redis.clients.jedis.Connection.getStatusCodeReply(Connection.java:181) [info] at redis.clients.jedis.Jedis.watch(Jedis.java:1449)