17
17
import java .net .MalformedURLException ;
18
18
import java .net .URL ;
19
19
import java .nio .file .Paths ;
20
+ import java .util .Map ;
20
21
import java .util .concurrent .atomic .AtomicInteger ;
21
22
22
23
/**
@@ -40,7 +41,9 @@ public TestProxyManager(File recordingPath) {
40
41
41
42
// This is necessary to stop the proxy when the debugger is stopped.
42
43
Runtime .getRuntime ().addShutdownHook (new Thread (this ::stopProxy ));
43
- TestProxyDownloader .installTestProxy ();
44
+ if (runningLocally ()) {
45
+ TestProxyDownloader .installTestProxy ();
46
+ }
44
47
}
45
48
46
49
/**
@@ -53,15 +56,23 @@ public void startProxy() {
53
56
try {
54
57
String commandLine = "test-proxy" ;
55
58
// 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 ()) {
58
60
commandLine = Paths .get (TestProxyDownloader .getProxyDirectory ().toString (),
59
61
TestProxyUtils .getProxyProcessName ()).toString ();
60
62
}
61
63
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" );
64
74
proxy = builder .start ();
75
+
65
76
HttpURLConnectionHttpClient client = new HttpURLConnectionHttpClient ();
66
77
HttpRequest request = new HttpRequest (HttpMethod .GET ,
67
78
String .format ("%s/admin/isalive" , getProxyUrl ()));
@@ -116,4 +127,13 @@ public URL getProxyUrl() {
116
127
}
117
128
return proxyUrl ;
118
129
}
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
+ }
119
139
}
0 commit comments