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
18 changes: 17 additions & 1 deletion testkitbackend/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@
# 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.
from inspect import getmembers, isfunction
from inspect import (
getmembers,
isfunction,
)
import io
from json import loads, dumps
import logging
import sys
Expand All @@ -28,9 +32,13 @@

import testkitbackend.requests as requests

buffer_handler = logging.StreamHandler(io.StringIO())
buffer_handler.setLevel(logging.DEBUG)

handler = logging.StreamHandler(sys.stdout)
handler.setLevel(logging.DEBUG)
logging.getLogger("neo4j").addHandler(handler)
logging.getLogger("neo4j").addHandler(buffer_handler)
logging.getLogger("neo4j").setLevel(logging.DEBUG)

log = logging.getLogger("testkitbackend")
Expand Down Expand Up @@ -165,6 +173,14 @@ def _process(self, request):
def send_response(self, name, data):
""" Sends a response to backend.
"""
buffer_handler.acquire()
log_output = buffer_handler.stream.getvalue()
buffer_handler.stream.truncate(0)
buffer_handler.stream.seek(0)
buffer_handler.release()
if not log_output.endswith("\n"):
log_output += "\n"
self._wr.write(log_output.encode("utf-8"))
response = {"name": name, "data": data}
response = dumps(response)
log.info(">>> " + name + dumps(data))
Expand Down
41 changes: 39 additions & 2 deletions testkitbackend/requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,14 @@
from testkitbackend.fromtestkit import to_meta_and_timeout


with open(path.join(path.dirname(__file__), "skipped_tests.json"), "r") as fd:
SKIPPED_TESTS = json.load(fd)
def load_config():
with open(path.join(path.dirname(__file__), "test_config.json"), "r") as fd:
config = json.load(fd)
return (config["skips"],
[k for k, v in config["features"].items() if v is True])


SKIPPED_TESTS, FEATURES = load_config()


def StartTest(backend, data):
Expand All @@ -35,6 +41,10 @@ def StartTest(backend, data):
backend.send_response("RunTest", {})


def GetFeatures(backend, data):
backend.send_response("FeatureList", {"features": FEATURES})


def NewDriver(backend, data):
auth_token = data["authorizationToken"]["data"]
data["authorizationToken"].mark_item_as_read_if_equals(
Expand Down Expand Up @@ -310,3 +320,30 @@ def RetryableNegative(backend, data):
session_tracker = backend.sessions[key]
session_tracker.state = '-'
session_tracker.error_id = data.get('errorId', '')


def ForcedRoutingTableUpdate(backend, data):
driver_id = data["driverId"]
driver = backend.drivers[driver_id]
database = data["database"]
bookmarks = data["bookmarks"]
with driver._pool.refresh_lock:
driver._pool.create_routing_table(database)
driver._pool.update_routing_table(database=database,
bookmarks=bookmarks)
backend.send_response("Driver", {"id": driver_id})


def GetRoutingTable(backend, data):
driver_id = data["driverId"]
database = data["database"]
driver = backend.drivers[driver_id]
routing_table = driver._pool.routing_tables[database]
response_data = {
"database": routing_table.database,
"ttl": routing_table.ttl,
}
for role in ("routers", "readers", "writers"):
addresses = routing_table.__getattribute__(role)
response_data[role] = list(map(str, addresses))
backend.send_response("RoutingTable", response_data)
28 changes: 0 additions & 28 deletions testkitbackend/skipped_tests.json

This file was deleted.

37 changes: 37 additions & 0 deletions testkitbackend/test_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"skips": {
"stub.routing.Routing.test_should_retry_write_until_success_with_leader_change_using_tx_function":
"Driver closes connection to router if DNS resolved name not in routing table",
"stub.routing.RoutingV3.test_should_retry_write_until_success_with_leader_change_using_tx_function":
"Driver closes connection to router if DNS resolved name not in routing table",
"stub.routing.RoutingV4.test_should_retry_write_until_success_with_leader_change_using_tx_function":
"Driver closes connection to router if DNS resolved name not in routing table",
"stub.routing.Routing.test_should_retry_write_until_success_with_leader_shutdown_during_tx_using_tx_function":
"Driver closes connection to router if DNS resolved name not in routing table",
"stub.routing.RoutingV3.test_should_retry_write_until_success_with_leader_shutdown_during_tx_using_tx_function":
"Driver closes connection to router if DNS resolved name not in routing table",
"stub.routing.RoutingV4.test_should_retry_write_until_success_with_leader_shutdown_during_tx_using_tx_function":
"Driver closes connection to router if DNS resolved name not in routing table",
"stub.routing.Routing.test_should_successfully_acquire_rt_when_router_ip_changes":
"Test makes assumptions about how verify_connectivity is implemented",
"stub.routing.RoutingV3.test_should_successfully_acquire_rt_when_router_ip_changes":
"Test makes assumptions about how verify_connectivity is implemented",
"stub.routing.RoutingV4.test_should_successfully_acquire_rt_when_router_ip_changes":
"Test makes assumptions about how verify_connectivity is implemented",
"stub.retry.TestRetryClustering.test_retry_ForbiddenOnReadOnlyDatabase_ChangingWriter":
"Test makes assumptions about how verify_connectivity is implemented",
"stub.authorization.AuthorizationTests.test_should_retry_on_auth_expired_on_begin_using_tx_function":
"Flaky: test requires the driver to contact servers in a specific order",
"stub.authorization.AuthorizationTestsV3.test_should_retry_on_auth_expired_on_begin_using_tx_function":
"Flaky: test requires the driver to contact servers in a specific order",
"stub.authorization.AuthorizationTestsV4.test_should_retry_on_auth_expired_on_begin_using_tx_function":
"Flaky: test requires the driver to contact servers in a specific order"
},
"features": {
"AuthorizationExpiredTreatment": true,
"Optimization:ImplicitDefaultArguments": true,
"Optimization:MinimalResets": "Driver resets some clean connections when put back into pool",
"Optimization:ConnectionReuse": true,
"Optimization:PullPipelining": true
}
}