Ejemplo n.º 1
0
def test_pub_send_pub_first():

    print("Start test: pub_send_pub_first")

    username = runtime.get_active_config("username")
    userdir = os.path.join("/home", username)
    riaps_app_path = os.path.join(userdir,
                                  runtime.get_active_config("riaps_apps_path"))
    test_app_path = os.path.join(riaps_app_path,
                                 runtime.get_active_config('app_dir'))

    pubActorName = "ActorTest1p"
    subActorName = "ActorTest1s"

    testId = "pubfirst_" + pubActorName
    deployer = runtime.get_deployer(pubActorName)
    deployer.start(
        testId,
        configs={
            'sync':
            False,
            'args': [
                os.path.join(test_app_path,
                             runtime.get_active_config('app_dir') + '.json'),
                pubActorName, '--logfile="' + testId + '.log"', '> /dev/null'
            ]
        })

    # start test, publisher comes first
    #for target in runtime.get_active_config("targets"):
    #    if target["actor"] == pubActorName:
    #        deployer = runtime.get_deployer(target["actor"])
    #        deployer.start(target["actor"], configs={"sync": False})

    sleep(2)

    testId = "pubfirst_" + subActorName
    deployer = runtime.get_deployer(subActorName)
    deployer.start(
        testId,
        configs={
            "sync":
            False,
            'args': [
                os.path.join(test_app_path,
                             runtime.get_active_config('app_dir') + '.json'),
                subActorName, '--logfile="' + testId + '.log"', '> /dev/null'
            ]
        })

    # start subscriber
    #for target in runtime.get_active_config("targets"):
    #    if target["actor"] == subActorName:
    #        deployer = runtime.get_deployer(target["actor"])
    #        deployer.start(target["actor"], configs={"sync": False})

    sleep(30)
Ejemplo n.º 2
0
def test_server_off():
  """
  Tests what happens when trying to connect when the server is off
  """
  client_deployer = runtime.get_deployer("AdditionClient")
  server_deployer = runtime.get_deployer("AdditionServer")

  server_deployer.stop("server1")
  client_deployer.start("client1", configs={"args": "localhost 8000 1 2 3".split(), "delay": 3})
Ejemplo n.º 3
0
def test_multi_basic():
  """
  Tests single client multiple runs on same server session
  """
  client_deployer = runtime.get_deployer("AdditionClient")
  server_deployer = runtime.get_deployer("AdditionServer")

  server_deployer.hard_bounce("server1")
  for i in range(0, 3):
    client_deployer.start("client1", configs={"args": "localhost 8000 1 2 3 4".split(), "delay": 3})
Ejemplo n.º 4
0
def test_fault_tolerance():
  """
  Tests what happens when servers are stopped
  """
  client_deployer = runtime.get_deployer("AdditionClient")
  server_deployer = runtime.get_deployer("AdditionServer")

  server_deployer.stop("server2")
  server_deployer.stop("server3")

  client_deployer.start("client1", configs={"args": "localhost 8000".split() + SMALL_SAMPLE, "sync": True})
Ejemplo n.º 5
0
def test_server_off():
    """
  Tests what happens when trying to connect when the server is off
  """
    client_deployer = runtime.get_deployer("AdditionClient")
    server_deployer = runtime.get_deployer("AdditionServer")

    server_deployer.stop("server1")
    client_deployer.start("client1",
                          configs={
                              "args": "localhost 8000 1 2 3".split(),
                              "delay": 3
                          })
Ejemplo n.º 6
0
def test_multi_basic():
    """
  Tests single client multiple runs on same server session
  """
    client_deployer = runtime.get_deployer("AdditionClient")
    server_deployer = runtime.get_deployer("AdditionServer")

    server_deployer.hard_bounce("server1")
    for i in range(0, 3):
        client_deployer.start("client1",
                              configs={
                                  "args": "localhost 8000 1 2 3 4".split(),
                                  "delay": 3
                              })
