mirror of https://github.com/apache/jclouds.git
Reduced the number of failing tests from 48 to 23
* ID equality test fixes. Changed from == to .equals * throw ResourceNotFoundException for all server responses with code 431 that contain "does not exist" * skip tests rather than failing when running the suite as a regular or domain admin user. It's not possible to have global admin access on public clouds
This commit is contained in:
parent
c18c97552f
commit
03867b97b2
|
@ -71,8 +71,7 @@ public class CloudStackErrorHandler implements HttpErrorHandler {
|
||||||
break;
|
break;
|
||||||
case 409:
|
case 409:
|
||||||
case 431:
|
case 431:
|
||||||
if (command.getCurrentRequest().getRequestLine().indexOf("delete") != -1
|
if (message.contains("does not exist")) {
|
||||||
&& message.indexOf("does not exist") != -1) {
|
|
||||||
exception = new ResourceNotFoundException(message, exception);
|
exception = new ResourceNotFoundException(message, exception);
|
||||||
} else {
|
} else {
|
||||||
exception = new IllegalStateException(message, exception);
|
exception = new IllegalStateException(message, exception);
|
||||||
|
|
|
@ -49,7 +49,7 @@ public class AccountClientLiveTest extends BaseCloudStackClientLiveTest {
|
||||||
assert user.getName() != null : user;
|
assert user.getName() != null : user;
|
||||||
assert user.getAccountType().equals(account.getType()) : user;
|
assert user.getAccountType().equals(account.getType()) : user;
|
||||||
assert user.getDomain().equals(account.getDomain()) : user;
|
assert user.getDomain().equals(account.getDomain()) : user;
|
||||||
assert user.getDomainId() == account.getDomainId() : user;
|
assert user.getDomainId().equals(account.getDomainId()) : user;
|
||||||
assert user.getApiKey() != null : user;
|
assert user.getApiKey() != null : user;
|
||||||
assert user.getCreated() != null : user;
|
assert user.getCreated() != null : user;
|
||||||
assert user.getEmail() != null : user;
|
assert user.getEmail() != null : user;
|
||||||
|
|
|
@ -57,6 +57,7 @@ import org.jclouds.predicates.RetryablePredicate;
|
||||||
import org.jclouds.rest.RestContext;
|
import org.jclouds.rest.RestContext;
|
||||||
import org.jclouds.ssh.SshClient;
|
import org.jclouds.ssh.SshClient;
|
||||||
import org.jclouds.sshj.config.SshjSshClientModule;
|
import org.jclouds.sshj.config.SshjSshClientModule;
|
||||||
|
import org.testng.SkipException;
|
||||||
import org.testng.annotations.AfterGroups;
|
import org.testng.annotations.AfterGroups;
|
||||||
import org.testng.annotations.BeforeGroups;
|
import org.testng.annotations.BeforeGroups;
|
||||||
|
|
||||||
|
@ -270,6 +271,18 @@ public class BaseCloudStackClientLiveTest extends BaseGenericComputeServiceConte
|
||||||
return currentUser;
|
return currentUser;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void skipIfNotDomainAdmin() {
|
||||||
|
if (!domainAdminEnabled) {
|
||||||
|
throw new SkipException("Test cannot run without domain admin identity and credentials");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void skipIfNotGlobalAdmin() {
|
||||||
|
if (!globalAdminEnabled) {
|
||||||
|
throw new SkipException("Test cannot run without global admin identity and credentials");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@AfterGroups(groups = "live")
|
@AfterGroups(groups = "live")
|
||||||
protected void tearDown() {
|
protected void tearDown() {
|
||||||
if (cloudStackContext != null)
|
if (cloudStackContext != null)
|
||||||
|
|
|
@ -38,7 +38,7 @@ public class DomainAccountClientLiveTest extends BaseCloudStackClientLiveTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testEnableDisableAccount() {
|
public void testEnableDisableAccount() {
|
||||||
assert globalAdminEnabled;
|
skipIfNotGlobalAdmin();
|
||||||
|
|
||||||
Account testAccount = null;
|
Account testAccount = null;
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -43,7 +43,7 @@ public class DomainDomainClientLiveTest extends BaseCloudStackClientLiveTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testListDomains() {
|
public void testListDomains() {
|
||||||
assert domainAdminEnabled;
|
skipIfNotDomainAdmin();
|
||||||
|
|
||||||
Set<Domain> allDomains = domainAdminClient.getDomainClient().listDomains();
|
Set<Domain> allDomains = domainAdminClient.getDomainClient().listDomains();
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ public class DomainDomainClientLiveTest extends BaseCloudStackClientLiveTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testListDomainChildren() {
|
public void testListDomainChildren() {
|
||||||
assert domainAdminEnabled;
|
skipIfNotDomainAdmin();
|
||||||
|
|
||||||
Set<Domain> allDomains = domainAdminClient.getDomainClient().listDomains();
|
Set<Domain> allDomains = domainAdminClient.getDomainClient().listDomains();
|
||||||
Domain root = find(allDomains, withName("ROOT"));
|
Domain root = find(allDomains, withName("ROOT"));
|
||||||
|
|
|
@ -40,7 +40,7 @@ public class DomainUserClientLiveTest extends BaseCloudStackClientLiveTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testListUsers() {
|
public void testListUsers() {
|
||||||
assert domainAdminEnabled;
|
skipIfNotDomainAdmin();
|
||||||
|
|
||||||
Set<User> users = domainAdminClient.getUserClient().listUsers();
|
Set<User> users = domainAdminClient.getUserClient().listUsers();
|
||||||
|
|
||||||
|
@ -60,7 +60,8 @@ public class DomainUserClientLiveTest extends BaseCloudStackClientLiveTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testEnableDisableUser() {
|
public void testEnableDisableUser() {
|
||||||
assert globalAdminEnabled && domainAdminEnabled;
|
skipIfNotDomainAdmin();
|
||||||
|
skipIfNotDomainAdmin();
|
||||||
|
|
||||||
Account testAccount = null;
|
Account testAccount = null;
|
||||||
User testUser = null;
|
User testUser = null;
|
||||||
|
|
|
@ -42,7 +42,7 @@ public class GlobalAccountClientLiveTest extends BaseCloudStackClientLiveTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCreateAndRemoveAccount() {
|
public void testCreateAndRemoveAccount() {
|
||||||
assert globalAdminEnabled;
|
skipIfNotGlobalAdmin();
|
||||||
|
|
||||||
Account account = null;
|
Account account = null;
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -38,7 +38,7 @@ public class GlobalAlertClientLiveTest extends BaseCloudStackClientLiveTest {
|
||||||
|
|
||||||
@Test(groups = "live", enabled = true)
|
@Test(groups = "live", enabled = true)
|
||||||
public void testListAlerts() throws Exception {
|
public void testListAlerts() throws Exception {
|
||||||
assertTrue(globalAdminEnabled, "Test cannot run without global admin identity and credentials");
|
skipIfNotGlobalAdmin();
|
||||||
|
|
||||||
final Set<Alert> response = globalAdminClient.getAlertClient().listAlerts(ListAlertsOptions.Builder.id("20"));
|
final Set<Alert> response = globalAdminClient.getAlertClient().listAlerts(ListAlertsOptions.Builder.id("20"));
|
||||||
assert null != response;
|
assert null != response;
|
||||||
|
|
|
@ -36,7 +36,7 @@ public class GlobalCapacityClientLiveTest extends BaseCloudStackClientLiveTest {
|
||||||
|
|
||||||
@Test(groups = "live", enabled = true)
|
@Test(groups = "live", enabled = true)
|
||||||
public void testListCapacity() throws Exception {
|
public void testListCapacity() throws Exception {
|
||||||
assertTrue(globalAdminEnabled, "Test cannot run without global admin identity and credentials");
|
skipIfNotGlobalAdmin();
|
||||||
|
|
||||||
final Set<Capacity> response = globalAdminClient.getCapacityClient().listCapacity();
|
final Set<Capacity> response = globalAdminClient.getCapacityClient().listCapacity();
|
||||||
assert null != response;
|
assert null != response;
|
||||||
|
|
|
@ -45,7 +45,7 @@ public class GlobalConfigurationClientLiveTest extends BaseCloudStackClientLiveT
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testListConfigurationEntries() {
|
public void testListConfigurationEntries() {
|
||||||
assert globalAdminEnabled;
|
skipIfNotGlobalAdmin();
|
||||||
|
|
||||||
Set<ConfigurationEntry> entries = globalAdminClient
|
Set<ConfigurationEntry> entries = globalAdminClient
|
||||||
.getConfigurationClient().listConfigurationEntries();
|
.getConfigurationClient().listConfigurationEntries();
|
||||||
|
@ -62,7 +62,7 @@ public class GlobalConfigurationClientLiveTest extends BaseCloudStackClientLiveT
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUpdateConfigurationEntry() {
|
public void testUpdateConfigurationEntry() {
|
||||||
assert globalAdminEnabled;
|
skipIfNotGlobalAdmin();
|
||||||
|
|
||||||
Set<ConfigurationEntry> entries = globalAdminClient
|
Set<ConfigurationEntry> entries = globalAdminClient
|
||||||
.getConfigurationClient().listConfigurationEntries();
|
.getConfigurationClient().listConfigurationEntries();
|
||||||
|
|
|
@ -55,7 +55,7 @@ public class GlobalDomainClientLiveTest extends BaseCloudStackClientLiveTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCreateUpdateDeleteDomain() {
|
public void testCreateUpdateDeleteDomain() {
|
||||||
assert globalAdminEnabled;
|
skipIfNotDomainAdmin();
|
||||||
|
|
||||||
Domain domain = null;
|
Domain domain = null;
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -40,7 +40,7 @@ public class GlobalHostClientLiveTest extends BaseCloudStackClientLiveTest {
|
||||||
|
|
||||||
@Test(groups = "live", enabled = true)
|
@Test(groups = "live", enabled = true)
|
||||||
public void testListHosts() throws Exception {
|
public void testListHosts() throws Exception {
|
||||||
assertTrue(globalAdminEnabled, "Test cannot run without global admin identity and credentials");
|
skipIfNotGlobalAdmin();
|
||||||
|
|
||||||
Set<Host> hosts = globalAdminClient.getHostClient().listHosts();
|
Set<Host> hosts = globalAdminClient.getHostClient().listHosts();
|
||||||
assert hosts.size() > 0 : hosts;
|
assert hosts.size() > 0 : hosts;
|
||||||
|
@ -68,7 +68,7 @@ public class GlobalHostClientLiveTest extends BaseCloudStackClientLiveTest {
|
||||||
|
|
||||||
@Test(groups = "live", enabled = true)
|
@Test(groups = "live", enabled = true)
|
||||||
public void testListClusters() throws Exception {
|
public void testListClusters() throws Exception {
|
||||||
assertTrue(globalAdminEnabled, "Test cannot run without global admin identity and credentials");
|
skipIfNotGlobalAdmin();
|
||||||
|
|
||||||
Set<Cluster> clusters = globalAdminClient.getHostClient().listClusters();
|
Set<Cluster> clusters = globalAdminClient.getHostClient().listClusters();
|
||||||
assert clusters.size() > 0 : clusters;
|
assert clusters.size() > 0 : clusters;
|
||||||
|
|
|
@ -50,7 +50,7 @@ public class GlobalOfferingClientLiveTest extends BaseCloudStackClientLiveTest {
|
||||||
|
|
||||||
@Test(groups = "live", enabled = true)
|
@Test(groups = "live", enabled = true)
|
||||||
public void testCreateServiceOffering() throws Exception {
|
public void testCreateServiceOffering() throws Exception {
|
||||||
assertTrue(globalAdminEnabled, "Test cannot run without global admin identity and credentials");
|
skipIfNotGlobalAdmin();
|
||||||
|
|
||||||
String name = prefix + "-test-create-service-offering";
|
String name = prefix + "-test-create-service-offering";
|
||||||
String displayText = name + "-display";
|
String displayText = name + "-display";
|
||||||
|
@ -90,7 +90,7 @@ public class GlobalOfferingClientLiveTest extends BaseCloudStackClientLiveTest {
|
||||||
|
|
||||||
@Test(groups = "live", enabled = true)
|
@Test(groups = "live", enabled = true)
|
||||||
public void testCreateDiskOffering() throws Exception {
|
public void testCreateDiskOffering() throws Exception {
|
||||||
assertTrue(globalAdminEnabled, "Test cannot run without global admin identity and credentials");
|
skipIfNotGlobalAdmin();
|
||||||
|
|
||||||
String name = prefix + "-test-create-disk-offering";
|
String name = prefix + "-test-create-disk-offering";
|
||||||
String displayText = name + "-display";
|
String displayText = name + "-display";
|
||||||
|
@ -127,7 +127,7 @@ public class GlobalOfferingClientLiveTest extends BaseCloudStackClientLiveTest {
|
||||||
|
|
||||||
@Test(groups = "live", enabled = true)
|
@Test(groups = "live", enabled = true)
|
||||||
public void testUpdateNetworkOffering() throws Exception {
|
public void testUpdateNetworkOffering() throws Exception {
|
||||||
assertTrue(globalAdminEnabled, "Test cannot run without global admin identity and credentials");
|
skipIfNotGlobalAdmin();
|
||||||
|
|
||||||
NetworkOffering offering = getFirst(globalAdminClient.getOfferingClient().listNetworkOfferings(), null);
|
NetworkOffering offering = getFirst(globalAdminClient.getOfferingClient().listNetworkOfferings(), null);
|
||||||
assertNotNull(offering, "Unable to test, no network offering found.");
|
assertNotNull(offering, "Unable to test, no network offering found.");
|
||||||
|
|
|
@ -51,10 +51,13 @@ public class GlobalPodClientLiveTest extends BaseCloudStackClientLiveTest {
|
||||||
private Pod pod;
|
private Pod pod;
|
||||||
|
|
||||||
public void testListPods() throws Exception {
|
public void testListPods() throws Exception {
|
||||||
|
skipIfNotGlobalAdmin();
|
||||||
|
|
||||||
Set<Pod> response = globalAdminClient.getPodClient().listPods();
|
Set<Pod> response = globalAdminClient.getPodClient().listPods();
|
||||||
assert null != response;
|
assert null != response;
|
||||||
long podCount = response.size();
|
long podCount = response.size();
|
||||||
assertTrue(podCount >= 0);
|
assertTrue(podCount >= 0);
|
||||||
|
|
||||||
for (Pod pod : response) {
|
for (Pod pod : response) {
|
||||||
Pod newDetails = Iterables.getOnlyElement(globalAdminClient.getPodClient().listPods(
|
Pod newDetails = Iterables.getOnlyElement(globalAdminClient.getPodClient().listPods(
|
||||||
ListPodsOptions.Builder.id(pod.getId())));
|
ListPodsOptions.Builder.id(pod.getId())));
|
||||||
|
@ -74,7 +77,7 @@ public class GlobalPodClientLiveTest extends BaseCloudStackClientLiveTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCreatePod() {
|
public void testCreatePod() {
|
||||||
assertTrue(globalAdminEnabled, "Global admin credentials must be given");
|
skipIfNotGlobalAdmin();
|
||||||
|
|
||||||
zone = globalAdminClient.getZoneClient().createZone(prefix + "-zone", NetworkType.BASIC, "8.8.8.8", "10.10.10.10");
|
zone = globalAdminClient.getZoneClient().createZone(prefix + "-zone", NetworkType.BASIC, "8.8.8.8", "10.10.10.10");
|
||||||
pod = globalAdminClient.getPodClient().createPod(prefix + "-pod", zone.getId(), "172.20.0.1", "172.20.0.250", "172.20.0.254", "255.255.255.0",
|
pod = globalAdminClient.getPodClient().createPod(prefix + "-pod", zone.getId(), "172.20.0.1", "172.20.0.250", "172.20.0.254", "255.255.255.0",
|
||||||
|
|
|
@ -39,7 +39,7 @@ public class GlobalStoragePoolClientLiveTest extends BaseCloudStackClientLiveTes
|
||||||
|
|
||||||
@Test(groups = "live", enabled = true)
|
@Test(groups = "live", enabled = true)
|
||||||
public void testListStoragePools() throws Exception {
|
public void testListStoragePools() throws Exception {
|
||||||
assertTrue(globalAdminEnabled, "Test cannot run without global admin identity and credentials");
|
skipIfNotGlobalAdmin();
|
||||||
|
|
||||||
Set<StoragePool> result = globalAdminClient.getStoragePoolClient().listStoragePools();
|
Set<StoragePool> result = globalAdminClient.getStoragePoolClient().listStoragePools();
|
||||||
assertNotNull(result);
|
assertNotNull(result);
|
||||||
|
|
|
@ -42,6 +42,8 @@ public class GlobalUsageClientLiveTest extends BaseCloudStackClientLiveTest {
|
||||||
|
|
||||||
@Test(groups = "live", enabled = true)
|
@Test(groups = "live", enabled = true)
|
||||||
public void testListUsage() {
|
public void testListUsage() {
|
||||||
|
skipIfNotGlobalAdmin();
|
||||||
|
|
||||||
Calendar c = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
|
Calendar c = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
|
||||||
Date end = c.getTime();
|
Date end = c.getTime();
|
||||||
c.add(Calendar.MONTH, -1);
|
c.add(Calendar.MONTH, -1);
|
||||||
|
|
|
@ -50,7 +50,7 @@ public class GlobalUserClientLiveTest extends BaseCloudStackClientLiveTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCreateUser() {
|
public void testCreateUser() {
|
||||||
assert globalAdminEnabled;
|
skipIfNotGlobalAdmin();
|
||||||
|
|
||||||
Account testAccount = createTestAccount(globalAdminClient, prefix);
|
Account testAccount = createTestAccount(globalAdminClient, prefix);
|
||||||
User testUser = null;
|
User testUser = null;
|
||||||
|
|
|
@ -57,10 +57,13 @@ public class GlobalVlanClientLiveTest extends BaseCloudStackClientLiveTest {
|
||||||
private VlanIPRange range;
|
private VlanIPRange range;
|
||||||
|
|
||||||
public void testListVlanIPRanges() throws Exception {
|
public void testListVlanIPRanges() throws Exception {
|
||||||
|
skipIfNotGlobalAdmin();
|
||||||
|
|
||||||
Set<VlanIPRange> response = globalAdminClient.getVlanClient().listVlanIPRanges();
|
Set<VlanIPRange> response = globalAdminClient.getVlanClient().listVlanIPRanges();
|
||||||
assert null != response;
|
assert null != response;
|
||||||
long rangeCount = response.size();
|
long rangeCount = response.size();
|
||||||
assertTrue(rangeCount >= 0);
|
assertTrue(rangeCount >= 0);
|
||||||
|
|
||||||
for (VlanIPRange range : response) {
|
for (VlanIPRange range : response) {
|
||||||
VlanIPRange newDetails = Iterables.getOnlyElement(globalAdminClient.getVlanClient().listVlanIPRanges(
|
VlanIPRange newDetails = Iterables.getOnlyElement(globalAdminClient.getVlanClient().listVlanIPRanges(
|
||||||
ListVlanIPRangesOptions.Builder.id(range.getId())));
|
ListVlanIPRangesOptions.Builder.id(range.getId())));
|
||||||
|
@ -90,7 +93,7 @@ public class GlobalVlanClientLiveTest extends BaseCloudStackClientLiveTest {
|
||||||
new Predicate<Network>() {
|
new Predicate<Network>() {
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Network network) {
|
public boolean apply(Network network) {
|
||||||
return network.getNetworkOfferingId() == offering.getId();
|
return network.getNetworkOfferingId().equals(offering.getId());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@ public class GlobalZoneClientLiveTest extends BaseCloudStackClientLiveTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCreateUpdateDeleteZone() {
|
public void testCreateUpdateDeleteZone() {
|
||||||
assert globalAdminEnabled;
|
skipIfNotGlobalAdmin();
|
||||||
|
|
||||||
Zone zone = null;
|
Zone zone = null;
|
||||||
String zoneName = prefix + "-zone";
|
String zoneName = prefix + "-zone";
|
||||||
|
|
|
@ -44,11 +44,12 @@ public class SessionClientLiveTest extends BaseCloudStackClientLiveTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCreateContextUsingUserAndPasswordAuthentication() {
|
public void testCreateContextUsingUserAndPasswordAuthentication() {
|
||||||
String endpoint = cloudStackContext.getProviderMetadata().getEndpoint();
|
skipIfNotGlobalAdmin();
|
||||||
assert globalAdminEnabled;
|
|
||||||
|
|
||||||
|
String endpoint = cloudStackContext.getProviderMetadata().getEndpoint();
|
||||||
Account testAccount = null;
|
Account testAccount = null;
|
||||||
User testUser = null;
|
User testUser = null;
|
||||||
|
|
||||||
String prefix = this.prefix + "-session";
|
String prefix = this.prefix + "-session";
|
||||||
try {
|
try {
|
||||||
testAccount = createTestAccount(globalAdminClient, prefix);
|
testAccount = createTestAccount(globalAdminClient, prefix);
|
||||||
|
|
|
@ -147,7 +147,7 @@ public class SnapshotClientLiveTest extends BaseCloudStackClientLiveTest {
|
||||||
return find(client.getSnapshotClient().listSnapshots(), new Predicate<Snapshot>() {
|
return find(client.getSnapshotClient().listSnapshots(), new Predicate<Snapshot>() {
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Snapshot arg0) {
|
public boolean apply(Snapshot arg0) {
|
||||||
return arg0.getId() == id;
|
return arg0.getId().equals(id);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -246,7 +246,7 @@ public class VolumeClientLiveTest extends BaseCloudStackClientLiveTest {
|
||||||
|
|
||||||
static Volume findVolumeWithId(final CloudStackClient client, final String id) {
|
static Volume findVolumeWithId(final CloudStackClient client, final String id) {
|
||||||
for (Volume v: client.getVolumeClient().listVolumes())
|
for (Volume v: client.getVolumeClient().listVolumes())
|
||||||
if (v.getId()==id) return v;
|
if (v.getId().equals(id)) return v;
|
||||||
throw new NoSuchElementException("no volume with id "+id);
|
throw new NoSuchElementException("no volume with id "+id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue