diff --git a/.gitmodules b/.gitmodules index 83904f5af..940f8c3d4 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ [submodule "neokit"] - path = neokit - url = https://github.com/nigelsmall/neokit.git + path = neokit + url = https://github.com/neo-technology/neokit.git diff --git a/examples/test_examples.py b/examples/test_examples.py index be2a1c3ef..46fed58b5 100644 --- a/examples/test_examples.py +++ b/examples/test_examples.py @@ -32,7 +32,7 @@ # (* "good reason" is defined as knowing what you are doing) -auth_token = basic_auth("neo4j", "password") +auth_token = basic_auth("neo4j", "neo4j") class FreshDatabaseTestCase(ServerTestCase): @@ -48,7 +48,7 @@ class MinimalWorkingExampleTestCase(FreshDatabaseTestCase): def test_minimal_working_example(self): # tag::minimal-example[] - driver = GraphDatabase.driver("bolt://localhost", auth=basic_auth("neo4j", "password")) + driver = GraphDatabase.driver("bolt://localhost", auth=basic_auth("neo4j", "neo4j")) session = driver.session() session.run("CREATE (a:Person {name:'Arthur', title:'King'})") @@ -65,33 +65,33 @@ class ExamplesTestCase(FreshDatabaseTestCase): def test_construct_driver(self): # tag::construct-driver[] - driver = GraphDatabase.driver("bolt://localhost", auth=basic_auth("neo4j", "password")) + driver = GraphDatabase.driver("bolt://localhost", auth=basic_auth("neo4j", "neo4j")) # end::construct-driver[] return driver def test_configuration(self): # tag::configuration[] - driver = GraphDatabase.driver("bolt://localhost", auth=basic_auth("neo4j", "password"), max_pool_size=10) + driver = GraphDatabase.driver("bolt://localhost", auth=basic_auth("neo4j", "neo4j"), max_pool_size=10) # end::configuration[] return driver @skipUnless(SSL_AVAILABLE, "Bolt over TLS is not supported by this version of Python") def test_tls_require_encryption(self): # tag::tls-require-encryption[] - driver = GraphDatabase.driver("bolt://localhost", auth=basic_auth("neo4j", "password"), encrypted=True) + driver = GraphDatabase.driver("bolt://localhost", auth=basic_auth("neo4j", "neo4j"), encrypted=True) # end::tls-require-encryption[] @skipUnless(SSL_AVAILABLE, "Bolt over TLS is not supported by this version of Python") def test_tls_trust_on_first_use(self): # tag::tls-trust-on-first-use[] - driver = GraphDatabase.driver("bolt://localhost", auth=basic_auth("neo4j", "password"), encrypted=True, trust=TRUST_ON_FIRST_USE) + driver = GraphDatabase.driver("bolt://localhost", auth=basic_auth("neo4j", "neo4j"), encrypted=True, trust=TRUST_ON_FIRST_USE) # end::tls-trust-on-first-use[] assert driver @skip("testing verified certificates not yet supported ") def test_tls_signed(self): # tag::tls-signed[] - driver = GraphDatabase.driver("bolt://localhost", auth=basic_auth("neo4j", "password"), encrypted=True, trust=TRUST_SIGNED_CERTIFICATES) + driver = GraphDatabase.driver("bolt://localhost", auth=basic_auth("neo4j", "neo4j"), encrypted=True, trust=TRUST_SIGNED_CERTIFICATES) # end::tls-signed[] assert driver diff --git a/neokit b/neokit index c206a8317..3ab3ec582 160000 --- a/neokit +++ b/neokit @@ -1 +1 @@ -Subproject commit c206a831783d9ea352cca8c1b2772927cbcae91e +Subproject commit 3ab3ec582936ef3329c51c6f9a891147287230cd diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index e69de29bb..000000000 diff --git a/runtests.py b/runtests.py new file mode 100644 index 000000000..a3c25e402 --- /dev/null +++ b/runtests.py @@ -0,0 +1,138 @@ +#!/usr/bin/env python +# -*- encoding: utf-8 -*- + +# Copyright (c) 2002-2016 "Neo Technology," +# Network Engine for Objects in Lund AB [http://neotechnology.com] +# +# This file is part of Neo4j. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +""" +Usage: runtests.py + -h : show this help message + --test=name : run this specific test + --tests : run all unit tests + --examples : run all example tests + --tck : run tck tests + --neorun.start.args : args to neorun script +example: + python ./runtests.py --tests --examples --tck + python ./runtests.py --tests --examples --tck --neorun.start.args="-n 3.1 -p neo4j" +""" +from sys import argv, stdout, exit, version_info +from os import name, path +from atexit import register +import subprocess +import getopt + +UNITTEST_RUNNER = "coverage run -m unittest discover -vfs " +BEHAVE_RUNNER="behave --tags=-db --tags=-tls --tags=-fixed_session_pool test/tck" + +NEORUN_PATH = path.abspath('./neokit/neorun.py') +NEO4J_HOME = path.abspath('./build/neo4jhome') + +is_windows = (name == 'nt') + + +def runpymodule(command): + commands = command.split() + if is_windows: + commands = ['powershell.exe', 'python', '-m'] + commands + return run0(commands) + + +def runcommand(command): + commands = command.split() + return runcommands(commands) + + +def runcommands(commands): + if is_windows: + commands = ['powershell.exe'] + commands + return run0(commands) + + +def run0(commands): + stdout.write("Running commands: %s\n" % commands) + p = subprocess.Popen(commands, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + out, err = p.communicate() + retcode = p.wait() + if version_info < (3, 0): + stdout.write(out) + stdout.write(err) + else: + stdout.write(out.decode(stdout.encoding)) + stdout.write(err.decode(stdout.encoding)) + return retcode + + +def neorun(command): + runcommand('python ' + NEORUN_PATH + ' ' + command) + + +def main(): + if len(argv) <= 1: + print_help() + exit(2) + try: + opts, args = getopt.getopt(argv[1:], "h", ["test=", "tests", "examples", "tck", "neorun.start.args="]) + except getopt.GetoptError as err: + print(str(err)) + print_help() + exit(2) + else: + + stdout.write("Using python version:\n") + runcommand('python --version') + runpymodule('pip install --upgrade -r ./test_requirements.txt') + retcode = 0 + + register(neorun, '--stop=' + NEO4J_HOME) + + neorun_args = '-p neo4j' + for opt, arg in opts: + if opt == '--neorun.start.args': + neorun_args = arg + break + neorun('--start=' + NEO4J_HOME + ' ' + neorun_args) + + for opt, arg in opts: + if opt == '-h': + print_help() + retcode = 2 + + elif opt == "--tests": + retcode = retcode or runpymodule(UNITTEST_RUNNER + "test") + elif opt == "--test=": + retcode = retcode or runpymodule(UNITTEST_RUNNER + arg) + elif opt == "--example": + retcode = retcode or runpymodule(UNITTEST_RUNNER + "examples") + elif opt == "--tck": + retcode = runpymodule('coverage report --show-missing') or \ + runcommands(["python", "-c", "\"from test.tck.configure_feature_files import *; set_up()\""]) or \ + runpymodule(BEHAVE_RUNNER) or \ + runcommands(["python", "-c", "\"from test.tck.configure_feature_files import *; clean_up()\""]) + + if retcode != 0: + break + + return retcode + + +def print_help(): + print(__doc__) + + +if __name__ == "__main__": + main() \ No newline at end of file diff --git a/runtests.sh b/runtests.sh index 89aa15b5b..be32af5f3 100755 --- a/runtests.sh +++ b/runtests.sh @@ -17,99 +17,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -DRIVER_HOME=$(dirname $0) - -NEORUN_OPTIONS="" -RUNNING=0 -QUICK=0 -KNOWN_HOSTS="${HOME}/.neo4j/known_hosts" -KNOWN_HOSTS_BACKUP="${KNOWN_HOSTS}.backup" - -FG_BRIGHT_RED='\033[1;31m' -FG_DEFAULT='\033[0m' - -# Parse options -while getopts ":dqr" OPTION -do - case ${OPTION} in - d) - NEORUN_OPTIONS="-f" - ;; - q) - QUICK=1 - ;; - r) - RUNNING=1 - ;; - \?) - echo "Invalid option: -${OPTARG}" >&2 - ;; - esac -done -shift $(($OPTIND - 1)) - -if [ -z "${TEAMCITY_VERSION}" ] -then - UNITTEST="unittest" +if [ "$1" == "" ]; then + python ./runtests.py --tests --examples --tck else - UNITTEST="teamcity.unittestpy" + #Example: python ./runtests.py --tests --examples --tck --neorun.start.args=ā€-n 3.1 -p neo4jā€ + python ./runtests.py --tests --examples --tck --neorun.start.args=\""$1"\" fi - -if [ -z "${TEST}" ] -then - TEST="test" -fi - -VERSIONS=$* -if [ "${VERSIONS}" == "" ] -then - VERSIONS="nightly" -fi - -function check_exit_status { - EXIT_STATUS=$1 - if [ ${EXIT_STATUS} -ne 0 ] - then - echo "" - echo -e "${FG_BRIGHT_RED}Tests failed with status ${EXIT_STATUS}${FG_DEFAULT}" - exit ${EXIT_STATUS} - fi -} - -# Run tests -echo "Using $(python --version)" -pip install --upgrade -r ${DRIVER_HOME}/test_requirements.txt -echo "" - -TEST_RUNNER="coverage run -m ${UNITTEST} discover -vfs ${TEST}" -EXAMPLES_RUNNER="coverage run -m ${UNITTEST} discover -vfs examples" -BEHAVE_RUNNER="behave --tags=-db --tags=-tls --tags=-fixed_session_pool test/tck" - -if [ ${RUNNING} -eq 1 ] -then - ${TEST_RUNNER} - check_exit_status $? -else - export NEO4J_PASSWORD="password" - - echo "Running unit tests" - neokit/neorun ${NEORUN_OPTIONS} "${TEST_RUNNER}" ${VERSIONS} - check_exit_status $? - - if [ ${QUICK} -eq 0 ] - then - echo "Testing example code" - neokit/neorun ${NEORUN_OPTIONS} "${EXAMPLES_RUNNER}" ${VERSIONS} - check_exit_status $? - - echo "Testing TCK" - coverage report --show-missing - python -c 'from test.tck.configure_feature_files import *; set_up()' - echo "Feature files downloaded" - neokit/neorun ${NEORUN_OPTIONS} "${BEHAVE_RUNNER}" ${VERSIONS} - python -c 'from test.tck.configure_feature_files import *; clean_up()' - echo "Feature files removed" - - fi - -fi \ No newline at end of file diff --git a/test/tck/steps/driver_auth_steps.py b/test/tck/steps/driver_auth_steps.py index 0eaa1dffd..edc9d266a 100644 --- a/test/tck/steps/driver_auth_steps.py +++ b/test/tck/steps/driver_auth_steps.py @@ -30,7 +30,7 @@ def step_impl(context): @given("a driver is configured with auth enabled and correct password is provided") def step_impl(context): - context.driver = GraphDatabase.driver("bolt://localhost", auth=basic_auth("neo4j", "password"), encrypted=False) + context.driver = GraphDatabase.driver("bolt://localhost", auth=basic_auth("neo4j", "neo4j"), encrypted=False) @given("a driver is configured with auth enabled and the wrong password is provided") diff --git a/test/tck/tck_util.py b/test/tck/tck_util.py index 57144ab21..063e0635f 100644 --- a/test/tck/tck_util.py +++ b/test/tck/tck_util.py @@ -23,7 +23,7 @@ from test.tck.test_value import TestValue from test.tck.resultparser import parse_values_to_comparable -driver = GraphDatabase.driver("bolt://localhost", auth=basic_auth("neo4j", "password"), encrypted=False) +driver = GraphDatabase.driver("bolt://localhost", auth=basic_auth("neo4j", "neo4j"), encrypted=False) runners = [] diff --git a/test/test_session.py b/test/test_session.py index d421aafb3..91f609344 100644 --- a/test/test_session.py +++ b/test/test_session.py @@ -33,7 +33,7 @@ from test.util import ServerTestCase -auth_token = basic_auth("neo4j", "password") +auth_token = basic_auth("neo4j", "neo4j") from neo4j.v1.exceptions import ProtocolError