new-integration-tests/src/test/java/oracle/weblogic/kubernetes/assertions/impl/Pod.java
private static Callable<Boolean> podRestarted(String podName, Map<String, DateTime> pods, int maxUnavailable,
      String namespace) {
    return () -> {
      int terminatingPods = 0;
      boolean podRestartStatus = false;
      for (Map.Entry<String, DateTime> entry : pods.entrySet()) {
        V1Pod pod = Kubernetes.getPod(namespace, null, entry.getKey());
        DateTime deletionTimeStamp = Optional.ofNullable(pod)
            .map(metadata -> metadata.getMetadata())
            .map(timeStamp -> timeStamp.getDeletionTimestamp()).orElse(null);
        if (deletionTimeStamp != null) {
          getLogger().info("Pod {0} is getting replaced", entry.getKey());
          if (++terminatingPods > maxUnavailable) {
            getLogger().severe("more than maxUnavailable {0} pod(s) are restarting", maxUnavailable);
            throw new Exception("more than maxUnavailable pods are restarting");
          }
        }
        if (podName.equals(entry.getKey())) {
          if (pod != null && pod.getMetadata().getCreationTimestamp() != null) {
            DateTime newCreationTimeStamp = pod.getMetadata().getCreationTimestamp();
            getLogger().info("Comparing creation timestamps old: {0} new {1}",
                entry.getValue(), newCreationTimeStamp);
            if (newCreationTimeStamp.isAfter(entry.getValue())) {
              getLogger().info("Pod {0} is restarted", entry.getKey());
              podRestartStatus = true;
            }
          }
        }
      }
      return podRestartStatus;
    };
  }
/**
   * Return true if the given pod podName is restarted. This method will throw a exception if more than maxUnavailable
   * pods are restarted at the same time.
   *
   * @param pods map of pod names with its creation time stamps
   * @param podName name of pod to check for restart status
   * @param maxUnavailable number of pods that can concurrently restart at the same time
   * @param namespace name of the namespace in which the pod restart status to be checked
   * @return true if given pod is restarted
   */
Return true if the given pod podName is restarted. This method will throw a exception if more than maxUnavailable
pods are restarted at the same time.


Return true if the given pod podName is restarted . This method will throw a exception if more than maxUnavailable pods are restarted at the same time .
private static Callable<Boolean> podRestarted(String podName, Map<String, DateTime> pods, int maxUnavailable,
      String namespace) {
    return () -> {
      int terminatingPods = 0;
      boolean podRestartStatus = false;
      for (Map.Entry<String, DateTime> entry : pods.entrySet()) {
        V1Pod pod = Kubernetes.getPod(namespace, null, entry.getKey());
        DateTime deletionTimeStamp = Optional.ofNullable(pod)
            .map(metadata -> metadata.getMetadata())
            .map(timeStamp -> timeStamp.getDeletionTimestamp()).orElse(null);
        if (deletionTimeStamp != null) {
          getLogger().info("Pod {0} is getting replaced", entry.getKey());
          if (++terminatingPods > maxUnavailable) {
            getLogger().severe("more than maxUnavailable {0} pod(s) are restarting", maxUnavailable);
            throw new Exception("more than maxUnavailable pods are restarting");
          }
        }
        if (podName.equals(entry.getKey())) {
          if (pod != null && pod.getMetadata().getCreationTimestamp() != null) {
            DateTime newCreationTimeStamp = pod.getMetadata().getCreationTimestamp();
            getLogger().info("Comparing creation timestamps old: {0} new {1}",
                entry.getValue(), newCreationTimeStamp);
            if (newCreationTimeStamp.isAfter(entry.getValue())) {
              getLogger().info("Pod {0} is restarted", entry.getKey());
              podRestartStatus = true;
            }
          }
        }
      }
      return podRestartStatus;
    };
  }
private static Callable < Boolean > podRestarted ( String podName , Map < String , DateTime > pods , int maxUnavailable , String namespace ) { return ( ) -> { int terminatingPods = 0 ; boolean podRestartStatus = false ; for ( Map . Entry < String , DateTime > entry : pods . entrySet ( ) ) { V1Pod pod = Kubernetes . getPod ( namespace , null , entry . getKey ( ) ) ; DateTime deletionTimeStamp = Optional . ofNullable ( pod ) . map ( metadata -> metadata . getMetadata ( ) ) . map ( timeStamp -> timeStamp . getDeletionTimestamp ( ) ) . orElse ( null ) ; if ( deletionTimeStamp != null ) { getLogger ( ) . info ( "Pod {0} is getting replaced" , entry . getKey ( ) ) ; if ( ++ terminatingPods > maxUnavailable ) { getLogger ( ) . severe ( "more than maxUnavailable {0} pod(s) are restarting" , maxUnavailable ) ; throw new Exception ( "more than maxUnavailable pods are restarting" ) ; } } if ( podName . equals ( entry . getKey ( ) ) ) { if ( pod != null && pod . getMetadata ( ) . getCreationTimestamp ( ) != null ) { DateTime newCreationTimeStamp = pod . getMetadata ( ) . getCreationTimestamp ( ) ; getLogger ( ) . info ( "Comparing creation timestamps old: {0} new {1}" , entry . getValue ( ) , newCreationTimeStamp ) ; if ( newCreationTimeStamp . isAfter ( entry . getValue ( ) ) ) { getLogger ( ) . info ( "Pod {0} is restarted" , entry . getKey ( ) ) ; podRestartStatus = true ; } } } } return podRestartStatus ; } ; }
Return true if the given pod podName is restarted.
Return true if the given pod podName is restarted .