Skip to content

Commit d62edb7

Browse files
committed
use a logger instead of println
1 parent 4b738ba commit d62edb7

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

sdk/identity/azure-identity/src/test/java/LiveManagedIdentityTests.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import static org.junit.jupiter.api.Assertions.fail;
3030

3131
public class LiveManagedIdentityTests {
32+
final private static ClientLogger LOGGER = new ClientLogger(LiveManagedIdentityTests.class);
3233

3334
@Test
3435
@EnabledIfEnvironmentVariable(named = "AZURE_TEST_MODE", matches = "LIVE")
@@ -67,9 +68,9 @@ public void testManagedIdentityWebAppDeployment() {
6768
@Timeout(value = 15, unit = TimeUnit.MINUTES)
6869
@Retry(maxRetries = 3)
6970
public void testManagedIdentityAksDeployment() {
70-
System.out.println("Environment: " + System.getenv("IDENTITY_ENVIRONMENT"));
71+
LOGGER.log(LogLevel.INFORMATIONAL, () -> "Environment: " + System.getenv("IDENTITY_ENVIRONMENT"));
7172
String os = System.getProperty("os.name");
72-
System.out.println("OS: " + os);
73+
LOGGER.log(LogLevel.INFORMATIONAL, () -> "OS: " + os);
7374
//Setup Env
7475
Configuration configuration = Configuration.getGlobalConfiguration().clone();
7576

@@ -82,6 +83,7 @@ public void testManagedIdentityAksDeployment() {
8283
assertTrue(podOutput.contains(podName), "Pod name not found in the output");
8384

8485
String output = runCommand(kubectlPath, "exec", "-it", podName, "--", "java", "-jar", "/identity-test.jar");
86+
8587
assertTrue(output.contains("Successfully retrieved managed identity tokens"),
8688
"Failed to get response from AKS");
8789
}
@@ -93,9 +95,9 @@ public void testManagedIdentityAksDeployment() {
9395
@Timeout(value = 15, unit = TimeUnit.MINUTES)
9496
@Retry(maxRetries = 3)
9597
public void testManagedIdentityVmDeployment() {
96-
System.out.println("Environment: " + System.getenv("IDENTITY_ENVIRONMENT"));
98+
LOGGER.log(LogLevel.INFORMATIONAL, () -> "Environment: " + System.getenv("IDENTITY_ENVIRONMENT"));
9799
String os = System.getProperty("os.name");
98-
System.out.println("OS: " + os);
100+
LOGGER.log(LogLevel.INFORMATIONAL, () -> "OS: " + os);
99101
//Setup Env
100102
Configuration configuration = Configuration.getGlobalConfiguration().clone();
101103

@@ -128,7 +130,7 @@ public void testManagedIdentityVmDeployment() {
128130
storageAcccountName, sasToken);
129131
String script = String.format("curl \'%s\' -o ./testfile.jar && java -jar ./testfile.jar", vmBlob);
130132

131-
System.out.println("Script: " + script);
133+
LOGGER.log(LogLevel.INFORMATIONAL, () -> "Script: " + script);
132134

133135
String output = runCommand(azPath, "vm", "run-command", "invoke", "-n", vmName, "-g", resourceGroup,
134136
"--command-id", "RunShellScript", "--scripts", script);
@@ -163,7 +165,7 @@ private String runCommand(String... args) {
163165
for (String arg : args) {
164166
command.append(arg).append(" ");
165167
}
166-
System.out.println("Running command: " + command);
168+
LOGGER.log(LogLevel.INFORMATIONAL, () -> "Running command: " + command);
167169
ProcessBuilder processBuilder = new ProcessBuilder(args);
168170
processBuilder.redirectErrorStream(true);
169171
Process process = processBuilder.start();
@@ -176,7 +178,7 @@ private String runCommand(String... args) {
176178
output.append(line).append(System.lineSeparator());
177179
}
178180
}
179-
System.out.println("Output:" + System.lineSeparator() + output);
181+
LOGGER.log(LogLevel.INFORMATIONAL, () -> "Output:" + System.lineSeparator() + output);
180182
return output.toString();
181183
} catch (IOException | InterruptedException e) {
182184
e.printStackTrace();

0 commit comments

Comments
 (0)