示例#1
0
def run_test():
    for testconfig in testconfigs:
        utils.print_test_section_separator()
        utils.pmdastatsd_install(testconfig)
        for payload in payloads:
            sock.sendto("test_gauge:{}|g".format(payload).encode("utf-8"),
                        (ip, port))
        utils.print_metric("statsd.pmda.dropped")
        utils.print_metric('statsd.test_gauge')
        overflow_payload = sys.float_info.max
        sock.sendto(
            "test_gauge2:+{}|g".format(overflow_payload).encode("utf-8"),
            (ip, port))
        utils.print_metric("statsd.pmda.dropped")
        utils.print_metric("statsd.test_gauge2")
        sock.sendto(
            "test_gauge2:+{}|g".format(overflow_payload).encode("utf-8"),
            (ip, port))
        utils.print_metric("statsd.pmda.dropped")
        utils.print_metric("statsd.test_gauge2")
        underflow_payload = sys.float_info.max * -1.0
        sock.sendto(
            "test_gauge3:{}|g".format(underflow_payload).encode("utf-8"),
            (ip, port))
        utils.print_metric("statsd.pmda.dropped")
        utils.print_metric("statsd.test_gauge3")
        sock.sendto(
            "test_gauge3:{}|g".format(underflow_payload).encode("utf-8"),
            (ip, port))
        utils.print_metric("statsd.pmda.dropped")
        utils.print_metric("statsd.test_gauge3")
        utils.pmdastatsd_remove()
        utils.restore_config()
示例#2
0
def run_test():
    utils.print_test_section_separator()
    utils.pmdastatsd_install(debug_output_filename1)
    for payload in payloads:
        sock.sendto(payload.encode("utf-8"), (ip, port))
    pmdastatsd_pids = utils.get_pmdastatsd_pids()
    time.sleep(5)
    for pid in pmdastatsd_pids:
        utils.send_debug_output_signal(pid)
    time.sleep(5)
    debug_output = utils.get_debug_file("debug")
    print(debug_output)
    utils.pmdastatsd_remove()
    utils.restore_config()
    utils.remove_debug_file("debug")

    utils.pmdastatsd_install(debug_output_filename2)
    for payload in payloads:
        sock.sendto(payload.encode("utf-8"), (ip, port))
    pmdastatsd_pids = utils.get_pmdastatsd_pids()
    time.sleep(5)
    for pid in pmdastatsd_pids:
        utils.send_debug_output_signal(pid)
    time.sleep(5)
    debug_output = utils.get_debug_file("debug_test")
    print(debug_output)
    utils.pmdastatsd_remove()
    utils.restore_config()
    utils.remove_debug_file("debug_test")
示例#3
0
文件: 04.py 项目: yvk2493/pcp
def run_test():
    for testconfig in testconfigs:
        utils.print_test_section_separator()
        utils.pmdastatsd_install(testconfig)
        for payload in payloads:
            sock.sendto(payload.encode("utf-8"), (ip, port))
        utils.print_metric('statsd.pmda.received')
        utils.print_metric('statsd.pmda.parsed')
        utils.print_metric('statsd.pmda.aggregated')
        utils.print_metric('statsd.pmda.dropped')
        time_spent_parsing = utils.request_metric(
            'statsd.pmda.time_spent_parsing')
        if time_spent_parsing:
            val = extract_value(time_spent_parsing)
            if not val == "value 0":
                print("time_spent_parsing is not 0")
            else:
                print("time_spent_parsing is 0")
        time_spent_aggregating = utils.request_metric(
            'statsd.pmda.time_spent_aggregating')
        if time_spent_aggregating:
            val = extract_value(time_spent_aggregating)
            if not val == "value 0":
                print("time_spent_aggregating is not 0")
            else:
                print("time_spent_aggregating is 0")
        utils.print_metric('statsd.pmda.metrics_tracked')
        utils.pmdastatsd_remove()
        utils.restore_config()
示例#4
0
def run_test():
    utils.print_test_section_separator()
    utils.pmdastatsd_install(basic_duration_aggregation)
    for x in range(1, 101):
        sock.sendto("test_duration:{}|ms".format(x).encode("utf-8"),
                    (ip, port))
    utils.print_metric("statsd.test_duration")
    utils.pmdastatsd_remove()
    utils.restore_config()
