1717import java .net .MalformedURLException ;
1818import java .net .URL ;
1919import java .nio .file .Paths ;
20+ import java .util .Map ;
2021import java .util .concurrent .atomic .AtomicInteger ;
2122
2223/**
@@ -40,7 +41,9 @@ public TestProxyManager(File recordingPath) {
4041
4142 // This is necessary to stop the proxy when the debugger is stopped.
4243 Runtime .getRuntime ().addShutdownHook (new Thread (this ::stopProxy ));
43- TestProxyDownloader .installTestProxy ();
44+ if (runningLocally ()) {
45+ TestProxyDownloader .installTestProxy ();
46+ }
4447 }
4548
4649 /**
@@ -53,15 +56,23 @@ public void startProxy() {
5356 try {
5457 String commandLine = "test-proxy" ;
5558 // if we're not running in CI, construct the local path. TF_BUILD indicates Azure DevOps. CI indicates Github Actions.
56- if (Configuration .getGlobalConfiguration ().get ("TF_BUILD" ) == null
57- && Configuration .getGlobalConfiguration ().get ("CI" ) == null ) {
59+ if (runningLocally ()) {
5860 commandLine = Paths .get (TestProxyDownloader .getProxyDirectory ().toString (),
5961 TestProxyUtils .getProxyProcessName ()).toString ();
6062 }
6163
62- ProcessBuilder builder = new ProcessBuilder (commandLine , "--storage-location" , recordingPath .getPath (), "--" , "--urls" , getProxyUrl ().toString ())
63- .directory (TestProxyDownloader .getProxyDirectory ().toFile ());
64+ ProcessBuilder builder = new ProcessBuilder (commandLine ,
65+ "--storage-location" ,
66+ recordingPath .getPath (),
67+ "--" ,
68+ "--urls" ,
69+ getProxyUrl ().toString ());
70+ Map <String , String > environment = builder .environment ();
71+ environment .put ("LOGGING__LOGLEVEL" , "Information" );
72+ environment .put ("LOGGING__LOGLEVEL__MICROSOFT" , "Warning" );
73+ environment .put ("LOGGING__LOGLEVEL__DEFAULT" , "Information" );
6474 proxy = builder .start ();
75+
6576 HttpURLConnectionHttpClient client = new HttpURLConnectionHttpClient ();
6677 HttpRequest request = new HttpRequest (HttpMethod .GET ,
6778 String .format ("%s/admin/isalive" , getProxyUrl ()));
@@ -116,4 +127,13 @@ public URL getProxyUrl() {
116127 }
117128 return proxyUrl ;
118129 }
130+
131+ /**
132+ * Checks the environment variables commonly set in CI to determine if the run is local.
133+ * @return True if the run is local.
134+ */
135+ private boolean runningLocally () {
136+ return Configuration .getGlobalConfiguration ().get ("TF_BUILD" ) == null
137+ && Configuration .getGlobalConfiguration ().get ("CI" ) == null ;
138+ }
119139}
0 commit comments