Esempio n. 1
0
    def testLocalSourceSink(self):
        _log.analyze("TESTRUN", "+", {})
        src = utils.new_actor(self.rt1, 'std.CountTimer', 'src')
        snk = utils.new_actor_wargs(self.rt1, 'io.StandardOut', 'snk', store_tokens=1, quiet=1)

        utils.connect(self.rt1, snk, 'token', self.rt1.id, src, 'integer')

        time.sleep(.5)

        actual = utils.report(self.rt1, snk)

        self.assert_lists_equal(range(1, 10), actual)

        utils.delete_actor(self.rt1, src)
        utils.delete_actor(self.rt1, snk)
Esempio n. 2
0
    def test10(self):
        _log.analyze("TESTRUN", "+", {})
        # Two actors, doesn't seem to trigger the bug
        src = utils.new_actor(self.rt1, 'std.Counter', 'src')
        snk = utils.new_actor_wargs(self.rt1, 'io.StandardOut', 'snk', store_tokens=1, quiet=1)

        utils.connect(self.rt1, snk, 'token', self.rt1.id, src, 'integer')

        time.sleep(0.1)

        actual = utils.report(self.rt1, snk)

        self.assert_lists_equal(range(1, 10), actual)

        utils.delete_actor(self.rt1, src)
        utils.delete_actor(self.rt1, snk)
Esempio n. 3
0
    def testTwoStepMigrateSinkSource(self):
        _log.analyze("TESTRUN", "+", {})
        src = utils.new_actor(self.rt1, 'std.CountTimer', 'src')
        snk = utils.new_actor_wargs(self.rt1, 'io.StandardOut', 'snk', store_tokens=1, quiet=1)

        utils.connect(self.rt1, snk, 'token', self.rt1.id, src, 'integer')

        time.sleep(1)
        utils.migrate(self.rt1, snk, self.rt2.id)
        time.sleep(1)
        utils.migrate(self.rt1, src, self.rt2.id)
        time.sleep(1)

        actual = utils.report(self.rt2, snk)
        self.assert_lists_equal(range(1,15), actual, min_length=10)

        utils.delete_actor(self.rt2, src)
        utils.delete_actor(self.rt2, snk)
Esempio n. 4
0
    def testRemoteSlowFanoutPort(self):
        """Testing remote slow port with fan out and that token flow control works"""

        rt = self.runtime
        id_ = rt.id
        peer = self.runtimes[0]
        peer_id = peer.id

        snk1 = utils.new_actor_wargs(rt, 'io.StandardOut', 'snk1', store_tokens=1)
        snk2 = utils.new_actor_wargs(peer, 'io.StandardOut', 'snk2', store_tokens=1)
        alt = utils.new_actor(peer, 'std.Alternate', 'alt')
        src1 = utils.new_actor_wargs(rt, 'std.CountTimer', 'src1', sleep=0.1, steps=100)
        src2 = utils.new_actor_wargs(rt, 'std.CountTimer', 'src2', sleep=1.0, steps=10)

        utils.connect(rt, snk1, 'token', peer_id, alt, 'token')
        utils.connect(peer, snk2, 'token', id_, src1, 'integer')
        utils.connect(peer, alt, 'token_1', id_, src1, 'integer')
        utils.connect(peer, alt, 'token_2', id_, src2, 'integer')
        time.sleep(2)

        utils.disable(rt, src1)
        utils.disable(rt, src2)
        time.sleep(0.2)  # HACK

        def _d():
            for i in range(1,100):
                yield i
                yield i

        expected = list(_d())
        actual = actual_tokens(rt, snk1)
        assert(len(actual) > 1)
        self.assertListPrefix(expected, actual)

        expected = range(1, 100)
        actual = actual_tokens(peer, snk2)
        assert(len(actual) > 1)
        self.assertListPrefix(expected, actual)

        utils.delete_actor(rt, snk1)
        utils.delete_actor(peer, snk2)
        utils.delete_actor(peer, alt)
        utils.delete_actor(rt, src1)
        utils.delete_actor(rt, src2)
