You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would like to use scassandra to verify that my code under test re-tries its Cassandra queries 2 times if encountering read timeouts, and only gives up if 3 consecutive read timeouts occur (but works if one of the tries results in a success).
To do so, I prime scassandra with the following pattern:
1. query is "SELECT * FROM foo;" -> result in ReadTimeout
2. query is "SELECT * FROM foo;" -> result in ReadTimeout
3. query is "SELECT * FROM foo;" -> respond with rows
The problem here is that as far as I can see, priming strictly works with a "last prime for a given query wins". Thus, the priming pattern above will always respond with a success and the primed rows, ignoring prime 1. and 2. completely, because all three queries are identical.
What I would like to actually prime is the following behaviour:
1. For the first "SELECT * FROM foo;" query -> result in ReadTimeout
2. For the second "SELECT * FROM foo;" query -> result in ReadTimeout
3. For the third "SELECT * FROM foo;" query -> respond with rows
But it seems that this isn't possible right now. I'm now utilizing a rather hacky workaround by adding a CQL comment that denotes the (re)try number to my queries in my code under test, which allows to prime like this:
1. query is "SELECT * FROM foo; /* 1. try */" -> result in ReadTimeout
2. query is "SELECT * FROM foo; /* 2. try */" -> result in ReadTimeout
3. query is "SELECT * FROM foo; /* 3. try */" -> respond with rows
Which gives me 3 logically identical CQL queries denoted by 3 physically different query strings.
I think this is a good feature. What I have done in the past to test retry behaviour is to prime it to fail and expect the behaviour from my application for when it can't talk to cassandra then verify via the Activity client that the failed query was executed N times.
To add this we can add an optional field to a prime that is the # of times with a default of unlimited to preserve existing behaviour.
I won't have time to work on this anytime soon but would happily accept a PR.
I would like to use scassandra to verify that my code under test re-tries its Cassandra queries 2 times if encountering read timeouts, and only gives up if 3 consecutive read timeouts occur (but works if one of the tries results in a success).
To do so, I prime scassandra with the following pattern:
The problem here is that as far as I can see, priming strictly works with a "last prime for a given query wins". Thus, the priming pattern above will always respond with a success and the primed rows, ignoring prime 1. and 2. completely, because all three queries are identical.
What I would like to actually prime is the following behaviour:
But it seems that this isn't possible right now. I'm now utilizing a rather hacky workaround by adding a CQL comment that denotes the (re)try number to my queries in my code under test, which allows to prime like this:
Which gives me 3 logically identical CQL queries denoted by 3 physically different query strings.
(See https://github.com/journeymonitor/analyze/blob/c639c491f4deda8a41f0bcb3f9c5622bcb88f5ea/api/app/repositories/CassandraRepository.scala#L15 and https://github.com/journeymonitor/analyze/blob/c639c491f4deda8a41f0bcb3f9c5622bcb88f5ea/api/test/IntegrationWithFailingCassandraSpec.scala#L22)
The text was updated successfully, but these errors were encountered: