From a1e4dc0268dd4fec653f47693eb2360693fe306c Mon Sep 17 00:00:00 2001 From: Marko Budiselic <marko.budiselic@memgraph.io> Date: Mon, 4 Jun 2018 00:09:40 +0100 Subject: [PATCH] Add stackoverflow answers TCK test suite Reviewers: teon.banek, mferencevic, mculinovic, mtomic Reviewed By: teon.banek Subscribers: pullbot Differential Revision: https://phabricator.memgraph.io/D1412 --- .../features/wsp.feature | 30 +++++++++++++++++++ .../stackoverflow_answers/graphs/wsp1.cypher | 5 ++++ .../stackoverflow_answers/graphs/wsp2.cypher | 5 ++++ 3 files changed, 40 insertions(+) create mode 100644 tests/qa/tck_engine/tests/stackoverflow_answers/features/wsp.feature create mode 100644 tests/qa/tck_engine/tests/stackoverflow_answers/graphs/wsp1.cypher create mode 100644 tests/qa/tck_engine/tests/stackoverflow_answers/graphs/wsp2.cypher diff --git a/tests/qa/tck_engine/tests/stackoverflow_answers/features/wsp.feature b/tests/qa/tck_engine/tests/stackoverflow_answers/features/wsp.feature new file mode 100644 index 000000000..d7a0e9035 --- /dev/null +++ b/tests/qa/tck_engine/tests/stackoverflow_answers/features/wsp.feature @@ -0,0 +1,30 @@ +Feature: Queries related to all Stackoverflow questions related to WSP + + Scenario: Dijkstra with pre calculated cost + + Given graph "wsp1" + When executing query: + """ + MATCH (a {id: 1})-[ + edges *wShortest + (e, n | (e.distance * 0.25) + (e.noise_level * 0.25) + (e.pollution_level * 0.5)) + total_weight + ]-(b {id: 4}) + RETURN startNode(head(edges)).id + reduce(acc = "", edge IN edges | acc + " -> " + endNode(edge).id) AS hops, total_weight; + """ + Then the result should be: + | hops | total_weight | + |'1 -> 2 -> 4'| 4.75 | + + Scenario: Using more than one property Dijkstra + + Given graph "wsp2" + When executing query: + """ + MATCH (a {id: 1})-[edges *wShortest (e, n | e.weight1 + e.weight2) total_weight]-(b {id: 4}) + RETURN startNode(head(edges)).id + reduce(acc = "", edge IN edges | acc + " -> " + endNode(edge).id) AS hops, total_weight; + """ + Then the result should be: + | hops | total_weight | + |'1 -> 3 -> 4'| 17.0 | + diff --git a/tests/qa/tck_engine/tests/stackoverflow_answers/graphs/wsp1.cypher b/tests/qa/tck_engine/tests/stackoverflow_answers/graphs/wsp1.cypher new file mode 100644 index 000000000..588a51d66 --- /dev/null +++ b/tests/qa/tck_engine/tests/stackoverflow_answers/graphs/wsp1.cypher @@ -0,0 +1,5 @@ +CREATE (n1 {id: 1}) CREATE (n2 {id: 2}) CREATE (n3 {id: 3}) CREATE (n4 {id: 4}) +CREATE (n1)-[:E {pollution_level: 1, distance: 1.0, noise_level: 5}]->(n2) +CREATE (n1)-[:E {pollution_level: 2, distance: 2.0, noise_level: 4}]->(n3) +CREATE (n2)-[:E {pollution_level: 3, distance: 2.0, noise_level: 3}]->(n4) +CREATE (n3)-[:E {pollution_level: 4, distance: 1.0, noise_level: 2}]->(n4); diff --git a/tests/qa/tck_engine/tests/stackoverflow_answers/graphs/wsp2.cypher b/tests/qa/tck_engine/tests/stackoverflow_answers/graphs/wsp2.cypher new file mode 100644 index 000000000..1a19a3745 --- /dev/null +++ b/tests/qa/tck_engine/tests/stackoverflow_answers/graphs/wsp2.cypher @@ -0,0 +1,5 @@ +CREATE (n1 {id: 1}) CREATE (n2 {id: 2}) CREATE (n3 {id: 3}) CREATE (n4 {id: 4}) +CREATE (n1)-[:E {weight1: 1, weight2: 1}]->(n2) +CREATE (n1)-[:E {weight1: 2, weight2: 10}]->(n3) +CREATE (n2)-[:E {weight1: 3, weight2: 100}]->(n4) +CREATE (n3)-[:E {weight1: 4, weight2: 1}]->(n4);