Esempio n. 5
0
    def testLocalSourceSink(self):
        """Testing local source and sink"""

        rt, id_, peers = self.runtime, self.runtime.id, self.peerlist

        src = utils.new_actor(rt, 'std.CountTimer', 'src')
        snk = utils.new_actor_wargs(rt, 'io.StandardOut', 'snk', store_tokens=1)
        utils.connect(rt, snk, 'token', id_, src, 'integer')

        time.sleep(0.4)

        # disable(rt, id_, src)
        utils.disconnect(rt, src)

        expected = expected_tokens(rt, src, 'std.CountTimer')
        actual = actual_tokens(rt, snk)

        self.assertListPrefix(expected, actual)

        utils.delete_actor(rt, src)
        utils.delete_actor(rt, snk)
Esempio n. 6
0
    def testRemoteOneActor(self):
        """Testing remote port"""

        rt = self.runtime
        id_ = rt.id
        peer = self.runtimes[0]
        peer_id = peer.id

        snk = utils.new_actor_wargs(rt, 'io.StandardOut', 'snk', store_tokens=1)
        sum_ = utils.new_actor(peer, 'std.Sum', 'sum')
        src = utils.new_actor(rt, 'std.CountTimer', 'src')

        utils.connect(rt, snk, 'token', peer_id, sum_, 'integer')
        utils.connect(peer, sum_, 'integer', id_, src, 'integer')
        time.sleep(0.5)

        utils.disable(rt, src)

        expected = expected_tokens(rt, src, 'std.Sum')
        actual = actual_tokens(rt, snk)
        assert(len(actual) > 1)
        self.assertListPrefix(expected, actual)

        utils.delete_actor(rt, snk)
        utils.delete_actor(peer, sum_)
        utils.delete_actor(rt, src)
Esempio n. 7
0
    def testLocalConnectDisconnectFilter(self):
        """Testing local connect/disconnect/re-connect on filter"""

        rt, id_ = self.runtime, self.runtime.id

        src = utils.new_actor(rt, "std.CountTimer", "src")
        sum_ = utils.new_actor(rt, "std.Sum", "sum")
        snk = utils.new_actor_wargs(rt, "io.StandardOut", "snk", store_tokens=1)

        utils.connect(rt, snk, "token", id_, sum_, "integer")
        utils.connect(rt, sum_, "integer", id_, src, "integer")

        time.sleep(0.2)

        utils.disconnect(rt, sum_)

        utils.connect(rt, snk, "token", id_, sum_, "integer")
        utils.connect(rt, sum_, "integer", id_, src, "integer")

        time.sleep(0.2)

        utils.disconnect(rt, src)
        # disable(rt, id_, src)

        expected = expected_tokens(rt, src, "std.Sum")
        actual = actual_tokens(rt, snk)
        self.assertListPrefix(expected, actual)

        utils.delete_actor(rt, src)
        utils.delete_actor(rt, sum_)
        utils.delete_actor(rt, snk)
Esempio n. 8
0
    def testInOutPortLocalRemoteRepeatedMigration(self):
        """Testing outport local to remote migration and revers repeatedly"""

        rt = self.runtime
        id_ = rt.id
        peer = self.runtimes[0]
        peer_id = peer.id

        snk = utils.new_actor_wargs(rt, 'io.StandardOut', 'snk', store_tokens=1)
        sum_ = utils.new_actor(rt, 'std.Sum', 'sum')
        src = utils.new_actor(rt, 'std.CountTimer', 'src')

        utils.connect(rt, snk, 'token', id_, sum_, 'integer')
        utils.connect(rt, sum_, 'integer', id_, src, 'integer')
        time.sleep(0.27)
        actual_x = []
        actual_1 = actual_tokens(rt, snk)
        for i in range(5):
            if i % 2 == 0:
                utils.migrate(rt, sum_, peer_id)
            else:
                utils.migrate(peer, sum_, id_)
            time.sleep(0.2)
            actual_x_ = actual_tokens(rt, snk)
            assert(len(actual_x_) > len(actual_x))
            actual_x = actual_x_

        expected = expected_tokens(rt, src, 'std.Sum')
        actual = actual_tokens(rt, snk)
        assert(len(actual) > 1)
        assert(len(actual) > len(actual_1))
        self.assertListPrefix(expected, actual)
        utils.delete_actor(rt, snk)
        utils.delete_actor(peer, sum_)
        utils.delete_actor(rt, src)
