From 99fffc23f7de9b0663ba4b9aba7bfd40835b7e35 Mon Sep 17 00:00:00 2001 From: Mislav Bradac Date: Mon, 10 Jul 2017 15:22:43 +0200 Subject: [PATCH] Change FILE COPY to configure_file COPYONLY Summary: FILE COPY copies files only in configuration stage, configure_file copies files in make stage if file has changed. Reviewers: buda, teon.banek Reviewed By: teon.banek Subscribers: pullbot Differential Revision: https://phabricator.memgraph.io/D531 --- CMakeLists.txt | 77 ++++++------- tests/CMakeLists.txt | 26 ++--- tests/qa/README.md | 7 -- tests/qa/docker/kpi_service.docker | 16 --- tests/qa/kpi_service/kpi_service.py | 166 ---------------------------- tests/qa/plot_latency | 4 +- 6 files changed, 43 insertions(+), 253 deletions(-) delete mode 100644 tests/qa/docker/kpi_service.docker delete mode 100644 tests/qa/kpi_service/kpi_service.py diff --git a/CMakeLists.txt b/CMakeLists.txt index 8d463d020..024c1f17f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -114,24 +114,32 @@ set(fmt_static_lib ${fmt_source_dir}/fmt/libfmt.a) # and memgraph server binary # copy query_engine template file set(query_engine_template_file ${src_dir}/query/plan_template_cpp) -FILE(COPY ${query_engine_template_file} - DESTINATION ${CMAKE_BINARY_DIR}/tests/template) -FILE(COPY ${query_engine_template_file} - DESTINATION ${CMAKE_BINARY_DIR}/tests/integration/template) -FILE(COPY ${query_engine_template_file} - DESTINATION ${CMAKE_BINARY_DIR}/tests/manual/template) -FILE(COPY ${query_engine_template_file} - DESTINATION ${CMAKE_BINARY_DIR}/template) +configure_file(${query_engine_template_file} + ${CMAKE_BINARY_DIR}/tests/template/plan_template_cpp COPYONLY) +configure_file(${query_engine_template_file} + ${CMAKE_BINARY_DIR}/tests/integration/template/plan_template_cpp COPYONLY) +configure_file(${query_engine_template_file} + ${CMAKE_BINARY_DIR}/tests/manual/template/plan_template_cpp COPYONLY) +configure_file(${query_engine_template_file} + ${CMAKE_BINARY_DIR}/template/plan_template_cpp COPYONLY) # create destination folder for compiled queries FILE(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/tests/integration/compiled) FILE(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/tests/manual/compiled) FILE(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/tests/compiled) FILE(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/compiled) # copy hardcoded queries -FILE(COPY ${tests_dir}/integration/hardcoded_query - DESTINATION ${CMAKE_BINARY_DIR}/tests/integration) -FILE(COPY ${tests_dir}/integration/stream - DESTINATION ${CMAKE_BINARY_DIR}/tests/integration) +file(GLOB __HARDCODED_FILES + ${CMAKE_SOURCE_DIR}/tests/integration/hardcoded_query/*) +foreach(file_path ${__HARDCODED_FILES}) + get_filename_component(file_name ${file_path} NAME) + configure_file(${file_path} ${CMAKE_BINARY_DIR}/tests/integration/hardcoded_query/${file_name} COPYONLY) +endforeach() +file(GLOB __STREAM + ${CMAKE_SOURCE_DIR}/tests/integration/stream/*) +foreach(file_path ${__STREAM}) + get_filename_component(file_name ${file_path} NAME) + configure_file(${file_path} ${CMAKE_BINARY_DIR}/tests/integration/stream/${file_name} COPYONLY) +endforeach() # ----------------------------------------------------------------------------- # linter setup (clang-tidy) @@ -206,20 +214,6 @@ message(STATUS "MEMGRAPH binary: ${MEMGRAPH}") option(POC "Build proof of concept binaries" ON) message(STATUS "POC binaries: ${POC}") # tests -option(ALL_TESTS "Add all test binaries" ON) -message(STATUS "Add all test binaries: ${ALL_TESTS}") -option(BENCHMARK_TESTS "Add benchmark test binaries" OFF) -message(STATUS "Add benchmark test binaries: ${BENCHMARK_TESTS}") -option(CONCURRENT_TESTS "Add concurrent test binaries" OFF) -message(STATUS "Add concurrent test binaries: ${CONCURRENT_TESTS}") -option(INTEGRATION_TESTS "Add integration test binaries" OFF) -message(STATUS "Add integration test binaries: ${INTEGRATION_TESTS}") -option(MANUAL_TESTS "Add manual test binaries" OFF) -message(STATUS "Add manual test binaries: ${MANUAL_TESTS}") -option(UNIT_TESTS "Add unit test binaries" OFF) -message(STATUS "Add unit test binaries: ${UNIT_TESTS}") -option(PROPERTY_BASED_TESTS "Add property based test binaries" OFF) -message(STATUS "Add property based test binaries: ${PROPERTY_BASED_TESTS}") option(HARDCODED_TARGETS "Make hardcoded query targets" ON) message(STATUS "Make hardcoded query targets: ${HARDCODED_TARGETS}") option(TEST_COVERAGE "Generate coverage reports from unit tests" OFF) @@ -334,10 +328,7 @@ endif() # ----------------------------------------------------------------------------- # tests -if (ALL_TESTS OR BENCHMARK_TESTS OR CONCURRENT_TEST OR INTEGRATION_TEST - OR MANUAL_TESTS OR UNIT_TESTS OR PROPERTY_BASED_TESTS) - add_subdirectory(tests) -endif() +add_subdirectory(tests) # ----------------------------------------------------------------------------- add_custom_target(recursive_include_plan_template @@ -403,19 +394,19 @@ set_target_properties(__refactor_target PROPERTIES EXCLUDE_FROM_ALL 1) # 3. integration tests for all pilot/clients written in cucumber # the following targets address only the first phase if(HARDCODED_TARGETS) - file(GLOB __HARDCODED_SOURCES - ${CMAKE_SOURCE_DIR}/tests/integration/hardcoded_query/*.cpp) - foreach(file_path ${__HARDCODED_SOURCES}) - get_filename_component(file_name ${file_path} NAME_WE) - set(target_name __${file_name}_hardcoded_target) - add_executable(${target_name} ${CMAKE_SOURCE_DIR}/libs/__main.cpp - ${file_path}) - target_link_libraries(${target_name} memgraph_lib) - set_property(TARGET ${target_name} PROPERTY CXX_STANDARD ${cxx_standard}) - set_target_properties(${target_name} - PROPERTIES RUNTIME_OUTPUT_DIRECTORY - "${CMAKE_BINARY_DIR}/__hardcoded_targets") - endforeach() + file(GLOB __HARDCODED_SOURCES + ${CMAKE_SOURCE_DIR}/tests/integration/hardcoded_query/*.cpp) + foreach(file_path ${__HARDCODED_SOURCES}) + get_filename_component(file_name ${file_path} NAME_WE) + set(target_name __${file_name}_hardcoded_target) + add_executable(${target_name} ${CMAKE_SOURCE_DIR}/libs/__main.cpp + ${file_path}) + target_link_libraries(${target_name} memgraph_lib) + set_property(TARGET ${target_name} PROPERTY CXX_STANDARD ${cxx_standard}) + set_target_properties(${target_name} + PROPERTIES RUNTIME_OUTPUT_DIRECTORY + "${CMAKE_BINARY_DIR}/__hardcoded_targets") + endforeach() endif() get_target_cxx_flags(memgraph_lib compile_flags) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 576c48c88..d6b8ba986 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -25,32 +25,20 @@ endif (UNIX) # ----------------------------------------------------------------------------- # benchmark test binaries -if (ALL_TESTS OR BENCHMARK_TESTS) - add_subdirectory(${PROJECT_SOURCE_DIR}/benchmark) -endif() +add_subdirectory(${PROJECT_SOURCE_DIR}/benchmark) # concurrent test binaries -if (ALL_TESTS OR CONCURRENT_TESTS) - add_subdirectory(${PROJECT_SOURCE_DIR}/concurrent) -endif() +add_subdirectory(${PROJECT_SOURCE_DIR}/concurrent) # integration test binaries -if (ALL_TESTS OR INTEGRATION_TESTS) - add_subdirectory(${PROJECT_SOURCE_DIR}/integration) -endif() +add_subdirectory(${PROJECT_SOURCE_DIR}/integration) # manual test binaries -if (ALL_TESTS OR MANUAL_TESTS) - add_subdirectory(${PROJECT_SOURCE_DIR}/manual) -endif() +add_subdirectory(${PROJECT_SOURCE_DIR}/manual) # unit test binaries -if (ALL_TESTS OR UNIT_TESTS) - add_subdirectory(${PROJECT_SOURCE_DIR}/unit) -endif() +add_subdirectory(${PROJECT_SOURCE_DIR}/unit) # property based test binaries -if (ALL_TESTS OR PROPERTY_BASED_TESTS) - include_directories(${CMAKE_SOURCE_DIR}/libs/rapidcheck/extras/gtest/include) - add_subdirectory(${PROJECT_SOURCE_DIR}/property_based) -endif() +include_directories(${CMAKE_SOURCE_DIR}/libs/rapidcheck/extras/gtest/include) +add_subdirectory(${PROJECT_SOURCE_DIR}/property_based) diff --git a/tests/qa/README.md b/tests/qa/README.md index 134c128c2..b36a03079 100644 --- a/tests/qa/README.md +++ b/tests/qa/README.md @@ -51,10 +51,3 @@ TCK Engine problems: | -properties | 1 | Database is returning properties_set, not properties_created and properties_deleted. - -## KPI Service - -Flask application used to get results from executing tests with TCK Engine. -Application can be ran executing: - - 1. python3 kpi_service/kpi_service.py diff --git a/tests/qa/docker/kpi_service.docker b/tests/qa/docker/kpi_service.docker deleted file mode 100644 index a947e9d57..000000000 --- a/tests/qa/docker/kpi_service.docker +++ /dev/null @@ -1,16 +0,0 @@ -FROM ubuntu:16.04 - -RUN apt-get update \ - && apt-get install -y python3 python3-pip \ - && apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* - -COPY kpi_service /kpi_service -COPY requirements.txt /kpi_service/requirements.txt - -WORKDIR /kpi_service -RUN pip3 install --upgrade pip -RUN pip3 install -r requirements.txt - -EXPOSE 5000 -CMD python3 kpi_service.py --results /results - diff --git a/tests/qa/kpi_service/kpi_service.py b/tests/qa/kpi_service/kpi_service.py deleted file mode 100644 index 605da2351..000000000 --- a/tests/qa/kpi_service/kpi_service.py +++ /dev/null @@ -1,166 +0,0 @@ -from flask import Flask, jsonify, request -import os -import json -from argparse import ArgumentParser - -app = Flask(__name__) -""" -Script runs web application used for getting test results. -Default file with results is "../tck_engine/results". -Application lists files with results or returnes result -file as json. -Default host is 0.0.0.0, and default port is 5000. -Host, port and result file can be passed as arguments of a script. -""" - - -def parse_args(): - argp = ArgumentParser(description=__doc__) - argp.add_argument("--host", default="0.0.0.0", - help="Application host ip, default is 0.0.0.0.") - argp.add_argument("--port", default="5000", - help="Application host ip, default is 5000.") - argp.add_argument("--results", default="tck_engine/results", - help="Path where the results are stored.") - return argp.parse_args() - - -@app.route("/results") -def results(): - """ - Function accessed with route /result. Function lists - last tail result files added. Tail is a parameter given - in the route. If the tail is not given, function lists - last ten added files. If parameter last is true, only last - test result is returned. - - @return: - json list of test results - """ - l = [f for f in os.listdir(app.config["RESULTS_PATH"]) - if f != ".gitignore"] - return get_ret_list(l) - - -@app.route("/results/") -def results_for_db(dbname): - """ - Function accessed with route /result/. Function - lists last tail result files added of database . If param last is true, only last test result - is returned. - - @param dbname: - string, database name - @return: - json list of test results - """ - print(os.listdir(app.config["RESULTS_PATH"])) - l = [f for f in os.listdir(app.config["RESULTS_PATH"]) - if f != ".gitignore" and f.split('-')[1] == dbname] - return get_ret_list(l) - - -@app.route("/results//") -def result(dbname, test_suite): - """ - Function accessed with route /results// - Function lists last tail result files added of database - tested on . Tail is a parameter given in the - route. If tail is not given, function lists last ten results. - If param last is true, only last test result is returned. - - @param dbname: - string, database name - @param test_suite: - string, test suite of result file - @return: - json list of test results - """ - fname = dbname + "-" + test_suite + ".json" - l = [f for f in os.listdir(app.config["RESULTS_PATH"]) - if f.endswith(fname)] - return get_ret_list(l) - - -def get_ret_list(l): - """ - Function returns json list of test results of files given in - list l. - - @param l: - list of file names - @return: - json list of test results - """ - l.sort() - ret_list = [] - for f in l: - ret_list.append(get_content(f)) - return list_to_json( - ret_list, - request.args.get("last"), - request.args.get("tail") - ) - - -def get_content(fname): - """ - Function returns data of the json file fname located in - results directory in json format. - - @param fname: - string, name of the file - @return: - json of a file - """ - with open(app.config["RESULTS_PATH"] + "/" + fname) as f: - json_data = json.load(f) - return json_data - - -def list_to_json(l, last, tail): - """ - Function converts list to json format. If last is true, - only the first item in list is returned list, else last - tail results are returned in json list. If tail is not - given, last ten results are returned in json list. - - @param l: - list to convert to json format - @param last: - string from description - @param tail: - string from description - """ - l.reverse() - if len(l) == 0: - return jsonify(results=[]) - - if last == "true": - return jsonify(results=[l[0]]) - - if tail is None: - tail = 10 - else: - tail = int(tail) - if tail > len(l): - tail = len(l) - return jsonify(results=l[0:tail]) - - -def main(): - args = parse_args() - app.config.update(dict( - RESULTS_PATH=os.path.abspath(args.results) - )) - app.run( - host=args.host, - port=int(args.port) - ) - - -if __name__ == "__main__": - main() diff --git a/tests/qa/plot_latency b/tests/qa/plot_latency index 99224f515..cf9d5ce47 100755 --- a/tests/qa/plot_latency +++ b/tests/qa/plot_latency @@ -19,10 +19,10 @@ def main(): argp.add_argument('--neo4j-latency', help='Path to the json of neo4j latency') args = argp.parse_args() - + fig = plt.gcf() fig.set_size_inches(10, 16) - + with open(args.neo4j_latency) as json_file: json_neo = json.load(json_file)