def test_negative_correctness():
  """
  Tests sending non-integers to the server
  """
  client_deployer = runtime.get_deployer("AdditionClient")
  client_deployer.start("client1", configs={"args": "localhost 8000 a b 3.14".split(), "sync": True})
  client_deployer.start("client2", configs={"args": "localhost 8000 a b 3.14".split(), "sync": True})
Ejemplo n.º 8
0
def test_connection():
    '''
    Must connect on machine4 and receive a string.
    '''
    print "==> Test Connection machine3 and machine4"
    client = runtime.get_deployer("client")
    client.start("client1", configs={"sync": True})
Ejemplo n.º 9
0
def test_negative_correctness():
  """
  Tests sending non-integers to the server
  """
  client_deployer = runtime.get_deployer("AdditionClient")
  client_deployer.start("client1", configs={"args": "localhost 8000 a b 3.14".split(), "sync": True})
  client_deployer.start("client2", configs={"args": "localhost 8000 a b 3.14".split(), "sync": True})
Ejemplo n.º 10
0
def teardown():
    print("Stop riaps actors...")

    # kill all the runing riaps actors
    for target in runtime.get_active_config("targets"):
        deployerId = "killer_" + target["host"]
        deployer = runtime.get_deployer(deployerId)
        deployer.start(deployerId, configs={"sync": True})

    print("Stop discovery...")
    # Stop discovery
    for target in runtime.get_active_config("targets"):
        deployerId = "discostop_" + target["host"]
        deployer = runtime.get_deployer(deployerId)
        deployer.start(deployerId, configs={"sync": True})
    sleep(10)
    print(" -- END -- ")
Ejemplo n.º 11
0
def test_single_client_perf():
  """
  Tests the performance of a server when handling single client
  """
  #Leaving the print for proof of order
  print "test_single_client_perf"
  client_deployer = runtime.get_deployer("AdditionClient")
  client_deployer.start("client1", configs={"args": "localhost 8000".split() + MEDIUM_SAMPLE, "sync": True})
Ejemplo n.º 12
0
def test_multi_client_perf():
  """
  Tests the performance of a server when handling multiple clients
  """
  client_deployer = runtime.get_deployer("AdditionClient")

  client_deployer.start("client1", configs={"args": "localhost 8000".split() + [str(i) for i in range(1, 2000)], "sync": True})
  client_deployer.start("client2", configs={"args": "localhost 8000".split() + [str(i) for i in range(1, 2000)], "sync": True})
Ejemplo n.º 13
0
def test_client_isolation():
  """
  Tests what happens when the client is faulty
  """
  client_deployer = runtime.get_deployer("AdditionClient")

  client_deployer.start("client1", configs={"args": "localhost 8000".split() + LARGE_SAMPLE})
  client_deployer.stop("client1")
Ejemplo n.º 14
0
def test_bouncing_with_state():
  """
  Tests that bouncing the server retains state
  """
  client_deployer = runtime.get_deployer("AdditionClient")
  server_deployer = runtime.get_deployer("AdditionServer")

  start_client = lambda: client_deployer.start("client1", configs={"args": "localhost 8000".split() + LARGE_SAMPLE, "sync": True})
  client_thread = threading.Thread(target=start_client)

  # create a thread that will bounce (stop and start) the server
  bounce_server = lambda: server_deployer.soft_bounce("server1")
  server_thread = threading.Thread(target=bounce_server)

  client_thread.start()
  server_thread.start()
  client_thread.join()
Ejemplo n.º 15
0
def test_ordered_events():
  """
  Tests that integers to a server are received in the same order that they are sent
  """
  client_deployer = runtime.get_deployer("AdditionClient")

  # set client to connect to localhost:8000 and send 1, 2, and 3 in that order
  client_deployer.start("client1", configs={"args": "localhost 8000 1 2 3".split(), "sync": True})
