Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add recording file location #6517

Merged
merged 5 commits into from
Jul 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ public async void TestStartPlaybackSimple()
await controller.Start();

var value = httpContext.Response.Headers["x-recording-id"].ToString();
Assert.NotNull(value);
var recordLocation = httpContext.Response.Headers["x-recording-file-location"].ToString();
Assert.False(String.IsNullOrEmpty(value));
Assert.False(String.IsNullOrEmpty(recordLocation));
Assert.True(testRecordingHandler.PlaybackSessions.ContainsKey(value));
}

Expand Down Expand Up @@ -74,7 +76,9 @@ public async void TestStartPlaybackInMemory()
await playbackController.Start();

var value = playbackContext.Response.Headers["x-recording-id"].ToString();
Assert.NotNull(value);
var recordLocation = playbackContext.Response.Headers["x-recording-file-location"].ToString();
Assert.False(String.IsNullOrEmpty(value));
Assert.True(String.IsNullOrEmpty(recordLocation));
Assert.True(testRecordingHandler.PlaybackSessions.ContainsKey(value));
Assert.True(testRecordingHandler.InMemorySessions.Count() == 1);
}
Expand Down Expand Up @@ -206,7 +210,7 @@ public async Task TestPlaybackSetsRetryAfterToZero()
await controller.Start();

var recordingId = httpContext.Response.Headers["x-recording-id"].ToString();
Assert.NotNull(recordingId);
Assert.False(String.IsNullOrEmpty(recordingId));
Assert.True(testRecordingHandler.PlaybackSessions.ContainsKey(recordingId));
var entry = testRecordingHandler.PlaybackSessions[recordingId].Session.Entries[0];
HttpRequest request = TestHelpers.CreateRequestFromEntry(entry);
Expand Down Expand Up @@ -241,7 +245,7 @@ public async Task TestPlaybackWithGZippedContentPlayback()
await controller.Start();

var recordingId = httpContext.Response.Headers["x-recording-id"].ToString();
Assert.NotNull(recordingId);
Assert.False(String.IsNullOrEmpty(recordingId));
Assert.True(testRecordingHandler.PlaybackSessions.ContainsKey(recordingId));
var entry = testRecordingHandler.PlaybackSessions[recordingId].Session.Entries[0];
HttpRequest request = TestHelpers.CreateRequestFromEntry(entry);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public async Task TestStartRecordSimple()
};
await controller.Start();
var recordingId = httpContext.Response.Headers["x-recording-id"].ToString();
Assert.NotNull(recordingId);
Assert.False(string.IsNullOrEmpty(recordingId));
Assert.True(testRecordingHandler.RecordingSessions.ContainsKey(recordingId));
}

Expand All @@ -62,9 +62,9 @@ public async Task TestStartRecordInMemory()

[Theory]
[InlineData("recordings/TestStartRecordSimple_nosave.json", "request-response")]
[InlineData("recordings/TestStartRecordSimpl�_nosave.json", "request-response")]
[InlineData("recordings/TestStartRecordSimplé_nosave.json", "request-response")]
[InlineData("recordings/TestStartRecordSimple.json", "")]
[InlineData("recordings/TestStartRecordSimpl�.json", "")]
[InlineData("recordings/TestStartRecordSimplé.json", "")]
Comment on lines +65 to +67
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just noticed this - VS must have "helped." Should this get reverted?

public async Task TestStopRecordingSimple(string targetFile, string additionalEntryModeHeader)
{
RecordingHandler testRecordingHandler = new RecordingHandler(Directory.GetCurrentDirectory());
Expand Down
2 changes: 2 additions & 0 deletions tools/test-proxy/Azure.Sdk.Tools.TestProxy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,8 @@ To start an individual test recording or playback, users will POST to a route on

You will receive a recordingId in the reponse under header `x-recording-id`. This value should be included under header `x-recording-id` in all further requests.

For playback, you will receive the location of the recording file (if it is on disk) in the header `x-recording-file-location`.
scbedd marked this conversation as resolved.
Show resolved Hide resolved

### Run your tests

The implicit assumption about this proxy is that you as a dev have _some way_ to reroute your existing requests (with some header additions) to the test-proxy.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ public async Task StartPlaybackAsync(string sessionId, HttpResponse outgoingResp
{
await RestoreAssetsJson(assetsPath, true);
var path = await GetRecordingPath(sessionId, assetsPath);

outgoingResponse.Headers.Add("x-recording-file-location", path);
scbedd marked this conversation as resolved.
Show resolved Hide resolved
if (!File.Exists(path))
{
throw new TestRecordingMismatchException($"Recording file path {path} does not exist.");
Expand Down