Skip to content

Commit 2968077

Browse files
Changes to make integration tests work with CouchDB 3.4
1 parent 70fd123 commit 2968077

File tree

4 files changed

+9
-7
lines changed

4 files changed

+9
-7
lines changed

couchdb/src/main/java/me/retrodaredevil/couchdbjava/okhttp/CouchDbConfigService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import retrofit2.http.Path;
1313

1414
/**
15-
* @see <a href="ttps://docs.couchdb.org/en/stable/api/server/configuration.html#accessing-the-local-node-s-configuration ">docs.couchdb.org/en/stable/api/server/configuration.html#accessing-the-local-node-s-configuration</a>
15+
* @see <a href="https://docs.couchdb.org/en/stable/api/server/configuration.html#accessing-the-local-node-s-configuration ">docs.couchdb.org/en/stable/api/server/configuration.html#accessing-the-local-node-s-configuration</a>
1616
*/
1717
public interface CouchDbConfigService {
1818
@HEAD("./")

couchdb/src/test/java/me/retrodaredevil/couchdbjava/integration/test/ConfigEndpointTest.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public class ConfigEndpointTest {
2323

2424
@ParameterizedTest
2525
@MethodSource("me.retrodaredevil.couchdbjava.integration.DatabaseService#values")
26-
void test(DatabaseService databaseService) throws CouchDbException, JsonProcessingException {
26+
void test(DatabaseService databaseService) throws CouchDbException, JsonProcessingException, InterruptedException {
2727
CouchDbInstance instance = TestUtil.createInstance(databaseService);
2828
MembershipResponse membership = instance.membership();
2929
// the configured CouchDB from the compose file is not clustered and even if it was it should only handle 1 node
@@ -49,10 +49,13 @@ void test(DatabaseService databaseService) throws CouchDbException, JsonProcessi
4949
assertEquals("0.0.0.0", config.queryValue(httpSectionName, "bind_address"));
5050
}
5151
assertEquals("", config.putValue("admins", "newadmin", "coolpass"));
52-
assertTrue(config.queryValue("admins", "newadmin").startsWith("-pbkdf2-"));
52+
// NOTE: As of CouchDB 3.4, values under the "admins" section are not hashed immediately, hence this sleep // https://github.com/apache/couchdb/issues/5358
53+
Thread.sleep(500);
54+
// NOTE: As of CouchDB 3.4, hashed passwords may be hashed differently. The "-pbkdf2-" prefix is no longer reliable, but "-pbkdf2" prefix is
55+
assertTrue(config.queryValue("admins", "newadmin").startsWith("-pbkdf2"));
5356
if (databaseService == DatabaseService.COUCHDB) {
5457
// only for CouchDB because PouchDB gives us a "unknown_config_value" error, which doesn't make any sense
55-
assertTrue(config.deleteValue("admins", "newadmin").startsWith("-pbkdf2-"));
58+
assertTrue(config.deleteValue("admins", "newadmin").startsWith("-pbkdf2"));
5659
}
5760
}
5861
}

couchdb/src/test/java/me/retrodaredevil/couchdbjava/integration/test/ReplicatorTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ void test(DatabaseService databaseService) throws CouchDbException, JsonProcessi
6565
}
6666

6767

68-
for (int i = 0; i < 15 && !target.exists(); i++) { // 15 iterations is ~7.5 seconds maximum
68+
// NOTE: For CouchDB 3.3 and lower, we were able to get away with a timeout of about 7.5 seconds, but for CouchDB 3.4 we increased that
69+
for (int i = 0; i < 20 && !target.exists(); i++) { // 20 iterations is ~10 seconds maximum
6970
//noinspection BusyWait
7071
Thread.sleep(500);
7172
}

testing/docker-compose.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
version: '3.7'
2-
31
services:
42
couchdb:
53
image: 'apache/couchdb:3'

0 commit comments

Comments
 (0)