示例#1
0
def t16(factory):
    pretty = '%s t16' % __file__
    print(pretty)

    PROFILE = {'type': 'handset', 'pretty': 'jane'}

    try:
        master = factory.make_master('master')
        slave_a = factory.make_share(master, 'slave_a', True, slow_down=0.1)
        slave_b = factory.make_share(slave_a, 'slave_b', True)

        if not verify_allocators_on_broker(pretty, master, 2):
            raise Exception('Failing allocator setup')

        # create clients for manipulation
        master_client = RemoteBroker(master.address, home=factory.HOME.path)
        slave_b_client = RemoteBroker(slave_b.address, home=factory.HOME.path)

        # Allocate three handsets
        h1 = slave_b_client.get(PROFILE)
        time.sleep(0.15)
        h2 = master_client.get(PROFILE)
        time.sleep(0.15)
        h3 = master_client.get(PROFILE)
        time.sleep(0.15)
    except Exception, e:
        print('FAIL %s: Setup failed, Exception: %s' % (pretty, e.message))
        return False
示例#2
0
def t9(factory):
    pretty = '%s t9' % __file__
    print(pretty)

    handover = factory.make_master('master')
    client = RemoteBroker(handover.address, home=factory.HOME.path)

    # make first allocation
    h, w = client.get_resources({'type': 'handset'}, {'type': 'workspace'})

    # hand over
    adoption, config, fdtx_path = handover.begin_handover()
    takeover = factory.make_takeover('master', adoption, config, fdtx_path)
    handover.end_handover(1)

    # make seconc allocation
    try:
        client.get({'type': 'handset'})
        print('FAIL %s: second allocation did not fail' % pretty)
        return False
    except Restarting:
        pass  # good
    except Exception, e:
        print('FAIL %s: wrong exception: %s' % (pretty, e))
        return False
示例#3
0
def t15(factory):
    pretty = '%s t15' % __file__
    print(pretty)

    PROFILE = {'type': 'handset'}
    MAX_ALLOWED_ITERATIONS = 10

    try:
        master = factory.make_master('master')
        slave_a = factory.make_share(master, 'slave_a', True)
        slave_b = factory.make_share(slave_a, 'slave_b', True)

        if not verify_allocators_on_broker(pretty, master, 2):
            return False

        # create clients for manipulation
        master_client = RemoteBroker(master.address, home=factory.HOME.path)
        slave_a_client = RemoteBroker(slave_a.address, home=factory.HOME.path)
        slave_b_client = RemoteBroker(slave_b.address, home=factory.HOME.path)

        handsets_master = []
        handsets_slave_a = []
        handsets_slave_b = []

        # Allocate all 9 handsets
        for i in range(3):
            handsets_master.append(master_client.get(PROFILE))
            time.sleep(.1)
            handsets_slave_a.append(slave_a_client.get(PROFILE))
            time.sleep(.1)
            handsets_slave_b.append(slave_b_client.get(PROFILE))
            time.sleep(.1)

    except Exception, e:
        print('FAIL %s: Setup failed, Exception: %s' % (pretty, e.message))
        return False
示例#4
0
文件: restart.py 项目: yiu31802/ave
def t3(pretty, factory):
    factory.write_config('authkeys.json', setup.AUTHKEYS)
    b = factory.make_broker()
    client = RemoteBroker(b.address)
    admin = RemoteBroker(b.address,authkey='admin')

    # create a server with a couple of boards
    handover = factory.make_server()
    handover.set_boards([setup.BOARD_1,setup.BOARD_2,setup.BOARD_3])

    # wait for added boards to become available in the broker
    ok = False
    wanted = RelayProfile(setup.RELAY_3)
    for i in range(10):
        if wanted in admin.list_available():
            ok = True
            break
        time.sleep(0.3)
    if not ok:
        print('FAIL %s: boards not available' % pretty)
        return False

    # let the client allocate a relay and manipulate it to make sure it has
    # connected to the relay server
    relay = client.get({
        'type':'relay','circuits':['usb.pc.vcc','handset.battery']
    })
    relay.set_circuit('usb.pc.vcc', False)

    # hand over to the replacement server
    state = handover.begin_handover()
    takeover = factory.make_server(state['boards'], make_socket=False)
    takeover.set_boards([setup.BOARD_1,setup.BOARD_2,setup.BOARD_3])
    handover.end_handover(__async__=True)

    try:
        relay.set_circuit('handset.battery', False)
    except AveException, e:
        print e.format_trace()
        print('FAIL %s: could not set battery circuit: %s' % (pretty, e))
        return False