Skip to content

Commit b9c0065

Browse files
committed
Remove colision with testkit
1 parent 4613f81 commit b9c0065

File tree

2 files changed

+71
-2
lines changed

2 files changed

+71
-2
lines changed
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
2+
export default class Neo4jContainer {
3+
constructor ({ user, password, containerLogs, version, edition, disabled }) {
4+
this._user = user
5+
this._password = password
6+
this._containerLogs = containerLogs || false
7+
this._version = version
8+
this._edition = edition
9+
this._container = null
10+
this._disabled = disabled || false
11+
}
12+
13+
async start () {
14+
if (this._disabled) {
15+
return
16+
}
17+
console.log('Starting container')
18+
if (this._container != null) {
19+
console.log('Container already started')
20+
return
21+
}
22+
23+
const tag = this._edition != null ? `${this._version}-${this._edition}` : this._version
24+
25+
const { GenericContainer, Wait } = require('testcontainers')
26+
const { DockerImageName } = require('testcontainers/dist/docker-image-name')
27+
28+
let container = new GenericContainer(new DockerImageName(null, 'neo4j', tag).toString())
29+
.withEnv('NEO4J_AUTH', `${this._user}/${this._password}`)
30+
31+
if (this._edition === 'enterprise') {
32+
container = container.withEnv('NEO4J_ACCEPT_LICENSE_AGREEMENT', 'yes')
33+
}
34+
35+
this._container = await container.withExposedPorts(7687, 7474)
36+
.withWaitStrategy(Wait.forLogMessage(/Started/))
37+
.start()
38+
39+
console.log('Container started at ' + `${this._container.getHost()}:${this._container.getMappedPort(7687)}`)
40+
41+
if (this._containerLogs) {
42+
const stream = await this._container.logs()
43+
stream
44+
.on('data', line => console.log(line))
45+
.on('err', line => console.error(line))
46+
.on('end', () => console.log('Stream closed'))
47+
}
48+
}
49+
50+
getBoltPort () {
51+
return this.getMappedPort(7687)
52+
}
53+
54+
getHttpPort () {
55+
return this.getMappedPort(7474)
56+
}
57+
58+
getMappedPort (port) {
59+
return this._container != null ? this._container.getMappedPort(port) : port
60+
}
61+
62+
async stop () {
63+
await this._container.stop()
64+
this._container = undefined
65+
}
66+
}

testkit/integration.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
if __name__ == "__main__":
1111
os.environ["TEST_NEO4J_IPV6_ENABLED"] = "False"
12+
os.environ["TEST_CONTAINERS_DISABLED"] = "True"
1213

1314
if is_lite():
1415
ignore = "--ignore=neo4j-driver"
@@ -18,6 +19,8 @@
1819
if is_deno():
1920
pass
2021
elif is_browser():
21-
run_in_driver_repo(["npm", "run", "test::browser", "--", ignore])
22+
run_in_driver_repo(["npm", "run", "test::browser",
23+
"--", ignore], env=os.environ)
2224
else:
23-
run_in_driver_repo(["npm", "run", "test::integration", "--", ignore])
25+
run_in_driver_repo(
26+
["npm", "run", "test::integration", "--", ignore], env=os.environ)

0 commit comments

Comments
 (0)