Ejemplo n.º 16
0
def await_job(package_id, job_id):
  """
  Wait for a Samza job to finish.
  """
  logger.info('Awaiting {0}.{1}'.format(package_id, job_id))
  samza_job_deployer = runtime.get_deployer(DEPLOYER)
  samza_job_deployer.await(job_id, {
    'package_id': package_id,
  })
Ejemplo n.º 17
0
def test_redlining():
  """
  Sends a large sample of integers to the server.
  """
  # obtain the deployer for AdditionClient
  client_deployer = runtime.get_deployer("AdditionClient")

  # set client to connect to localhost:8000 with a large sample
  client_deployer.start("client1", configs={"args": "localhost 8000".split() + LARGE_SAMPLE, "sync": True})
Ejemplo n.º 18
0
def await_job(package_id, job_id):
    """
  Wait for a Samza job to finish.
  """
    logger.info('Awaiting {0}.{1}'.format(package_id, job_id))
    samza_job_deployer = runtime.get_deployer(DEPLOYER)
    samza_job_deployer. await (job_id, {
        'package_id': package_id,
    })
Ejemplo n.º 19
0
def test_client_timeout():
  """
  Tests what happens when the client does not finish a full request
  """
  client_deployer = runtime.get_deployer("AdditionClient")

  start_client = lambda: client_deployer.start("client1", configs={"args": "localhost 8000".split() + LARGE_SAMPLE, "sync": True})
  timeout_client = lambda: _client_timeout(client_deployer, "client1")
  testutilities.start_threads_and_join([start_client, timeout_client])
Ejemplo n.º 20
0
def test_client_isolation():
    """
  Tests what happens when the client is faulty
  """
    client_deployer = runtime.get_deployer("AdditionClient")

    client_deployer.start(
        "client1", configs={"args": "localhost 8000".split() + LARGE_SAMPLE})
    client_deployer.stop("client1")
Ejemplo n.º 21
0
def test_load_balance():
  """
  Tests if clients perform correct load balancing
  """
  client_deployer = runtime.get_deployer("AdditionClient")

  # start the client that will send integers from 1 to 1000
  for i in range(3):
    client_deployer.start("client1", configs={"args": "localhost 8000".split() + SMALL_SAMPLE, "sync": True})
Ejemplo n.º 22
0
def setup():
    print("Start discovery service...")
    # Start discovery
    for target in runtime.get_active_config("targets"):
        deployerId = "discostart_" + target["host"]
        deployer = runtime.get_deployer(deployerId)
        deployer.start(deployerId, configs={"sync": False})
    sleep(2)

    reach_discovery()
Ejemplo n.º 23
0
def start_job(package_id, job_id, config_file):
    """
  Start a Samza job.
  """
    logger.info('Starting {0}.{1}'.format(package_id, job_id))
    samza_job_deployer = runtime.get_deployer(DEPLOYER)
    samza_job_deployer.start(job_id, {
        'package_id': package_id,
        'config_file': config_file,
    })
Ejemplo n.º 24
0
def test_ping_host1():
    print "==> ping example.com (machine1)"
    pyhk_deployer = runtime.get_deployer("pyhk")

    pyhk_deployer.start(
        "machine1",
        configs={
            "start_command": runtime.get_active_config('ping_cmd'),
            "sync": True
            })
Ejemplo n.º 25
0
def test_race_condition():
  """
  Tests what happens when two clients send requests to the same server
  """
  # obtain the deployer for AdditionClients
  client_deployer = runtime.get_deployer("AdditionClient")

  start_client1 = lambda: client_deployer.start("client1", configs={"args": "localhost 8000".split() + SMALL_SAMPLE, "sync": True})
  start_client2 = lambda: client_deployer.start("client2", configs={"args": "localhost 8000".split() + SMALL_SAMPLE, "sync": True})
  testutilities.start_threads_and_join([start_client1, start_client2])
