Package org.jclouds.openstack.trove.v1.features

Examples of org.jclouds.openstack.trove.v1.features.UserApiExpectTest


        List<HttpResponse> responses = ImmutableList.of(responseWithKeystoneAccess,                       createInstanceFail, createInstanceFail, createInstanceSuccess, badStatus,   deleteInstanceResponse, deletedStatus, createInstanceFail, createInstanceSuccess, goodStatus);

        TroveApi api = orderedRequestsSendResponses(requests, responses);

        TroveUtils utils = new TroveUtils(api);
        Instance instance = utils.getWorkingInstance("RegionOne", "json_rack_instance", "1", 2);
        assertEquals(instance.getSize(),2);
        assertEquals(instance.getName(), "json_rack_instance")
    }
View Full Code Here


        TroveUtils utils = new TroveUtils(api);
        for (String zone : api.getConfiguredZones()) {
            List<Instance> zoneList = Lists.newArrayList();
            InstanceApi instanceApi = api.getInstanceApiForZone(zone);
            zoneList.add(utils.getWorkingInstance(zone, "first_instance_testing_" + zone, "1", 1));
            Instance second = utils.getWorkingInstance(zone, "second_instance_testing_" + zone, "1", 1);
            instanceApi.enableRoot(second.getId());
            zoneList.add(second);           
            created.put(zone, zoneList);
        }
    }
View Full Code Here

    @Test
    public void testGetInstance() {
        for (String zone : api.getConfiguredZones()) {
            InstanceApi instanceApi = api.getInstanceApiForZone(zone);          
            for (Instance instance : instanceApi.list()) {
                Instance instanceFromGet = instanceApi.get(instance.getId());
                assertNotNull(instanceFromGet.getHostname());
                assertNull(instance.getHostname());
                assertEquals(instanceFromGet.getId(), instance.getId());
                assertEquals(instanceFromGet.getName(), instance.getName());
                assertEquals(instanceFromGet.getStatus(), instance.getStatus());
                assertEquals(instanceFromGet.getFlavor(), instance.getFlavor());
                assertEquals(instanceFromGet.getSize(), instance.getSize());
                assertEquals(instanceFromGet.getLinks(), instance.getLinks());
            }
        }
    }
View Full Code Here

    @Test
    public void testGetRootStatus() {
        for (String zone : api.getConfiguredZones()) {
            InstanceApi instanceApi = api.getInstanceApiForZone(zone);
            Iterator<Instance> iterator = instanceApi.list().iterator();
            Instance first;
            Instance second;
            do {
               first = iterator.next();
            } while(!first.getName().contains("instance_testing"));
            do {
               second = iterator.next();
            } while(!second.getName().contains("instance_testing"));
            assertTrue(instanceApi.isRooted(first.getId()) || instanceApi.isRooted(second.getId()));
        }
    }
View Full Code Here

                .payload(payloadFromResourceWithContentType("/instance_create_request.json", MediaType.APPLICATION_JSON))
                .build(),
                HttpResponse.builder().statusCode(200).payload(payloadFromResource("/instance_create.json")).build() // response
                ).getInstanceApiForZone("RegionOne");

        Instance instance = api.create("1", 2, "json_rack_instance");
        assertEquals(instance.getSize(), 2);
        assertEquals(instance.getName(), "json_rack_instance")
    }
View Full Code Here

            responseWithKeystoneAccess,
            authenticatedGET().endpoint(endpoint).build(),
            HttpResponse.builder().statusCode(200).payload(payloadFromResource("/instance_get.json")).build()
      ).getInstanceApiForZone("RegionOne");

      Instance instance = api.get("44b277eb-39be-4921-be31-3d61b43651d7");
      assertEquals(instance.getName(), "json_rack_instance");
      assertEquals(instance.getId(), "44b277eb-39be-4921-be31-3d61b43651d7");
      assertEquals(instance.getLinks().size(), 2);
      assertEquals(instance.getHostname(), "e09ad9a3f73309469cf1f43d11e79549caf9acf2.rackspaceclouddb.com");
   }
View Full Code Here

    * @return Instance object in active state or NULL.
    */
   public Instance getWorkingInstance(String zone, String name, String flavorId, int size) {
      InstanceApi instanceApi = api.getInstanceApiForZone(zone);
      for (int retries = 0; retries < 10; retries++) {
         Instance instance = null;
         try {
            instance = instanceApi.create(flavorId, size, name);
         } catch (Exception e) {

            Uninterruptibles.sleepUninterruptibly(15, TimeUnit.SECONDS);

            logger.error(Arrays.toString(e.getStackTrace()));
            continue;
         }

         Instance updatedInstance = awaitAvailable(instance, instanceApi);
         if (updatedInstance != null) {
            return updatedInstance;
         }
         instanceApi.delete(instance.getId());
         InstancePredicates.awaitDeleted(instanceApi).apply(instance);
View Full Code Here

      return getWorkingInstance(zone, UUID.randomUUID().toString(), "1", 1);
   }

   private Instance awaitAvailable(Instance instance, InstanceApi iapi) {
      for (int n = 0; n < 100; n = n + 1) {
         Instance updatedInstance = iapi.get(instance.getId());
         if (updatedInstance.getStatus() == Instance.Status.ACTIVE)
            return updatedInstance;
         if (updatedInstance.getStatus() == Instance.Status.UNRECOGNIZED)
            return null; // fast fail
         Uninterruptibles.sleepUninterruptibly(15, TimeUnit.SECONDS);
      }
      return null;
   }
View Full Code Here

        
         if (status.equals(instance.getStatus())) {
            return true;
         }
         else {
            Instance instanceUpdated = instanceApi.get(instance.getId());
            checkNotNull(instanceUpdated, "Instance %s not found.", instance.getId());
           
            return status.equals(instanceUpdated.getStatus());
         }
      }
View Full Code Here

   private void createInstance(Flavor flavor) throws TimeoutException {
      System.out.format("Create Instance for Flavor: %s%n", flavor.getId());

      TroveUtils utils = new TroveUtils(troveApi);
      // This call will take a while - it ensures a working instance is created.
      Instance instance = utils.getWorkingInstance(ZONE, NAME, "" + flavor.getId(), 1);

      System.out.format("  %s%n", instance);
   }
View Full Code Here

TOP

Related Classes of org.jclouds.openstack.trove.v1.features.UserApiExpectTest

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.