コード例 #1
0
def test_creates_defined_user():
    assert User.objects.count() == 1  # anonymous user exists
    faker = Faker()
    user = create_user(username="******", faker=faker)
    user.save()
    assert User.objects.count() == 2
    assert user.username == "berth_user"
コード例 #2
0
def test_creates_random_user():
    assert User.objects.count() == 1  # anonymous user exists
    user = create_user(faker=Faker())
    assert user
    assert User.objects.count() == 1
    user.save()
    assert User.objects.count() == 2
コード例 #3
0
def client():
    user_name = 'test'

    user_file = tempfile.NamedTemporaryFile(mode="w+")
    user_file.write(json.dumps({}))
    user_file.flush()

    password = create_user(user_name, user_file.name)

    app.config['USER_NAME'] = user_name
    app.config['TESTING'] = True
    app.config['PASSWORD'] = password
    app.config['USER_FILE'] = user_file.name

    with app.test_client() as client:
        yield client
コード例 #4
0
def main():
    config = ConfigParser.ConfigParser()
    config.read("Testsuite/2_Unixbench2_test/parameters.cfg")
    No_of_cloudspaces = int(config.get("parameters", "No_of_cloudspaces"))
    VMs = int(config.get("parameters", "VMs"))
    cpus = int(config.get("parameters", "cpus"))
    memory = int(config.get("parameters", "memory"))
    Bdisksize = int(config.get("parameters", "Bdisksize"))
    no_of_disks = 0
    data_disksize = 0
    vm_specs = [no_of_disks, data_disksize, Bdisksize, memory, cpus]

    sys.path.append(os.getcwd())
    from utils import utils

    ccl = j.clients.osis.getNamespace('cloudbroker')
    pcl = j.clients.portal.getByInstance('main')
    scl = j.clients.osis.getNamespace('system')

    USERNAME = '******'
    email = "*****@*****.**" % str(uuid.uuid4())[0:8]
    utils.create_user(USERNAME, email, pcl, scl)
    ACCOUNTNAME = str(uuid.uuid4())[0:8]
    accountId = utils.create_account(USERNAME, email, ACCOUNTNAME, ccl, pcl)

    cloudspaces_list = []
    for i in range(No_of_cloudspaces):
        cloudspace = utils.create_cloudspace(accountId,
                                             USERNAME,
                                             ccl,
                                             pcl,
                                             cs_name='default_%s' % i)
        cloudspaces_list.append(cloudspace)
    cloudspace_publicport = 2000

    stacks = utils.get_stacks(ccl)
    current_stack = ccl.stack.search({
        'referenceId':
        str(j.application.whoAmI.nid),
        'gid':
        j.application.whoAmI.gid
    })[1]
    stacks.remove(current_stack['id'])
    stacks_temp = []

    def select_stackid():
        global stacks_temp
        ns = list(set(stacks) - set(stacks_temp))
        stacks_temp.append(ns[0])
        if (len(stacks_temp) == len(stacks)):
            stacks_temp = []
        return ns[0]

    print('creating %s vms' % VMs)
    machines = []
    iteration = 1
    c = 0
    for k in range(VMs):
        [machineId,
         cloudspace_ip] = utils.create_machine_onStack(select_stackid(),
                                                       cloudspaces_list[c],
                                                       iteration,
                                                       ccl,
                                                       pcl,
                                                       scl,
                                                       vm_specs,
                                                       cloudspace_publicport,
                                                       Res_dir='test_res')
        machines.append([
            machineId, cloudspace_ip, cloudspace_publicport,
            cloudspaces_list[c]
        ])
        c += 1
        if c == No_of_cloudspaces:
            c = 0
        iteration += 1
        cloudspace_publicport += 1

    # installing unixbench on machines
    print('Installing Unixbench on required machines')
    processes = []
    for vm in machines:
        vmid = vm[0]
        cs = vm[3]
        cs_pp = vm[2]
        p = multiprocessing.Process(
            target=utils.Install_unixbench,
            args=(vmid, cs, cs_pp, pcl,
                  'Testsuite/2_Unixbench2_test/2_machine_script.py'))
        processes.append(p)
    for l in range(len(processes)):
        processes[l].start()
        time.sleep(1)
    for k in range(len(processes)):
        processes[k].join()

    #removing finger prints
    for vm in machines:
        cs_ip = vm[1]
        cs_pp = vm[2]
        j.do.execute('ssh-keygen -f "/root/.ssh/known_hosts" -R [%s]:%s' %
                     (cs_ip, cs_pp))
