Skip to content

Commit ad33403

Browse files
committed
Merge pull request #68 from neo4j/1.0-new-neokit
Chaning to use new neokit to start and stop server
2 parents cd78511 + eb2ed22 commit ad33403

File tree

9 files changed

+155
-107
lines changed

9 files changed

+155
-107
lines changed

.gitmodules

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[submodule "neokit"]
2-
path = neokit
3-
url = https://github.com/nigelsmall/neokit.git
2+
path = neokit
3+
url = https://github.com/neo-technology/neokit.git

examples/test_examples.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
# (* "good reason" is defined as knowing what you are doing)
3333

3434

35-
auth_token = basic_auth("neo4j", "password")
35+
auth_token = basic_auth("neo4j", "neo4j")
3636

3737

3838
class FreshDatabaseTestCase(ServerTestCase):
@@ -48,7 +48,7 @@ class MinimalWorkingExampleTestCase(FreshDatabaseTestCase):
4848

4949
def test_minimal_working_example(self):
5050
# tag::minimal-example[]
51-
driver = GraphDatabase.driver("bolt://localhost", auth=basic_auth("neo4j", "password"))
51+
driver = GraphDatabase.driver("bolt://localhost", auth=basic_auth("neo4j", "neo4j"))
5252
session = driver.session()
5353

5454
session.run("CREATE (a:Person {name:'Arthur', title:'King'})")
@@ -65,33 +65,33 @@ class ExamplesTestCase(FreshDatabaseTestCase):
6565

6666
def test_construct_driver(self):
6767
# tag::construct-driver[]
68-
driver = GraphDatabase.driver("bolt://localhost", auth=basic_auth("neo4j", "password"))
68+
driver = GraphDatabase.driver("bolt://localhost", auth=basic_auth("neo4j", "neo4j"))
6969
# end::construct-driver[]
7070
return driver
7171

7272
def test_configuration(self):
7373
# tag::configuration[]
74-
driver = GraphDatabase.driver("bolt://localhost", auth=basic_auth("neo4j", "password"), max_pool_size=10)
74+
driver = GraphDatabase.driver("bolt://localhost", auth=basic_auth("neo4j", "neo4j"), max_pool_size=10)
7575
# end::configuration[]
7676
return driver
7777

7878
@skipUnless(SSL_AVAILABLE, "Bolt over TLS is not supported by this version of Python")
7979
def test_tls_require_encryption(self):
8080
# tag::tls-require-encryption[]
81-
driver = GraphDatabase.driver("bolt://localhost", auth=basic_auth("neo4j", "password"), encrypted=True)
81+
driver = GraphDatabase.driver("bolt://localhost", auth=basic_auth("neo4j", "neo4j"), encrypted=True)
8282
# end::tls-require-encryption[]
8383

8484
@skipUnless(SSL_AVAILABLE, "Bolt over TLS is not supported by this version of Python")
8585
def test_tls_trust_on_first_use(self):
8686
# tag::tls-trust-on-first-use[]
87-
driver = GraphDatabase.driver("bolt://localhost", auth=basic_auth("neo4j", "password"), encrypted=True, trust=TRUST_ON_FIRST_USE)
87+
driver = GraphDatabase.driver("bolt://localhost", auth=basic_auth("neo4j", "neo4j"), encrypted=True, trust=TRUST_ON_FIRST_USE)
8888
# end::tls-trust-on-first-use[]
8989
assert driver
9090

9191
@skip("testing verified certificates not yet supported ")
9292
def test_tls_signed(self):
9393
# tag::tls-signed[]
94-
driver = GraphDatabase.driver("bolt://localhost", auth=basic_auth("neo4j", "password"), encrypted=True, trust=TRUST_SIGNED_CERTIFICATES)
94+
driver = GraphDatabase.driver("bolt://localhost", auth=basic_auth("neo4j", "neo4j"), encrypted=True, trust=TRUST_SIGNED_CERTIFICATES)
9595
# end::tls-signed[]
9696
assert driver
9797

neokit

requirements.txt

Whitespace-only changes.

