kikocis/java-driver public
Changesets · Branches · Tags · Compare
| Changeset | a175ba23471dbccab7b37bf6a129f6c90f5b36bfe41b32f3554bfd31a393a69d |
|---|---|
| Author | Alexandre Dutra <alexandre.dutra@datastax.com> · 2016-01-28 11:50 +01:00 |
| Committer | Alexandre Dutra <alexandre.dutra@datastax.com> · 2016-01-28 11:50 +01:00 |
| Parents | b1d245a67292 |
2 files changed
modified driver-core/src/test/java/com/datastax/driver/core/CCMTestsSupport.java +12 −1
| @@ -852,9 +852,20 @@ | ||
| 852 | 852 | * Tests fail randomly with InvalidQueryException: Keyspace 'xxx' does not exist; |
| 853 | 853 | * this method tries at most 3 times to issue a successful USE statement. |
| 854 | 854 | * |
| 855 | - * @param ks The keyspace to use | |
| 855 | + * @param ks The keyspace to USE | |
| 856 | 856 | */ |
| 857 | 857 | public void useKeyspace(String ks) { |
| 858 | + useKeyspace(session(), ks); | |
| 859 | + } | |
| 860 | + | |
| 861 | + /** | |
| 862 | + * Tests fail randomly with InvalidQueryException: Keyspace 'xxx' does not exist; | |
| 863 | + * this method tries at most 3 times to issue a successful USE statement. | |
| 864 | + * | |
| 865 | + * @param session The session to use | |
| 866 | + * @param ks The keyspace to USE | |
| 867 | + */ | |
| 868 | + public void useKeyspace(Session session, String ks) { | |
| 858 | 869 | final int maxTries = 3; |
| 859 | 870 | for (int i = 1; i <= maxTries; i++) { |
| 860 | 871 | try { |
modified driver-core/src/test/java/com/datastax/driver/core/policies/DowngradingConsistencyRetryPolicyIntegrationTest.java +2 −6
| @@ -17,13 +17,10 @@ | ||
| 17 | 17 | |
| 18 | 18 | import com.datastax.driver.core.*; |
| 19 | 19 | import com.google.common.base.Objects; |
| 20 | -import com.google.common.util.concurrent.Uninterruptibles; | |
| 21 | 20 | import org.mockito.Mockito; |
| 22 | 21 | import org.mockito.verification.VerificationMode; |
| 23 | 22 | import org.testng.annotations.Test; |
| 24 | 23 | |
| 25 | -import java.util.concurrent.TimeUnit; | |
| 26 | - | |
| 27 | 24 | import static com.datastax.driver.core.ConsistencyLevel.*; |
| 28 | 25 | import static com.datastax.driver.core.TestUtils.ipOfNode; |
| 29 | 26 | import static org.assertj.core.api.Assertions.assertThat; |
| @@ -56,15 +53,14 @@ | ||
| 56 | 53 | Cluster cluster = register(Cluster.builder() |
| 57 | 54 | .addContactPoints(getContactPoints().get(0)) |
| 58 | 55 | .withPort(ccm().getBinaryPort()) |
| 56 | + .withSocketOptions(new SocketOptions().setReadTimeoutMillis(120000)) | |
| 59 | 57 | .withRetryPolicy(Mockito.spy(DowngradingConsistencyRetryPolicy.INSTANCE)) |
| 60 | 58 | .build()); |
| 61 | 59 | Session session = cluster.connect(); |
| 62 | 60 | |
| 63 | 61 | String ks = TestUtils.generateIdentifier("ks_"); |
| 64 | 62 | session.execute(String.format("CREATE KEYSPACE %s WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 3}", ks)); |
| 65 | - // tests fail randomly here with InvalidQueryException: Keyspace 'xxx' does not exist | |
| 66 | - Uninterruptibles.sleepUninterruptibly(5, TimeUnit.SECONDS); | |
| 67 | - session.execute(String.format("USE %s", ks)); | |
| 63 | + useKeyspace(session, ks); | |
| 68 | 64 | session.execute("CREATE TABLE foo(k int primary key)"); |
| 69 | 65 | session.execute("INSERT INTO foo(k) VALUES (0)"); |
| 70 | 66 |