(t *testing.T)
| 116 | } |
| 117 | |
| 118 | func TestExecResize(t *testing.T) { |
| 119 | ctx := setupTest(t) |
| 120 | apiClient := testEnv.APIClient() |
| 121 | |
| 122 | cID := container.Run(ctx, t, apiClient, container.WithTty(true)) |
| 123 | defer container.Remove(ctx, t, apiClient, cID, client.ContainerRemoveOptions{Force: true}) |
| 124 | |
| 125 | cmd := []string{"top"} |
| 126 | if runtime.GOOS == "windows" { |
| 127 | cmd = []string{"sleep", "240"} |
| 128 | } |
| 129 | res, err := apiClient.ExecCreate(ctx, cID, client.ExecCreateOptions{ |
| 130 | TTY: true, // Windows requires a TTY for the resize to work, otherwise fails with "is not a tty: failed precondition", see https://github.com/moby/moby/pull/48665#issuecomment-2412530345 |
| 131 | Cmd: cmd, |
| 132 | }) |
| 133 | assert.NilError(t, err) |
| 134 | execID := res.ID |
| 135 | assert.NilError(t, err) |
| 136 | _, err = apiClient.ExecStart(ctx, execID, client.ExecStartOptions{ |
| 137 | Detach: true, |
| 138 | }) |
| 139 | assert.NilError(t, err) |
| 140 | |
| 141 | t.Run("success", func(t *testing.T) { |
| 142 | _, err := apiClient.ExecResize(ctx, execID, client.ExecResizeOptions{ |
| 143 | Height: 40, |
| 144 | Width: 40, |
| 145 | }) |
| 146 | if runtime.GOOS == "windows" && err != nil { |
| 147 | // FIXME(thaJeztah): temporarily allowing test to fail on Windows: see https://github.com/moby/moby/issues/50402 |
| 148 | t.Log("XFAIL:", err) |
| 149 | t.Skip("XFAIL: flaky test on Windows: see https://github.com/moby/moby/issues/50402") |
| 150 | return |
| 151 | } |
| 152 | assert.NilError(t, err) |
| 153 | |
| 154 | // TODO(thaJeztah): also check if the resize happened |
| 155 | // |
| 156 | // Note: container inspect shows the initial size that was |
| 157 | // set when creating the container. Actual resize happens in |
| 158 | // containerd, and currently does not update the container's |
| 159 | // config after running (but does send a "resize" event). |
| 160 | }) |
| 161 | |
| 162 | t.Run("invalid size", func(t *testing.T) { |
| 163 | const valueNotSet = "unset" |
| 164 | |
| 165 | sizes := []struct { |
| 166 | doc, height, width, expErr string |
| 167 | }{ |
| 168 | { |
| 169 | doc: "unset height", |
| 170 | height: valueNotSet, |
| 171 | width: "100", |
| 172 | expErr: `invalid resize height "": invalid syntax`, |
| 173 | }, |
| 174 | { |
| 175 | doc: "unset width", |
nothing calls this directly
no test coverage detected
searching dependent graphs…