Closed Rob-Hague closed 2 months ago
string token = ""; // https://ci.appveyor.com/api-keys
var client = new HttpClient();
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
JsonDocument x = JsonDocument.Parse(await client.GetStringAsync("https://ci.appveyor.com/api/projects/drieseng/ssh-net/history?recordsNumber=200"));
int buildCount = 0;
int badCount = 0;
foreach (JsonElement build in x.RootElement.GetProperty("builds").EnumerateArray())
{
buildCount++;
long buildId = build.GetProperty("buildId").GetInt64();
string status = build.GetProperty("status").GetString();
if (status != "success")
{
continue;
}
foreach (var job in JsonDocument.Parse(
await client.GetStringAsync($"https://ci.appveyor.com/api/projects/drieseng/ssh-net/builds/{buildId}"))
.RootElement.GetProperty("build").GetProperty("jobs").EnumerateArray())
{
string jobId = job.GetProperty("jobId").GetString();
int testsCount = job.GetProperty("testsCount").GetInt32();
if (testsCount < 1000)
{
badCount++;
Console.WriteLine($"Bad: {testsCount} tests in https://ci.appveyor.com/project/drieseng/ssh-net/builds/{buildId}");
Console.WriteLine(string.Join(Environment.NewLine,
ReadLines(await client.GetStreamAsync($"https://ci.appveyor.com/api/buildjobs/{jobId}/log"))
.TakeLast(5)));
Console.WriteLine();
Console.WriteLine();
}
}
}
Console.WriteLine($"{badCount} bad of {buildCount}");
static IEnumerable<string> ReadLines(Stream s)
{
using StreamReader sr = new(s);
string line;
while ((line = sr.ReadLine()) != null)
{
yield return line;
}
}
Memory explodes:
[00:04:54] Passed CreateShellStreamShouldRethrowExceptionThrownByOpenOnChannelSession [26 ms]
[00:04:54] Standard Output Messages:
[00:04:54] memout1 ServiceFactoryTest_CreateShellStream_ChannelOpenThrowsException: 29,558,432
[00:04:54] memout2 ServiceFactoryTest_CreateShellStream_ChannelOpenThrowsException: 1,496,752,520
[00:04:54]
[00:04:54]
[00:04:54] Passed DisposeOnChannelSessionShouldHaveBeenInvokedOnce [2 ms]
[00:04:54] Standard Output Messages:
[00:04:54] memout1 ServiceFactoryTest_CreateShellStream_ChannelOpenThrowsException: 1,496,893,136
[00:04:54] memout2 ServiceFactoryTest_CreateShellStream_ChannelOpenThrowsException: 4,440,210,096
[00:04:54]
[00:04:54]
[00:04:54] Passed CreateShellStreamShouldThrowSshException [305 ms]
[00:04:54] Passed DisposeOnChannelSessionShouldHaveBeenInvokedOnce [529 ms]
Found it 🙂
Found it 🙂
Since these changes, I have run the CI 13 times successfully without any silent crashes at the ~840 test mark (the latest build failed one of the usual integration tests afterwards).
At a 21 / 100 prior occurrence rate, the chance of 13 passes would be (1 - 0.21) ^ 13 ~= 4.66%. So I think we can say that this is the fix and that the process was crashing due to out-of-memory from these randomly-sized array allocations.
Still a bit of a mystery why the dotnet process was showing exit code 0 though
I have opened a ticket for lack of ideas https://help.appveyor.com/discussions/problems/35588-net-tests-silently-exiting-on-ubuntu2204