示例#5
0
def run_test():
    utils.print_test_section_separator()
    utils.pmdastatsd_install()
    utils.print_metric('statsd.pmda.received')
    utils.print_metric('statsd.pmda.parsed')
    utils.print_metric('statsd.pmda.aggregated')
    utils.print_metric('statsd.pmda.dropped')
    utils.print_metric('statsd.pmda.time_spent_parsing')
    utils.print_metric('statsd.pmda.time_spent_aggregating')
    utils.print_metric('statsd.pmda.metrics_tracked')
    utils.pmdastatsd_remove()
    utils.restore_config()
示例#6
0
def run_test():
    utils.print_test_section_separator()
    utils.pmdastatsd_install()
    pminfo_metrics = utils.pminfo("statsd")
    before_metric_count = len(pminfo_metrics.split('\n')) - 1

    def thread_fun1():
        for i in range(1, n + 1):
            sock.sendto("test_thread1_counter:1|c".encode("utf-8"), (ip, port))

    def thread_fun2():
        for i in range(1, n + 1):
            sock.sendto("test_thread2_counter:2|c".encode("utf-8"), (ip, port))

    def thread_fun3():
        for i in range(1, n + 1):
            sock.sendto(
                "test_thread3_gauge:+{}|g".format(uniform(
                    1.0, 100.0)).encode("utf-8"), (ip, port))

    def thread_fun4():
        for i in range(1, n + 1):
            sock.sendto(
                "test_thread4_ms:{}|ms".format(uniform(0, 1)).encode("utf-8"),
                (ip, port))

    thread1 = Thread(target=thread_fun1)
    thread2 = Thread(target=thread_fun2)
    thread3 = Thread(target=thread_fun3)
    thread4 = Thread(target=thread_fun4)

    thread1.start()
    thread2.start()
    thread3.start()
    thread4.start()

    thread1.join()
    thread2.join()
    thread3.join()
    thread4.join()

    after_result = utils.pminfo("statsd")
    after_metric_tracked_count = len(after_result.split('\n')) - 1
    if before_metric_count + 4 == after_metric_tracked_count:
        print("OK. +4 metrics, none lost.")
    else:
        print("FAIL, some metrics were lost / none were added.")

    utils.pmdastatsd_remove()
    utils.restore_config()
示例#7
0
文件: 11.py 项目: yvk2493/pcp
def run_test():
    utils.print_test_section_separator()
    utils.pmdastatsd_install(port_a_config)
    sock.sendto("test_port_a:1|c".encode("utf-8"), (ip, port_a))
    print("Testing port {}".format(port_a))
    utils.print_metric("statsd.test_port_a")
    utils.pmdastatsd_remove()
    utils.restore_config()
    utils.pmdastatsd_install(port_b_config)
    sock.sendto("test_port_b:1|c".encode("utf-8"), (ip, port_b))
    print("Testing port {}".format(port_b))
    utils.print_metric("statsd.test_port_b")
    utils.pmdastatsd_remove()
    utils.restore_config()
示例#8
0
文件: 09.py 项目: infinera/pcp
def run_test():
    utils.print_test_section_separator()
    utils.pmdastatsd_install(hdr_duration_aggregation)
    for i in range(0, 10000001):
        sock.sendto("test_hdr:{}|ms".format(i * 2).encode("utf-8"), (ip, port))
    labels_output = utils.request_metric("statsd.test_hdr")
    output = utils.get_instances(labels_output)
    for k, v in output.items():
        status = False
        number_value = float(v)
        sys.stderr.write(k + ' = ' + str(number_value) + '\n')
        if k == "/average":
            if utils.check_is_in_bounds(expected_average, number_value):
                status = True
        elif k == "/count":
            if utils.check_is_in_range(expected_count_max, expected_count_min, number_value):
                status = True
        elif k == "/max":
            if utils.check_is_in_bounds(expected_max, number_value):
                status = True
        elif k == "/median":
            if utils.check_is_in_bounds(expected_median, number_value):
                status = True
        elif k == "/min":
            if utils.check_is_in_bounds(expected_min, number_value):
                status = True
        elif k == "/percentile90":
            if utils.check_is_in_bounds(expected_percentile90, number_value):
                status = True
        elif k == "/percentile95":
            if utils.check_is_in_bounds(expected_percentile95, number_value):
                status = True
        elif k == "/percentile99":
            if utils.check_is_in_bounds(expected_percentile99, number_value):
                status = True
        elif k == "/std_deviation":
            if utils.check_is_in_bounds(expected_stddev, number_value):
                status = True
        if status:
            print(k, "OK")
        else:
            print(k, v)
    utils.pmdastatsd_remove()
    utils.restore_config()
