From 7f2ad99ce7c0f8c745ab1771865eff023971a1bc Mon Sep 17 00:00:00 2001 From: Matej Ferencevic Date: Fri, 19 Oct 2018 14:47:43 +0200 Subject: [PATCH] Integrate mg_client test with Apollo Reviewers: teon.banek, buda, mculinovic Reviewed By: teon.banek Subscribers: pullbot Differential Revision: https://phabricator.memgraph.io/D1685 --- tools/tests/apollo_runs.yaml | 9 +++ .../tests/client/output_tabular/escaping.txt | 10 ++-- .../client/output_tabular/multiline_query.txt | 60 +++++++++---------- .../output_tabular/multiple_columns.txt | 10 ++-- .../multiple_queries_per_line.txt | 22 +++---- .../client/output_tabular/query_per_line.txt | 24 ++++---- tools/tests/client/output_tabular/quote.txt | 50 ++++++++-------- .../output_tabular/unfinished_query.txt | 60 +++++++++---------- tools/tests/test_mg_client | 17 +++++- 9 files changed, 142 insertions(+), 120 deletions(-) create mode 100644 tools/tests/apollo_runs.yaml diff --git a/tools/tests/apollo_runs.yaml b/tools/tests/apollo_runs.yaml new file mode 100644 index 000000000..0150f81ba --- /dev/null +++ b/tools/tests/apollo_runs.yaml @@ -0,0 +1,9 @@ +- name: tools__test_mg_client + commands: | + ./test_mg_client + ./test_mg_client --use-ssl + infiles: + - test_mg_client # test_mg_client script + - client # test files + - ../../build_release/memgraph # memgraph binary + - ../../build_release/tools/src/mg_client # mg_client binary diff --git a/tools/tests/client/output_tabular/escaping.txt b/tools/tests/client/output_tabular/escaping.txt index b0ae9bcc0..d691d62e3 100644 --- a/tools/tests/client/output_tabular/escaping.txt +++ b/tools/tests/client/output_tabular/escaping.txt @@ -1,5 +1,5 @@ -+------------------------+ -| n | -+------------------------+ -|(:Node {tmp: "\"\\;\\"})| -+------------------------+ ++--------------------------+ +| n | ++--------------------------+ +| (:Node {tmp: "\"\\;\\"}) | ++--------------------------+ diff --git a/tools/tests/client/output_tabular/multiline_query.txt b/tools/tests/client/output_tabular/multiline_query.txt index f5e1179ac..74caf466c 100644 --- a/tools/tests/client/output_tabular/multiline_query.txt +++ b/tools/tests/client/output_tabular/multiline_query.txt @@ -1,30 +1,30 @@ -+---------------------------------------------+ -| n | -+---------------------------------------------+ -|(:Constantine {quote: "In hoc signo vinces"})| -+---------------------------------------------+ -+---------------------------------------------+ -| n | -+---------------------------------------------+ -|(:Constantine {quote: "In hoc signo vinces"})| -+---------------------------------------------+ -+-------------------------------------------------------+ -| n | -+-------------------------------------------------------+ -|(:Erdody {quote: "Regnum regno non praescribit leges"})| -+-------------------------------------------------------+ -+-------------------------------------------------------+ -| n | -+-------------------------------------------------------+ -|(:Erdody {quote: "Regnum regno non praescribit leges"})| -+-------------------------------------------------------+ -+-----------------------------------+ -| n | -+-----------------------------------+ -|(:Caesar {quote: "Alea iacta est"})| -+-----------------------------------+ -+-----------------------------------+ -| n | -+-----------------------------------+ -|(:Caesar {quote: "Alea iacta est"})| -+-----------------------------------+ ++-----------------------------------------------+ +| n | ++-----------------------------------------------+ +| (:Constantine {quote: "In hoc signo vinces"}) | ++-----------------------------------------------+ ++-----------------------------------------------+ +| n | ++-----------------------------------------------+ +| (:Constantine {quote: "In hoc signo vinces"}) | ++-----------------------------------------------+ ++---------------------------------------------------------+ +| n | ++---------------------------------------------------------+ +| (:Erdody {quote: "Regnum regno non praescribit leges"}) | ++---------------------------------------------------------+ ++---------------------------------------------------------+ +| n | ++---------------------------------------------------------+ +| (:Erdody {quote: "Regnum regno non praescribit leges"}) | ++---------------------------------------------------------+ ++-------------------------------------+ +| n | ++-------------------------------------+ +| (:Caesar {quote: "Alea iacta est"}) | ++-------------------------------------+ ++-------------------------------------+ +| n | ++-------------------------------------+ +| (:Caesar {quote: "Alea iacta est"}) | ++-------------------------------------+ diff --git a/tools/tests/client/output_tabular/multiple_columns.txt b/tools/tests/client/output_tabular/multiple_columns.txt index b5af47139..14c2d90f3 100644 --- a/tools/tests/client/output_tabular/multiple_columns.txt +++ b/tools/tests/client/output_tabular/multiple_columns.txt @@ -1,5 +1,5 @@ -+---------+---------+---------+ -| n | e | m | -+---------+---------+---------+ -|(:Node) |[Edge] |(:Vertex)| -+---------+---------+---------+ ++-----------+-----------+-----------+ +| n | e | m | ++-----------+-----------+-----------+ +| (:Node) | [Edge] | (:Vertex) | ++-----------+-----------+-----------+ diff --git a/tools/tests/client/output_tabular/multiple_queries_per_line.txt b/tools/tests/client/output_tabular/multiple_queries_per_line.txt index 675075707..e59ff48f8 100644 --- a/tools/tests/client/output_tabular/multiple_queries_per_line.txt +++ b/tools/tests/client/output_tabular/multiple_queries_per_line.txt @@ -1,15 +1,15 @@ -+-------+ -| n | -+-------+ -|(:Node)| -+-------+ +---------+ | n | +---------+ -|(:Vertex)| -+---------+ -+---------+ -| n | -+---------+ -|(:Vertex)| +| (:Node) | +---------+ ++-----------+ +| n | ++-----------+ +| (:Vertex) | ++-----------+ ++-----------+ +| n | ++-----------+ +| (:Vertex) | ++-----------+ diff --git a/tools/tests/client/output_tabular/query_per_line.txt b/tools/tests/client/output_tabular/query_per_line.txt index 2e8258b54..6b74b97bb 100644 --- a/tools/tests/client/output_tabular/query_per_line.txt +++ b/tools/tests/client/output_tabular/query_per_line.txt @@ -1,20 +1,20 @@ -+-------+ -| n | -+-------+ -|(:Node)| -+-------+ -+-------+ -| n | -+-------+ -|(:Node)| -+-------+ +---------+ | n | +---------+ -|(:Vertex)| +| (:Node) | +---------+ +---------+ | n | +---------+ -|(:Vertex)| +| (:Node) | +---------+ ++-----------+ +| n | ++-----------+ +| (:Vertex) | ++-----------+ ++-----------+ +| n | ++-----------+ +| (:Vertex) | ++-----------+ diff --git a/tools/tests/client/output_tabular/quote.txt b/tools/tests/client/output_tabular/quote.txt index 7bd4a04d8..956704f29 100644 --- a/tools/tests/client/output_tabular/quote.txt +++ b/tools/tests/client/output_tabular/quote.txt @@ -1,25 +1,25 @@ -+---------------------------------------+ -| n | -+---------------------------------------+ -|(:Ciceron {quote: "o tempora o mores"})| -+---------------------------------------+ -+----------------------------------------+ -| n | -+----------------------------------------+ -|(:Ciceron {quote: "o tempora o mores!"})| -+----------------------------------------+ -+-------------------------------------------+ -| n | -+-------------------------------------------+ -|(:Ciceron {quote: "o tempora \'o mores\'"})| -+-------------------------------------------+ -+-------------------------------------------+ -| n | -+-------------------------------------------+ -|(:Ciceron {quote: "o tempora \"o mores\""})| -+-------------------------------------------+ -+-------------------------------------------+ -| n | -+-------------------------------------------+ -|(:Ciceron {quote: "o tempora \"o mores\""})| -+-------------------------------------------+ ++-----------------------------------------+ +| n | ++-----------------------------------------+ +| (:Ciceron {quote: "o tempora o mores"}) | ++-----------------------------------------+ ++------------------------------------------+ +| n | ++------------------------------------------+ +| (:Ciceron {quote: "o tempora o mores!"}) | ++------------------------------------------+ ++---------------------------------------------+ +| n | ++---------------------------------------------+ +| (:Ciceron {quote: "o tempora \'o mores\'"}) | ++---------------------------------------------+ ++---------------------------------------------+ +| n | ++---------------------------------------------+ +| (:Ciceron {quote: "o tempora \"o mores\""}) | ++---------------------------------------------+ ++---------------------------------------------+ +| n | ++---------------------------------------------+ +| (:Ciceron {quote: "o tempora \"o mores\""}) | ++---------------------------------------------+ diff --git a/tools/tests/client/output_tabular/unfinished_query.txt b/tools/tests/client/output_tabular/unfinished_query.txt index 5f1606171..abe1b2416 100644 --- a/tools/tests/client/output_tabular/unfinished_query.txt +++ b/tools/tests/client/output_tabular/unfinished_query.txt @@ -1,30 +1,30 @@ -+-------------------------------------+ -| n | -+-------------------------------------+ -|(:Ovid {quote: "Exitus Acta Probat"})| -+-------------------------------------+ -+-------------------------------------+ -| n | -+-------------------------------------+ -|(:Ovid {quote: "Exitus Acta Probat"})| -+-------------------------------------+ -+-------------------------------------+ -| n | -+-------------------------------------+ -|(:Ovid {quote: "Exitus Acta Probat"})| -+-------------------------------------+ -+----------------------------+ -| n | -+----------------------------+ -|(:Bible {quote: "Fiat Lux"})| -+----------------------------+ -+-------------------------------------+ -| n | -+-------------------------------------+ -|(:Plinius {quote: "In vino veritas"})| -+-------------------------------------+ -+-------------------------------------+ -| n | -+-------------------------------------+ -|(:Plinius {quote: "In vino veritas"})| -+-------------------------------------+ ++---------------------------------------+ +| n | ++---------------------------------------+ +| (:Ovid {quote: "Exitus Acta Probat"}) | ++---------------------------------------+ ++---------------------------------------+ +| n | ++---------------------------------------+ +| (:Ovid {quote: "Exitus Acta Probat"}) | ++---------------------------------------+ ++---------------------------------------+ +| n | ++---------------------------------------+ +| (:Ovid {quote: "Exitus Acta Probat"}) | ++---------------------------------------+ ++------------------------------+ +| n | ++------------------------------+ +| (:Bible {quote: "Fiat Lux"}) | ++------------------------------+ ++---------------------------------------+ +| n | ++---------------------------------------+ +| (:Plinius {quote: "In vino veritas"}) | ++---------------------------------------+ ++---------------------------------------+ +| n | ++---------------------------------------+ +| (:Plinius {quote: "In vino veritas"}) | ++---------------------------------------+ diff --git a/tools/tests/test_mg_client b/tools/tests/test_mg_client index 03e2bb4c3..df21fcb12 100755 --- a/tools/tests/test_mg_client +++ b/tools/tests/test_mg_client @@ -54,12 +54,25 @@ if [ ! -d $input_dir ]; then exit 1 fi +# Check and generate SSL certificates +use_ssl=false +key_file="" +cert_file="" +if [ "$1" == "--use-ssl" ]; then + use_ssl=true + key_file=".key.pem" + cert_file=".cert.pem" + openssl req -new -newkey rsa:4096 -days 365 -nodes -x509 \ + -subj "/C=HR/ST=Zagreb/L=Zagreb/O=Memgraph/CN=db.memgraph.com" \ + -keyout $key_file -out $cert_file || exit 1 +fi + ## Startup # Start the memgraph process and wait for it to start. echo_info "Starting memgraph" -$memgraph_dir/memgraph &> /dev/null & +$memgraph_dir/memgraph --cert-file=$cert_file --key-file=$key_file & pid=$! wait_for_server 7687 echo_success "Started memgraph" @@ -70,7 +83,7 @@ echo_success "Started memgraph" echo_info "Running tests" echo # Blank line -client_flags="--use-ssl=false" +client_flags="--use-ssl=$use_ssl" test_code=0 for output_dir in $tests_dir/output_*; do for filename in $input_dir/*; do