コード例 #1
0
def test_default_reading(started_cluster):
    assert None != dictionary_node.get_process_pid("clickhouse"), "ClickHouse must be alive"

    # Key 0 is not in dictionary, so default value will be returned

    def test_helper():
        assert '42' == main_node.query("select dictGetOrDefault('experimental_dict', 'i8',  toUInt64(13),  toInt8(42));").rstrip()
        assert '42' == main_node.query("select dictGetOrDefault('experimental_dict', 'i16', toUInt64(13),  toInt16(42));").rstrip()
        assert '42' == main_node.query("select dictGetOrDefault('experimental_dict', 'i32', toUInt64(13),  toInt32(42));").rstrip()
        assert '42' == main_node.query("select dictGetOrDefault('experimental_dict', 'i64', toUInt64(13),  toInt64(42));").rstrip()
        assert '42' == main_node.query("select dictGetOrDefault('experimental_dict', 'u8',  toUInt64(13),  toUInt8(42));").rstrip()
        assert '42' == main_node.query("select dictGetOrDefault('experimental_dict', 'u16', toUInt64(13),  toUInt16(42));").rstrip()
        assert '42' == main_node.query("select dictGetOrDefault('experimental_dict', 'u32', toUInt64(13),  toUInt32(42));").rstrip()
        assert '42' == main_node.query("select dictGetOrDefault('experimental_dict', 'u64', toUInt64(13),  toUInt64(42));").rstrip()

    test_helper()

    with PartitionManager() as pm, ClickHouseKiller(dictionary_node):
        assert None == dictionary_node.get_process_pid("clickhouse"), "ClickHouse must be alive"

        # Remove connection between main_node and dictionary for sure
        pm.heal_all()
        pm.partition_instances(main_node, dictionary_node)

        # Dictionary max lifetime is 2 seconds.
        time.sleep(3)

        test_helper()
コード例 #2
0
def test_simple_dict_get(started_cluster):
    assert None != dictionary_node.get_process_pid("clickhouse"), "ClickHouse must be alive"

    def test_helper():
        assert '7' == main_node.query("select dictGet('anime_dict', 'i8',  toUInt64(7));").rstrip(), "Wrong answer."
        assert '7' == main_node.query("select dictGet('anime_dict', 'i16', toUInt64(7));").rstrip(), "Wrong answer."
        assert '7' == main_node.query("select dictGet('anime_dict', 'i32', toUInt64(7));").rstrip(), "Wrong answer."
        assert '7' == main_node.query("select dictGet('anime_dict', 'i64', toUInt64(7));").rstrip(), "Wrong answer."
        assert '7' == main_node.query("select dictGet('anime_dict', 'u8',  toUInt64(7));").rstrip(), "Wrong answer."
        assert '7' == main_node.query("select dictGet('anime_dict', 'u16', toUInt64(7));").rstrip(), "Wrong answer."
        assert '7' == main_node.query("select dictGet('anime_dict', 'u32', toUInt64(7));").rstrip(), "Wrong answer."
        assert '7' == main_node.query("select dictGet('anime_dict', 'u64', toUInt64(7));").rstrip(), "Wrong answer."

    test_helper()

    with PartitionManager() as pm, ClickHouseKiller(dictionary_node):
        assert None == dictionary_node.get_process_pid("clickhouse")

        # Remove connection between main_node and dictionary for sure
        pm.heal_all()
        pm.partition_instances(main_node, dictionary_node)

        # Dictionary max lifetime is 2 seconds.
        time.sleep(3)

        test_helper()
コード例 #3
0
def test_simple_dict_get_or_default(started_cluster):
    assert None != dictionary_node.get_process_pid(
        "clickhouse"), "ClickHouse must be alive"

    def test_helper():
        assert ("5" == main_node.query(
            "select dictGetOrDefault('experimental_dict', 'i8',  toUInt64(5),  toInt8(42));"
        ).rstrip())
        assert ("5" == main_node.query(
            "select dictGetOrDefault('experimental_dict', 'i16', toUInt64(5),  toInt16(42));"
        ).rstrip())
        assert ("5" == main_node.query(
            "select dictGetOrDefault('experimental_dict', 'i32', toUInt64(5),  toInt32(42));"
        ).rstrip())
        assert ("5" == main_node.query(
            "select dictGetOrDefault('experimental_dict', 'i64', toUInt64(5),  toInt64(42));"
        ).rstrip())
        assert ("5" == main_node.query(
            "select dictGetOrDefault('experimental_dict', 'u8',  toUInt64(5),  toUInt8(42));"
        ).rstrip())
        assert ("5" == main_node.query(
            "select dictGetOrDefault('experimental_dict', 'u16', toUInt64(5),  toUInt16(42));"
        ).rstrip())
        assert ("5" == main_node.query(
            "select dictGetOrDefault('experimental_dict', 'u32', toUInt64(5),  toUInt32(42));"
        ).rstrip())
        assert ("5" == main_node.query(
            "select dictGetOrDefault('experimental_dict', 'u64', toUInt64(5),  toUInt64(42));"
        ).rstrip())

    test_helper()

    with PartitionManager() as pm, ClickHouseKiller(dictionary_node):
        assert None == dictionary_node.get_process_pid("clickhouse")

        # Remove connection between main_node and dictionary for sure
        pm.partition_instances(main_node, dictionary_node)

        # Dictionary max lifetime is 2 seconds.
        time.sleep(3)

        test_helper()