From 548e680f22d637e435465b6a3cb8cd2e0939b40d Mon Sep 17 00:00:00 2001 From: Kamil Sobol <61715331+kasobol-msft@users.noreply.github.com> Date: Mon, 30 Nov 2020 09:48:34 -0800 Subject: [PATCH] log azurite stderr. (#17230) --- .../tests/AzuriteFixture.cs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/sdk/storage/Microsoft.Azure.WebJobs.Extensions.Storage.Common/tests/AzuriteFixture.cs b/sdk/storage/Microsoft.Azure.WebJobs.Extensions.Storage.Common/tests/AzuriteFixture.cs index af0ce283156b..7ec6f88fafee 100644 --- a/sdk/storage/Microsoft.Azure.WebJobs.Extensions.Storage.Common/tests/AzuriteFixture.cs +++ b/sdk/storage/Microsoft.Azure.WebJobs.Extensions.Storage.Common/tests/AzuriteFixture.cs @@ -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; @@ -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) @@ -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(); @@ -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;