test_skopeo.py 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import infra.basetest
  2. import json
  3. import os
  4. class TestSkopeo(infra.basetest.BRTest):
  5. config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \
  6. """
  7. BR2_PER_PACKAGE_DIRECTORIES=y
  8. BR2_SYSTEM_DHCP="eth0"
  9. BR2_PACKAGE_CA_CERTIFICATES=y
  10. BR2_PACKAGE_SKOPEO=y
  11. BR2_PACKAGE_HOST_GO_BIN=y
  12. BR2_TARGET_ROOTFS_CPIO=y
  13. # BR2_TARGET_ROOTFS_TAR is not set
  14. """
  15. def test_run(self):
  16. cpio_file = os.path.join(self.builddir, "images", "rootfs.cpio")
  17. self.emulator.boot(arch="armv5",
  18. kernel="builtin",
  19. options=["-initrd", cpio_file, "-nic", "user,model=rtl8139"])
  20. self.emulator.login()
  21. self.assertRunOk("skopeo --version", timeout=30)
  22. # First, check we can reach the default registry: docker.io
  23. output, _ = self.emulator.run(
  24. "skopeo inspect docker://busybox:latest",
  25. timeout=60,
  26. )
  27. bb_info = json.loads("".join(output))
  28. self.assertEqual(bb_info["Name"], "docker.io/library/busybox")
  29. # Then check we can retrieve the image from the default registry
  30. # Copy all archs in the image to check we can enumerate those (inspect
  31. # does not enumerate all archs)
  32. self.assertRunOk(
  33. "skopeo copy -a docker://busybox:latest oci-archive:busybox-latest.oci",
  34. timeout=120,
  35. )
  36. # Check we can inspect a local OCI archive
  37. self.assertRunOk(
  38. "skopeo inspect oci-archive:busybox-latest.oci",
  39. timeout=30,
  40. )
  41. # Now, check we can reach an arbitrary registry: quay.io
  42. output, _ = self.emulator.run(
  43. "skopeo inspect docker://quay.io/quay/busybox:latest",
  44. timeout=60,
  45. )
  46. skopeo_info = json.loads("".join(output))
  47. self.assertEqual(skopeo_info["Name"], "quay.io/quay/busybox")
  48. # Finally check we can retrieve the image from an arbitrary registry
  49. self.assertRunOk(
  50. "skopeo copy docker://quay.io/quay/busybox:latest oci-archive:busybox-quay.io-latest.oci",
  51. timeout=120,
  52. )