Skip to content

Commit 5f2341a

Browse files
authored
Test-Proxy Documentation updates (#7943)
* some feedback from richard + additional logging discussed with Mike
1 parent dcaa900 commit 5f2341a

3 files changed

Lines changed: 21 additions & 45 deletions

File tree

tools/assets-automation/asset-sync/README.md

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
- [Azure SDK Assets Relocation -- "move recordings out of repos"](#azure-sdk-assets-relocation----move-recordings-out-of-repos)
44
- [What is the problem? Why?](#what-is-the-problem-why)
55
- [How the test-proxy can ease transition of external recordings](#how-the-test-proxy-can-ease-transition-of-external-recordings)
6-
- [Old](#old)
7-
- [New](#new)
86
- [Which external storage mediums were considered?](#which-external-storage-mediums-were-considered)
97
- [`Git SubModules`](#git-submodules)
108
- [Advantages of `Git SubModules`](#advantages-of-git-submodules)
@@ -99,18 +97,6 @@ All that needs to happen is to:
9997
2. Adjust the provided "file path" to the recording within the asset repo if necesssary.
10098
3. Profit.
10199

102-
If you were invoking the test-proxy as a docker image, the difference in initialization is as easy as:
103-
104-
### Old
105-
106-
`docker run -v C:/repo/sdk-for-python/:/etc/testproxy azsdkengsys.azurecr.io/engsys/testproxy-lin:latest`
107-
108-
### New
109-
110-
`docker run -v C:/repo/sdk-for-python-assets/:/etc/testproxy azsdkengsys.azurecr.io/engsys/testproxy-lin:latest`
111-
112-
Given the same relative path in the assets repo, zero changes to test code are necessary.
113-
114100
## Which external storage mediums were considered?
115101

116102
Prior to ScottB starting on this project, JimS was the one leading the charge. As part of that work, [Jim explored a few potentional storage solutions](https://microsoft.sharepoint.com/:w:/t/AzureDeveloperExperience/EZ8CA-UTsENIoORsOxekfG8BzwoNV4xhVOIzTGmdk8j4rA?e=RKAkkc). He did not evaluate these strictly from a `usability` standpoint.

tools/test-proxy/Azure.Sdk.Tools.TestProxy/Store/GitProcessHandler.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,8 @@ public virtual CommandResult Run(string arguments, string workingDirectory)
184184
throw new GitProcessException(result);
185185
}
186186

187+
DebugLogger.LogInformation($"Retrying git command {arguments} in {workingDirectory} after {attempts} attempts.");
188+
187189
attempts++;
188190

189191
if (continueToAttempt && attempts < RETRY_INTERMITTENT_FAILURE_COUNT)

tools/test-proxy/documentation/asset-sync/README.md

Lines changed: 19 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ An `assets.json` takes the form:
2424

2525
```jsonc
2626
{
27-
"AssetsRepo": "Azure/azure-sdk-assets-integration",
27+
"AssetsRepo": "Azure/azure-sdk-assets",
2828
"AssetsRepoPrefixPath": "python",
2929
"TagPrefix": "python/core",
3030
"Tag": "python/core_<10-character-commit-SHA>"
@@ -35,7 +35,7 @@ An `assets.json` takes the form:
3535
|---|---|
3636
| AssetsRepo | The full name of the external github repo storing the data. EG: `Azure/azure-sdk-assets` |
3737
| AssetsRepoPrefixPath | The assets repository may want to place the content under a specific path in the assets repo. The default should be the language that the assets belong to. EG: `python`, `net`, `java` etc. |
38-
| TagPrefix | `<Language>/<ServiceDirectory>` or `<Language>/<ServiceDirectory>/<Library>` or deeper if things are nested in such a manner. |
38+
| TagPrefix | `<Language>/<ServiceDirectory>` or `<Language>/<ServiceDirectory>/<Library>` or deeper if things are nested in such a manner. This exists **purely** for ease of recognizing your tags.|
3939
| Tag | Initially empty until after the first push at which point the tag will be the `<TagPrefix><10-character-commit-SHA>` |
4040

4141
Comments within the assets.json are allowed and _maintained_ by the tooling. Feel free to leave notes to yourself. They will not be eliminated.
@@ -167,6 +167,19 @@ As you run tests in `recording` or `playback` mode, the `test-proxy` automatical
167167

168168
To view the changes before pushing, use one of the one-liners defined below [below](#attempt-to-manually-resolve).
169169

170+
### I'm starting entirely fresh with no recordings, what should I do first?
171+
172+
All new packages in `azure-sdk` must externalize their recordings, so begin by creating an `assets.json` at your package root.
173+
174+
You could...
175+
176+
- **Manually** generate it from the example `assets.json` [further up in this document](#the-assetsjson-and-how-it-enables-external-recordings)
177+
- Utilize the powershell script `eng/common/testproxy/onboarding/generate-assets-json.ps1` **without** `-InitialPush` flag. [The README is here.](/eng/common/testproxy/onboarding/README.md)
178+
179+
Given the relative lack of complexity present in an `assets.json`, manual generation is recommended _unless recordings already exist_. In which case [this later section has you covered.](#im-a-dev-who-uses-the-test-proxy-currently-how-do-i-externalize-my-recordings)
180+
181+
Once an assets.json with **blank** `Tag` value is present, start your recordings in `Record` mode as normal. Given that there is no tag present in the `assets.json`, the `main` branch will be restored from `azure-sdk-assets`. From there, on successful record-test run, the assets will be in a `test-proxy push`-able state. After that first push, your `tag` will be populated!
182+
170183
### My tests don't use the test-proxy at all currently, how do I externalize my recordings?
171184

172185
You don't. Your first step is to integrate your test framework with the `test-proxy`.
@@ -189,7 +202,7 @@ Use [the transition script](https://github.com/Azure/azure-sdk-tools/blob/main/e
189202

190203
In summary, once an assets.json is present, the shim _must_ be updated to **actually send** a reference to that assets.json inside the `record/start` or `playback/start` requests!
191204

192-
![assets diagram](../_images/before_after.png)
205+
![request with and without assets.json](../_images/before_after.png)
193206

194207
### What does this look like in practice?
195208

@@ -205,7 +218,7 @@ One can see the automatically restored assets repos within the `.assets` folder.
205218

206219
The below diagram illustrates how an individual assets.json, language repo, and assets repo relate to each other.
207220

208-
![assets diagram](../_images/organization_of_assets1.png)
221+
![assets diagram](../_images/organization_of_assets.png)
209222

210223
A user can use the `config` verb to access this the location of their assets on disk! Using assets diagram directly as a reference. we can work an example:
211224

@@ -229,7 +242,7 @@ C:/repo/sdk-for-python/>test-proxy push -a sdk/tables/assets.json
229242

230243
So with the above invocation, the _actual_ location of the assets.json would be: `C:/repo/sdk-for-python/sdk/tables/assets.json`.
231244

232-
When calling the tool (not `docker` unfortunately , due to `mount` constraints), _absolute_ paths are also supported. In that case, context directory does not matter at all.
245+
When calling the tool, _absolute_ paths are also supported. In that case, context directory does not matter at all.
233246

234247
```text
235248
test-proxy push -a C:/repo/sdk-for-python/sdk/tables/assets.json
@@ -244,31 +257,6 @@ After running tests in `record` mode.
244257
1. Confirm lack of secrets (as always with recordings).
245258
2. `test-proxy push <path-to-assets-json>`
246259

247-
> **Important Note** When using `docker` mode with test-proxy push, one will need to invoke the docker container with a couple additional environment variable settings.
248-
249-
Example Docker Push Call
250-
251-
```powershell
252-
docker run --rm -v "<repo-root>:/srv/testproxy" -e "GIT_TOKEN=<git token>" -e "GIT_COMMIT_OWNER=<git commit owner>" -e "GIT_COMMIT_EMAIL=<git commit email>" azsdkengsys.azurecr.io/engsys/test-proxy:latest test-proxy <proxy-args>
253-
```
254-
255-
Please note that any proxy arguments that include _paths_ will need to be **relative** when calling the docker container to do the work for you. This is due to the fact that the running container stores its files under an **internal** path representation. The repo root will be mounted under the default context-directory of `/srv/testproxy/` _always_ for the running container, so all paths must be expressed relatively from that root to actually resolve.
256-
257-
```powershell
258-
# absolute path to assets json
259-
C:/repo/sdk-for-python/sdk/tables/assets.json
260-
261-
# docker container is run, mounting repo root C:/repo/sdk-for-python/ to /srv/testproxy/. The whole path will no longer align
262-
# but the relative path from the root of the repo WILL.
263-
/srv/testproxy/sdk/tables/assets.json
264-
```
265-
266-
So to make a push work for the above scenario, all one must do is only include the path from the root of the repo.
267-
268-
```powershell
269-
docker run --rm -v "C:/repo/sdk-for-python:/srv/testproxy" -e "GIT_TOKEN=myveryrealtoken" -e "GIT_COMMIT_OWNER=scbedd" -e "GIT_COMMIT_EMAIL=scbedd@microsoft.com" azsdkengsys.azurecr.io/engsys/test-proxy:latest test-proxy push -a sdk/tables/assets.json
270-
```
271-
272260
#### An additional note about using `test-proxy push` in codespaces
273261

274262
The `test-proxy` can (and is) used to run tests in github codespaces. However, there is a wrinkle when **pushing** from a default codespaces configuration to the assets repository.
@@ -283,7 +271,7 @@ The `azure-sdk` team has chosen to address this difficulty by [applying the foll
283271

284272
> **Note** Codespaces created on **forks** do not magically gain write permissions to `azure-sdk-assets`.
285273
286-
To push from a codespace on a fork, devs will need to set `GIT_TOKEN` themselves to a PAT that has write access to `azure-sdk-assets`. Effectively the same route as if they wanted to use docker.
274+
To push from a codespace on a fork, devs will need to set `GIT_TOKEN` themselves to a PAT that has write access to `azure-sdk-assets`.
287275

288276
### I am getting weird errors out of my test-proxy operations
289277

0 commit comments

Comments
 (0)