mirror of https://github.com/apache/jclouds.git
Improved network selection for Load Balancer client live test
This commit is contained in:
parent
56aa4e5ece
commit
cc28a2a370
|
@ -19,6 +19,8 @@
|
||||||
package org.jclouds.cloudstack.features;
|
package org.jclouds.cloudstack.features;
|
||||||
|
|
||||||
import static com.google.common.collect.Iterables.find;
|
import static com.google.common.collect.Iterables.find;
|
||||||
|
import static org.jclouds.cloudstack.predicates.NetworkPredicates.hasLoadBalancerService;
|
||||||
|
import static org.jclouds.cloudstack.predicates.NetworkPredicates.isVirtualNetwork;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
import static org.testng.Assert.assertNotNull;
|
import static org.testng.Assert.assertNotNull;
|
||||||
import static org.testng.Assert.assertTrue;
|
import static org.testng.Assert.assertTrue;
|
||||||
|
@ -48,6 +50,8 @@ import org.testng.annotations.Test;
|
||||||
import com.google.common.base.Predicate;
|
import com.google.common.base.Predicate;
|
||||||
import com.google.common.base.Predicates;
|
import com.google.common.base.Predicates;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests behavior of {@code LoadBalancerClientLiveTest}
|
* Tests behavior of {@code LoadBalancerClientLiveTest}
|
||||||
*
|
*
|
||||||
|
@ -71,7 +75,16 @@ public class LoadBalancerClientLiveTest extends BaseCloudStackClientLiveTest {
|
||||||
prefix += "rule";
|
prefix += "rule";
|
||||||
try {
|
try {
|
||||||
network = find(client.getNetworkClient().listNetworks(),
|
network = find(client.getNetworkClient().listNetworks(),
|
||||||
Predicates.and(NetworkPredicates.hasLoadBalancerService(), NetworkPredicates.isVirtualNetwork()));
|
Predicates.and(hasLoadBalancerService(), isVirtualNetwork(),
|
||||||
|
new Predicate<Network>() {
|
||||||
|
@Override
|
||||||
|
public boolean apply(@Nullable Network network) {
|
||||||
|
return network.isDefault()
|
||||||
|
&& !network.isSecurityGroupEnabled()
|
||||||
|
&& !network.isSystem()
|
||||||
|
&& network.getAccount().equals(user.getName());
|
||||||
|
}
|
||||||
|
}));
|
||||||
} catch (NoSuchElementException e) {
|
} catch (NoSuchElementException e) {
|
||||||
networksDisabled = true;
|
networksDisabled = true;
|
||||||
}
|
}
|
||||||
|
@ -82,8 +95,8 @@ public class LoadBalancerClientLiveTest extends BaseCloudStackClientLiveTest {
|
||||||
return;
|
return;
|
||||||
Long defaultTemplate = (imageId != null && !"".equals(imageId)) ? new Long(imageId) : null;
|
Long defaultTemplate = (imageId != null && !"".equals(imageId)) ? new Long(imageId) : null;
|
||||||
vm = VirtualMachineClientLiveTest.createVirtualMachineInNetwork(network,
|
vm = VirtualMachineClientLiveTest.createVirtualMachineInNetwork(network,
|
||||||
defaultTemplateOrPreferredInZone(defaultTemplate, client, network.getZoneId()), client, jobComplete,
|
defaultTemplateOrPreferredInZone(defaultTemplate, client, network.getZoneId()),
|
||||||
virtualMachineRunning);
|
client, jobComplete, virtualMachineRunning);
|
||||||
if (vm.getPassword() != null && !loginCredentials.hasPasswordOption())
|
if (vm.getPassword() != null && !loginCredentials.hasPasswordOption())
|
||||||
loginCredentials = loginCredentials.toBuilder().password(vm.getPassword()).build();
|
loginCredentials = loginCredentials.toBuilder().password(vm.getPassword()).build();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue