29
29
import static org .junit .jupiter .api .Assertions .fail ;
30
30
31
31
public class LiveManagedIdentityTests {
32
+ final private static ClientLogger LOGGER = new ClientLogger (LiveManagedIdentityTests .class );
32
33
33
34
@ Test
34
35
@ EnabledIfEnvironmentVariable (named = "AZURE_TEST_MODE" , matches = "LIVE" )
@@ -67,9 +68,9 @@ public void testManagedIdentityWebAppDeployment() {
67
68
@ Timeout (value = 15 , unit = TimeUnit .MINUTES )
68
69
@ Retry (maxRetries = 3 )
69
70
public void testManagedIdentityAksDeployment () {
70
- System . out . println ( "Environment: " + System .getenv ("IDENTITY_ENVIRONMENT" ));
71
+ LOGGER . log ( LogLevel . INFORMATIONAL , () -> "Environment: " + System .getenv ("IDENTITY_ENVIRONMENT" ));
71
72
String os = System .getProperty ("os.name" );
72
- System . out . println ( "OS: " + os );
73
+ LOGGER . log ( LogLevel . INFORMATIONAL , () -> "OS: " + os );
73
74
//Setup Env
74
75
Configuration configuration = Configuration .getGlobalConfiguration ().clone ();
75
76
@@ -82,6 +83,7 @@ public void testManagedIdentityAksDeployment() {
82
83
assertTrue (podOutput .contains (podName ), "Pod name not found in the output" );
83
84
84
85
String output = runCommand (kubectlPath , "exec" , "-it" , podName , "--" , "java" , "-jar" , "/identity-test.jar" );
86
+
85
87
assertTrue (output .contains ("Successfully retrieved managed identity tokens" ),
86
88
"Failed to get response from AKS" );
87
89
}
@@ -93,9 +95,9 @@ public void testManagedIdentityAksDeployment() {
93
95
@ Timeout (value = 15 , unit = TimeUnit .MINUTES )
94
96
@ Retry (maxRetries = 3 )
95
97
public void testManagedIdentityVmDeployment () {
96
- System . out . println ( "Environment: " + System .getenv ("IDENTITY_ENVIRONMENT" ));
98
+ LOGGER . log ( LogLevel . INFORMATIONAL , () -> "Environment: " + System .getenv ("IDENTITY_ENVIRONMENT" ));
97
99
String os = System .getProperty ("os.name" );
98
- System . out . println ( "OS: " + os );
100
+ LOGGER . log ( LogLevel . INFORMATIONAL , () -> "OS: " + os );
99
101
//Setup Env
100
102
Configuration configuration = Configuration .getGlobalConfiguration ().clone ();
101
103
@@ -128,7 +130,7 @@ public void testManagedIdentityVmDeployment() {
128
130
storageAcccountName , sasToken );
129
131
String script = String .format ("curl \' %s\' -o ./testfile.jar && java -jar ./testfile.jar" , vmBlob );
130
132
131
- System . out . println ( "Script: " + script );
133
+ LOGGER . log ( LogLevel . INFORMATIONAL , () -> "Script: " + script );
132
134
133
135
String output = runCommand (azPath , "vm" , "run-command" , "invoke" , "-n" , vmName , "-g" , resourceGroup ,
134
136
"--command-id" , "RunShellScript" , "--scripts" , script );
@@ -163,7 +165,7 @@ private String runCommand(String... args) {
163
165
for (String arg : args ) {
164
166
command .append (arg ).append (" " );
165
167
}
166
- System . out . println ( "Running command: " + command );
168
+ LOGGER . log ( LogLevel . INFORMATIONAL , () -> "Running command: " + command );
167
169
ProcessBuilder processBuilder = new ProcessBuilder (args );
168
170
processBuilder .redirectErrorStream (true );
169
171
Process process = processBuilder .start ();
@@ -176,7 +178,7 @@ private String runCommand(String... args) {
176
178
output .append (line ).append (System .lineSeparator ());
177
179
}
178
180
}
179
- System . out . println ( "Output:" + System .lineSeparator () + output );
181
+ LOGGER . log ( LogLevel . INFORMATIONAL , () -> "Output:" + System .lineSeparator () + output );
180
182
return output .toString ();
181
183
} catch (IOException | InterruptedException e ) {
182
184
e .printStackTrace ();
0 commit comments