This writeup is NOT a reference on how to install or run the test-proxy
, it is a shortcut guide to helping a test-proxy dev debug each language's tests.
- Install npm, ensure
node
is available on PATH - Install npm version of azurite,
npm install -g azurite
- Set environment variable
AZURE_AZURITE_LOCATION
to the location of yournpm root -g
output- For me this was
C:/.tools/.npm-global/
- For me this was
- Set environment variable
PROXY_DEBUG_MODE
totrue
.- Optionally, opening up
TestProxy.cs
, scrolling down the TestProxy startup, and settingdebugMode = true
will ensure that it always runs with traffic directed at 5000/5001.
- Optionally, opening up
- Start the debugging proxy instance
- Open VS2022 and then the targeted .NET solution
- Open VS2022 after running
New-TestResources
and setting the environment variables in a CLI instance, then open vs manually from there. - That is
C:/Program Files/Microsoft Visual Studio/2022/Enterprise/Common7/IDE/devenv.exe
for me.
- Open VS2022 after running
- Debug whichever tests by right click -> debug, it'll route to your running proxy.
- Set environment variable
PROXY_MANUAL_START
totrue
- If you wish to fiddle or otherwise intercept the traffic, using
PROXY_URL=http://localhost:5000
is a good idea.
- Start the debugging proxy instance
--storage-location=/path/to/target/repo/root
- Debug python tests as normal
- Set the environment variable
PROXY_MANUAL_START
totrue
- Run the prxoy in selected mode
- go to targeted directory,
go build
- Invoke tests
go test
go test -run TestClient_GetManifest
For livetests, if there is NO test-resources.json
, DO NOT DESPAIR. To successfully invoke livetests in in record
mode, I set the following env variables (for sdk/containers/azcontainerregistry
), which can be obtained by:
.\eng\common\TestResources\New-TestResources.ps1 containers/azcontainerregistry -UserAuth
${env:REGISTRY_NAME} = '<blahblah>'
${env:AZCONTAINERREGISTRY_RESOURCE_GROUP} = '<my-rg>'
${env:LOGIN_SERVER} = '<blahblah>.azurecr.io'
${env:AZURE_SERVICE_DIRECTORY} = 'AZCONTAINERREGISTRY'
${env:AZCONTAINERREGISTRY_RESOURCE_MANAGER_URL} = 'https://management.azure.com/'
${env:AZCONTAINERREGISTRY_SUBSCRIPTION_ID} = '<subid>'
${env:AZCONTAINERREGISTRY_AZURE_AUTHORITY_HOST} = 'https://login.microsoftonline.com/'
${env:AZCONTAINERREGISTRY_LOCATION} = '<region>'
${env:AZCONTAINERREGISTRY_SERVICE_MANAGEMENT_URL} = 'https://management.core.windows.net/'
#I did NOT set AZCONTAINERREGISTRY_CLOUD, had to reset that to avoid a panic
$env:AZURE_SUBSCRIPTION_ID=$env:AZCONTAINERREGISTRY_SUBSCRIPTION_ID
$env:PROXY_MANUAL_START="true"
$env:AZURE_RECORD_MODE="record"
If you need to make changes to the test framework, and also need to reference that updated local go code. You need to adjust the following.
C:/repo/azure-sdk-for-go [main]|>git diff sdk/containers/azcontainerregistry/go.mod
diff --git a/sdk/containers/azcontainerregistry/go.mod b/sdk/containers/azcontainerregistry/go.mod
index 132a7273c0..8c28f09f81 100644
--- a/sdk/containers/azcontainerregistry/go.mod
+++ b/sdk/containers/azcontainerregistry/go.mod
@@ -25,3 +25,5 @@ require (
golang.org/x/text v0.14.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
+
+replace github.com/Azure/azure-sdk-for-go/sdk/internal => ../../../sdk/internal
The addition of replace
is what enables this. Then in recording.go
, change the defaultOptions proxyPort
to 5001
. That way you can get a connection to the proxy port.
This language doesn't utilize the proxy. No instructions.
PROXY_MANUAL_START=true
rush update
cd <target package>
rush build -t .
rushx test:node
- Install
maven
. Ensure it's available on the path. - Set
TF_BUILD
orCI
totrue
so that the java tests look for an already running proxy. - Install necessary prereqs for the package being tested
mvn install -f sdk/core/azure-core/pom.xml "-Dcodesnippet.skip" "-Drevapi.skip" "-Dspotbugs.skip" -DskipTests=true "-Djacoco.skip" "-Dmaven.javadoc.skip=true" -DskipTestCompile "-Dcheckstyle.skip=true"
mvn install -f sdk/core/azure-core-test/pom.xml "-Dcodesnippet.skip" "-Drevapi.skip" "-Dspotbugs.skip" -DskipTests=true "-Djacoco.skip" "-Dmaven.javadoc.skip=true" "-Dcheckstyle.skip=true"
mvn install -f common/perf-test-core/pom.xml "-Dcodesnippet.skip" "-Drevapi.skip" "-Dspotbugs.skip" -DskipTests=true "-Djacoco.skip" "-Dmaven.javadoc.skip=true" "-Dcheckstyle.skip=true"
mvn clean install -f sdk/parents/azure-perf-test-parent/pom.xml "-Dcodesnippet.skip" "-Drevapi.skip" "-Dspotbugs.skip" -DskipTests=true "-Djacoco.skip" "-Dmaven.javadoc.skip=true" "-Dcheckstyle.skip=true"
mvn install -f sdk/core/azure-core-perf/pom.xml "-Dcodesnippet.skip" "-Drevapi.skip" "-Dspotbugs.skip" -DskipTests=true "-Djacoco.skip" "-Dmaven.javadoc.skip=true" "-Dcheckstyle.skip=true"
mvn install -f sdk/resourcemanager/ "-Dcodesnippet.skip" "-Drevapi.skip" "-Dspotbugs.skip" -DskipTests=true "-Djacoco.skip" "-Dmaven.javadoc.skip=true" "-Dcheckstyle.skip=true"
mvn surefire:test -f sdk/resourcemanager/azure-resourcemanager-compute/pom.xml -Dtest=TestProxyTests#testRecordWithRedaction
-Dtest=<testClassName>#<testFunctionName>
Samples
mvn install -f sdk/containerregistry/azure-containers-containerregistry/pom.xml "-Dcodesnippet.skip" "-Drevapi.skip" "-Dspotbugs.skip" -DskipTests=true "-Djacoco.skip" "-Dmaven.javadoc.skip=true" "-Dcheckstyle.skip=true"
mvn surefire:test -f sdk/containerregistry/azure-containers-containerregistry/pom.xml -Dtest=ContainerRegistryContentClientIntegrationTests#canUploadDockerManifestWithTagAsync
mvn surefire:test -f sdk/containerregistry/azure-containers-containerregistry/pom.xml -Dtest=ContainerRegistryContentClientIntegrationTests#canUploadDockerManifestWithTag
mvn surefire:test -f sdk/containerregistry/azure-containers-containerregistry/pom.xml -Dtest=ContainerRegistryContentClientIntegrationTests#getOciListManifest
mvn surefire:test -f sdk/containerregistry/azure-containers-containerregistry/pom.xml -Dtest=ContainerRegistryContentClientIntegrationTests#getDockerManifestListType
mvn surefire:test -f sdk/containerregistry/azure-containers-containerregistry/pom.xml -Dtest=ContainerRegistryContentClientIntegrationTests#getOciListManifestAsync
url="https://github.com/Azure/azure-sdk-tools/releases/download/Azure.Sdk.Tools.TestProxy_1.0.0-dev.20240515.4/test-proxy-standalone-linux-x64.tar.gz"
directory="/path/to/destination/directory"
mkdir -p "$directory"
wget "$url" -O /tmp/test-proxy-standalone-linux-x64.tar.gz
tar -xzf /tmp/test-proxy-standalone-linux-x64.tar.gz -C "$directory"
rm /tmp/test-proxy-standalone-linux-x64.tar.gz