def test_single_client_perf():
    """
  Tests the performance of a server when handling single client
  """
    client_deployer = runtime.get_deployer("AdditionClient")
    client_deployer.start("client1",
                          configs={
                              "args": "localhost 8000".split() + MEDIUM_SAMPLE,
                              "sync": True
                          })
Ejemplo n.º 27
0
def start_job(package_id, job_id, config_file):
  """
  Start a Samza job.
  """
  logger.info('Starting {0}.{1}'.format(package_id, job_id))
  samza_job_deployer = runtime.get_deployer(DEPLOYER)
  samza_job_deployer.start(job_id, {
    'package_id': package_id,
    'config_file': config_file,
  })
Ejemplo n.º 28
0
def test_no_valid_ints():
    """
  Tests sending non-integers to the server
  """
    client_deployer = runtime.get_deployer("AdditionClient")
    client_deployer.start("client1",
                          configs={
                              "args": "localhost 8000 a b 3.14".split(),
                              "delay": 3
                          })
Ejemplo n.º 29
0
def test_correctness():
  """
  Tests if the correct sums are calculated
  """
  client_deployer = runtime.get_deployer("AdditionClient")

  client_deployer.start("client1", configs={"args": "localhost 8000 1".split(), "sync": True})
  client_deployer.start("client1", configs={"args": "localhost 8001 1 2".split(), "sync": True})
  client_deployer.start("client1", configs={"args": "localhost 8002 1 2 3".split(), "sync": True})
  client_deployer.start("client2", configs={"args": "localhost 8000 1".split(), "sync": True})
  client_deployer.start("client2", configs={"args": "localhost 8001 1 2".split(), "sync": True})
  client_deployer.start("client2", configs={"args": "localhost 8002 1 2 3".split(), "sync": True})
Ejemplo n.º 30
0
def test_ordered_events():
    """
  Tests that integers to a server are received in the same order that they are sent
  """
    client_deployer = runtime.get_deployer("AdditionClient")

    # set client to connect to localhost:8000 and send 1, 2, and 3 in that order
    client_deployer.start("client1",
                          configs={
                              "args": "localhost 8000 1 2 3".split(),
                              "sync": True
                          })
Ejemplo n.º 31
0
def test_correctness():
  """
  Tests if the correct sums are calculated
  """
  client_deployer = runtime.get_deployer("AdditionClient")

  client_deployer.start("client1", configs={"args": "localhost 8000 1".split(), "sync": True})
  client_deployer.start("client1", configs={"args": "localhost 8001 1 2".split(), "sync": True})
  client_deployer.start("client1", configs={"args": "localhost 8002 1 2 3".split(), "sync": True})
  client_deployer.start("client2", configs={"args": "localhost 8000 1".split(), "sync": True})
  client_deployer.start("client2", configs={"args": "localhost 8001 1 2".split(), "sync": True})
  client_deployer.start("client2", configs={"args": "localhost 8002 1 2 3".split(), "sync": True})
Ejemplo n.º 32
0
def test_basic():
  """
  Trivial interaction between client and server
  """
  client_deployer = runtime.get_deployer("AdditionClient")

  client_deployer.start("client1", configs={"args": "localhost 8000 1".split(), "delay": 3})
  client_deployer.start("client1", configs={"args": "localhost 8001 1 2".split(), "delay": 3})
  client_deployer.start("client1", configs={"args": "localhost 8002 1 2 3".split(), "delay": 3})

  client_deployer.start("client2", configs={"args": "localhost 8000 1".split(), "delay": 3})
  client_deployer.start("client2", configs={"args": "localhost 8001 1 2".split(), "delay": 3})
  client_deployer.start("client2", configs={"args": "localhost 8002 1 2 3".split(), "delay": 3})
