Пример #1
0
def test_simple_dictionaries(started_cluster):
    fields = FIELDS["simple"]
    data = [
        Row(fields, [
            1, 22, 333, 4444, 55555, -6, -77, -888, -999,
            '550e8400-e29b-41d4-a716-446655440003', '1973-06-28',
            '1985-02-28 23:43:25', 'hello', 22.543, 3332154213.4, 0
        ]),
        Row(fields, [
            2, 3, 4, 5, 6, -7, -8, -9, -10,
            '550e8400-e29b-41d4-a716-446655440002', '1978-06-28',
            '1986-02-28 23:42:25', 'hello', 21.543, 3222154213.4, 1
        ]),
    ]

    simple_dicts = [
        d for d in DICTIONARIES if d.structure.layout.layout_type == "simple"
    ]
    for dct in simple_dicts:
        dct.load_data(data)

    node.query("system reload dictionaries")

    queries_with_answers = []
    for dct in simple_dicts:
        for row in data:
            for field in fields:
                if not field.is_key:
                    for query in dct.get_select_get_queries(field, row):
                        queries_with_answers.append(
                            (query, row.get_value_by_name(field.name)))

                    for query in dct.get_select_has_queries(field, row):
                        queries_with_answers.append((query, 1))

                    for query in dct.get_select_get_or_default_queries(
                            field, row):
                        queries_with_answers.append(
                            (query, field.default_value_for_get))
        for query in dct.get_hierarchical_queries(data[0]):
            queries_with_answers.append((query, [1]))

        for query in dct.get_hierarchical_queries(data[1]):
            queries_with_answers.append((query, [2, 1]))

        for query in dct.get_is_in_queries(data[0], data[1]):
            queries_with_answers.append((query, 0))

        for query in dct.get_is_in_queries(data[1], data[0]):
            queries_with_answers.append((query, 1))

    for query, answer in queries_with_answers:
        print query
        if isinstance(answer, list):
            answer = str(answer).replace(' ', '')
        assert node.query(query) == str(answer) + '\n'
Пример #2
0
def test_key_value_simple_dictionaries(started_cluster, fold):
    fields = FIELDS["simple"]
    values = VALUES["simple"]
    data = [Row(fields, vals) for vals in values]

    all_simple_dicts = [d for d in DICTIONARIES_KV if d.structure.layout.layout_type == "simple"]
    simple_dicts = get_dictionaries(fold, 10, all_simple_dicts)

    for dct in simple_dicts:
        queries_with_answers = []
        local_data = []
        for row in data:
            local_fields = dct.get_fields()
            local_values = [row.get_value_by_name(field.name) for field in local_fields if row.has_field(field.name)]
            local_data.append(Row(local_fields, local_values))

        dct.load_data(local_data)

        node.query("system reload dictionary {}".format(dct.name))

        print 'name: ', dct.name

        for row in local_data:
            print dct.get_fields()
            for field in dct.get_fields():
                print field.name, field.is_key
                if not field.is_key:
                    for query in dct.get_select_get_queries(field, row):
                        queries_with_answers.append((query, row.get_value_by_name(field.name)))

                    for query in dct.get_select_has_queries(field, row):
                        queries_with_answers.append((query, 1))

                    for query in dct.get_select_get_or_default_queries(field, row):
                        queries_with_answers.append((query, field.default_value_for_get))

        if dct.structure.has_hierarchy:
            for query in dct.get_hierarchical_queries(data[0]):
                queries_with_answers.append((query, [1]))

            for query in dct.get_hierarchical_queries(data[1]):
                queries_with_answers.append((query, [2, 1]))

            for query in dct.get_is_in_queries(data[0], data[1]):
                queries_with_answers.append((query, 0))

            for query in dct.get_is_in_queries(data[1], data[0]):
                queries_with_answers.append((query, 1))

        for query, answer in queries_with_answers:
            print query
            if isinstance(answer, list):
                answer = str(answer).replace(' ', '')
            assert node.query(query) == str(answer) + '\n'
