Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/v1/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ const logging = {
function driver(url, authToken, config = {}) {
assertString(url, 'Bolt URL');
const parsedUrl = urlUtil.parseDatabaseUrl(url);
if (parsedUrl.scheme === 'bolt+routing') {
if (['bolt+routing', 'neo4j'].indexOf(parsedUrl.scheme) !== -1) {
return new RoutingDriver(ServerAddress.fromUrl(parsedUrl.hostAndPort), parsedUrl.query, USER_AGENT, authToken, config);
} else if (parsedUrl.scheme === 'bolt') {
if (!isEmptyObjectOrNull(parsedUrl.query)) {
Expand Down
1 change: 0 additions & 1 deletion test/internal/node/direct.driver.boltkit.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,6 @@ describe('direct driver with stub server', () => {
writeTx.run('CREATE (n {name: \'Bob\'})').then(() =>
writeTx.commit().then(result => fail('expected an error'), (error) => {
expect(error.code).toBe(SERVICE_UNAVAILABLE);
expect(error.message).toContain('Connection was closed by server');
})
).finally(() =>
session.close(() => {
Expand Down
64 changes: 36 additions & 28 deletions test/internal/node/routing.driver.boltkit.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,36 +39,14 @@ describe('routing driver with stub server', () => {
jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout;
});

it('should discover servers', done => {
if (!boltStub.supported) {
done();
return;
}
// Given
const server = boltStub.start('./test/resources/boltstub/discover_servers_and_read.script', 9001);

boltStub.run(() => {
const driver = boltStub.newDriver('bolt+routing://127.0.0.1:9001');
// When
const session = driver.session();
session.run("MATCH (n) RETURN n.name").then(() => {

session.close();
// Then
expect(hasAddressInConnectionPool(driver, '127.0.0.1:9001')).toBeTruthy();
assertHasRouters(driver, ["127.0.0.1:9001", "127.0.0.1:9002", "127.0.0.1:9003"]);
assertHasReaders(driver, ["127.0.0.1:9002", "127.0.0.1:9003"]);
assertHasWriters(driver, ["127.0.0.1:9001"]);

driver.close();
server.exit(code => {
expect(code).toEqual(0);
done();
});
});
});
it('should discover servers with bolt+routing scheme', done => {
testDiscovery('bolt+routing', done)
});

it('should discover servers with neo4j scheme', done => {
testDiscovery('neo4j', done)
})

it('should discover IPv6 servers', done => {
if (!boltStub.supported) {
done();
Expand Down Expand Up @@ -2168,6 +2146,36 @@ describe('routing driver with stub server', () => {
});
});

function testDiscovery(scheme, done) {
if (!boltStub.supported) {
done()
return
}
// Given
const server = boltStub.start('./test/resources/boltstub/discover_servers_and_read.script', 9001)

boltStub.run(() => {
const driver = boltStub.newDriver(`${scheme}://127.0.0.1:9001`)
// When
const session = driver.session()
session.run('MATCH (n) RETURN n.name').then(() => {

session.close()
// Then
expect(hasAddressInConnectionPool(driver, '127.0.0.1:9001')).toBeTruthy()
assertHasRouters(driver, ['127.0.0.1:9001', '127.0.0.1:9002', '127.0.0.1:9003'])
assertHasReaders(driver, ['127.0.0.1:9002', '127.0.0.1:9003'])
assertHasWriters(driver, ['127.0.0.1:9001'])

driver.close()
server.exit(code => {
expect(code).toEqual(0)
done()
})
})
})
}

function testAddressPurgeOnDatabaseError(query, accessMode, done) {
if (!boltStub.supported) {
done();
Expand Down
2 changes: 1 addition & 1 deletion test/internal/url-util.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -724,7 +724,7 @@ describe('url-util', () => {
});

it('should parse URLs with port 80', () => {
['http', 'https', 'ws', 'wss', 'bolt', 'bolt+routing'].forEach(scheme => {
['http', 'https', 'ws', 'wss', 'bolt', 'bolt+routing', 'neo4j'].forEach(scheme => {
verifyUrl(`${scheme}://localhost:80`, {
scheme: scheme,
host: 'localhost',
Expand Down
2 changes: 1 addition & 1 deletion test/v1/stress.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ describe('stress tests', () => {
}

function verifyServers(context) {
const routing = DATABASE_URI.indexOf('bolt+routing') === 0;
const routing = DATABASE_URI.indexOf('bolt+routing') === 0 || DATABASE_URI.indexOf('neo4j') === 0

if (routing) {
return verifyCausalClusterMembers(context);
Expand Down