Ejemplo n.º 33
0
def test_bouncing_with_state():
    """
  Tests that bouncing the server retains state
  """
    client_deployer = runtime.get_deployer("AdditionClient")
    server_deployer = runtime.get_deployer("AdditionServer")

    start_client = lambda: client_deployer.start(
        "client1",
        configs={
            "args": "localhost 8000".split() + LARGE_SAMPLE,
            "sync": True
        })
    client_thread = threading.Thread(target=start_client)

    # create a thread that will bounce (stop and start) the server
    bounce_server = lambda: server_deployer.soft_bounce("server1")
    server_thread = threading.Thread(target=bounce_server)

    client_thread.start()
    server_thread.start()
    client_thread.join()
Ejemplo n.º 34
0
def test_redlining():
    """
  Sends a large sample of integers to the server.
  """
    # obtain the deployer for AdditionClient
    client_deployer = runtime.get_deployer("AdditionClient")

    # set client to connect to localhost:8000 with a large sample
    client_deployer.start("client1",
                          configs={
                              "args": "localhost 8000".split() + LARGE_SAMPLE,
                              "sync": True
                          })
Ejemplo n.º 35
0
def test_client_timeout():
    """
  Tests what happens when the client does not finish a full request
  """
    client_deployer = runtime.get_deployer("AdditionClient")

    start_client = lambda: client_deployer.start(
        "client1",
        configs={
            "args": "localhost 8000".split() + LARGE_SAMPLE,
            "sync": True
        })
    timeout_client = lambda: _client_timeout(client_deployer, "client1")
    testutilities.start_threads_and_join([start_client, timeout_client])
def test_zookeeper_fault_tolerance():
  """
  Kill zookeeper1 and see if other zookeeper instances are in quorum
  """
  zookeper_deployer = runtime.get_deployer("zookeeper")
  kazoo_connection_url = str(runtime.get_active_config('zookeeper_host') + ':2181')
  zkclient = KazooClient(hosts=kazoo_connection_url)

  zkclient.start()

  zkclient.ensure_path("/my/zookeeper_errorinjection")
  # kill the Zookeeper1 instance
  print "killing zoookeeper instance1"
  zookeper_deployer.kill("zookeeper1")
  time.sleep(20)
  zkclient.stop()
Ejemplo n.º 37
0
def test_zookeeper_fault_tolerance():
    """
  Kill zookeeper1 and see if other zookeeper instances are in quorum
  """
    zookeper_deployer = runtime.get_deployer("zookeeper")
    kazoo_connection_url = str(
        runtime.get_active_config('zookeeper_host') + ':2181')
    zkclient = KazooClient(hosts=kazoo_connection_url)

    zkclient.start()

    zkclient.ensure_path("/my/zookeeper_errorinjection")
    # kill the Zookeeper1 instance
    print "killing zoookeeper instance1"
    zookeper_deployer.kill("zookeeper1")
    time.sleep(20)
    zkclient.stop()
Ejemplo n.º 38
0
def test_resilience():
  """
  Tests if after killing one of the clients it restarts back correctly within 10 seconds
  """
  client_deployer = runtime.get_deployer("AdditionClient")

  client_deployer.start("client1", configs={"args": "localhost 8000 1".split(), "sync": True})
  client_deployer.start("client2", configs={"args": "localhost 8002 1 2 3".split(), "sync": True})

  restart_func_dict = {"client1":{"args": "localhost 8000 1".split(), "sync": True}, "client2" : {"args": "localhost 8002 1 2 3".split(), "sync": True}}

  verify_client_recovery_dict = {"client1" : verify_client_recovery, "client2" : verify_client_recovery}

  timeout_dict = {"client1" : 10, "client2" : 10}
  
  #Verifies if the client recovers in 10s
  testrecipe.test_kill_recovery(client_deployer, ["client1", "client2"], restart_func_dict, verify_client_recovery_dict, timeout_dict)
