Example #1
0
  public void testUpdateQuotasOfCurrentTenantThenReset() {
    if (apiOption.isPresent()) {
      QuotaApi api = apiOption.get();
      Quota before = api.getByTenant(tenant);
      assertQuotasIsValid(before);

      Quota modified =
          before
              .toBuilder()
              .cores(before.getCores() - 1)
              .instances(before.getInstances() - 1)
              .metadataItems(before.getMetadatas() - 1)
              .ram(before.getRam() - 1)
              .volumes(before.getVolumes() - 1)
              .build();

      assertTrue(api.updateQuotaOfTenant(modified, tenant));

      assertEquals(api.getByTenant(tenant), modified);

      assertTrue(api.updateQuotaOfTenant(before, tenant));

      assertEquals(api.getByTenant(tenant), before);
    }
  }
Example #2
0
 protected void assertQuotasIsValid(Quota quota) {
   assertTrue(quota.getCores() > 0);
   assertTrue(quota.getFloatingIps() >= 0);
   assertTrue(quota.getGigabytes() > 0);
   assertTrue(quota.getInjectedFileContentBytes() >= 0);
   assertTrue(quota.getInjectedFiles() >= 0);
   assertTrue(quota.getInstances() > 0);
   assertTrue(quota.getKeyPairs() > 0);
   assertTrue(quota.getRam() > 0);
   assertTrue(quota.getSecurityGroups() > 0);
   assertTrue(quota.getSecurityGroupRules() > 0);
   assertTrue(quota.getVolumes() > 0);
 }