MCPcopy
hub / github.com/containerd/containerd / TestIssue13030

Function TestIssue13030

integration/client/container_linux_test.go:1824–1883  ·  view source on GitHub ↗

TestIssue13030 is a regression test for parallel image unpacking. The test validates that when multiple layers are unpacked in parallel, that whiteout files are properly processed and do not cause files to be unexpectedly present in the final rootfs. https://github.com/containerd/containerd/issues/

(t *testing.T)

Source from the content-addressed store, hash-verified

1822//
1823// https://github.com/containerd/containerd/issues/13030
1824func TestIssue13030(t *testing.T) {
1825 client, err := newClient(t, address)
1826 if err != nil {
1827 t.Fatal(err)
1828 }
1829 t.Cleanup(func() { client.Close() })
1830
1831 ctx, cancel := testContext(t)
1832 t.Cleanup(cancel)
1833
1834 image, err := client.Pull(ctx,
1835 images.Get(images.Whiteout),
1836 WithPlatformMatcher(platforms.Default()),
1837 WithPullUnpack,
1838 WithUnpackOpts([]UnpackOpt{WithUnpackLimiter(semaphore.NewWeighted(3))}),
1839 )
1840 t.Cleanup(func() {
1841 client.ImageService().Delete(ctx, images.Get(images.Whiteout))
1842 })
1843 if err != nil {
1844 t.Fatal(err)
1845 }
1846
1847 container, err := client.NewContainer(ctx, t.Name(),
1848 WithNewSnapshot(t.Name(), image),
1849 WithNewSpec(oci.WithImageConfig(image),
1850 withProcessArgs("/bin/sh", "-e", "-c", "test ! -e /file-to-delete && test ! -e /dir-to-delete")),
1851 )
1852 if err != nil {
1853 t.Fatal(err)
1854 }
1855 t.Cleanup(func() {
1856 container.Delete(ctx, WithSnapshotCleanup)
1857 })
1858
1859 task, err := container.NewTask(ctx, empty())
1860 if err != nil {
1861 t.Fatal(err)
1862 }
1863 t.Cleanup(func() {
1864 task.Delete(ctx)
1865 })
1866
1867 statusC, err := task.Wait(ctx)
1868 if err != nil {
1869 t.Fatal(err)
1870 }
1871 err = task.Start(ctx)
1872 if err != nil {
1873 t.Fatal(err)
1874 }
1875 status := <-statusC
1876 code, _, err := status.Result()
1877 if err != nil {
1878 t.Fatal(err)
1879 }
1880 if code != 0 {
1881 t.Errorf("expected status 0 from wait but received %d", code)

Callers

nothing calls this directly

Calls 15

DeleteMethod · 0.95
NewTaskMethod · 0.95
GetFunction · 0.92
WithImageConfigFunction · 0.92
newClientFunction · 0.85
testContextFunction · 0.85
WithPlatformMatcherFunction · 0.85
WithUnpackOptsFunction · 0.85
WithNewSpecFunction · 0.85
emptyFunction · 0.85
FatalMethod · 0.80
ResultMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…