Пример #3
0
def test_key_value_complex_dictionaries(started_cluster, fold):
    fields = FIELDS["complex"]
    values = VALUES["complex"]
    data = [Row(fields, vals) for vals in values]

    all_complex_dicts = [
        d for d in DICTIONARIES_KV
        if d.structure.layout.layout_type == "complex"
    ]
    complex_dicts = get_dictionaries(fold, 10, all_complex_dicts)
    for dct in complex_dicts:
        dct.load_data(data)

    node.query("system reload dictionaries")

    for dct in complex_dicts:
        queries_with_answers = []
        local_data = []
        for row in data:
            local_fields = dct.get_fields()
            local_values = [
                row.get_value_by_name(field.name) for field in local_fields
                if row.has_field(field.name)
            ]
            local_data.append(Row(local_fields, local_values))

        dct.load_data(local_data)

        node.query("system reload dictionary {}".format(dct.name))

        for row in local_data:
            for field in dct.get_fields():
                if not field.is_key:
                    for query in dct.get_select_get_queries(field, row):
                        queries_with_answers.append(
                            (query, row.get_value_by_name(field.name)))

                    for query in dct.get_select_has_queries(field, row):
                        queries_with_answers.append((query, 1))

                    for query in dct.get_select_get_or_default_queries(
                            field, row):
                        queries_with_answers.append(
                            (query, field.default_value_for_get))

        for query, answer in queries_with_answers:
            print query
            assert node.query(query) == str(answer) + '\n'
Пример #4
0
def test_ranged_dictionaries(started_cluster, fold):
    fields = FIELDS["ranged"]
    values = VALUES["ranged"]
    data = [Row(fields, vals) for vals in values]

    all_ranged_dicts = [
        d for d in DICTIONARIES if d.structure.layout.layout_type == "ranged"
    ]
    ranged_dicts = get_dictionaries(fold, 10, all_ranged_dicts)

    for dct in ranged_dicts:
        dct.load_data(data)

    node.query("system reload dictionaries")

    queries_with_answers = []
    for dct in ranged_dicts:
        for row in data:
            for field in fields:
                if not field.is_key and not field.is_range:
                    for query in dct.get_select_get_queries(field, row):
                        queries_with_answers.append(
                            (query, row.get_value_by_name(field.name)))

    for query, answer in queries_with_answers:
        print query
        assert node.query(query) == str(answer) + '\n'
Пример #5
0
def test_complex_dictionaries(started_cluster):
    fields = FIELDS["complex"]
    values = VALUES["complex"]
    data = [Row(fields, vals) for vals in values]

    complex_dicts = [
        d for d in DICTIONARIES if d.structure.layout.layout_type == "complex"
    ]
    for dct in complex_dicts:
        dct.load_data(data)

    node.query("system reload dictionaries")

    queries_with_answers = []
    for dct in complex_dicts:
        for row in data:
            for field in fields:
                if not field.is_key:
                    for query in dct.get_select_get_queries(field, row):
                        queries_with_answers.append(
                            (query, row.get_value_by_name(field.name)))

                    for query in dct.get_select_has_queries(field, row):
                        queries_with_answers.append((query, 1))

                    for query in dct.get_select_get_or_default_queries(
                            field, row):
                        queries_with_answers.append(
                            (query, field.default_value_for_get))

    for query, answer in queries_with_answers:
        print query
        assert node.query(query) == str(answer) + '\n'
