Skip to content

Commit

Permalink
log azurite stderr. (#17230)
Browse files Browse the repository at this point in the history
  • Loading branch information
kasobol-msft authored Nov 30, 2020
1 parent 56b647a commit c360eba
Showing 1 changed file with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public class AzuriteFixture : IDisposable
private AzuriteAccount account;
private CountdownEvent countdownEvent = new CountdownEvent(2);
private StringBuilder azuriteOutput = new StringBuilder();
private StringBuilder azuriteError = new StringBuilder();
private int blobsPort;
private int queuesPort;

Expand Down Expand Up @@ -79,6 +80,7 @@ public AzuriteFixture()
process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.RedirectStandardInput = true;
process.StartInfo.RedirectStandardError = true;
process.OutputDataReceived += delegate (object sender, DataReceivedEventArgs e)
{
if (e.Data != null)
Expand All @@ -99,6 +101,16 @@ public AzuriteFixture()
}
}
};
process.ErrorDataReceived += delegate (object sender, DataReceivedEventArgs e)
{
if (e.Data != null)
{
if (!countdownEvent.IsSet) // stop error collection if it started successfully.
{
azuriteError.AppendLine(e.Data);
}
}
};
try
{
process.Start();
Expand All @@ -107,10 +119,11 @@ public AzuriteFixture()
throw new ArgumentException(ErrorMessage("could not run NodeJS, make sure it's installed"), e);
}
process.BeginOutputReadLine();
process.BeginErrorReadLine();
var didAzuriteStart = countdownEvent.Wait(TimeSpan.FromSeconds(15));
if (!didAzuriteStart)
{
throw new InvalidOperationException(ErrorMessage($"azurite process could not start with following output:\n{azuriteOutput}"));
throw new InvalidOperationException(ErrorMessage($"azurite process could not start with following output:\n{azuriteOutput}\nand error:\n{azuriteError}"));
}
account.BlobsPort = blobsPort;
account.QueuesPort = queuesPort;
Expand Down

0 comments on commit c360eba

Please sign in to comment.