runtests.py

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
#!/usr/bin/env python
2+
# -*- encoding: utf-8 -*-
3+
4+
# Copyright (c) 2002-2016 "Neo Technology,"
5+
# Network Engine for Objects in Lund AB [http://neotechnology.com]
6+
#
7+
# This file is part of Neo4j.
8+
#
9+
# Licensed under the Apache License, Version 2.0 (the "License");
10+
# you may not use this file except in compliance with the License.
11+
# You may obtain a copy of the License at
12+
#
13+
# http://www.apache.org/licenses/LICENSE-2.0
14+
#
15+
# Unless required by applicable law or agreed to in writing, software
16+
# distributed under the License is distributed on an "AS IS" BASIS,
17+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18+
# See the License for the specific language governing permissions and
19+
# limitations under the License.
20+
21+
"""
22+
Usage: runtests.py
23+
-h : show this help message
24+
--test=name : run this specific test
25+
--tests : run all unit tests
26+
--examples : run all example tests
27+
--tck : run tck tests
28+
--neorun.start.args : args to neorun script
29+
example:
30+
python ./runtests.py --tests --examples --tck
31+
python ./runtests.py --tests --examples --tck --neorun.start.args="-n 3.1 -p neo4j"
32+
"""
33+
from sys import argv, stdout, exit, version_info
34+
from os import name, path
35+
from atexit import register
36+
import subprocess
37+
import getopt
38+
39+
UNITTEST_RUNNER = "coverage run -m unittest discover -vfs "
40+
BEHAVE_RUNNER="behave --tags=-db --tags=-tls --tags=-fixed_session_pool test/tck"
41+
42+
NEORUN_PATH = path.abspath('./neokit/neorun.py')
43+
NEO4J_HOME = path.abspath('./build/neo4jhome')
44+
45+
is_windows = (name == 'nt')
46+
47+
48+
def runpymodule(command):
49+
commands = command.split()
50+
if is_windows:
51+
commands = ['powershell.exe', 'python', '-m'] + commands
52+
return run0(commands)
53+
54+
55+
def runcommand(command):
56+
commands = command.split()
57+
return runcommands(commands)
58+
59+
60+
def runcommands(commands):
61+
if is_windows:
62+
commands = ['powershell.exe'] + commands
63+
return run0(commands)
64+
65+
66+
def run0(commands):
67+
stdout.write("Running commands: %s\n" % commands)
68+
p = subprocess.Popen(commands, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
69+
out, err = p.communicate()
70+
retcode = p.wait()
71+
if version_info < (3, 0):
72+
stdout.write(out)
73+
stdout.write(err)
74+
else:
75+
stdout.write(out.decode(stdout.encoding))
76+
stdout.write(err.decode(stdout.encoding))
77+
return retcode
78+
79+
80+
def neorun(command):
81+
runcommand('python ' + NEORUN_PATH + ' ' + command)
82+
83+
84+
def main():
85+
if len(argv) <= 1:
86+
print_help()
87+
exit(2)
88+
try:
89+
opts, args = getopt.getopt(argv[1:], "h", ["test=", "tests", "examples", "tck", "neorun.start.args="])
90+
except getopt.GetoptError as err:
91+
print(str(err))
92+
print_help()
93+
exit(2)
94+
else:
95+
96+
stdout.write("Using python version:\n")
97+
runcommand('python --version')
98+
runpymodule('pip install --upgrade -r ./test_requirements.txt')
99+
retcode = 0
100+
101+
register(neorun, '--stop=' + NEO4J_HOME)
102+
103+
neorun_args = '-p neo4j'
104+
for opt, arg in opts:
105+
if opt == '--neorun.start.args':
106+
neorun_args = arg
107+
break
108+
neorun('--start=' + NEO4J_HOME + ' ' + neorun_args)
109+
110+
for opt, arg in opts:
111+
if opt == '-h':
112+
print_help()
113+
retcode = 2
114+
115+
elif opt == "--tests":
116+
retcode = retcode or runpymodule(UNITTEST_RUNNER + "test")
117+
elif opt == "--test=":
118+
retcode = retcode or runpymodule(UNITTEST_RUNNER + arg)
119+
elif opt == "--example":
120+
retcode = retcode or runpymodule(UNITTEST_RUNNER + "examples")
121+
elif opt == "--tck":
122+
retcode = runpymodule('coverage report --show-missing') or \
123+
runcommands(["python", "-c", "\"from test.tck.configure_feature_files import *; set_up()\""]) or \
124+
runpymodule(BEHAVE_RUNNER) or \
125+
runcommands(["python", "-c", "\"from test.tck.configure_feature_files import *; clean_up()\""])
126+
127+
if retcode != 0:
128+
break
129+
130+
return retcode
131+
132+
133+
def print_help():
134+
print(__doc__)
135+
136+
137+
if __name__ == "__main__":
138+
main()

runtests.sh

Lines changed: 4 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -17,99 +17,9 @@
1717
# See the License for the specific language governing permissions and
1818
# limitations under the License.
1919

20-
DRIVER_HOME=$(dirname $0)
21-
22-
NEORUN_OPTIONS=""
23-
RUNNING=0
24-
QUICK=0
25-
KNOWN_HOSTS="${HOME}/.neo4j/known_hosts"
26-
KNOWN_HOSTS_BACKUP="${KNOWN_HOSTS}.backup"
27-
28-
FG_BRIGHT_RED='\033[1;31m'
29-
FG_DEFAULT='\033[0m'
30-
31-
# Parse options
32-
while getopts ":dqr" OPTION
33-
do
34-
case ${OPTION} in
35-
d)
36-
NEORUN_OPTIONS="-f"
37-
;;
38-
q)
39-
QUICK=1
40-
;;
41-
r)
42-
RUNNING=1
43-
;;
44-
\?)
45-
echo "Invalid option: -${OPTARG}" >&2
46-
;;
47-
esac
48-
done
49-
shift $(($OPTIND - 1))
50-
51-
if [ -z "${TEAMCITY_VERSION}" ]
52-
then
53-
UNITTEST="unittest"
20+
if [ "$1" == "" ]; then
21+
python ./runtests.py --tests --examples --tck
5422
else
55-
UNITTEST="teamcity.unittestpy"
23+
#Example: python ./runtests.py --tests --examples --tck --neorun.start.args=”-n 3.1 -p neo4j”
24+
python ./runtests.py --tests --examples --tck --neorun.start.args=\""$1"\"
5625
fi
57-
58-
if [ -z "${TEST}" ]
59-
then
60-
TEST="test"
61-
fi
62-
63-
VERSIONS=$*
64-
if [ "${VERSIONS}" == "" ]
65-
then
66-
VERSIONS="nightly"
67-
fi
68-
69-
function check_exit_status {
70-
EXIT_STATUS=$1
71-
if [ ${EXIT_STATUS} -ne 0 ]
72-
then
73-
echo ""
74-
echo -e "${FG_BRIGHT_RED}Tests failed with status ${EXIT_STATUS}${FG_DEFAULT}"
75-
exit ${EXIT_STATUS}
76-
fi
77-
}
78-
79-
# Run tests
80-
echo "Using $(python --version)"
81-
pip install --upgrade -r ${DRIVER_HOME}/test_requirements.txt
82-
echo ""
83-
84-
TEST_RUNNER="coverage run -m ${UNITTEST} discover -vfs ${TEST}"
85-
EXAMPLES_RUNNER="coverage run -m ${UNITTEST} discover -vfs examples"
86-
BEHAVE_RUNNER="behave --tags=-db --tags=-tls --tags=-fixed_session_pool test/tck"
87-
88-
if [ ${RUNNING} -eq 1 ]
89-
then
90-
${TEST_RUNNER}
91-
check_exit_status $?
92-
else
93-
export NEO4J_PASSWORD="password"
94-
95-
echo "Running unit tests"
96-
neokit/neorun ${NEORUN_OPTIONS} "${TEST_RUNNER}" ${VERSIONS}
97-
check_exit_status $?
98-
99-
if [ ${QUICK} -eq 0 ]
100-
then
101-
echo "Testing example code"
102-
neokit/neorun ${NEORUN_OPTIONS} "${EXAMPLES_RUNNER}" ${VERSIONS}
103-
check_exit_status $?
104-
105-
echo "Testing TCK"
106-
coverage report --show-missing
107-
python -c 'from test.tck.configure_feature_files import *; set_up()'
108-
echo "Feature files downloaded"
109-
neokit/neorun ${NEORUN_OPTIONS} "${BEHAVE_RUNNER}" ${VERSIONS}
110-
python -c 'from test.tck.configure_feature_files import *; clean_up()'
111-
echo "Feature files removed"
112-
113-
fi
114-
115-
fi

test/tck/steps/driver_auth_steps.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def step_impl(context):
3030

3131
@given("a driver is configured with auth enabled and correct password is provided")
3232
def step_impl(context):
33-
context.driver = GraphDatabase.driver("bolt://localhost", auth=basic_auth("neo4j", "password"), encrypted=False)
33+
context.driver = GraphDatabase.driver("bolt://localhost", auth=basic_auth("neo4j", "neo4j"), encrypted=False)
3434

3535

3636
@given("a driver is configured with auth enabled and the wrong password is provided")

test/tck/tck_util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
from test.tck.test_value import TestValue
2424
from test.tck.resultparser import parse_values_to_comparable
2525

26-
driver = GraphDatabase.driver("bolt://localhost", auth=basic_auth("neo4j", "password"), encrypted=False)
26+
driver = GraphDatabase.driver("bolt://localhost", auth=basic_auth("neo4j", "neo4j"), encrypted=False)
2727
runners = []
2828

2929

test/test_session.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
from test.util import ServerTestCase
3434

3535

36-
auth_token = basic_auth("neo4j", "password")
36+
auth_token = basic_auth("neo4j", "neo4j")
3737
from neo4j.v1.exceptions import ProtocolError
3838

3939

0 commit comments

Comments
 (0)