def basic_setup():
    # setup
    host1_uuid = util.generate_uuid()
    host2_uuid = util.generate_uuid()

    a_b_conn = test_util.DummyConnectionObj()
    c_r2_conn = test_util.DummyConnectionObj()

    garbage_conn = test_util.DummyConnectionObj()

    # host one endpoints
    r1 = EndpointR1(garbage_conn,host1_uuid)
    a = EndpointA(a_b_conn,host1_uuid)
    c = EndpointC(a,c_r2_conn,host1_uuid)

    # host two endpoints
    r2 = EndpointR2(c_r2_conn,host2_uuid)
    b = EndpointB(a_b_conn,host2_uuid)

    # start each event
    act_r1 = r1.evt_r1(a)
    act_r2 = r2.evt_r2(b)

    try1 = TryCommit(act_r1)
    try2 = TryCommit(act_r2)
    try2.start()
    try1.start()


    return True
Esempio n. 2
0
    def __init__(self, conn_obj, host_uuid=None):

        # all dummy endpoints will have the same _VariableStore
        # Peered Number numero = 100;
        # Peered Text some_str = 'test';
        # Peered List (elements: Text) text_list;
        if host_uuid == None:
            host_uuid = util.generate_uuid()

        glob_var_store = waldoVariableStore._VariableStore(host_uuid)

        self.peered_number_var_name = "numero"
        glob_var_store.add_var(
            self.peered_number_var_name, wVariables.WaldoNumVariable(self.peered_number_var_name, host_uuid, True, 100)
        )

        self.peered_str_var_name = "some_str"
        glob_var_store.add_var(
            self.peered_str_var_name, wVariables.WaldoTextVariable(self.peered_str_var_name, host_uuid, True, "test")
        )

        self.peered_list_var_name = "text_list"
        glob_var_store.add_var(
            self.peered_list_var_name, wVariables.WaldoTextVariable(self.peered_list_var_name, host_uuid, True)
        )

        waldoEndpoint._Endpoint.__init__(self, Waldo._waldo_classes, host_uuid, conn_obj, glob_var_store)
def run_test():
    host_uuid = util.generate_uuid()
    dummy_endpoint = test_util.DummyEndpoint(
        test_util.SingleEndpointConnectionObj(),host_uuid)
    number = wVariables.WaldoNumVariable('some num',host_uuid,22)

    start = time.time()
    for i in range(0,NUM_ITERATIONS):
        evt1 = dummy_endpoint._act_event_map.create_root_event()        
        val = number.get_val(evt1)
        number.write_val(evt1,val+1)
        evt1.hold_can_commit()
        evt1.complete_commit()

    elapsed = time.time() - start
    print '\n\n'
    print str(NUM_ITERATIONS) + ' in ' + str(elapsed) + ' seconds'
    print '\n\n'        
Esempio n. 4
0
def run_test():
    host_uuid = util.generate_uuid()
    dummy_endpoint = test_util.DummyEndpoint(
        test_util.SingleEndpointConnectionObj(), host_uuid)
    number = wVariables.WaldoNumVariable('some num', host_uuid, 22)

    start = time.time()
    for i in range(0, NUM_ITERATIONS):
        evt1 = dummy_endpoint._act_event_map.create_root_event()
        val = number.get_val(evt1)
        number.write_val(evt1, val + 1)
        evt1.hold_can_commit()
        evt1.complete_commit()

    elapsed = time.time() - start
    print '\n\n'
    print str(NUM_ITERATIONS) + ' in ' + str(elapsed) + ' seconds'
    print '\n\n'
#!/usr/bin/env python

import os, sys, test_util

base_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)), "..", "..")
sys.path.append(base_dir)
from lib import wVariables, util

host_uuid = util.generate_uuid()

"""
Waldo's semantics disallow sharing references between peered pieces of
data.

To test this, we create a map and put it inside of a peered list.  We
then make changes to the map and try to ensure that the changes are
not reflected in the map when accessed through the list.
"""


def create_two_events(dummy_endpoint):
    evt1 = dummy_endpoint._act_event_map.create_root_event()
    evt2 = dummy_endpoint._act_event_map.create_root_event()
    return evt1, evt2


def create_map(dummy_endpoint, to_populate_with):
    """
    @param {map} to_populate_with --- Each element gets inserted into
    the map that we return.
    """