Ejemplo n.º 1
0
def set_create(connection, args):
    project_id = get_scalar(connection,
                            "SELECT id FROM projects WHERE name = ?",
                            (args.project, ))
    if project_id is None:
        print("Cannot find project.")
    else:
        query = "INSERT INTO test_sets (id, project, name) VALUES (?, ?, ?)"
        execute_statement(connection, query,
                          (str(uuid.uuid4()), project_id, args.name))
Ejemplo n.º 2
0
def test_link(connection, args):
    with contextlib.closing(sqlite3.connect("pptam.db")) as connection:
        with connection:
            test_set_id = get_scalar(
                connection,
                "SELECT test_sets.id FROM test_sets INNER JOIN projects ON test_sets.project = projects.id WHERE test_sets.name = ? AND projects.name = ?",
                (args.set, args.project))
            if test_set_id is None:
                print("Cannot find test set.")
            else:
                test_id = get_scalar(
                    connection,
                    "SELECT tests.id FROM tests INNER JOIN projects ON tests.project = projects.id WHERE tests.name = ? AND projects.name = ?",
                    (args.test, args.project))
                if test_id is None:
                    print("Cannot find test.")
                else:
                    execute_statement(
                        connection,
                        "INSERT OR IGNORE INTO test_set_tests (id, test_set, test) VALUES (?, ?, ?)",
                        (str(uuid.uuid4()), test_set_id, test_id))
Ejemplo n.º 3
0
def profile_delete(connection, args):
    execute_statement(connection,
                      "DELETE FROM operational_profiles WHERE name = ?",
                      (args.name, ))
Ejemplo n.º 4
0
def profile_rename(connection, args):
    query = f"UPDATE operational_profiles SET name = ? WHERE name = ? AND project = (SELECT id FROM projects WHERE name = ?)"
    execute_statement(connection, query,
                      (args.name2, args.name1, args.project))
Ejemplo n.º 5
0
def test_delete(connection, args):
    execute_statement(connection, "DELETE FROM tests WHERE name = ?",
                      (args.name, ))
Ejemplo n.º 6
0
def test_rename(connection, args):
    query = "UPDATE tests SET name = ? WHERE name = ? AND project = (SELECT id FROM projects WHERE name = ?)"
    execute_statement(connection, query,
                      (args.name2, args.name1, args.project))
Ejemplo n.º 7
0
def project_create(connection, args):
    execute_statement(
        connection, "INSERT OR IGNORE INTO projects (id, name) VALUES (?, ?);",
        (str(uuid.uuid4()), args.name))
