Пример #1
0
    def testTimerLocalSourceSink(self):
        """Testing timer based local source and sink"""

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

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

        time.sleep(1.2)

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

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

        self.assertListPrefix(expected, actual)
        self.assertTrue(len(actual) > 0)
Пример #2
0
    def testRemoteSlowPort(self):
        """Testing remote slow port 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)
        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, 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)
Пример #3
0
    def testRemoteSlowPort(self):
        """Testing remote slow port 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)
        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, 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)
Пример #4
0
    def test30(self):
        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.5)

        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)
Пример #5
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)
Пример #6
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)
Пример #7
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)
Пример #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)
Пример #9
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)
Пример #10
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)
Пример #11
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)
Пример #12
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)
Пример #13
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)
Пример #14
0
 def instantiate_primitive(self,
                           actor_name,
                           actor_type,
                           args,
                           signature=None):
     # name is <namespace>:<identifier>, e.g. app:src, or app:component:src
     # args is a **dictionary** of key-value arguments for this instance
     # signature is the GlobalStore actor-signature to lookup the actor
     args['name'] = actor_name
     if self.node is not None:
         instance_id = self.node.new(actor_type=actor_type,
                                     args=args,
                                     deploy_args={
                                         'app_id': self.app_id,
                                         'app_name': self.name,
                                         'signature': signature
                                     })
     else:
         instance_id = utils.new_actor_wargs(rt=self.runtime,
                                             actor_type=actor_type,
                                             actor_name=actor_name,
                                             args=args,
                                             deploy_args={
                                                 'app_id': self.app_id,
                                                 'signature': signature
                                             })
     return instance_id
Пример #15
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)
    def test30(self):
        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)
    def testLocalSourceSink(self):
        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)
Пример #18
0
    def testTimerLocalSourceSink(self):
        """Testing timer based local source and sink"""

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

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

        time.sleep(1.2)

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

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

        self.assertListPrefix(expected, actual)
        self.assertTrue(len(actual) > 0)
    def test10(self):
        # 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)
    def test25(self):
        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, ity, 'token', self.rt1.id, src, 'integer')
        utils.connect(self.rt1, snk, 'token', self.rt1.id, ity, 'token')

        time.sleep(0.2)

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

        self.assert_lists_equal(range(1, 10), actual)
    def testTwoStepMigrateSinkSource(self):
        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)
Пример #22
0
    def testLocalSourceSink(self):
        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)

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

        self.assert_lists_equal(range(1, 10), actual)
Пример #23
0
    def testMigrateSink(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(.4)
        utils.migrate(self.rt1, snk, self.rt2.id)
        time.sleep(.6)

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

        utils.delete_actor(self.rt1, src)
        utils.delete_actor(self.rt2, snk)
Пример #24
0
    def test10(self):
        # 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.5)

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

        self.assert_lists_equal(range(1, 10), actual)
Пример #25
0
    def test25(self):
        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, ity, 'token', self.rt1.id, src, 'integer')
        utils.connect(self.rt1, snk, 'token', self.rt1.id, ity, 'token')

        time.sleep(0.5)

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

        self.assert_lists_equal(range(1, 10), actual)
Пример #26
0
 def instantiate_primitive(self, actor_name, actor_type, args):
     # name is <namespace>:<identifier>, e.g. app:src, or app:component:src
     # args is a **dictionary** of key-value arguments for this instance
     args['name'] = actor_name
     if self.node is not None:
         instance_id = self.node.new(
             actor_type=actor_type,
             args=args,
             deploy_args={'app_id': self.app_id, 'app_name': self.name})
     else:
         instance_id = utils.new_actor_wargs(
             rt=self.runtime,
             actor_type=actor_type,
             actor_name=actor_name,
             args=args,
             deploy_args={'app_id': self.app_id})
     return instance_id
Пример #27
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)
Пример #28
0
    def testTwoStepMigrateSinkSource(self):
        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)
Пример #29
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)
Пример #30
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)
Пример #31
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)
Пример #32
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)