Skip to content

Commit

Permalink
repair tests. add additional logging
Browse files Browse the repository at this point in the history
  • Loading branch information
scbedd committed Sep 12, 2023
1 parent d6311c0 commit 295caa5
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
16 changes: 8 additions & 8 deletions tools/test-proxy/Azure.Sdk.Tools.TestProxy.Tests/LoggingTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public async Task PlaybackLogsSanitizedRequest()
HttpResponse response = new DefaultHttpContext().Response;
await testRecordingHandler.HandlePlaybackRequest(recordingId, request, response);

AssertLogs(logger);
AssertLogs(logger, 1);
}
finally
{
Expand Down Expand Up @@ -92,7 +92,7 @@ public async Task RecordingHandlerLogsSanitizedRequests()

try
{
AssertLogs(logger);
AssertLogs(logger, 0);
}
finally
{
Expand All @@ -101,27 +101,27 @@ public async Task RecordingHandlerLogsSanitizedRequests()
}
}

private static void AssertLogs(TestLogger logger)
private static void AssertLogs(TestLogger logger, int logOffSet)
{
Assert.Equal(5, logger.Logs.Count);
Assert.Equal(4 + logOffSet, logger.Logs.Count);
Assert.Equal(
$"URI: [ http://127.0.0.1:5000/admin/addsanitizer]{Environment.NewLine}Headers: " +
"[{\"Host\":[\"127.0.0.1:5000\"],\"x-abstraction-identifier\":[\"HeaderRegexSanitizer\"]," +
"\"Content-Length\":[\"92\"]}]" + Environment.NewLine,
logger.Logs[1].ToString());
logger.Logs[0 + logOffSet].ToString());
Assert.Equal(
"Request Body Content{\"key\":\"Location\",\"value\":\"https://fakeazsdktestaccount.table.core.windows.net/Tables\"}",
logger.Logs[2].ToString());
logger.Logs[1 + logOffSet].ToString());
// sanitizer request body is currently duplicated for each key/value pair
Assert.Equal(
"Request Body Content{\"key\":\"Location\",\"value\":\"https://fakeazsdktestaccount.table.core.windows.net/Tables\"}",
logger.Logs[3].ToString());
logger.Logs[2 + logOffSet].ToString());
Assert.Equal("URI: [ https://fakeazsdktestaccount.table.core.windows.net/Tables]" +
Environment.NewLine + "Headers: [{\"Accept\":[\"application/json;odata=minimalmetadata\"],\"Accept-Encoding\":[\"gzip, deflate\"],\"Authorization\":[\"Sanitized\"],\"Connection\":[\"keep-alive\"]," +
"\"Content-Length\":[\"12\"],\"Content-Type\":[\"application/octet-stream\"],\"DataServiceVersion\":[\"3.0\"],\"Date\":[\"Tue, 18 May 2021 23:27:42 GMT\"]," +
"\"User-Agent\":[\"azsdk-python-data-tables/12.0.0b7 Python/3.8.6 (Windows-10-10.0.19041-SP0)\"],\"x-ms-client-request-id\":[\"a4c24b7a-b830-11eb-a05e-10e7c6392c5a\"]," +
"\"x-ms-date\":[\"Tue, 18 May 2021 23:27:42 GMT\"],\"x-ms-version\":[\"2019-02-02\"]}]" + Environment.NewLine,
logger.Logs[4].ToString());
logger.Logs[3 + logOffSet].ToString());
}

private static async Task AddSanitizerAsync(RecordingHandler testRecordingHandler, TestLogger logger)
Expand Down
1 change: 0 additions & 1 deletion tools/test-proxy/Azure.Sdk.Tools.TestProxy/Playback.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ public async Task Start()


var logBody = body == null ? "" : body.ToString();

_logger.LogInformation($"recording: {recordingId ?? "null"}\nbody: {logBody}");

if (String.IsNullOrEmpty(file) && !String.IsNullOrEmpty(recordingId))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ public virtual CommandResult Run(string arguments, string workingDirectory)
}

ProcessStartInfo processStartInfo = CreateGitProcessInfo(workingDirectory);

processStartInfo.Arguments = arguments;

CommandResult result = new CommandResult()
Expand All @@ -131,7 +132,7 @@ public virtual CommandResult Run(string arguments, string workingDirectory)
int attempts = 1;
while (attempts <= RETRY_INTERMITTENT_FAILURE_COUNT)
{
DebugLogger.LogInformation($"git {arguments}");
DebugLogger.LogInformation($"git {arguments} in {workingDirectory}");

var output = new List<string>();
var error = new List<string>();
Expand Down Expand Up @@ -284,7 +285,7 @@ public virtual bool TryRun(string arguments, string workingDirectory, out Comman
bool continueToAttempt = true;
while (continueToAttempt && attempts <= RETRY_INTERMITTENT_FAILURE_COUNT)
{
DebugLogger.LogInformation($"git {arguments}");
DebugLogger.LogInformation($"git {arguments} in {workingDirectory}");
var output = new List<string>();
var error = new List<string>();

Expand Down

0 comments on commit 295caa5

Please sign in to comment.