memgraph/tools/tests/test_mg_import_csv
Teon Banek df72861b90 Make csv_to_snapshot more user friendly
Summary:
Time csv_to_snapshot conversion and log it.
Check if writing csv_to_snapshot failed.
Extract LoadConfig from memgraph_bolt to config.hpp.
Read memgraph config in csv_to_snapshot for snapshot_directory.
Rename csv_to_snapshot to mg_import_csv.
Add tests for tools.
Run tools tests in apollo.

Reviewers: mislav.bradac, florijan, mferencevic, buda

Reviewed By: mferencevic

Subscribers: pullbot

Differential Revision: https://phabricator.memgraph.io/D931
2017-10-26 09:37:56 +02:00

39 lines
1.4 KiB
Python
Executable File

#!/usr/bin/env python3
'''Run mg_import_csv and test that recovery works with mg_recovery_check.'''
import argparse
import subprocess
import os
import tempfile
_SCRIPT_DIR = os.path.dirname(os.path.realpath(__file__))
def parse_args():
argp = argparse.ArgumentParser(description=__doc__)
argp.add_argument('--mg-import-csv', required=True,
help='Path to mg_import_csv executable.')
argp.add_argument('--mg-recovery-check', required=True,
help='Path to mg_recovery_check executable.')
return argp.parse_args()
def main():
args = parse_args()
comment_nodes = os.path.join(_SCRIPT_DIR, 'csv', 'comment_nodes.csv')
forum_nodes = os.path.join(_SCRIPT_DIR, 'csv', 'forum_nodes.csv')
relationships = os.path.join(_SCRIPT_DIR, 'csv', 'relationships.csv')
with tempfile.TemporaryDirectory(suffix='-snapshots', dir=_SCRIPT_DIR) as snapshot_dir:
out_snapshot = os.path.join(snapshot_dir, 'snapshot')
mg_import_csv = [args.mg_import_csv, '--nodes', comment_nodes,
'--nodes', forum_nodes, '--relationships', relationships,
'--out', out_snapshot, '--csv-delimiter=|', '--array-delimiter=;']
subprocess.check_call(mg_import_csv)
mg_recovery_check = [args.mg_recovery_check, '--snapshot-dir', snapshot_dir]
subprocess.check_call(mg_recovery_check)
if __name__ == '__main__':
main()