Esempio n. 9
0
    def testInOutPortRemoteToRemoteMigration(self):
        """Testing out- and inport remote to remote migration"""

        rt = self.runtime
        id_ = rt.id
        peer0 = self.runtimes[0]
        peer0_id = peer0.id
        peer1 = self.runtimes[1]
        peer1_id = peer1.id

        time.sleep(0.5)
        snk = utils.new_actor_wargs(rt, 'io.StandardOut', 'snk', store_tokens=1)
        sum_ = utils.new_actor(peer0, 'std.Sum', 'sum')
        src = utils.new_actor(rt, 'std.CountTimer', 'src')

        utils.connect(rt, snk, 'token', peer0_id, sum_, 'integer')
        time.sleep(0.5)
        utils.connect(peer0, sum_, 'integer', id_, src, 'integer')
        time.sleep(0.5)

        actual_1 = actual_tokens(rt, snk)
        utils.migrate(peer0, sum_, peer1_id)
        time.sleep(0.5)

        expected = expected_tokens(rt, src, 'std.Sum')
        actual = actual_tokens(rt, snk)
        assert(len(actual) > 1)
        assert(len(actual) > len(actual_1))
        self.assertListPrefix(expected, actual)
        utils.delete_actor(rt, snk)
        utils.delete_actor(peer1, sum_)
        utils.delete_actor(rt, src)
Esempio n. 10
0
    def test22(self):
        _log.analyze("TESTRUN", "+", {})
        src = utils.new_actor(self.rt1, 'std.Counter', 'src')
        ity = utils.new_actor(self.rt2, 'std.Identity', 'ity')
        snk = utils.new_actor_wargs(self.rt3, 'io.StandardOut', 'snk', store_tokens=1, quiet=1)

        utils.connect(self.rt2, ity, 'token', self.rt1.id, src, 'integer')
        utils.connect(self.rt3, snk, 'token', self.rt2.id, ity, 'token')

        interval = 0.5

        for retries in range(1, 5):
            time.sleep(retries * interval)
            actual = utils.report(self.rt3, snk)
            if len(actual) > 10:
                break

        self.assert_lists_equal(range(1, 11), actual)

        time.sleep(0.1)

        actual = utils.report(self.rt3, snk)

        self.assert_lists_equal(range(1, 10), actual)

        utils.delete_actor(self.rt1, src)
        utils.delete_actor(self.rt2, ity)
        utils.delete_actor(self.rt3, snk)
Esempio n. 11
0
    def testExplicitStateMigration(self):
        """Testing migration of explicit state handling"""

        rt = self.runtime
        id_ = rt.id
        peer0 = self.runtimes[0]
        peer0_id = peer0.id
        peer1 = self.runtimes[1]
        peer1_id = peer1.id

        snk = utils.new_actor_wargs(peer0, 'io.StandardOut', 'snk', store_tokens=1)
        wrapper = utils.new_actor(rt, 'misc.ExplicitStateExample', 'wrapper')
        src = utils.new_actor(rt, 'std.CountTimer', 'src')

        utils.connect(peer0, snk, 'token', id_, wrapper, 'token')
        utils.connect(rt, wrapper, 'token', id_, src, 'integer')
        time.sleep(0.3)

        actual_1 = actual_tokens(peer0, snk)
        utils.migrate(rt, wrapper, peer0_id)
        time.sleep(0.3)

        actual = actual_tokens(peer0, snk)
        expected = [u'((( 1 )))', u'((( 2 )))', u'((( 3 )))', u'((( 4 )))', u'((( 5 )))', u'((( 6 )))', u'((( 7 )))', u'((( 8 )))']
        assert(len(actual) > 1)
        assert(len(actual) > len(actual_1))
        self.assertListPrefix(expected, actual)
        utils.delete_actor(peer0, snk)
        utils.delete_actor(peer0, wrapper)
        utils.delete_actor(rt, src)
