Skip to content

Commit c360eba

Browse files
authored
log azurite stderr. (#17230)
1 parent 56b647a commit c360eba

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

sdk/storage/Microsoft.Azure.WebJobs.Extensions.Storage.Common/tests/AzuriteFixture.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ public class AzuriteFixture : IDisposable
3535
private AzuriteAccount account;
3636
private CountdownEvent countdownEvent = new CountdownEvent(2);
3737
private StringBuilder azuriteOutput = new StringBuilder();
38+
private StringBuilder azuriteError = new StringBuilder();
3839
private int blobsPort;
3940
private int queuesPort;
4041

@@ -79,6 +80,7 @@ public AzuriteFixture()
7980
process.StartInfo.UseShellExecute = false;
8081
process.StartInfo.RedirectStandardOutput = true;
8182
process.StartInfo.RedirectStandardInput = true;
83+
process.StartInfo.RedirectStandardError = true;
8284
process.OutputDataReceived += delegate (object sender, DataReceivedEventArgs e)
8385
{
8486
if (e.Data != null)
@@ -99,6 +101,16 @@ public AzuriteFixture()
99101
}
100102
}
101103
};
104+
process.ErrorDataReceived += delegate (object sender, DataReceivedEventArgs e)
105+
{
106+
if (e.Data != null)
107+
{
108+
if (!countdownEvent.IsSet) // stop error collection if it started successfully.
109+
{
110+
azuriteError.AppendLine(e.Data);
111+
}
112+
}
113+
};
102114
try
103115
{
104116
process.Start();
@@ -107,10 +119,11 @@ public AzuriteFixture()
107119
throw new ArgumentException(ErrorMessage("could not run NodeJS, make sure it's installed"), e);
108120
}
109121
process.BeginOutputReadLine();
122+
process.BeginErrorReadLine();
110123
var didAzuriteStart = countdownEvent.Wait(TimeSpan.FromSeconds(15));
111124
if (!didAzuriteStart)
112125
{
113-
throw new InvalidOperationException(ErrorMessage($"azurite process could not start with following output:\n{azuriteOutput}"));
126+
throw new InvalidOperationException(ErrorMessage($"azurite process could not start with following output:\n{azuriteOutput}\nand error:\n{azuriteError}"));
114127
}
115128
account.BlobsPort = blobsPort;
116129
account.QueuesPort = queuesPort;

0 commit comments

Comments
 (0)