Skip to content

Commit fde3b4b

Browse files
committed
fix: Make sure container runs before reading output
1 parent 56b6fed commit fde3b4b

File tree

3 files changed

+7
-15
lines changed

3 files changed

+7
-15
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: CI
33
on:
44
pull_request:
55
branches:
6-
- master
6+
- main
77

88
jobs:
99
build:

test/Docker.DotNet.Tests/IContainerOperationsTests.cs

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,6 @@ await _dockerClient.Containers.StopContainerAsync(
135135
[Fact]
136136
public async Task GetContainerLogs_Tty_False_Follow_False_ReadsLogs()
137137
{
138-
using var containerLogsCts = new CancellationTokenSource(TimeSpan.FromSeconds(60));
139138
var logList = new List<string>();
140139

141140
var createContainerResponse = await _dockerClient.Containers.CreateContainerAsync(
@@ -154,9 +153,7 @@ await _dockerClient.Containers.StartContainerAsync(
154153
_cts.Token
155154
);
156155

157-
containerLogsCts.CancelAfter(TimeSpan.FromSeconds(5));
158-
159-
var containerLogsTask = _dockerClient.Containers.GetContainerLogsAsync(
156+
await _dockerClient.Containers.GetContainerLogsAsync(
160157
createContainerResponse.ID,
161158
new ContainerLogsParameters
162159
{
@@ -165,7 +162,7 @@ await _dockerClient.Containers.StartContainerAsync(
165162
Timestamps = true,
166163
Follow = false
167164
},
168-
containerLogsCts.Token,
165+
default,
169166
new Progress<string>(m => { logList.Add(m); _output.WriteLine(m); })
170167
);
171168

@@ -175,7 +172,6 @@ await _dockerClient.Containers.StopContainerAsync(
175172
_cts.Token
176173
);
177174

178-
await containerLogsTask;
179175
_output.WriteLine($"Line count: {logList.Count}");
180176

181177
Assert.NotEmpty(logList);
@@ -184,7 +180,6 @@ await _dockerClient.Containers.StopContainerAsync(
184180
[Fact]
185181
public async Task GetContainerLogs_Tty_True_Follow_False_ReadsLogs()
186182
{
187-
using var containerLogsCts = new CancellationTokenSource(TimeSpan.FromSeconds(60));
188183
var logList = new List<string>();
189184

190185
var createContainerResponse = await _dockerClient.Containers.CreateContainerAsync(
@@ -203,9 +198,9 @@ await _dockerClient.Containers.StartContainerAsync(
203198
_cts.Token
204199
);
205200

206-
containerLogsCts.CancelAfter(TimeSpan.FromSeconds(5));
201+
await Task.Delay(TimeSpan.FromSeconds(5));
207202

208-
var containerLogsTask = _dockerClient.Containers.GetContainerLogsAsync(
203+
await _dockerClient.Containers.GetContainerLogsAsync(
209204
createContainerResponse.ID,
210205
new ContainerLogsParameters
211206
{
@@ -214,19 +209,16 @@ await _dockerClient.Containers.StartContainerAsync(
214209
Timestamps = true,
215210
Follow = false
216211
},
217-
containerLogsCts.Token,
212+
default,
218213
new Progress<string>(m => { _output.WriteLine(m); logList.Add(m); })
219214
);
220215

221-
await Task.Delay(TimeSpan.FromSeconds(5));
222-
223216
await _dockerClient.Containers.StopContainerAsync(
224217
createContainerResponse.ID,
225218
new ContainerStopParameters(),
226219
_cts.Token
227220
);
228221

229-
await containerLogsTask;
230222
_output.WriteLine($"Line count: {logList.Count}");
231223

232224
Assert.NotEmpty(logList);

version.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// optional list of paths to consider when calculating version height.
99
],
1010
"publicReleaseRefSpec": [
11-
"^refs/heads/master$", // we release out of master
11+
"^refs/heads/main$", // we release out of main
1212
"^refs/tags/v\\d+\\.\\d+" // we also release tags starting with vN.N
1313
],
1414
"cloudBuild": {

0 commit comments

Comments
 (0)