use of com.google.cloud.tools.jib.builder.steps.PullBaseImageStep.ImagesAndRegistryClient in project jib by GoogleContainerTools.
the class PullBaseImageStepTest method testCall_allMirrorsFail.
@Test
public void testCall_allMirrorsFail() throws InvalidImageReferenceException, IOException, RegistryException, LayerPropertyNotFoundException, LayerCountMismatchException, BadContainerConfigurationFormatException, CacheCorruptedException, CredentialRetrievalException {
Mockito.when(imageConfiguration.getImage()).thenReturn(ImageReference.parse("registry/repo"));
Mockito.when(imageConfiguration.getImageRegistry()).thenReturn("registry");
Mockito.when(buildContext.getRegistryMirrors()).thenReturn(ImmutableListMultimap.of("registry", "quay.io", "registry", "gcr.io"));
Mockito.when(buildContext.newBaseImageRegistryClientFactory(Mockito.any())).thenReturn(registryClientFactory);
Mockito.when(registryClient.pullManifest(Mockito.any())).thenThrow(new RegistryException("not found"));
RegistryClient.Factory dockerHubRegistryClientFactory = setUpWorkingRegistryClientFactory();
Mockito.when(buildContext.newBaseImageRegistryClientFactory()).thenReturn(dockerHubRegistryClientFactory);
ImagesAndRegistryClient result = pullBaseImageStep.call();
Assert.assertEquals(dockerHubRegistryClientFactory.newRegistryClient(), result.registryClient);
InOrder inOrder = Mockito.inOrder(eventHandlers);
inOrder.verify(eventHandlers).dispatch(LogEvent.info("trying mirror quay.io for the base image"));
inOrder.verify(eventHandlers).dispatch(LogEvent.debug("failed to get manifest from mirror quay.io: not found"));
inOrder.verify(eventHandlers).dispatch(LogEvent.info("trying mirror gcr.io for the base image"));
inOrder.verify(eventHandlers).dispatch(LogEvent.debug("failed to get manifest from mirror gcr.io: not found"));
}
use of com.google.cloud.tools.jib.builder.steps.PullBaseImageStep.ImagesAndRegistryClient in project jib by GoogleContainerTools.
the class PullBaseImageStepTest method testTryMirrors_mirrorIoError.
@Test
public void testTryMirrors_mirrorIoError() throws LayerCountMismatchException, BadContainerConfigurationFormatException, IOException, RegistryException {
Mockito.when(imageConfiguration.getImageRegistry()).thenReturn("registry");
Mockito.when(buildContext.getRegistryMirrors()).thenReturn(ImmutableListMultimap.of("registry", "gcr.io"));
Mockito.when(buildContext.newBaseImageRegistryClientFactory("gcr.io")).thenReturn(registryClientFactory);
Mockito.when(registryClient.pullManifest(Mockito.any())).thenThrow(new IOException("test exception"));
Optional<ImagesAndRegistryClient> result = pullBaseImageStep.tryMirrors(buildContext, progressDispatcherFactory);
Assert.assertEquals(Optional.empty(), result);
InOrder inOrder = Mockito.inOrder(eventHandlers);
inOrder.verify(eventHandlers).dispatch(LogEvent.info("trying mirror gcr.io for the base image"));
inOrder.verify(eventHandlers).dispatch(LogEvent.debug("failed to get manifest from mirror gcr.io: test exception"));
}
Aggregations