Ejemplo n.º 8
0
def add_sample_operational_profile(connection, args):
    with contextlib.closing(sqlite3.connect("pptam.db")) as connection:
        with connection:
            project_id = get_scalar(connection,
                                    "SELECT id FROM projects WHERE name = ?",
                                    (args.project, ))
            if project_id is None:
                print("Cannot find project.")
            else:
                id = str(uuid.uuid4())
                execute_statement(
                    connection,
                    "INSERT INTO operational_profiles (id, project, name) VALUES (?, ?, ?)",
                    (id, project_id, "Operational profile"))

                if args.number == 1:
                    execute_statement(
                        connection,
                        "INSERT INTO operational_profile_observations (id, operational_profile, users, frequency) VALUES (?, ?, ?, ?)",
                        (str(uuid.uuid4()), id, 0, 3))
                    execute_statement(
                        connection,
                        "INSERT INTO operational_profile_observations (id, operational_profile, users, frequency) VALUES (?, ?, ?, ?)",
                        (str(uuid.uuid4()), id, 1, 11))
                    execute_statement(
                        connection,
                        "INSERT INTO operational_profile_observations (id, operational_profile, users, frequency) VALUES (?, ?, ?, ?)",
                        (str(uuid.uuid4()), id, 2, 6))
                    execute_statement(
                        connection,
                        "INSERT INTO operational_profile_observations (id, operational_profile, users, frequency) VALUES (?, ?, ?, ?)",
                        (str(uuid.uuid4()), id, 3, 6))
                    execute_statement(
                        connection,
                        "INSERT INTO operational_profile_observations (id, operational_profile, users, frequency) VALUES (?, ?, ?, ?)",
                        (str(uuid.uuid4()), id, 4, 6))
                    execute_statement(
                        connection,
                        "INSERT INTO operational_profile_observations (id, operational_profile, users, frequency) VALUES (?, ?, ?, ?)",
                        (str(uuid.uuid4()), id, 5, 8))
                    execute_statement(
                        connection,
                        "INSERT INTO operational_profile_observations (id, operational_profile, users, frequency) VALUES (?, ?, ?, ?)",
                        (str(uuid.uuid4()), id, 10, 2))
                    execute_statement(
                        connection,
                        "INSERT INTO operational_profile_observations (id, operational_profile, users, frequency) VALUES (?, ?, ?, ?)",
                        (str(uuid.uuid4()), id, 11, 4))
                    execute_statement(
                        connection,
                        "INSERT INTO operational_profile_observations (id, operational_profile, users, frequency) VALUES (?, ?, ?, ?)",
                        (str(uuid.uuid4()), id, 12, 2))
                    execute_statement(
                        connection,
                        "INSERT INTO operational_profile_observations (id, operational_profile, users, frequency) VALUES (?, ?, ?, ?)",
                        (str(uuid.uuid4()), id, 13, 2))
                    execute_statement(
                        connection,
                        "INSERT INTO operational_profile_observations (id, operational_profile, users, frequency) VALUES (?, ?, ?, ?)",
                        (str(uuid.uuid4()), id, 15, 4))
                    execute_statement(
                        connection,
                        "INSERT INTO operational_profile_observations (id, operational_profile, users, frequency) VALUES (?, ?, ?, ?)",
                        (str(uuid.uuid4()), id, 16, 4))
                    execute_statement(
                        connection,
                        "INSERT INTO operational_profile_observations (id, operational_profile, users, frequency) VALUES (?, ?, ?, ?)",
                        (str(uuid.uuid4()), id, 17, 8))
                    execute_statement(
                        connection,
                        "INSERT INTO operational_profile_observations (id, operational_profile, users, frequency) VALUES (?, ?, ?, ?)",
                        (str(uuid.uuid4()), id, 18, 7))
                    execute_statement(
                        connection,
                        "INSERT INTO operational_profile_observations (id, operational_profile, users, frequency) VALUES (?, ?, ?, ?)",
                        (str(uuid.uuid4()), id, 19, 7))
                    execute_statement(
                        connection,
                        "INSERT INTO operational_profile_observations (id, operational_profile, users, frequency) VALUES (?, ?, ?, ?)",
                        (str(uuid.uuid4()), id, 20, 7))
                    execute_statement(
                        connection,
                        "INSERT INTO operational_profile_observations (id, operational_profile, users, frequency) VALUES (?, ?, ?, ?)",
                        (str(uuid.uuid4()), id, 21, 7))
                    execute_statement(
                        connection,
                        "INSERT INTO operational_profile_observations (id, operational_profile, users, frequency) VALUES (?, ?, ?, ?)",
                        (str(uuid.uuid4()), id, 22, 6))
                    execute_statement(
                        connection,
                        "INSERT INTO operational_profile_observations (id, operational_profile, users, frequency) VALUES (?, ?, ?, ?)",
                        (str(uuid.uuid4()), id, 23, 5))
                    execute_statement(
                        connection,
                        "INSERT INTO operational_profile_observations (id, operational_profile, users, frequency) VALUES (?, ?, ?, ?)",
                        (str(uuid.uuid4()), id, 24, 1))
                    execute_statement(
                        connection,
                        "INSERT INTO operational_profile_observations (id, operational_profile, users, frequency) VALUES (?, ?, ?, ?)",
                        (str(uuid.uuid4()), id, 25, 4))
                    execute_statement(
                        connection,
                        "INSERT INTO operational_profile_observations (id, operational_profile, users, frequency) VALUES (?, ?, ?, ?)",
                        (str(uuid.uuid4()), id, 26, 3))
                    execute_statement(
                        connection,
                        "INSERT INTO operational_profile_observations (id, operational_profile, users, frequency) VALUES (?, ?, ?, ?)",
                        (str(uuid.uuid4()), id, 27, 3))
                    execute_statement(
                        connection,
                        "INSERT INTO operational_profile_observations (id, operational_profile, users, frequency) VALUES (?, ?, ?, ?)",
                        (str(uuid.uuid4()), id, 28, 4))
                    execute_statement(
                        connection,
                        "INSERT INTO operational_profile_observations (id, operational_profile, users, frequency) VALUES (?, ?, ?, ?)",
                        (str(uuid.uuid4()), id, 30, 10))
                    execute_statement(
                        connection,
                        "INSERT INTO operational_profile_observations (id, operational_profile, users, frequency) VALUES (?, ?, ?, ?)",
                        (str(uuid.uuid4()), id, 35, 13))
                    execute_statement(
                        connection,
                        "INSERT INTO operational_profile_observations (id, operational_profile, users, frequency) VALUES (?, ?, ?, ?)",
                        (str(uuid.uuid4()), id, 40, 21))
                    execute_statement(
                        connection,
                        "INSERT INTO operational_profile_observations (id, operational_profile, users, frequency) VALUES (?, ?, ?, ?)",
                        (str(uuid.uuid4()), id, 42, 10))
                    execute_statement(
                        connection,
                        "INSERT INTO operational_profile_observations (id, operational_profile, users, frequency) VALUES (?, ?, ?, ?)",
                        (str(uuid.uuid4()), id, 45, 20))
                    execute_statement(
                        connection,
                        "INSERT INTO operational_profile_observations (id, operational_profile, users, frequency) VALUES (?, ?, ?, ?)",
                        (str(uuid.uuid4()), id, 50, 12))
                    execute_statement(
                        connection,
                        "INSERT INTO operational_profile_observations (id, operational_profile, users, frequency) VALUES (?, ?, ?, ?)",
                        (str(uuid.uuid4()), id, 55, 19))
                    execute_statement(
                        connection,
                        "INSERT INTO operational_profile_observations (id, operational_profile, users, frequency) VALUES (?, ?, ?, ?)",
                        (str(uuid.uuid4()), id, 60, 25))
                    execute_statement(
                        connection,
                        "INSERT INTO operational_profile_observations (id, operational_profile, users, frequency) VALUES (?, ?, ?, ?)",
                        (str(uuid.uuid4()), id, 65, 28))
                    execute_statement(
                        connection,
                        "INSERT INTO operational_profile_observations (id, operational_profile, users, frequency) VALUES (?, ?, ?, ?)",
                        (str(uuid.uuid4()), id, 70, 26))
                    execute_statement(
                        connection,
                        "INSERT INTO operational_profile_observations (id, operational_profile, users, frequency) VALUES (?, ?, ?, ?)",
                        (str(uuid.uuid4()), id, 75, 18))
                    execute_statement(
                        connection,
                        "INSERT INTO operational_profile_observations (id, operational_profile, users, frequency) VALUES (?, ?, ?, ?)",
                        (str(uuid.uuid4()), id, 80, 16))
                    execute_statement(
                        connection,
                        "INSERT INTO operational_profile_observations (id, operational_profile, users, frequency) VALUES (?, ?, ?, ?)",
                        (str(uuid.uuid4()), id, 105, 1))
                    execute_statement(
                        connection,
                        "INSERT INTO operational_profile_observations (id, operational_profile, users, frequency) VALUES (?, ?, ?, ?)",
                        (str(uuid.uuid4()), id, 85, 17))
                    execute_statement(
                        connection,
                        "INSERT INTO operational_profile_observations (id, operational_profile, users, frequency) VALUES (?, ?, ?, ?)",
                        (str(uuid.uuid4()), id, 90, 15))
                    execute_statement(
                        connection,
                        "INSERT INTO operational_profile_observations (id, operational_profile, users, frequency) VALUES (?, ?, ?, ?)",
                        (str(uuid.uuid4()), id, 95, 6))
                    execute_statement(
                        connection,
                        "INSERT INTO operational_profile_observations (id, operational_profile, users, frequency) VALUES (?, ?, ?, ?)",
                        (str(uuid.uuid4()), id, 100, 1))

                if args.number == 2:
                    execute_statement(
                        connection,
                        "INSERT INTO operational_profile_observations (id, operational_profile, users, frequency) VALUES (?, ?, ?, ?)",
                        (str(uuid.uuid4()), id, 10, 0))
                    execute_statement(
                        connection,
                        "INSERT INTO operational_profile_observations (id, operational_profile, users, frequency) VALUES (?, ?, ?, ?)",
                        (str(uuid.uuid4()), id, 11, 0))
                    execute_statement(
                        connection,
                        "INSERT INTO operational_profile_observations (id, operational_profile, users, frequency) VALUES (?, ?, ?, ?)",
                        (str(uuid.uuid4()), id, 12, 0))
                    execute_statement(
                        connection,
                        "INSERT INTO operational_profile_observations (id, operational_profile, users, frequency) VALUES (?, ?, ?, ?)",
                        (str(uuid.uuid4()), id, 13, 0))
                    execute_statement(
                        connection,
                        "INSERT INTO operational_profile_observations (id, operational_profile, users, frequency) VALUES (?, ?, ?, ?)",
                        (str(uuid.uuid4()), id, 14, 0))
                    execute_statement(
                        connection,
                        "INSERT INTO operational_profile_observations (id, operational_profile, users, frequency) VALUES (?, ?, ?, ?)",
                        (str(uuid.uuid4()), id, 15, 3))
                    execute_statement(
                        connection,
                        "INSERT INTO operational_profile_observations (id, operational_profile, users, frequency) VALUES (?, ?, ?, ?)",
                        (str(uuid.uuid4()), id, 16, 11))
                    execute_statement(
                        connection,
                        "INSERT INTO operational_profile_observations (id, operational_profile, users, frequency) VALUES (?, ?, ?, ?)",
                        (str(uuid.uuid4()), id, 17, 6))
                    execute_statement(
                        connection,
                        "INSERT INTO operational_profile_observations (id, operational_profile, users, frequency) VALUES (?, ?, ?, ?)",
                        (str(uuid.uuid4()), id, 18, 6))
                    execute_statement(
                        connection,
                        "INSERT INTO operational_profile_observations (id, operational_profile, users, frequency) VALUES (?, ?, ?, ?)",
                        (str(uuid.uuid4()), id, 19, 6))
                    execute_statement(
                        connection,
                        "INSERT INTO operational_profile_observations (id, operational_profile, users, frequency) VALUES (?, ?, ?, ?)",
                        (str(uuid.uuid4()), id, 20, 8))
                    execute_statement(
                        connection,
                        "INSERT INTO operational_profile_observations (id, operational_profile, users, frequency) VALUES (?, ?, ?, ?)",
                        (str(uuid.uuid4()), id, 25, 2))
                    execute_statement(
                        connection,
                        "INSERT INTO operational_profile_observations (id, operational_profile, users, frequency) VALUES (?, ?, ?, ?)",
                        (str(uuid.uuid4()), id, 26, 4))
                    execute_statement(
                        connection,
                        "INSERT INTO operational_profile_observations (id, operational_profile, users, frequency) VALUES (?, ?, ?, ?)",
                        (str(uuid.uuid4()), id, 27, 2))
                    execute_statement(
                        connection,
                        "INSERT INTO operational_profile_observations (id, operational_profile, users, frequency) VALUES (?, ?, ?, ?)",
                        (str(uuid.uuid4()), id, 28, 2))
                    execute_statement(
                        connection,
                        "INSERT INTO operational_profile_observations (id, operational_profile, users, frequency) VALUES (?, ?, ?, ?)",
                        (str(uuid.uuid4()), id, 30, 4))
                    execute_statement(
                        connection,
                        "INSERT INTO operational_profile_observations (id, operational_profile, users, frequency) VALUES (?, ?, ?, ?)",
                        (str(uuid.uuid4()), id, 31, 4))
                    execute_statement(
                        connection,
                        "INSERT INTO operational_profile_observations (id, operational_profile, users, frequency) VALUES (?, ?, ?, ?)",
                        (str(uuid.uuid4()), id, 32, 8))
                    execute_statement(
                        connection,
                        "INSERT INTO operational_profile_observations (id, operational_profile, users, frequency) VALUES (?, ?, ?, ?)",
                        (str(uuid.uuid4()), id, 33, 7))
                    execute_statement(
                        connection,
                        "INSERT INTO operational_profile_observations (id, operational_profile, users, frequency) VALUES (?, ?, ?, ?)",
                        (str(uuid.uuid4()), id, 34, 7))
                    execute_statement(
                        connection,
                        "INSERT INTO operational_profile_observations (id, operational_profile, users, frequency) VALUES (?, ?, ?, ?)",
                        (str(uuid.uuid4()), id, 35, 7))
                    execute_statement(
                        connection,
                        "INSERT INTO operational_profile_observations (id, operational_profile, users, frequency) VALUES (?, ?, ?, ?)",
                        (str(uuid.uuid4()), id, 36, 7))
                    execute_statement(
                        connection,
                        "INSERT INTO operational_profile_observations (id, operational_profile, users, frequency) VALUES (?, ?, ?, ?)",
                        (str(uuid.uuid4()), id, 37, 6))
                    execute_statement(
                        connection,
                        "INSERT INTO operational_profile_observations (id, operational_profile, users, frequency) VALUES (?, ?, ?, ?)",
                        (str(uuid.uuid4()), id, 38, 5))
                    execute_statement(
                        connection,
                        "INSERT INTO operational_profile_observations (id, operational_profile, users, frequency) VALUES (?, ?, ?, ?)",
                        (str(uuid.uuid4()), id, 39, 1))
                    execute_statement(
                        connection,
                        "INSERT INTO operational_profile_observations (id, operational_profile, users, frequency) VALUES (?, ?, ?, ?)",
                        (str(uuid.uuid4()), id, 40, 4))
                    execute_statement(
                        connection,
                        "INSERT INTO operational_profile_observations (id, operational_profile, users, frequency) VALUES (?, ?, ?, ?)",
                        (str(uuid.uuid4()), id, 41, 3))
                    execute_statement(
                        connection,
                        "INSERT INTO operational_profile_observations (id, operational_profile, users, frequency) VALUES (?, ?, ?, ?)",
                        (str(uuid.uuid4()), id, 42, 3))
                    execute_statement(
                        connection,
                        "INSERT INTO operational_profile_observations (id, operational_profile, users, frequency) VALUES (?, ?, ?, ?)",
                        (str(uuid.uuid4()), id, 43, 4))
                    execute_statement(
                        connection,
                        "INSERT INTO operational_profile_observations (id, operational_profile, users, frequency) VALUES (?, ?, ?, ?)",
                        (str(uuid.uuid4()), id, 45, 10))
                    execute_statement(
                        connection,
                        "INSERT INTO operational_profile_observations (id, operational_profile, users, frequency) VALUES (?, ?, ?, ?)",
                        (str(uuid.uuid4()), id, 50, 13))
                    execute_statement(
                        connection,
                        "INSERT INTO operational_profile_observations (id, operational_profile, users, frequency) VALUES (?, ?, ?, ?)",
                        (str(uuid.uuid4()), id, 55, 21))
                    execute_statement(
                        connection,
                        "INSERT INTO operational_profile_observations (id, operational_profile, users, frequency) VALUES (?, ?, ?, ?)",
                        (str(uuid.uuid4()), id, 57, 10))
                    execute_statement(
                        connection,
                        "INSERT INTO operational_profile_observations (id, operational_profile, users, frequency) VALUES (?, ?, ?, ?)",
                        (str(uuid.uuid4()), id, 60, 20))
                    execute_statement(
                        connection,
                        "INSERT INTO operational_profile_observations (id, operational_profile, users, frequency) VALUES (?, ?, ?, ?)",
                        (str(uuid.uuid4()), id, 65, 12))
                    execute_statement(
                        connection,
                        "INSERT INTO operational_profile_observations (id, operational_profile, users, frequency) VALUES (?, ?, ?, ?)",
                        (str(uuid.uuid4()), id, 70, 19))
                    execute_statement(
                        connection,
                        "INSERT INTO operational_profile_observations (id, operational_profile, users, frequency) VALUES (?, ?, ?, ?)",
                        (str(uuid.uuid4()), id, 75, 25))
                    execute_statement(
                        connection,
                        "INSERT INTO operational_profile_observations (id, operational_profile, users, frequency) VALUES (?, ?, ?, ?)",
                        (str(uuid.uuid4()), id, 80, 28))
                    execute_statement(
                        connection,
                        "INSERT INTO operational_profile_observations (id, operational_profile, users, frequency) VALUES (?, ?, ?, ?)",
                        (str(uuid.uuid4()), id, 85, 26))
                    execute_statement(
                        connection,
                        "INSERT INTO operational_profile_observations (id, operational_profile, users, frequency) VALUES (?, ?, ?, ?)",
                        (str(uuid.uuid4()), id, 90, 18))
                    execute_statement(
                        connection,
                        "INSERT INTO operational_profile_observations (id, operational_profile, users, frequency) VALUES (?, ?, ?, ?)",
                        (str(uuid.uuid4()), id, 95, 16))
                    execute_statement(
                        connection,
                        "INSERT INTO operational_profile_observations (id, operational_profile, users, frequency) VALUES (?, ?, ?, ?)",
                        (str(uuid.uuid4()), id, 100, 17))
