Elffuss BraidHub

kikocis/java-driver public

Relax auth error metric count validation in reconnection test (#754)

Test previously asserted that the getAuthenticationErrors() metric
incremented at the same rate as the AuthProvider#newAuthenticator count,
which may not be true as we could be checking between a newAuthenticator
request and an authentication request happening.  Instead ensure that
the count goes up.
Changeset0960065b032abc545eb1d691e6a55e75bdcb9635ff7ff02b01ea3a24aa8d1998
AuthorAndrew Tolbert <andrew.tolbert@datastax.com> · 2016-09-23 17:09 -05:00
CommitterOlivier Michallat <olim7t@users.noreply.github.com> · 2016-09-23 15:09 -07:00
Parentsda9ef71e7257

Browse the files at this changeset

1 file changed

modified driver-core/src/test/java/com/datastax/driver/core/ReconnectionTest.java +5 −3
@@ -106,17 +106,19 @@
106106 ccm().start(1);
107107 ccm().waitForUp(1);
108108
109- // Wait a few iterations to ensure that our authProvider has returned the wrong credentials at least once
109+ // Wait a few iterations to ensure that our authProvider has returned the wrong credentials at least twice
110110 // NB: authentication errors show up in the logs
111111 int initialCount = authProvider.count.get();
112+ long initialMetricCount = cluster.getMetrics().getErrorMetrics().getAuthenticationErrors().getCount();
112113 int iterations = 0, maxIterations = 12; // make sure we don't wait indefinitely
113114 do {
114115 iterations += 1;
115116 TimeUnit.SECONDS.sleep(5);
116- } while (iterations < maxIterations && authProvider.count.get() <= initialCount);
117+ } while (iterations < maxIterations && authProvider.count.get() <= initialCount + 1);
117118 assertThat(iterations).isLessThan(maxIterations);
119+ // Number of authentication errors should have increased.
118120 assertThat(cluster.getMetrics().getErrorMetrics().getAuthenticationErrors().getCount())
119- .isEqualTo(authProvider.count.get() - initialCount);
121+ .isGreaterThan(initialMetricCount);
120122
121123 // Fix the credentials
122124 authProvider.setPassword("cassandra");