示例#9
0
def run_test():
    for testconfig in testconfigs:
        utils.print_test_section_separator()
        utils.pmdastatsd_install(testconfig)
        utils.print_metric("statsd.pmda.dropped")
        for payload in payloads:
            sock.sendto("test_counter:{}|c".format(payload).encode("utf-8"),
                        (ip, port))
        utils.print_metric('statsd.test_counter')
        test_payload = sys.float_info.max
        sock.sendto("test_counter2:{}|c".format(test_payload).encode("utf-8"),
                    (ip, port))
        utils.print_metric("statsd.test_counter2")
        utils.print_metric("statsd.pmda.dropped")
        sock.sendto("test_counter2:{}|c".format(test_payload).encode("utf-8"),
                    (ip, port))
        utils.print_metric("statsd.test_counter2")
        utils.print_metric("statsd.pmda.dropped")
        utils.pmdastatsd_remove()
        utils.restore_config()
示例#10
0
def run_test():
    utils.print_test_section_separator()
    utils.pmdastatsd_install(basic_duration_aggregation)
    for payload in payloads:
        sock.sendto(payload.encode("utf-8"), (ip, port))
    for x in range(1, 101):
        sock.sendto("test_labels2:{}|ms".format(x).encode("utf-8"), (ip, port))
    for x in range(1, 101):
        sock.sendto(
            "test_labels2:{}|ms|#label:X".format(x * 2).encode("utf-8"),
            (ip, port))
    labels_output = utils.request_metric("statsd.test_labels")
    output = utils.get_instances(labels_output)
    for k, v in output.items():
        print(k, v)
    labels_output = utils.request_metric("statsd.test_labels2")
    output = utils.get_instances(labels_output)
    for k, v in output.items():
        print(k, v)
    utils.pmdastatsd_remove()
    utils.restore_config()
示例#11
0
文件: 14.py 项目: yvk2493/pcp
def run_test():
    utils.print_test_section_separator()
    utils.pmdastatsd_install(maxudp_1)
    for payload in payloads:
        sock.sendto(payload.encode("utf-8"), (ip, port))
    time.sleep(1)
    utils.print_metric("statsd.pmda.metrics_tracked")
    utils.pmdastatsd_remove()
    utils.restore_config()
    utils.print_test_section_separator()
    utils.pmdastatsd_install(maxudp_2)
    for payload in payloads:
        sock.sendto(payload.encode("utf-8"), (ip, port))
    time.sleep(1)
    utils.print_metric("statsd.pmda.metrics_tracked")
    utils.pmdastatsd_remove()
    utils.restore_config()
    utils.print_test_section_separator()
    utils.pmdastatsd_install(maxudp_3)
    for payload in payloads:
        sock.sendto(payload.encode("utf-8"), (ip, port))
    time.sleep(1)
    utils.print_metric("statsd.pmda.metrics_tracked")
    utils.pmdastatsd_remove()
    utils.restore_config()
示例#12
0
def run_test():
    utils.print_test_section_separator()

    utils.pmdastatsd_install(verbosity_lvl_0)
    for payload in payloads:
        sock.sendto(payload.encode("utf-8"), (ip, port))
    # time sleep to wait for log files to be filled with logs
    time.sleep(1)
    # explicitly refresh pmns
    utils.pminfo("statsd")
    time.sleep(4)
    log_lvl_0_count = get_number_of_lines_in_file(utils.pmdastatsd_log_path)
    utils.pmdastatsd_remove()
    utils.restore_config()

    utils.pmdastatsd_install(verbosity_lvl_1)
    for payload in payloads:
        sock.sendto(payload.encode("utf-8"), (ip, port))
    time.sleep(1)
    utils.pminfo("statsd")
    time.sleep(4)
    log_lvl_1_count = get_number_of_lines_in_file(utils.pmdastatsd_log_path)
    utils.pmdastatsd_remove()
    utils.restore_config()

    utils.pmdastatsd_install(verbosity_lvl_2)
    for payload in payloads:
        sock.sendto(payload.encode("utf-8"), (ip, port))
    time.sleep(1)
    utils.pminfo("statsd")
    time.sleep(4)
    log_lvl_2_count = get_number_of_lines_in_file(utils.pmdastatsd_log_path)
    utils.pmdastatsd_remove()
    utils.restore_config()

    if log_lvl_0_count < log_lvl_1_count and log_lvl_1_count < log_lvl_2_count:
        print("Verbosity specificity is OK. (lvl 0 < lvl 1 < lvl 2)")
示例#13
0
文件: 01.py 项目: yvk2493/pcp
def run_test():
    install_output = utils.pmdastatsd_install()
    print(install_output)
    remove_output = utils.pmdastatsd_remove()
    print(remove_output)