Пример #1
0
 def test_allocation(cls, data):
     extra_data = {}
     extra_data.update(data)
     member = extra_data[
         GeneralConfigurations.
         provider] if GeneralConfigurations.provider in extra_data else GeneralConfigurations.local_member
     if not CommonMethods.wait_compute_available(
             GeneralConfigurations.max_computes, member):
         print('  Failed. There is not %d instances available.' %
               GeneralConfigurations.max_computes)
         return
     response_get_allocation = cls.get_allocation(member)
     if response_get_allocation.status_code != 200:
         print('  Failed, trying next test')
         return
     if not cls.empty_allocation(response_get_allocation.json()):
         print(response_get_allocation.json())
         print('  Failed, allocationMode already in use, trying next test')
         return
     orders_id = CommonMethods.post_multiple_orders(
         extra_data, GeneralConfigurations.max_computes,
         GeneralConfigurations.type_compute)
     if not orders_id:
         print('  Failed. Could not create computes')
         return
     for order in orders_id:
         cls.wait_instance_ready(order, GeneralConfigurations.type_compute)
     response_get_allocation = cls.get_allocation(member)
     allocationMode = response_get_allocation.json()
     if cls.empty_allocation(allocationMode):
         CommonMethods.delete_multiple_orders(
             orders_id, GeneralConfigurations.type_compute)
         print(
             '  Failed. Allocation was not in use. Actual allocationMode was: %s'
             % allocationMode)
         return
     if allocationMode['instances'] == GeneralConfigurations.max_computes:
         print('  Ok. Removing compute')
     else:
         print('  Failed. Removing compute')
     CommonMethods.delete_multiple_orders(
         orders_id, GeneralConfigurations.type_compute)
Пример #2
0
 def test_get_all_compute(cls, data):
     extra_data = {}
     extra_data.update(data)
     member = extra_data[
         GeneralConfigurations.
         provider] if GeneralConfigurations.provider in extra_data else GeneralConfigurations.local_member
     if not CommonMethods.wait_compute_available(
             GeneralConfigurations.max_computes, member):
         print('  Failed. There is not %d instances available.' %
               GeneralConfigurations.max_computes)
         return
     response_get = CommonMethods.get_all_order(
         GeneralConfigurations.type_compute)
     if response_get.status_code != GeneralConfigurations.ok_status or response_get.text != '[]':
         print(
             '  Failed. Wrong status in get request, got status: %d, and message: %s'
             % (response_get.status_code, response_get.text))
         return
     orders_id = CommonMethods.post_multiple_orders(
         extra_data, GeneralConfigurations.max_computes,
         GeneralConfigurations.type_compute)
     if not orders_id:
         print('  Failed. Could not create computes')
         return
     if GeneralConfigurations.provider in extra_data:
         #if it is remote, we need to wait order request to be received
         time.sleep(10)
     response_get = CommonMethods.get_all_order(
         GeneralConfigurations.type_compute)
     test_ok = not (
         response_get.status_code != GeneralConfigurations.ok_status
         or response_get.text == '[]'
         or len(response_get.json()) != GeneralConfigurations.max_computes)
     if test_ok:
         print('  Ok. Removing computes')
     else:
         print('  Failed. Removing computes')
     CommonMethods.delete_multiple_orders(
         orders_id, GeneralConfigurations.type_compute)
Пример #3
0
 def test_get_all_networks(cls, data):
     extra_data = {}
     extra_data.update(data)
     response_get = CommonMethods.get_all_order(
         GeneralConfigurations.type_network)
     time.sleep(10)
     if response_get.status_code != GeneralConfigurations.ok_status or response_get.text != '[]':
         print(
             '  Failed. There was a network created already. Received http status %d and message: %s'
             % (response_get.status_code, response_get.text))
         return
     orders_id = CommonMethods.post_multiple_orders(
         extra_data, GeneralConfigurations.max_networks,
         GeneralConfigurations.type_network)
     if not orders_id:
         print('  Failed. Could not create networks')
         return
     if GeneralConfigurations.provider in extra_data:
         #if it is remote, we need to wait order request to be received
         time.sleep(10)
     response_get = CommonMethods.get_all_order(
         GeneralConfigurations.type_network)
     test_ok = not (
         response_get.status_code != GeneralConfigurations.ok_status
         or response_get.text == '[]'
         or len(response_get.json()) != GeneralConfigurations.max_networks)
     if test_ok:
         print('  Ok. Removing networks')
     else:
         print('  Failed. Removing networks')
     CommonMethods.delete_multiple_orders(
         orders_id, GeneralConfigurations.type_network)
     if GeneralConfigurations.provider in extra_data:
         #if it is remote, we need to wait order request to be received
         time.sleep(40)
     else:
         time.sleep(10)