use of com.google.cloud.tools.jib.api.DescriptorDigest in project jib by google.
the class LayerEntriesSelectorTest method testGenerateSelector_empty.
@Test
public void testGenerateSelector_empty() throws IOException {
DescriptorDigest expectedSelector = Digests.computeJsonDigest(ImmutableList.of());
Assert.assertEquals(expectedSelector, LayerEntriesSelector.generateSelector(ImmutableList.of()));
}
use of com.google.cloud.tools.jib.api.DescriptorDigest in project jib by google.
the class ObtainBaseImageLayerStepTest method setUp.
@Before
public void setUp() throws IOException, RegistryException, DigestException {
existingLayerDigest = DescriptorDigest.fromHash("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
freshLayerDigest = DescriptorDigest.fromHash("bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb");
DescriptorDigest diffId = Mockito.mock(DescriptorDigest.class);
existingLayer = new ReferenceLayer(new BlobDescriptor(existingLayerDigest), diffId);
freshLayer = new ReferenceLayer(new BlobDescriptor(freshLayerDigest), diffId);
Mockito.when(registryClient.checkBlob(existingLayerDigest)).thenReturn(Optional.of(Mockito.mock(BlobDescriptor.class)));
Mockito.when(registryClient.checkBlob(freshLayerDigest)).thenReturn(Optional.empty());
// necessary to prevent error from classes dealing with progress report
Answer3<Blob, DescriptorDigest, Consumer<Long>, Consumer<Long>> progressSizeSetter = (ignored1, progressSizeConsumer, ignored2) -> {
progressSizeConsumer.accept(Long.valueOf(12345));
return null;
};
Mockito.when(registryClient.pullBlob(Mockito.any(), Mockito.any(), Mockito.any())).thenAnswer(AdditionalAnswers.answer(progressSizeSetter));
}
use of com.google.cloud.tools.jib.api.DescriptorDigest in project jib by GoogleContainerTools.
the class BlobCheckerIntegrationTest method testCheck_doesNotExist.
@Test
public void testCheck_doesNotExist() throws IOException, RegistryException, DigestException {
RegistryClient registryClient = RegistryClient.factory(EventHandlers.NONE, "gcr.io", "distroless/base", httpClient).newRegistryClient();
DescriptorDigest fakeBlobDigest = DescriptorDigest.fromHash("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
Assert.assertFalse(registryClient.checkBlob(fakeBlobDigest).isPresent());
}
use of com.google.cloud.tools.jib.api.DescriptorDigest in project jib by GoogleContainerTools.
the class BlobPullerIntegrationTest method testPull.
@Test
public void testPull() throws IOException, RegistryException {
RegistryClient registryClient = RegistryClient.factory(EventHandlers.NONE, "gcr.io", "distroless/base", httpClient).newRegistryClient();
V22ManifestTemplate manifestTemplate = registryClient.pullManifest("latest", V22ManifestTemplate.class).getManifest();
DescriptorDigest realDigest = manifestTemplate.getLayers().get(0).getDigest();
// Pulls a layer BLOB of the distroless/base image.
LongAdder totalByteCount = new LongAdder();
LongAdder expectedSize = new LongAdder();
Blob pulledBlob = registryClient.pullBlob(realDigest, size -> {
Assert.assertEquals(0, expectedSize.sum());
expectedSize.add(size);
}, totalByteCount::add);
Assert.assertEquals(realDigest, pulledBlob.writeTo(ByteStreams.nullOutputStream()).getDigest());
Assert.assertTrue(expectedSize.sum() > 0);
Assert.assertEquals(expectedSize.sum(), totalByteCount.sum());
}
use of com.google.cloud.tools.jib.api.DescriptorDigest in project jib by GoogleContainerTools.
the class BlobPusherIntegrationTest method testPush.
@Test
public void testPush() throws DigestException, IOException, RegistryException {
Blob testBlob = Blobs.from("crepecake");
// Known digest for 'crepecake'
DescriptorDigest testBlobDigest = DescriptorDigest.fromHash("52a9e4d4ba4333ce593707f98564fee1e6d898db0d3602408c0b2a6a424d357c");
RegistryClient registryClient = RegistryClient.factory(EventHandlers.NONE, "localhost:5000", "testimage", httpClient).newRegistryClient();
Assert.assertFalse(registryClient.pushBlob(testBlobDigest, testBlob, null, ignored -> {
}));
}
Aggregations