26
26
import io .kubernetes .client .models .V1PersistentVolumeList ;
27
27
import io .kubernetes .client .models .V1Pod ;
28
28
import io .kubernetes .client .models .V1PodList ;
29
- import io .kubernetes .client .models .V1PodStatus ;
30
29
import io .kubernetes .client .models .V1ReplicaSetList ;
31
30
import io .kubernetes .client .models .V1RoleBindingList ;
32
31
import io .kubernetes .client .models .V1RoleList ;
38
37
import io .kubernetes .client .util .ClientBuilder ;
39
38
import java .io .IOException ;
40
39
import java .util .List ;
40
+ import java .util .logging .Level ;
41
+ import java .util .logging .Logger ;
41
42
42
43
public class K8sTestUtils {
43
44
static {
@@ -55,6 +56,7 @@ public class K8sTestUtils {
55
56
private ExtensionsV1beta1Api extensionsV1beta1Api = new ExtensionsV1beta1Api ();
56
57
private RbacAuthorizationV1Api rbacAuthorizationV1Api = new RbacAuthorizationV1Api ();
57
58
private ApiextensionsV1beta1Api apiextensionsV1beta1Api = new ApiextensionsV1beta1Api ();
59
+ public static final Logger logger = Logger .getLogger ("OperatorIT" , "OperatorIT" );
58
60
59
61
public void verifyDomainCrd () throws Exception {
60
62
try {
@@ -344,33 +346,42 @@ public void verifyNoClusterRoleBindings(String labelSelectors) throws Exception
344
346
assertEquals ("Number of cluster role bindings" , v1ClusterRoleBindingList .getItems ().size (), 0 );
345
347
}
346
348
347
- public V1PodList getPods (String namespace , String labelSelectors ) throws ApiException {
348
- V1PodList v1PodList =
349
- coreV1Api .listNamespacedPod (
350
- namespace ,
351
- Boolean .FALSE ,
352
- Boolean .FALSE .toString (),
353
- null ,
354
- null ,
355
- labelSelectors ,
356
- null ,
357
- null ,
358
- null ,
359
- Boolean .FALSE );
349
+ public V1PodList getPods (String namespace , String labelSelectors ) {
350
+ V1PodList v1PodList = null ;
351
+ try {
352
+ v1PodList =
353
+ coreV1Api .listNamespacedPod (
354
+ namespace ,
355
+ Boolean .FALSE ,
356
+ Boolean .FALSE .toString (),
357
+ null ,
358
+ null ,
359
+ labelSelectors ,
360
+ null ,
361
+ null ,
362
+ null ,
363
+ Boolean .FALSE );
364
+
365
+ } catch (ApiException ex ) {
366
+ Logger .getLogger (K8sTestUtils .class .getName ()).log (Level .SEVERE , null , ex );
367
+ }
368
+ logger .log (
369
+ Level .INFO ,
370
+ "Pods in namespace :{0} and label :{1} :{2}" ,
371
+ new Object [] {namespace , labelSelectors , v1PodList .getItems ().size ()});
360
372
return v1PodList ;
361
373
}
362
374
363
- public String getPodStatus (String namespace , String labelSelectors , String podName )
364
- throws ApiException {
375
+ public String getPodStatus (String namespace , String labelSelectors , String podName ) {
365
376
String status = null ;
366
377
List <V1Pod > pods = getPods (namespace , labelSelectors ).getItems ();
367
378
for (V1Pod pod : pods ) {
368
- V1PodStatus podStatus = pod . getStatus ();
369
- System . out . println ( pod . toString () + ":" + podStatus . getMessage ());
370
- System . out . println ( pod . toString () + ":" + podStatus . getPhase ());
371
- System . out . println ( pod .toString () + ":" + podStatus . toString () );
372
- if (pod .toString ().equals (podName )) {
373
- status = pod .getStatus ().toString ();
379
+ logger . log (
380
+ Level . INFO ,
381
+ "POD NAME:{0} POD STATUS :{1}" ,
382
+ new Object [] { pod . getMetadata (). getName (), pod .getStatus (). getPhase ()} );
383
+ if (pod .getMetadata (). getName ().equals (podName )) {
384
+ status = pod .getStatus ().getPhase ();
374
385
}
375
386
}
376
387
return status ;
0 commit comments