Repository: GoogleContainerTools/jib
File: jib-core/src/integration-test/java/com/google/cloud/tools/jib/registry/ManifestPullerIntegrationTest.java (Java)

Code before:

  @BeforeClass
  public static void setUp() throws IOException, InterruptedException {
    localRegistry.pullAndPushToLocal("busybox", "busybox");
  }

  private final FailoverHttpClient httpClient = new FailoverHttpClient(true, false, ignored -> {});

  @Test
  public void testPull_v21() throws IOException, RegistryException {
    RegistryClient registryClient =
        RegistryClient.factory(EventHandlers.NONE, dockerHost + ":5000", "busybox", httpClient)
            .newRegistryClient();

    V21ManifestTemplate manifestTemplate =
        registryClient.pullManifest("latest", V21ManifestTemplate.class).getManifest();

    Assert.assertEquals(1, manifestTemplate.getSchemaVersion());
    Assert.assertTrue(manifestTemplate.getFsLayers().size() > 0);
  }

  @Test
  public void testPull_v22() throws IOException, RegistryException {
    RegistryClient registryClient =
        RegistryClient.factory(EventHandlers.NONE, "gcr.io", "distroless/base", httpClient)
            .newRegistryClient();

    V22ManifestTemplate manifestTemplate =
        registryClient
            .pullManifest(KNOWN_MANIFEST_V22_SHA, V22ManifestTemplate.class)
            .getManifest();

    Assert.assertEquals(2, manifestTemplate.getSchemaVersion());
    Assert.assertTrue(manifestTemplate.getLayers().size() > 0);
  }

  @Test
  public void testPull_ociManifest() throws IOException, RegistryException {
    RegistryClient registryClient =
        RegistryClient.factory(EventHandlers.NONE, "gcr.io", "distroless/base", httpClient)
            .newRegistryClient();

    OciManifestTemplate manifestTemplate =
        registryClient
            .pullManifest(KNOWN_OCI_MANIFEST_SHA, OciManifestTemplate.class)
            .getManifest();

    Assert.assertEquals(2, manifestTemplate.getSchemaVersion());
    Assert.assertTrue(manifestTemplate.getLayers().size() > 0);
  }


Review comment (suggestion):
qq you may have covered this already but why do we need to replace `distroless/java` with `distroless/base`? Is there anything blocking us from using a previous tag from [`gcr.io/distroless/java`](https://pantheon.corp.google.com/gcr/images/distroless/global/java). 

Code after:

  @BeforeClass
  public static void setUp() throws IOException, InterruptedException {
    localRegistry.pullAndPushToLocal("busybox", "busybox");
  }

  private final FailoverHttpClient httpClient = new FailoverHttpClient(true, false, ignored -> {});

  @Test
  public void testPull_v21() throws IOException, RegistryException {
    RegistryClient registryClient =
        RegistryClient.factory(EventHandlers.NONE, dockerHost + ":5000", "busybox", httpClient)
            .newRegistryClient();

    V21ManifestTemplate manifestTemplate =
        registryClient.pullManifest("latest", V21ManifestTemplate.class).getManifest();

    assertThat(manifestTemplate.getSchemaVersion()).isEqualTo(1);
    assertThat(manifestTemplate.getFsLayers()).isNotEmpty();
  }

  @Test
  public void testPull_v22() throws IOException, RegistryException {
    RegistryClient registryClient =
        RegistryClient.factory(EventHandlers.NONE, "gcr.io", "distroless/base", httpClient)
            .newRegistryClient();

    V22ManifestTemplate manifestTemplate =
        registryClient
            .pullManifest(KNOWN_MANIFEST_V22_SHA, V22ManifestTemplate.class)
            .getManifest();

    assertThat(manifestTemplate.getSchemaVersion()).isEqualTo(2);
    assertThat(manifestTemplate.getLayers()).isNotEmpty();
  }

  @Test
  public void testPull_ociManifest() throws IOException, RegistryException {
    RegistryClient registryClient =
        RegistryClient.factory(EventHandlers.NONE, "gcr.io", "distroless/base", httpClient)
            .newRegistryClient();

    OciManifestTemplate manifestTemplate =
        registryClient
            .pullManifest(KNOWN_OCI_MANIFEST_SHA, OciManifestTemplate.class)
            .getManifest();

    assertThat(manifestTemplate.getSchemaVersion()).isEqualTo(2);
    assertThat(manifestTemplate.getLayers()).isNotEmpty();
  }