mirror of https://github.com/apache/jclouds.git
Issue 763: moved testTemplateBuildsFasterByImageIdThanBySearchingAllImages, from EC2ComputeServiceLiveTest to EC2TemplateBuilderLiveTest; disabled in eucalyptus-partner-cloud
This commit is contained in:
parent
f140688077
commit
d32bbc18c4
|
@ -22,7 +22,6 @@ import static org.testng.Assert.assertEquals;
|
|||
import static org.testng.Assert.assertTrue;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.Set;
|
||||
|
||||
import org.jclouds.compute.BaseComputeServiceLiveTest;
|
||||
|
@ -53,7 +52,6 @@ import org.jclouds.sshj.config.SshjSshClientModule;
|
|||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.base.Stopwatch;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSortedSet;
|
||||
import com.google.common.collect.Iterables;
|
||||
|
@ -239,45 +237,6 @@ public class EC2ComputeServiceLiveTest extends BaseComputeServiceLiveTest {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* e.g. on aws-ec2: timeByImageId=534ms; timeByOsFamily=11587ms.
|
||||
* Expecting it to be at least 2 times faster seems reasonable, including on other ec2 flavours.
|
||||
*/
|
||||
@Test(enabled = true)
|
||||
public void testTemplateBuildsFasterByImageIdThanBySearchingAllImages() throws Exception {
|
||||
Stopwatch stopwatch = new Stopwatch();
|
||||
|
||||
// Find any image, and get its id
|
||||
template = buildTemplate(client.templateBuilder());
|
||||
String imageId = template.getImage().getId();
|
||||
|
||||
// Build a template using that specific image-id
|
||||
context.close();
|
||||
setupClient();
|
||||
stopwatch.start();
|
||||
client.templateBuilder().imageId(imageId).build();
|
||||
stopwatch.stop();
|
||||
long timeByImageId = stopwatch.elapsedMillis();
|
||||
|
||||
// Build a template using that specific image-id
|
||||
context.close();
|
||||
setupClient();
|
||||
stopwatch.reset();
|
||||
stopwatch.start();
|
||||
try {
|
||||
client.templateBuilder().osFamily(OsFamily.UBUNTU).build();
|
||||
} catch (NoSuchElementException e) {
|
||||
// ignore; we are only interested in how long it took to establish this fact!
|
||||
}
|
||||
stopwatch.stop();
|
||||
long timeByOsFamily = stopwatch.elapsedMillis();
|
||||
|
||||
System.out.println("testTemplateBuildsFasterByImageIdThanBySearchingAllImages: " +
|
||||
"timeByImageId="+timeByImageId+"ms; timeByOsFamily="+timeByOsFamily+"ms");
|
||||
|
||||
assertTrue((timeByImageId*2) < timeByOsFamily, "timeByImageId="+timeByImageId+"; timeByOsFamily="+timeByOsFamily);
|
||||
}
|
||||
|
||||
protected RunningInstance getInstance(InstanceClient instanceClient, String id) {
|
||||
RunningInstance instance = Iterables.getOnlyElement(Iterables.getOnlyElement(instanceClient
|
||||
.describeInstancesInRegion(null, id)));
|
||||
|
|
|
@ -4,14 +4,18 @@ import static org.jclouds.http.internal.TrackingJavaUrlHttpCommandExecutorServic
|
|||
import static org.jclouds.http.internal.TrackingJavaUrlHttpCommandExecutorService.getJavaMethodForRequest;
|
||||
import static org.jclouds.http.internal.TrackingJavaUrlHttpCommandExecutorService.getJavaMethodForRequestAtIndex;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.Set;
|
||||
|
||||
import org.jclouds.compute.BaseTemplateBuilderLiveTest;
|
||||
import org.jclouds.compute.ComputeServiceContext;
|
||||
import org.jclouds.compute.ComputeServiceContextFactory;
|
||||
import org.jclouds.compute.domain.OsFamily;
|
||||
import org.jclouds.compute.domain.Template;
|
||||
import org.jclouds.ec2.options.DescribeAvailabilityZonesOptions;
|
||||
import org.jclouds.ec2.options.DescribeImagesOptions;
|
||||
|
@ -24,6 +28,7 @@ import org.jclouds.logging.log4j.config.Log4JLoggingModule;
|
|||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.base.Stopwatch;
|
||||
import com.google.common.collect.Collections2;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Lists;
|
||||
|
@ -72,6 +77,44 @@ public abstract class EC2TemplateBuilderLiveTest extends BaseTemplateBuilderLive
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* e.g. on aws-ec2: timeByImageId=534ms; timeByOsFamily=11587ms.
|
||||
* Expecting it to be at least 2 times faster seems reasonable.
|
||||
* Note, assertion fails on eucalyptus-partner-cloud, taking approx timeByImageId=1172ms; timeByOsFamily=774ms
|
||||
*/
|
||||
@Test(enabled = true)
|
||||
public void testTemplateBuildsFasterByImageIdThanBySearchingAllImages() throws Exception {
|
||||
Stopwatch stopwatch = new Stopwatch();
|
||||
|
||||
// Find any image, and get its id
|
||||
Template defaultTemplate = context.getComputeService().templateBuilder().build();
|
||||
String imageId = defaultTemplate.getImage().getId();
|
||||
|
||||
// Build a template using that specific image-id
|
||||
context.close();
|
||||
setupClient();
|
||||
stopwatch.start();
|
||||
context.getComputeService().templateBuilder().imageId(imageId).build();
|
||||
|
||||
stopwatch.stop();
|
||||
long timeByImageId = stopwatch.elapsedMillis();
|
||||
|
||||
// Build a template, searching for matching OS so fetches all images
|
||||
context.close();
|
||||
setupClient();
|
||||
stopwatch.reset();
|
||||
stopwatch.start();
|
||||
try {
|
||||
context.getComputeService().templateBuilder().osFamily(OsFamily.UBUNTU).build();
|
||||
} catch (NoSuchElementException e) {
|
||||
// ignore; we are only interested in how long it took to establish this fact!
|
||||
}
|
||||
stopwatch.stop();
|
||||
long timeByOsFamily = stopwatch.elapsedMillis();
|
||||
|
||||
assertTrue((timeByImageId*2) < timeByOsFamily, "timeByImageId="+timeByImageId+"; timeByOsFamily="+timeByOsFamily);
|
||||
}
|
||||
|
||||
private static void assertDescribeImagesOptionsEquals(DescribeImagesOptions[] actual, String expectedImageId) {
|
||||
assertEquals(actual.length, 1);
|
||||
assertEquals(actual[0].getImageIds(), ImmutableSet.of(expectedImageId));
|
||||
|
|
|
@ -48,6 +48,20 @@ public class EucalyptusPartnerCloudEucalyptusTemplateBuilderLiveTest extends EC2
|
|||
provider = "eucalyptus-partnercloud-ec2";
|
||||
}
|
||||
|
||||
/**
|
||||
* Note, assertion fails on eucalyptus-partner-cloud, taking approx timeByImageId=541; timeByOsFamily=277ms.
|
||||
* However, testTemplateBuilderCanUseImageIdWithoutFetchingAllImages and inspection of the debug logs shows
|
||||
* that we are submitting the HTTP request for a single image, e.g:
|
||||
* Action=DescribeImages&ImageId.1=emi-E0641459&Signature=YihCSyPfIAvGa6ZoJSeQtXVXBJ6zfikspJUxYoIXXh4%3D&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=2011-12-13T11%3A21%3A51.455Z&Version=2010-06-15&AWSAccessKeyId=NB0zdTG4CtdvijzOFj47W0nlyl4cBzcfPw
|
||||
* <p>
|
||||
* Therefore disabled here.
|
||||
*/
|
||||
@Override
|
||||
@Test(enabled = false)
|
||||
public void testTemplateBuildsFasterByImageIdThanBySearchingAllImages() throws Exception {
|
||||
super.testTemplateBuildsFasterByImageIdThanBySearchingAllImages();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Predicate<OsFamilyVersion64Bit> defineUnsupportedOperatingSystems() {
|
||||
return Predicates.not(new Predicate<OsFamilyVersion64Bit>() {
|
||||
|
|
Loading…
Reference in New Issue