Esempio n. 12
0
    def testOutPortLocalToRemoteMigration(self):
        """Testing outport local to remote migration"""

        rt = self.runtime
        id_ = rt.id
        peer = self.runtimes[0]
        peer_id = peer.id

        snk = utils.new_actor_wargs(rt, 'io.StandardOut', 'snk', store_tokens=1)
        sum_ = utils.new_actor(peer, 'std.Sum', 'sum')
        src = utils.new_actor(peer, 'std.CountTimer', 'src')

        utils.connect(rt, snk, 'token', peer_id, sum_, 'integer')
        utils.connect(peer, sum_, 'integer', peer_id, src, 'integer')
        time.sleep(0.27)

        actual_1 = actual_tokens(rt, snk)
        utils.migrate(peer, src, id_)
        time.sleep(0.2)

        expected = expected_tokens(rt, src, 'std.Sum')
        actual = actual_tokens(rt, snk)
        assert(len(actual) > 1)
        assert(len(actual) > len(actual_1))
        self.assertListPrefix(expected, actual)
        utils.delete_actor(rt, snk)
        utils.delete_actor(peer, sum_)
        utils.delete_actor(rt, src)
Esempio n. 13
0
    def testInOutPortRemoteToRemoteMigration(self):
        """Testing out- and inport remote to remote migration"""

        rt = self.runtime
        id_ = rt.id
        peer0 = self.runtimes[0]
        peer0_id = peer0.id
        peer1 = self.runtimes[1]
        peer1_id = peer1.id

        snk = utils.new_actor_wargs(rt,
                                    'io.StandardOut',
                                    'snk',
                                    store_tokens=1)
        sum_ = utils.new_actor(peer0, 'std.Sum', 'sum')
        src = utils.new_actor(rt, 'std.CountTimer', 'src')

        utils.connect(rt, snk, 'token', peer0_id, sum_, 'integer')
        utils.connect(peer0, sum_, 'integer', id_, src, 'integer')
        time.sleep(0.27)

        actual_1 = actual_tokens(rt, snk)
        utils.migrate(peer0, sum_, peer1_id)
        time.sleep(0.2)

        expected = expected_tokens(rt, src, 'std.Sum')
        actual = actual_tokens(rt, snk)
        assert (len(actual) > 1)
        assert (len(actual) > len(actual_1))
        self.assertListPrefix(expected, actual)
        utils.delete_actor(rt, snk)
        utils.delete_actor(peer1, sum_)
        utils.delete_actor(rt, src)
Esempio n. 14
0
    def testMigrateSource(self):
        _log.analyze("TESTRUN", "+", {})
        src = utils.new_actor(self.rt1, 'std.CountTimer', 'src')
        snk = utils.new_actor_wargs(self.rt1, 'io.StandardOut', 'snk', store_tokens=1, quiet=1)

        utils.connect(self.rt1, snk, 'token', self.rt1.id, src, 'integer')

        time.sleep(1)
        utils.migrate(self.rt1, src, self.rt2.id)

        interval = 0.5
        for retries in range(1,5):
            time.sleep(interval * retries)
            actual = utils.report(self.rt1, snk)
            if len(actual) > 10 :
                break


        self.assert_lists_equal(range(1, 10), actual)

        utils.delete_actor(self.rt2, src)
        utils.delete_actor(self.rt1, snk)
Esempio n. 15
0
    def testLocalConnectDisconnectSink(self):
        """Testing local connect/disconnect/re-connect on sink"""

        rt, id_ = self.runtime, self.runtime.id

        src = utils.new_actor(rt, "std.CountTimer", "src")
        snk = utils.new_actor_wargs(rt, "io.StandardOut", "snk", store_tokens=1)
        utils.connect(rt, snk, 'token', id_, src, 'integer')
        time.sleep(0.2)

        utils.disconnect(rt, snk)
        utils.connect(rt, snk, 'token', id_, src, 'integer')
        time.sleep(0.2)
        utils.disconnect(rt, snk)
        # disable(rt, id_, src)

        expected = expected_tokens(rt, src, 'std.CountTimer')
        actual = actual_tokens(rt, snk)
        self.assertListPrefix(expected, actual)

        utils.delete_actor(rt, src)
        utils.delete_actor(rt, snk)
Esempio n. 16
0
def control_actors(args):
    if args.cmd == 'list':
        return utils.get_actors(args.node)
    if args.cmd == 'info':
        if not args.id:
            raise Exception("No actor id given")
        return utils.get_actor(args.node, args.id)
    elif args.cmd == 'delete':
        if not args.id:
            raise Exception("No actor id given")
        return utils.delete_actor(args.node, args.id)
    elif args.cmd == 'migrate':
        if not args.id or not args.peer_node:
            raise Exception("No actor or peer given")
        return utils.migrate(args.node, args.id, args.peer_node)
Esempio n. 17
0
def control_actors(args):
    if args.cmd == "list":
        return utils.get_actors(args.node)
    if args.cmd == "info":
        if not args.id:
            raise Exception("No actor id given")
        return utils.get_actor(args.node, args.id)
    elif args.cmd == "delete":
        if not args.id:
            raise Exception("No actor id given")
        return utils.delete_actor(args.node, args.id)
    elif args.cmd == "migrate":
        if not args.id or not args.peer_node:
            raise Exception("No actor or peer given")
        return utils.migrate(args.node, args.id, args.peer_node)
Esempio n. 18
0
def control_actors(args):
    if args.cmd == 'list':
        return utils.get_actors(args.node)
    if args.cmd == 'info':
        if not args.id:
            raise Exception("No actor id given")
        return utils.get_actor(args.node, args.id)
    elif args.cmd == 'delete':
        if not args.id:
            raise Exception("No actor id given")
        return utils.delete_actor(args.node, args.id)
    elif args.cmd == 'migrate':
        if not args.id or not args.peer_node:
            raise Exception("No actor or peer given")
        return utils.migrate(args.node, args.id, args.peer_node)
    elif args.cmd == 'replicate':
        if not args.id:
            raise Exception("No actor id given")
        return utils.replicate(args.node, args.id, args.peer_node)
    elif args.cmd == 'lost':
        if not args.id:
            raise Exception("No actor id given")
        return utils.lost_actor(args.node, args.id)
Esempio n. 19
0
    def test20(self):
        _log.analyze("TESTRUN", "+", {})
        src = utils.new_actor(self.rt1, 'std.Counter', 'src')
        ity = utils.new_actor(self.rt1, 'std.Identity', 'ity')
        snk = utils.new_actor_wargs(self.rt1, 'io.StandardOut', 'snk', store_tokens=1, quiet=1)

        utils.connect(self.rt1, snk, 'token', self.rt1.id, ity, 'token')
        utils.connect(self.rt1, ity, 'token', self.rt1.id, src, 'integer')

        time.sleep(0.2)

        actual = utils.report(self.rt1, snk)

        self.assert_lists_equal(range(1, 11), actual)

        utils.delete_actor(self.rt1, src)
        utils.delete_actor(self.rt1, ity)
        utils.delete_actor(self.rt1, snk)
Esempio n. 20
0
    def test30(self):
        _log.analyze("TESTRUN", "+", {})
        src = utils.new_actor(self.rt1, 'std.Counter', 'src')
        snk1 = utils.new_actor_wargs(self.rt1, 'io.StandardOut', 'snk1', store_tokens=1, quiet=1)
        snk2 = utils.new_actor_wargs(self.rt1, 'io.StandardOut', 'snk2', store_tokens=1, quiet=1)

        utils.set_port_property(self.rt1, src, 'out', 'integer', 'fanout', 2)

        utils.connect(self.rt1, snk1, 'token', self.rt1.id, src, 'integer')
        utils.connect(self.rt1, snk2, 'token', self.rt1.id, src, 'integer')

        time.sleep(0.2)

        actual1 = utils.report(self.rt1, snk1)
        actual2 = utils.report(self.rt1, snk2)

        self.assert_lists_equal(list(range(1, 10)), actual1)
        self.assert_lists_equal(list(range(1, 10)), actual2)

        utils.delete_actor(self.rt1, src)
        utils.delete_actor(self.rt1, snk1)
        utils.delete_actor(self.rt1, snk2)