Ejemplo n.º 39
0
def test_multi_client_perf():
    """
  Tests the performance of a server when handling multiple clients
  """
    client_deployer = runtime.get_deployer("AdditionClient")

    client_deployer.start("client1",
                          configs={
                              "args":
                              "localhost 8000".split() +
                              [str(i) for i in range(1, 2000)],
                              "sync":
                              True
                          })
    client_deployer.start("client2",
                          configs={
                              "args":
                              "localhost 8000".split() +
                              [str(i) for i in range(1, 2000)],
                              "sync":
                              True
                          })
Ejemplo n.º 40
0
def test_resilience():
    """
  Tests if after killing one of the clients it restarts back correctly within 10 seconds
  """
    client_deployer = runtime.get_deployer("AdditionClient")

    client_deployer.start("client1",
                          configs={
                              "args": "localhost 8000 1".split(),
                              "sync": True
                          })
    client_deployer.start("client2",
                          configs={
                              "args": "localhost 8002 1 2 3".split(),
                              "sync": True
                          })

    restart_func_dict = {
        "client1": {
            "args": "localhost 8000 1".split(),
            "sync": True
        },
        "client2": {
            "args": "localhost 8002 1 2 3".split(),
            "sync": True
        }
    }

    verify_client_recovery_dict = {
        "client1": verify_client_recovery,
        "client2": verify_client_recovery
    }

    timeout_dict = {"client1": 10, "client2": 10}

    #Verifies if the client recovers in 10s
    testrecipe.test_kill_recovery(client_deployer, ["client1", "client2"],
                                  restart_func_dict,
                                  verify_client_recovery_dict, timeout_dict)
Ejemplo n.º 41
0
def test_basic():
    """
  Trivial interaction between client and server
  """
    client_deployer = runtime.get_deployer("AdditionClient")

    client_deployer.start("client1",
                          configs={
                              "args": "localhost 8000 1".split(),
                              "delay": 3
                          })
    client_deployer.start("client1",
                          configs={
                              "args": "localhost 8001 1 2".split(),
                              "delay": 3
                          })
    client_deployer.start("client1",
                          configs={
                              "args": "localhost 8002 1 2 3".split(),
                              "delay": 3
                          })

    client_deployer.start("client2",
                          configs={
                              "args": "localhost 8000 1".split(),
                              "delay": 3
                          })
    client_deployer.start("client2",
                          configs={
                              "args": "localhost 8001 1 2".split(),
                              "delay": 3
                          })
    client_deployer.start("client2",
                          configs={
                              "args": "localhost 8002 1 2 3".split(),
                              "delay": 3
                          })
Ejemplo n.º 42
0
 def teardown_suite(self):
    #Terminate Zookeeper
   zookeeper_deployer = runtime.get_deployer("zookeeper")
   zookeeper_deployer.undeploy("zookeeper")
   print "zookeeper terminated"
Ejemplo n.º 43
0
def reach_discovery():
    for target in runtime.get_active_config("targets"):
        deployerId = "disco" + target["host"]
        deployer = runtime.get_deployer(deployerId)
        deployer.start(deployerId, configs={"sync": True})
Ejemplo n.º 44
0
 def teardown_suite(self):
     #Terminate Zookeeper
     zookeeper_deployer = runtime.get_deployer("zookeeper")
     zookeeper_deployer.undeploy("zookeeper")
     print "zookeeper terminated"
Ejemplo n.º 45
0
def test_files_on_etc_host1():
    print "==> Check how many files on /etc/ (machine1)"
    pyhk_deployer = runtime.get_deployer("pyhk")
    pyhk_deployer.start("machine1", configs={
        "start_command": runtime.get_active_config('pyhk_cmd'),
        "sync": True})
Ejemplo n.º 46
0
def test_no_valid_ints():
  """
  Tests sending non-integers to the server
  """
  client_deployer = runtime.get_deployer("AdditionClient")
  client_deployer.start("client1", configs={"args": "localhost 8000 a b 3.14".split(), "delay": 3})