예제 #1
0
def test_LimitMemory():
    """Test RIAPS Memory limit handler
    """
    results = riaps_testing.runTest("test_LimitMemory", "testLimitMemory",
                                    "memlimit.riaps", "memlimit.depl")
    assert len(results) != 0, "Failed to retrieve any logs!"
    for key in results.keys():
        log = results[key]
        assert log[0].find(
            "Starting") != -1, "First line of %s isn't starting!" % key
        assert log[-1].find(
            "Stopping") != -1, "Last line of %s isn't stopping!" % key

        numTick = 0
        numLimit = 0
        curTick = 0

        for line in log:
            if line.find("Tick") != -1:
                curTick += 1
            elif line.find("Limit") != -1:
                if numLimit == 0:
                    curTick = 5  # Ignore startup time
                numLimit += 1
                numTick += curTick
                curTick = 0

        assert numLimit != 0, "Failed to ever hit limit!"

        # The ratio should be very close to 5.0 because the memory usage is increased by
        #   35MB each tick and the memory limit is 200MB
        ratio = numTick * 1.0 / numLimit
        assert ratio > 4.5, "Hit limit too frequently: Ratio=%.2f" % ratio
        assert ratio < 5.5, "Hit limit too infrequently: Ratio=%.2f" % ratio
예제 #2
0
def test_LimitNetwork():
    """Test RIAPS Network limit handler
    """
    results = riaps_testing.runTest("test_LimitNetwork", "testLimitNetwork",
                                    "netlimit.riaps", "netlimit.depl")
    assert len(results) != 0, "Failed to retrieve any logs!"
    for key in results.keys():
        log = results[key]
        assert log[0].find(
            "Starting") != -1, "First line of %s isn't starting!" % key
        assert log[-1].find(
            "Stopping") != -1, "Last line of %s isn't stopping!" % key

        numLimit = 0
        numTick = 0

        for line in log:
            if line.find("Starting") == -1 and line.find("Stopping") == -1:
                if line.find("Tick") != -1:
                    numTick += 1
                if line.find(
                        "Limit"
                ) != -1 and numTick != 0:  # Check if a tick has occurred to ignore startup process
                    if numLimit == 0:  # Reset numTick on first hit of limit
                        numTick = 6
                    numLimit += 1

        assert numLimit != 0, "Failed to ever hit limit!"

        # The ratio should be approximately 6.0 because the limit is 1.2KB/s and
        # the message size is increased by 256MB every second
        ratio = numTick * 1.0 / numLimit
        print("numTick=%d numLimit=%d ratio=%.2f" % (numTick, numLimit, ratio))
        assert ratio > 4.5, "Hit limit too frequently: Ratio=%.2f" % ratio
        assert ratio < 7.5, "Hit limit too infrequently: Ratio=%.2f" % ratio
예제 #3
0
def test_LimitSpace():
    """Test RIAPS Space limit handler
    """
    results = riaps_testing.runTest("test_LimitSpace", "testLimitSpace",
                                    "spclimit.riaps", "spclimit.depl")
    assert len(results) != 0, "Failed to retrieve any logs!"
    for key in results.keys():
        log = results[key]
        assert log[0].find(
            "Starting") != -1, "First line of %s isn't starting!" % key
        assert log[-1].find(
            "Stopping") != -1, "Last line of %s isn't stopping!" % key

        numTick = 0
        numLimit = 0
        curTick = 0

        for line in log:
            if line.find("Starting") == -1 and line.find("Stopping") == -1:
                if line.find("Tick") != -1:
                    curTick += 1
                elif line.find("Limit") != -1:
                    if numLimit == 0:
                        curTick = 5  # Ignore startup time
                    numLimit += 1
                    numTick += curTick
                    curTick = 0

        assert numLimit != 0, "Failed to ever hit limit!"

        ratio = numTick * 1.0 / numLimit
        # The ratio should be approximately 5 because the limit is 5MB
        # and the file size is incremented every second by 1MB
        assert ratio > 4.5, "Hit limit too frequently: Ratio=%.2f" % ratio
        assert ratio < 5.5, "Hit limit too infrequently: Ratio=%.2f" % ratio
