use of com.google.cloud.tools.jib.blob.Blobs in project jib by GoogleContainerTools.
the class ManifestPusherIntegrationTest method testPush.
/**
* Tests manifest pushing. This test is a comprehensive test of push and pull.
*/
@Test
public void testPush() throws DigestException, IOException, RegistryException {
Blob testLayerBlob = Blobs.from("crepecake");
// Known digest for 'crepecake'
DescriptorDigest testLayerBlobDigest = DescriptorDigest.fromHash("52a9e4d4ba4333ce593707f98564fee1e6d898db0d3602408c0b2a6a424d357c");
Blob testContainerConfigurationBlob = Blobs.from("12345");
DescriptorDigest testContainerConfigurationBlobDigest = DescriptorDigest.fromHash("5994471abb01112afcc18159f6cc74b4f511b99806da59b3caf5a9c173cacfc5");
// Creates a valid image manifest.
V22ManifestTemplate expectedManifestTemplate = new V22ManifestTemplate();
expectedManifestTemplate.addLayer(9, testLayerBlobDigest);
expectedManifestTemplate.setContainerConfiguration(5, testContainerConfigurationBlobDigest);
// Pushes the BLOBs.
RegistryClient registryClient = RegistryClient.factory(EventHandlers.NONE, "localhost:5000", "testimage", httpClient).newRegistryClient();
Assert.assertFalse(registryClient.pushBlob(testLayerBlobDigest, testLayerBlob, null, ignored -> {
}));
Assert.assertFalse(registryClient.pushBlob(testContainerConfigurationBlobDigest, testContainerConfigurationBlob, null, ignored -> {
}));
// Pushes the manifest.
DescriptorDigest imageDigest = registryClient.pushManifest(expectedManifestTemplate, "latest");
// Pulls the manifest.
V22ManifestTemplate manifestTemplate = registryClient.pullManifest("latest", V22ManifestTemplate.class).getManifest();
Assert.assertEquals(1, manifestTemplate.getLayers().size());
Assert.assertEquals(testLayerBlobDigest, manifestTemplate.getLayers().get(0).getDigest());
Assert.assertNotNull(manifestTemplate.getContainerConfiguration());
Assert.assertEquals(testContainerConfigurationBlobDigest, manifestTemplate.getContainerConfiguration().getDigest());
// Pulls the manifest by digest.
V22ManifestTemplate manifestTemplateByDigest = registryClient.pullManifest(imageDigest.toString(), V22ManifestTemplate.class).getManifest();
Assert.assertEquals(Digests.computeJsonDigest(manifestTemplate), Digests.computeJsonDigest(manifestTemplateByDigest));
}
use of com.google.cloud.tools.jib.blob.Blobs in project jib by google.
the class ManifestPusherIntegrationTest method testPush.
/**
* Tests manifest pushing. This test is a comprehensive test of push and pull.
*/
@Test
public void testPush() throws DigestException, IOException, RegistryException {
Blob testLayerBlob = Blobs.from("crepecake");
// Known digest for 'crepecake'
DescriptorDigest testLayerBlobDigest = DescriptorDigest.fromHash("52a9e4d4ba4333ce593707f98564fee1e6d898db0d3602408c0b2a6a424d357c");
Blob testContainerConfigurationBlob = Blobs.from("12345");
DescriptorDigest testContainerConfigurationBlobDigest = DescriptorDigest.fromHash("5994471abb01112afcc18159f6cc74b4f511b99806da59b3caf5a9c173cacfc5");
// Creates a valid image manifest.
V22ManifestTemplate expectedManifestTemplate = new V22ManifestTemplate();
expectedManifestTemplate.addLayer(9, testLayerBlobDigest);
expectedManifestTemplate.setContainerConfiguration(5, testContainerConfigurationBlobDigest);
// Pushes the BLOBs.
RegistryClient registryClient = RegistryClient.factory(EventHandlers.NONE, "localhost:5000", "testimage", httpClient).newRegistryClient();
Assert.assertFalse(registryClient.pushBlob(testLayerBlobDigest, testLayerBlob, null, ignored -> {
}));
Assert.assertFalse(registryClient.pushBlob(testContainerConfigurationBlobDigest, testContainerConfigurationBlob, null, ignored -> {
}));
// Pushes the manifest.
DescriptorDigest imageDigest = registryClient.pushManifest(expectedManifestTemplate, "latest");
// Pulls the manifest.
V22ManifestTemplate manifestTemplate = registryClient.pullManifest("latest", V22ManifestTemplate.class).getManifest();
Assert.assertEquals(1, manifestTemplate.getLayers().size());
Assert.assertEquals(testLayerBlobDigest, manifestTemplate.getLayers().get(0).getDigest());
Assert.assertNotNull(manifestTemplate.getContainerConfiguration());
Assert.assertEquals(testContainerConfigurationBlobDigest, manifestTemplate.getContainerConfiguration().getDigest());
// Pulls the manifest by digest.
V22ManifestTemplate manifestTemplateByDigest = registryClient.pullManifest(imageDigest.toString(), V22ManifestTemplate.class).getManifest();
Assert.assertEquals(Digests.computeJsonDigest(manifestTemplate), Digests.computeJsonDigest(manifestTemplateByDigest));
}
Aggregations