MCPcopy
hub / github.com/containerd/containerd / TestWindowsRootfsSize

Function TestWindowsRootfsSize

integration/windows_rootfs_size_test.go:36–134  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

34)
35
36func TestWindowsRootfsSize(t *testing.T) {
37 testPodLogDir := t.TempDir()
38
39 t.Log("Create a sandbox with log directory")
40 sb, sbConfig := PodSandboxConfigWithCleanup(t, "sandbox", "windows-rootfs-size",
41 WithPodLogDirectory(testPodLogDir),
42 )
43
44 var (
45 testImage = images.Get(images.Pause)
46 containerName = "test-container"
47 )
48
49 EnsureImageExists(t, testImage)
50
51 t.Log("Create a container to run the rootfs size test")
52
53 // Ask for 200GiB disk size
54 rootfsSize := int64(200 * 1024 * 1024 * 1024)
55 cnConfig := ContainerConfig(
56 containerName,
57 testImage,
58 // Execute dir on the root of the image as it'll show the size available.
59 // We're asking for ten times the default volume size so this should be
60 // easy to verify.
61 WithCommand("cmd", "/c", "dir", "/-C", "C:\\"),
62 WithLogPath(containerName),
63 WithWindowsResources(&runtime.WindowsContainerResources{RootfsSizeInBytes: rootfsSize}),
64 )
65 cn, err := runtimeService.CreateContainer(sb, cnConfig, sbConfig)
66 require.NoError(t, err)
67
68 t.Log("Start the container")
69 require.NoError(t, runtimeService.StartContainer(cn))
70
71 t.Log("Wait for container to finish running")
72 require.NoError(t, Eventually(func() (bool, error) {
73 s, err := runtimeService.ContainerStatus(cn)
74 if err != nil {
75 return false, err
76 }
77 if s.GetState() == runtime.ContainerState_CONTAINER_EXITED {
78 return true, nil
79 }
80 return false, nil
81 }, time.Second, 30*time.Second))
82
83 t.Log("Check container log")
84 content, err := os.ReadFile(filepath.Join(testPodLogDir, containerName))
85 assert.NoError(t, err)
86
87 // Format of output for dir /-C:
88 //
89 // Volume in drive C has no label.
90 // Volume Serial Number is 5CA1-BDE0
91
92 // Directory of C:\
93 //

Callers

nothing calls this directly

Calls 15

GetFunction · 0.92
WithPodLogDirectoryFunction · 0.85
EnsureImageExistsFunction · 0.85
ContainerConfigFunction · 0.85
WithCommandFunction · 0.85
WithLogPathFunction · 0.85
EventuallyFunction · 0.85
LogMethod · 0.80
FatalMethod · 0.80
WithWindowsResourcesFunction · 0.70
CreateContainerMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…