Ejemplo n.º 9
0
def store_test(test_path):
    logging.info(f"Storing test {test_path}.")

    configuration = configparser.ConfigParser()
    configuration.read([os.path.join(test_path, "configuration.ini")])

    project_name = configuration["CONFIGURATION"]["PROJECT_NAME"]
    test_set_name = configuration["CONFIGURATION"]["TEST_SET_NAME"]
    test_name = configuration["CONFIGURATION"]["TEST_NAME"]
    created_at = datetime.fromtimestamp(math.trunc(float(configuration["CONFIGURATION"]["TIMESTAMP"])))

    if not os.path.exists("pptam.db"):
        logging.debug(f"Creating database since pptam.db does not exist.")
        init_db()

    with contextlib.closing(sqlite3.connect("pptam.db")) as connection:
        with connection:
            project_id = create_or_get_project(connection, project_name)

            execute_statement(connection, "DELETE FROM tests WHERE project = ? AND name = ?;", (project_id, test_name))
            test_id = create_or_get_test(connection, project_id, test_name, created_at)

            logging.debug(f"Adding test with the id {test_id} and name {test_name}.")

            for item in configuration["CONFIGURATION"]:
                execute_statement(connection, "INSERT INTO test_properties (id, test, name, value) VALUES (?, ?, ?, ?);", (str(uuid.uuid4()), test_id, item, configuration["CONFIGURATION"][item]))

            summary_statistics_path = os.path.join(test_path, "result_stats.csv")
            if os.path.exists(summary_statistics_path):
                logging.debug(f"Reading {summary_statistics_path}.")

                # Get aggregated values first
                total_number_of_requests = 0.0
                with open(summary_statistics_path, newline="") as csvfile:
                    reader = csv.DictReader(csvfile, delimiter=",", quotechar='"')
                    for row in reader:
                        if row["Name"] == "Aggregated":
                            total_number_of_requests = float(row["Request Count"])

                with open(summary_statistics_path, newline="") as csvfile:
                    reader = csv.DictReader(csvfile, delimiter=",", quotechar='"')
                    for row in reader:
                        if row["Name"] != "Aggregated":
                            if "Request Count" in row and row["Request Count"] != "N/A":
                                execute_statement(connection, f"INSERT INTO results (id, test, item, metric, value, created_at) VALUES (?, ?, ?, ?, ?, ?);", (str(uuid.uuid4()), test_id, create_or_get_item(connection, project_id, row["Name"]), get_metric(connection, "rc"), float(row["Request Count"]), created_at))

                                mix = float(row["Request Count"]) / total_number_of_requests
                                execute_statement(connection, f"INSERT INTO results (id, test, item, metric, value, created_at) VALUES (?, ?, ?, ?, ?, ?);", (str(uuid.uuid4()), test_id, create_or_get_item(connection, project_id, row["Name"]), get_metric(connection, "mix"), mix, created_at))

                            if "Failure Count" in row and row["Failure Count"] != "N/A":
                                execute_statement(connection, f"INSERT INTO results (id, test, item, metric, value, created_at) VALUES (?, ?, ?, ?, ?, ?);", (str(uuid.uuid4()), test_id, create_or_get_item(connection, project_id, row["Name"]), get_metric(connection, "fc"), float(row["Failure Count"]), created_at))
                            if "Median Response Time" in row and row["Median Response Time"] != "N/A":
                                execute_statement(connection, f"INSERT INTO results (id, test, item, metric, value, created_at) VALUES (?, ?, ?, ?, ?, ?);", (str(uuid.uuid4()), test_id, create_or_get_item(connection, project_id, row["Name"]), get_metric(connection, "mrt"), float(row["Median Response Time"]), created_at))
                            if "Average Response Time" in row and row["Average Response Time"] != "N/A":
                                execute_statement(connection, f"INSERT INTO results (id, test, item, metric, value, created_at) VALUES (?, ?, ?, ?, ?, ?);", (str(uuid.uuid4()), test_id, create_or_get_item(connection, project_id, row["Name"]), get_metric(connection, "art"), float(row["Average Response Time"]), created_at))
                            if "Min Response Time" in row and row["Min Response Time"] != "N/A":
                                execute_statement(connection, f"INSERT INTO results (id, test, item, metric, value, created_at) VALUES (?, ?, ?, ?, ?, ?);", (str(uuid.uuid4()), test_id, create_or_get_item(connection, project_id, row["Name"]), get_metric(connection, "minrt"), float(row["Min Response Time"]), created_at))
                            if "Max Response Time" in row and row["Max Response Time"] != "N/A":
                                execute_statement(connection, f"INSERT INTO results (id, test, item, metric, value, created_at) VALUES (?, ?, ?, ?, ?, ?);", (str(uuid.uuid4()), test_id, create_or_get_item(connection, project_id, row["Name"]), get_metric(connection, "maxrt"), float(row["Max Response Time"]), created_at))
                            if "Average Content Size" in row and row["Average Content Size"] != "N/A":
                                execute_statement(connection, f"INSERT INTO results (id, test, item, metric, value, created_at) VALUES (?, ?, ?, ?, ?, ?);", (str(uuid.uuid4()), test_id, create_or_get_item(connection, project_id, row["Name"]), get_metric(connection, "acs"), float(row["Average Content Size"]), created_at))
                            if "Requests/s" in row and row["Requests/s"] != "N/A":
                                execute_statement(connection, f"INSERT INTO results (id, test, item, metric, value, created_at) VALUES (?, ?, ?, ?, ?, ?);", (str(uuid.uuid4()), test_id, create_or_get_item(connection, project_id, row["Name"]), get_metric(connection, "rps"), float(row["Requests/s"]), created_at))
                            if "Failures/s" in row and row["Failures/s"] != "N/A":
                                execute_statement(connection, f"INSERT INTO results (id, test, item, metric, value, created_at) VALUES (?, ?, ?, ?, ?, ?);", (str(uuid.uuid4()), test_id, create_or_get_item(connection, project_id, row["Name"]), get_metric(connection, "fps"), float(row["Failures/s"]), created_at))
                            if "Standard Deviation Response Time" in row and row["Standard Deviation Response Time"] != "N/A":
                                execute_statement(connection, f"INSERT INTO results (id, test, item, metric, value, created_at) VALUES (?, ?, ?, ?, ?, ?);", (str(uuid.uuid4()), test_id, create_or_get_item(connection, project_id, row["Name"]), get_metric(connection, "sdrt"), float(row["Standard Deviation Response Time"]), created_at))
                            else:
                                if row["25%"] != "N/A" and row["75%"] != "N/A":
                                    # https://bmcmedresmethodol.biomedcentral.com/articles/10.1186/1471-2288-14-135
                                    q1 = float(row["25%"])
                                    q3 = float(row["75%"])
                                    estimated_sd = (q3 - q1) / 1.35
                                    execute_statement(connection, f"INSERT INTO results (id, test, item, metric, value, created_at) VALUES (?, ?, ?, ?, ?, ?);", (str(uuid.uuid4()), test_id, create_or_get_item(connection, project_id, row["Name"]), get_metric(connection, "sdrt"), estimated_sd, created_at))

            history_statistics_path = os.path.join(test_path, "result_stats_history.csv")
            if os.path.exists(history_statistics_path):
                logging.debug(f"Reading {history_statistics_path}.")
                with open(history_statistics_path, newline="") as csvfile:
                    reader = csv.DictReader(csvfile, delimiter=",", quotechar='"')
                    for row in reader:
                        if row["Name"] != "Aggregated":
                            created_at = datetime.fromtimestamp(int(row["Timestamp"]))
                            if "User Count" in row and row["User Count"] != "N/A":
                                execute_statement(connection, f"INSERT INTO results (id, test, item, metric, value, created_at) VALUES (?, ?, ?, ?, ?, ?);", (str(uuid.uuid4()), test_id, create_or_get_item(connection, project_id, row["Name"]), get_metric(connection, "iuc"), float(row["User Count"]), created_at))
                            if "Total Request Count" in row and row["Total Request Count"] != "N/A":
                                execute_statement(connection, f"INSERT INTO results (id, test, item, metric, value, created_at) VALUES (?, ?, ?, ?, ?, ?);", (str(uuid.uuid4()), test_id, create_or_get_item(connection, project_id, row["Name"]), get_metric(connection, "irc"), float(row["Total Request Count"]), created_at))
                            if "Total Failure Count" in row and row["Total Failure Count"] != "N/A":
                                execute_statement(connection, f"INSERT INTO results (id, test, item, metric, value, created_at) VALUES (?, ?, ?, ?, ?, ?);", (str(uuid.uuid4()), test_id, create_or_get_item(connection, project_id, row["Name"]), get_metric(connection, "ifc"), float(row["Total Failure Count"]), created_at))
                            if "Total Median Response Time" in row and row["Total Median Response Time"] != "N/A":
                                execute_statement(connection, f"INSERT INTO results (id, test, item, metric, value, created_at) VALUES (?, ?, ?, ?, ?, ?);", (str(uuid.uuid4()), test_id, create_or_get_item(connection, project_id, row["Name"]), get_metric(connection, "imrt"), float(row["Total Median Response Time"]), created_at))
                            if "Total Average Response Time" in row and row["Total Average Response Time"] != "N/A":
                                execute_statement(connection, f"INSERT INTO results (id, test, item, metric, value, created_at) VALUES (?, ?, ?, ?, ?, ?);", (str(uuid.uuid4()), test_id, create_or_get_item(connection, project_id, row["Name"]), get_metric(connection, "iart"), float(row["Total Average Response Time"]), created_at))
                            if "Total Min Response Time" in row and row["Total Min Response Time"] != "N/A":
                                execute_statement(connection, f"INSERT INTO results (id, test, item, metric, value, created_at) VALUES (?, ?, ?, ?, ?, ?);", (str(uuid.uuid4()), test_id, create_or_get_item(connection, project_id, row["Name"]), get_metric(connection, "iminrt"), float(row["Total Min Response Time"]), created_at))
                            if "TotalMax Response Time" in row and row["TotalMax Response Time"] != "N/A":
                                execute_statement(connection, f"INSERT INTO results (id, test, item, metric, value, created_at) VALUES (?, ?, ?, ?, ?, ?);", (str(uuid.uuid4()), test_id, create_or_get_item(connection, project_id, row["Name"]), get_metric(connection, "imaxrt"), float(row["TotalMax Response Time"]), created_at))
                            if "Total Average Content Size" in row and row["Total Average Content Size"] != "N/A":
                                execute_statement(connection, f"INSERT INTO results (id, test, item, metric, value, created_at) VALUES (?, ?, ?, ?, ?, ?);", (str(uuid.uuid4()), test_id, create_or_get_item(connection, project_id, row["Name"]), get_metric(connection, "iacs"), float(row["Total Average Content Size"]), created_at))
                            if "Requests/s" in row and row["Requests/s"] != "N/A":
                                execute_statement(connection, f"INSERT INTO results (id, test, item, metric, value, created_at) VALUES (?, ?, ?, ?, ?, ?);", (str(uuid.uuid4()), test_id, create_or_get_item(connection, project_id, row["Name"]), get_metric(connection, "irps"), float(row["Requests/s"]), created_at))
                            if "Failures/s" in row and row["Failures/s"] != "N/A":
                                execute_statement(connection, f"INSERT INTO results (id, test, item, metric, value, created_at) VALUES (?, ?, ?, ?, ?, ?);", (str(uuid.uuid4()), test_id, create_or_get_item(connection, project_id, row["Name"]), get_metric(connection, "ifps"), float(row["Failures/s"]), created_at))

            if test_set_name != "":
                logging.debug(f"Assigning test to test set {test_set_name}.")
                test_set_id = create_or_get_test_set(connection, project_id, test_set_name)
                execute_statement(connection, "INSERT INTO test_set_tests (id, test_set, test) VALUES (?, ?, ?);", (str(uuid.uuid4()), test_set_id, test_id))