def test_snapshotter( nydus_anchor: NydusAnchor, rafs_conf: RafsConf, image_url, nydus_snapshotter, local_registry, ): snapshotter = Snapshotter(nydus_anchor) containerd = Containerd(nydus_anchor, snapshotter).gen_config() snapshotter.set_root(containerd.root) nydus_anchor.put_dustbin(snapshotter) nydus_anchor.put_dustbin(containerd) converter = Nydusify(nydus_anchor) converter.docker_v2().convert(image_url) rafs_conf.set_rafs_backend(Backend.REGISTRY, repo=converter.original_repo) rafs_conf.enable_xattr() rafs_conf.dump_rafs_conf() snapshotter.run(rafs_conf.path()) time.sleep(1) containerd.run() cri = Cri(containerd.address, containerd.address) container_name = str(uuid.uuid4()) cri.run_container(converter.converted_image, container_name) id, status = cri.check_container_status(container_name, timeout=30) assert id is not None assert status cri.stop_rm_container(id) cri.remove_image(converter.converted_image) containerd.remove_image_sync(converter.converted_image)
def test_snapshotter_converted_images( nydus_anchor: NydusAnchor, rafs_conf: RafsConf, converted_images, nydus_snapshotter, ): # snapshotter = Snapshotter(nydus_anchor).enable_nydus_overlayfs() snapshotter = Snapshotter(nydus_anchor) containerd = Containerd(nydus_anchor, snapshotter).gen_config() snapshotter.set_root(containerd.root) nydus_anchor.put_dustbin(snapshotter) nydus_anchor.put_dustbin(containerd) # We can safely pass the step provide repo configured into the rafs configuration file. rafs_conf.set_rafs_backend(Backend.REGISTRY, scheme="https") rafs_conf.enable_xattr() rafs_conf.dump_rafs_conf() snapshotter.run(rafs_conf.path()) time.sleep(1) containerd.run() cri = Cri(containerd.address, containerd.address) id_set = [] for ref in converted_images: container_name = str(uuid.uuid4()) cri.run_container(ref, container_name) id, status = cri.check_container_status(container_name, timeout=30) assert id is not None assert status id_set.append((id, ref)) time.sleep(2) for id, ref in id_set: cri.stop_rm_container(id) cri.remove_image(ref) containerd.remove_image_sync(ref) # TODO: Rafs won't be unmounted and and nydusd still be alive even image is removed locally # So kill all nydusd here to make following test verification pass. Is this a bug? # Ensure nydusd must have been stopped here time.sleep(3)
def test_snapshotter_restart( nydus_anchor: NydusAnchor, rafs_conf: RafsConf, converted_images, nydus_snapshotter, ): snapshotter = Snapshotter(nydus_anchor) containerd = Containerd(nydus_anchor, snapshotter).gen_config() snapshotter.set_root(containerd.root) nydus_anchor.put_dustbin(containerd) # We can safely pass the step provide repo configured into the rafs configuration file. rafs_conf.set_rafs_backend(Backend.REGISTRY, scheme="https") rafs_conf.enable_xattr().enable_fs_prefetch().enable_rafs_blobcache( work_dir=snapshotter.cache_dir()) rafs_conf.enable_xattr().dump_rafs_conf() rafs_conf.dump_rafs_conf() snapshotter.run(rafs_conf.path()) time.sleep(1) containerd.run() cri = Cri(containerd.address, containerd.address) id_set = [] for ref in converted_images: container_name = str(uuid.uuid4()) cri.run_container(ref, container_name) id, status = cri.check_container_status(container_name, timeout=30) assert id is not None assert status id_set.append((id, ref)) time.sleep(2) snapshotter.shutdown() snapshotter = Snapshotter(nydus_anchor) snapshotter.set_root(containerd.root) nydus_anchor.put_dustbin(snapshotter) snapshotter.run(rafs_conf.path()) for id, ref in id_set: cri.stop_rm_container(id) cri.remove_image(ref) containerd.remove_image_sync(ref)