Пример #6
0
def test_complex_dictionaries(started_cluster):
    fields = FIELDS["complex"]
    data = [
        Row(fields, [
            1, 'world', 22, 333, 4444, 55555, -6, -77, -888, -999,
            '550e8400-e29b-41d4-a716-446655440003', '1973-06-28',
            '1985-02-28 23:43:25', 'hello', 22.543, 3332154213.4
        ]),
        Row(fields, [
            2, 'qwerty2', 52, 2345, 6544, 9191991, -2, -717, -81818, -92929,
            '550e8400-e29b-41d4-a716-446655440007', '1975-09-28',
            '2000-02-28 23:33:24', 'my', 255.543, 3332221.44
        ]),
    ]

    complex_dicts = [
        d for d in DICTIONARIES if d.structure.layout.layout_type == "complex"
    ]
    for dct in complex_dicts:
        dct.load_data(data)

    node.query("system reload dictionaries")

    queries_with_answers = []
    for dct in complex_dicts:
        for row in data:
            for field in fields:
                if not field.is_key:
                    for query in dct.get_select_get_queries(field, row):
                        queries_with_answers.append(
                            (query, row.get_value_by_name(field.name)))

                    for query in dct.get_select_has_queries(field, row):
                        queries_with_answers.append((query, 1))

                    for query in dct.get_select_get_or_default_queries(
                            field, row):
                        queries_with_answers.append(
                            (query, field.default_value_for_get))

    for query, answer in queries_with_answers:
        print query
        assert node.query(query) == str(answer) + '\n'
Пример #7
0
def test_simple_dictionaries(started_cluster, fold):
    if node.is_built_with_thread_sanitizer():
        remove_mysql_dicts()

    fields = FIELDS["simple"]
    values = VALUES["simple"]
    data = [Row(fields, vals) for vals in values]

    all_simple_dicts = [
        d for d in DICTIONARIES if d.structure.layout.layout_type == "simple"
    ]
    simple_dicts = get_dictionaries(fold, 10, all_simple_dicts)

    print "Length of dicts:", len(simple_dicts)
    for dct in simple_dicts:
        dct.load_data(data)

    node.query("system reload dictionaries")

    queries_with_answers = []
    for dct in simple_dicts:
        for row in data:
            for field in fields:
                if not field.is_key:
                    for query in dct.get_select_get_queries(field, row):
                        queries_with_answers.append(
                            (query, row.get_value_by_name(field.name)))

                    for query in dct.get_select_has_queries(field, row):
                        queries_with_answers.append((query, 1))

                    for query in dct.get_select_get_or_default_queries(
                            field, row):
                        queries_with_answers.append(
                            (query, field.default_value_for_get))
        for query in dct.get_hierarchical_queries(data[0]):
            queries_with_answers.append((query, [1]))

        for query in dct.get_hierarchical_queries(data[1]):
            queries_with_answers.append((query, [2, 1]))

        for query in dct.get_is_in_queries(data[0], data[1]):
            queries_with_answers.append((query, 0))

        for query in dct.get_is_in_queries(data[1], data[0]):
            queries_with_answers.append((query, 1))

    for query, answer in queries_with_answers:
        print query
        if isinstance(answer, list):
            answer = str(answer).replace(' ', '')
        assert node.query(query) == str(answer) + '\n'
Пример #8
0
def test_ranged_dictionaries(started_cluster):
    fields = FIELDS["ranged"]
    data = [
        Row(fields, [
            1, '2019-02-10', '2019-02-01', '2019-02-28', 22, 333, 4444, 55555,
            -6, -77, -888, -999, '550e8400-e29b-41d4-a716-446655440003',
            '1973-06-28', '1985-02-28 23:43:25', 'hello', 22.543, 3332154213.4
        ]),
        Row(fields, [
            2, '2019-04-10', '2019-04-01', '2019-04-28', 11, 3223, 41444,
            52515, -65, -747, -8388, -9099,
            '550e8400-e29b-41d4-a716-446655440004', '1973-06-29',
            '2002-02-28 23:23:25', '!!!!', 32.543, 3332543.4
        ]),
    ]

    ranged_dicts = [
        d for d in DICTIONARIES if d.structure.layout.layout_type == "ranged"
    ]
    for dct in ranged_dicts:
        dct.load_data(data)

    node.query("system reload dictionaries")

    queries_with_answers = []
    for dct in ranged_dicts:
        for row in data:
            for field in fields:
                if not field.is_key and not field.is_range:
                    for query in dct.get_select_get_queries(field, row):
                        queries_with_answers.append(
                            (query, row.get_value_by_name(field.name)))

    for query, answer in queries_with_answers:
        print query
        assert node.query(query) == str(answer) + '\n'