user_port_pool = (("10.5.45.19", port)
                      for port in range(13000, 13000 + number_of_users))

    call_taker_ip_pool = (("10.5.45." + str(i), 5566)
                          for i in range(20, 20 + number_of_call_takers))

    try:
        for user, call_taker in zip(users, call_takers):
            setup(user, call_taker, secondaryNumbers, user_port_pool,
                  call_taker_ip_pool)
            sleep(0.5)

        # flow(user_pool, call_taker_pool, call_takers, secondary_line_pool)
        # sleep(15)
        # flow(user_pool, call_taker_pool, call_takers, secondary_line_pool)

        test = util.Load(flow,
                         user_pool,
                         call_taker_pool,
                         call_takers,
                         secondary_line_pool,
                         duration=-1,
                         quantity=1,
                         interval=2)
        test.start()
        test.monitor()
    finally:
        for user, call_taker in zip(users, call_takers):
            tear_down(user, call_taker)
    callers = ["302102310" + "%03d" % i for i in range(NumberOfCallers)]
    agents = ["302118840" + "%03d" % i for i in range(NumberOfAgents)]
    link = ConnectSip(callers, baseLocalPort=6280)
    link.update(ConnectSip(agents, baseLocalPort=6280 + NumberOfCallers))
    try:
        for user in callers + agents:
            Register(user)
            sleep(0.1)

        for agent in agents:
            agentThreads.append(util.serverThread(WaitForCall, user))
            sleep(0.1)

        test = util.Load(flow,
                         util.loop(callers),
                         duration=0,
                         quantity=calls,
                         interval=secondsPer)

    finally:
        for user in userPool:
            Unregister(user)
            link[user] = None
            sleep(0.1)
        print("Unregister done")
        # join all threads
        for thread in agentThreads:
            thread.result()
    # Close the connection
    #C.close()
    # If I don't though, the socket remains open, else it goes into TIME_WAIT for 3 minutes
Beispiel #3
0
    m = buildMessage(message["200_OK_1"], parameters)
    for h in ("To", "From", "CSeq", "Via", "Call-ID"):
        m[h] = Bye[h]
    #print(m)
    link[userb].send(m.contents())


if __name__ == "__main__":
    NumberOfUsers = 10
    calls = 1
    secondsPer = 3
    userPool = ["302128810" + "%03d" % i for i in range(NumberOfUsers)]
    link = Connect(userPool, baseLocalPort=6280)
    for user in userPool:
        Register(user)
        sleep(0.1)

    test = util.Load(flow,
                     util.loop(userPool),
                     duration=60,
                     quantity=calls,
                     interval=secondsPer)

    for user in userPool:
        Unregister(user)
        sleep(0.1)

    # Close the connection
    #C.close()
    # If I don't though, the socket remains open, else it goes into TIME_WAIT for 3 minutes
Beispiel #4
0
                          for i in range(20, 20 + number_of_call_takers))
    agentThreads = []

    try:
        for user, call_taker in zip(users, call_takers):
            setup(user, call_taker, secondary_numbers, user_port_pool,
                  call_taker_ip_pool, 3600)
            sleep(0.5)

        for call_taker, secondary_line in zip(call_takers, secondary_lines):
            call_taker.shutdown = False
            agentThreads.append(
                util.serverThread(wait_for_call, call_taker, secondary_line))
            sleep(0.1)

        test = util.Load(flow,
                         user_pool,
                         secondary_line_pool,
                         duration=5 * 60 * 60,
                         quantity=1,
                         interval=2)
        test.start()
        test.monitor()
    finally:
        for user, call_taker in zip(users, call_takers):
            call_taker.shutdown = True
            tear_down(user, call_taker)

        for thread in agentThreads:
            thread.result()
Beispiel #5
0
            "{} in call with {}".format(call[0].number, call[1].number)
            for call in csta_server.calls
        ])


if __name__ == "__main__":
    HOST, PORT = "localhost", 9999
    MockCSTATCP = CstaServer(HOST, PORT)
    MockCSTATCP.serve_in_background()
    MockCSTATCP.on("MakeCall", handle_make_call)
    MockCSTATCP.on("ClearConnection", handle_clear_connection)
    MockCSTATCP.calls = []  # will store active calls here
    A = CstaApplication()
    A.connect(("localhost", 0), (HOST, PORT), "tcp")
    statistics_thread = threading.Thread(target=statistics,
                                         args=(MockCSTATCP, A))
    statistics_thread.start()
    users = [str(i + 1000) for i in range(20)]
    user_pool = cycle(users)
    startup(A, users)
    test = util.Load(make_call,
                     A,
                     user_pool,
                     4,
                     duration=10,
                     quantity=5,
                     interval=1)
    test.start()
    test.monitor()
    MockCSTATCP.wait_shutdown()