コード例 #5
0
        j.sal.process.execute('rm -rf /test_results/*')
    j.sal.process.execute('mkdir -p /test_results')
    sys.path.append(os.getcwd())
    from utils import utils
    j.sal.process.execute('apt-get install sshpass')

    stacks = utils.remove_ovsnodes_from_stacks(utils.get_stacks(ccl), ccl)
    #current_stack = ccl.stack.search({'referenceId': str(j.application.whoAmI.nid), 'gid': j.application.whoAmI.gid})[1]
    #stacks.remove(current_stack['id'])
    stacks = stacks[0:used_stacks]
    vm_specs = [no_of_disks, data_disksize, Bdisksize, memory, cpu]
    cloudspace_publicport = 7000


    email = "*****@*****.**" % str(uuid.uuid4())[0:8]
    utils.create_user(USERNAME, email,  pcl, scl)

    cloudspaces_list=[]
    accountId = utils.create_account(USERNAME, email, ACCOUNTNAME, ccl, pcl)
    for i in range(No_of_cloudspaces):
        cloudspace = utils.create_cloudspace(accountId, USERNAME, ccl, pcl, cs_name='default_%s'%i)
        cloudspaces_list.append(cloudspace)


    #cloudspace = utils.create_account_cloudspace(USERNAME, email, ACCOUNTNAME, ccl, pcl, scl)

    vms_list = []
    i=0
    c=0
    while i < No_of_vms:
        for stackId in stacks:
コード例 #6
0
def test_create_user_returns_existing_user():
    username = "******"
    faker = Faker()
    user1 = create_user(username=username, faker=faker)
    user2 = create_user(username=username, faker=faker)
    assert user1 == user2
コード例 #7
0
def main():
    ccl = j.clients.osis.getNamespace('cloudbroker')
    pcl = j.clients.portal.getByInstance('main')
    scl = j.clients.osis.getNamespace('system')

    No_of_vms= int(sys.argv[1])

    #run the setup_test from inside the repo so the file could be parsed
    config = ConfigParser.ConfigParser()
    config.read("Testsuite/1_fio_vms/Perf_parameters.cfg")
    used_stacks = int(config.get("perf_parameters", "used_stacks"))
    memory = int(config.get("perf_parameters", "memory"))
    cpu = int(config.get("perf_parameters", "cpu"))
    Bdisksize = int(config.get("perf_parameters", "Bdisksize"))
    no_of_disks = int(config.get("perf_parameters", "no_of_disks"))
    data_disksize = int(config.get("perf_parameters", "data_disksize"))
    No_of_cloudspaces = int(config.get("perf_parameters", "No_of_cloudspaces"))
    USERNAME = config.get("perf_parameters", "username")
    ACCOUNTNAME = str(uuid.uuid4())[0:8]
    Res_dir = config.get("perf_parameters", "Res_dir")
    j.do.execute('mkdir -p %s' % Res_dir)
    if j.do.exists('/test_results'):
        j.do.execute('rm -rf /test_results/*')
    j.do.execute('mkdir -p /test_results')
    sys.path.append(os.getcwd())
    from utils import utils
    j.do.execute('apt-get install sshpass')

    stacks = utils.remove_ovsnodes_from_stacks(utils.get_stacks(ccl), ccl)
    #current_stack = ccl.stack.search({'referenceId': str(j.application.whoAmI.nid), 'gid': j.application.whoAmI.gid})[1]
    #stacks.remove(current_stack['id'])
    stacks = stacks[0:used_stacks]
    vm_specs = [no_of_disks, data_disksize, Bdisksize, memory, cpu]
    cloudspace_publicport = 7000


    email = "*****@*****.**" % str(uuid.uuid4())[0:8]
    utils.create_user(USERNAME, email,  pcl, scl)

    cloudspaces_list=[]
    accountId = utils.create_account(USERNAME, email, ACCOUNTNAME, ccl, pcl)
    for i in range(No_of_cloudspaces):
        cloudspace = utils.create_cloudspace(accountId, USERNAME, ccl, pcl, cs_name='default_%s'%i)
        cloudspaces_list.append(cloudspace)


    #cloudspace = utils.create_account_cloudspace(USERNAME, email, ACCOUNTNAME, ccl, pcl, scl)

    vms_list = []
    i=0
    c=0
    while i < No_of_vms:
        for stackId in stacks:
            cloudspace_publicport += 1
            [machineId, cloudspace_publicip] = utils.create_machine_onStack(stackId, cloudspaces_list[c], '_%s' %i, ccl, pcl, scl,
                                                                          vm_specs, cloudspace_publicport, Res_dir='/test_results')
            c += 1
            if c==No_of_cloudspaces:
                c=0
            vms_list.append({machineId: [cloudspace_publicip, cloudspace_publicport]})
            i += 1
            if i == No_of_vms:
                break
    #Removing vms fingerprints entries from known hosts
    for vm in vms_list:
        machineId = vm.keys()[0]
        cloudspace_publicip=vm[machineId][0]
        cloudspace_publicport=vm[machineId][1]
        j.do.execute('ssh-keygen -f "/root/.ssh/known_hosts" -R [%s]:%s'
                     %(cloudspace_publicip, cloudspace_publicport))