예제 #4
0
def runTest(name, depl, numClt):
    """Run a Clt Srv test

    Invokes riaps_testing.runTest(...) with the provided name and depl in addition to
        the testCltSrv folder and cltsrv.riaps model. Then automatically performs log
        validation with verifyResults(...)

    Args:
        name   (str): The name of the application
        depl   (str): The name of the deployment(.depl) file to be tested
        numClt (int): The number of clients expected to be created by the deployment

    """
    verifyResults(riaps_testing.runTest(name, "testCltSrv", "cltsrv.riaps", depl), numClt)
예제 #5
0
def runTest(name, depl, numDevices):
    """Run a Multiple Devices test

    Invokes riaps_testing.runTest(...) with the provided name and depl in addition to
        the testMultiDevices folder and multiDevices.riaps model. Then automatically performs log
        validation with verifyResults(...)

    Args:
        name       (str): The name of the application
        depl       (str): The name of the deployment(.depl) file to be tested
        numDevices (int): The number of devices expected to be created by the deployment

    """
    verifyResults(
        riaps_testing.runTest(name, "testMultiDevices", "multiDevices.riaps",
                              depl), numDevices)
예제 #6
0
def test_Timer():
    """
    Verify that test results match the expected behavior of the Timer ports
    """
    results = riaps_testing.runTest("Timer", "testTimer", "timer.riaps", "timer.depl")
    print(results)
    assert results != {}, "Logs are empty or not collected!"
    for key in results:
        if key.find("CompTimerPer") != -1:
            assert results[key][0].find("Starting") != -1, "First line of %s isn't starting!" % key
            assert results[key][-1].find("Stopping") != -1, "Last line of %s isn't stopping!" % key
            # cltCount += 1
            # cltID = 0
            # request = -1
            # repCount = 0p
            periodicTimerCounter = 0
            timerRunning = True
            lastTime = 0.0
            currTime = 0.0
            for line in results[key]:
            #     assert line.find("Failed") == -1, "Client request failed"
                if line.find("Periodic") != -1:
                    assert timerRunning, "Periodic timer fired while halted!"
                    periodicTimerCounter += 1
            #         assert request == -1, "Made another request before receiving a reply!"
                    parts = line.split(" ")
                    lastTime = currTime
                    currTime = float(parts[1])
                    if periodicTimerCounter < 10:
                        assert parts[2] == '1.0', "getPeriod() returned wrong value: %d" % int(parts[2])
                        if periodicTimerCounter > 3:
                            assert abs(currTime - lastTime -1.0) < 0.5, "Timer error greater than 0.5s"
                    if periodicTimerCounter < 12:
                        assert parts[2] == '5.0', "getPeriod() returned wrong value(%d) or setPeriod() failed" % int(parts[2])
                        if periodicTimerCounter > 10:
                            assert abs(currTime - lastTime - 5.0) < 0.5, "Timer error greater than 0.5s"
                elif line.find("Halt"):
                    timerRunning = False
                elif line.find("Launch"):
                    timerRunning = True
예제 #7
0
def test_PubSubRemote_N_N():
    verifyResults(runTest("PubSubRemote_N_N", "testPubSub", "remote.riaps", "testRemote_N_N.depl"), 3, 3)
예제 #8
0
def test_PubSubRemote_N_1():
    verifyResults(runTest("PubSubRemote_N_1", "testPubSub", "remote.riaps", "testRemote_N_1.depl"), 2, 1)
예제 #9
0
def test_PubSubLocal_N_N():
    verifyResults(runTest("PubSubLocal_N_N", "testPubSub", "local.riaps", "testLocal_N_N.depl"), 2, 2)
예제 #10
0
def test_PubSubLocal_1_1():
    verifyResults(runTest("PubSubLocal_1_1", "testPubSub", "local.riaps", "testLocal_1_1.depl"), 1, 1)