This little tool is intended to showcase what it would look like to transform a directory full of azure-sdk test-proxy
recordings files into traffic files consumable by the oav
tool.
Along the way, answer the questions:
- Does it help, or hurt us to output our recordings in this new format?
- If we were go to the converter route, how fast is it?
- At scale, we need to be able to consume and convert a large amount of recordings files. For context,
python storage
has 1313 recordings at time of writing.
- At scale, we need to be able to consume and convert a large amount of recordings files. For context,
All discussions WRT compatibility with oav
should be in context of the live validation mode.
This converter does not handle non-json files. It 100% assumes valid json input.
npm run build
node ./build/cli.js convert --directory <input-dir> --out <output-dir>
So for a local example...
npm run build
node ./build/cli.js convert --directory ./input-example/ --out ./output-example/
Or for a much bigger sample, use the tables storage tests
present in sample-tables-input/
.
npm run build
node ./build/cli.js convert --directory ./sample-tables-input/ --out ./output-example/
Time a run...
# on windows
measure-command { node .\build\cli.js convert --directory C:/repo/oav-traffic-converter/input-example/ --out ./output-example/ | out-host }
# on linux
time node ./build/cli.js convert --directory ./input-example/ --out ./output-example/
Cleanup a sample run...
Get-ChildItem .\output-example\ -Filter *.json | ? { !$_.Name.Contains("output-example.json") -and !$_.Name.Contains("test_retry.pyTestStorageRetrytest_retry_on_server_error0.json") } | % { Remove-Item $_ }
The current output format of the test-proxy is fairly close to what oav requires.
{
"Entries": [
{
"RequestUri": "",
"RequestMethod": "POST",
"RequestHeaders": {},
"RequestBody": "{}",
"StatusCode": 201,
"ResponseHeaders": {},
"ResponseBody": {}
}
]
}
needs to convert to
{
"liveRequest": {
"body": {},
"method": "",
"url": "",
"headers": {}
},
"liveResponse": {
"body": {},
"statusCode": "201",
"headers": {}
}
}
Repeated for each entry
in the Entries
array in the input value. This means that one Proxy
recording can generate from 1 to N ValidationPayload
s.
Couple Specificities:
- oav expects the request body to be valid json. This is definitely not always the case, as some
javascript
libraries definitely fire text-based request bodies (versus json). - There are no "integer" entries, all primitives are string, even if it's valid to have a number value.
- Ray Chen manually cleaned out the UTF8 encoded bodies. We are parsing as
utf8
before writing the files, so this is just naturally being taken care of by our converter. - The
url
attribute MUST have an additional argument ofapi-version=blah
. We will pull this from header valuex-ms-version
.
The converter performed adequately enough to not put a huge wrench in the process if we want to run this live.
Benchmark | Time (on windows) |
---|---|
1 file | Instant |
536 files (python tables recorded tests) | ~1 second (900ms to 1422ms) |
1300 files (.NET blob recorded tests) | ~5 seconds (4000ms to 5700ms) |
This tool has been run against the python tables
tests successfully.
- Also tested against all
azure.storage.blobs
SessionRecordings, ran into atoo many open files
error, but was quite effective otherwise. - The request URLS must have an API Version in them. This necessitates conversion of the recording until
oav
is patched.
Too many open files
is caused by the fact that we're just opening all the threads at once. We just gotta find an efficient way to batch without removing the performance characteristics of the current solution.