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

[Test-Proxy] During recording, re-use existing request body #5304

Merged
merged 7 commits into from
Feb 2, 2023
Merged
Show file tree
Hide file tree
Changes from 4 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 @@ -618,7 +618,7 @@ public async Task CreateEntryUsesAbsoluteUri()
request.Path = uri.PathAndQuery;
request.Headers["x-recording-upstream-base-uri"] = uri.AbsoluteUri;

var entry = await RecordingHandler.CreateEntryAsync(request);
var entry = (await RecordingHandler.CreateEntryAsync(request)).Item1;
Assert.Equal(uri.AbsoluteUri, entry.RequestUri);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
<LangVersion>preview</LangVersion>
<InformationalVersion>$(OfficialBuildId)</InformationalVersion>
<CheckEolTargetFramework>false</CheckEolTargetFramework>
<AssemblyName>test-proxy</AssemblyName>
</PropertyGroup>

<ItemGroup Condition="'$(TargetFramework)'=='net5.0'">
Expand Down
11 changes: 6 additions & 5 deletions tools/test-proxy/Azure.Sdk.Tools.TestProxy/RecordingHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,10 @@ public async Task HandleRecordRequestAsync(string recordingId, HttpRequest incom
throw new HttpException(HttpStatusCode.BadRequest, $"There is no active recording session under id {recordingId}.");
}

var entry = await CreateEntryAsync(incomingRequest).ConfigureAwait(false);
(RecordEntry entry, byte[] bytes) = await CreateEntryAsync(incomingRequest).ConfigureAwait(false);
var entry = entryTuple.Item1;

var upstreamRequest = CreateUpstreamRequest(incomingRequest, CompressionUtilities.CompressBody(entry.Request.Body, entry.Request.Headers));
var upstreamRequest = CreateUpstreamRequest(incomingRequest, entryTuple.Item2);

HttpResponseMessage upstreamResponse = null;

Expand Down Expand Up @@ -432,7 +433,7 @@ public async Task HandlePlaybackRequest(string recordingId, HttpRequest incoming
throw new HttpException(HttpStatusCode.BadRequest, $"There is no active playback session under recording id {recordingId}.");
}

var entry = await CreateEntryAsync(incomingRequest).ConfigureAwait(false);
var entry = (await CreateEntryAsync(incomingRequest).ConfigureAwait(false)).Item1;

// If request contains "x-recording-remove: false", then request is not removed from session after playback.
// Used by perf tests to play back the same request multiple times.
Expand Down Expand Up @@ -470,7 +471,7 @@ public async Task HandlePlaybackRequest(string recordingId, HttpRequest incoming
}
}

public static async Task<RecordEntry> CreateEntryAsync(HttpRequest request)
public static async Task<Tuple<RecordEntry, byte[]>> CreateEntryAsync(HttpRequest request)
scbedd marked this conversation as resolved.
Show resolved Hide resolved
{
var entry = new RecordEntry();
entry.RequestUri = GetRequestUri(request).AbsoluteUri;
Expand All @@ -487,7 +488,7 @@ public static async Task<RecordEntry> CreateEntryAsync(HttpRequest request)
byte[] bytes = await ReadAllBytes(request.Body).ConfigureAwait(false);

entry.Request.Body = CompressionUtilities.DecompressBody(bytes, request.Headers);
scbedd marked this conversation as resolved.
Show resolved Hide resolved
return entry;
return new Tuple<RecordEntry, byte[]>(entry, bytes);
scbedd marked this conversation as resolved.
Show resolved Hide resolved
}

#endregion
Expand Down
22 changes: 11 additions & 11 deletions tools/test-proxy/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@ extends:
stableTags:
- 'latest'
ReleaseBinaries: true
StandaloneExeMatrix:
- rid: osx-x64
framework: net6.0
- rid: osx-arm64
framework: net6.0
- rid: win-x64
framework: net6.0
- rid: linux-x64
framework: net6.0
- rid: linux-arm64
framework: net6.0
# StandaloneExeMatrix:
# - rid: osx-x64
# framework: net6.0
# - rid: osx-arm64
# framework: net6.0
# - rid: win-x64
# framework: net6.0
# - rid: linux-x64
# framework: net6.0
# - rid: linux-arm64
# framework: net6.0