integration-tests/src/test/java/oracle/kubernetes/operator/utils/TestUtils.java
public static void testWlsLivenessProbe(String domainUid, String serverName,
                                          String namespace, String userProjectsDir)
      throws Exception {
    String podName = domainUid + "-" + serverName;
    int initialRestartCnt = getPodRestartCount(podName, namespace);
    String filePath = userProjectsDir + "/weblogic-domains/" + domainUid + "/killserver.sh";
    // create file to kill server process
    FileWriter fw = new FileWriter(filePath);
    fw.write("#!/bin/bash\n");
    fw.write("kill -9 `jps | grep Server | awk '{print $1}'`");
    fw.close();
    new File(filePath).setExecutable(true, false);

    // copy file to pod
    copyFileViaCat(filePath, "/shared/killserver.sh", podName, namespace);

    // kill server process 3 times
    for (int i = 0; i < 3; i++) {
      ExecResult result =
          kubectlexecNoCheck(
              podName,
              namespace,
              "-- bash -c 'chmod +x /shared/killserver.sh && /shared/killserver.sh'");
      LoggerHelper.getLocal().log(Level.INFO, "kill server process command exitValue "
          + result.exitValue());
      LoggerHelper.getLocal().log(Level.INFO,
          "kill server process command result " + result.stdout() + " stderr " + result.stderr());
      Thread.sleep(2 * 1000);
    }
    // one more time so that liveness probe restarts
    kubectlexecNoCheck(podName, namespace, "/shared/killserver.sh");

    long startTime = System.currentTimeMillis();
    long maxWaitMillis = 180 * 1000;
    while (true) {
      final long currentTime = System.currentTimeMillis();
      int finalRestartCnt = getPodRestartCount(podName, namespace);
      LoggerHelper.getLocal().log(Level.INFO, "initialRestartCnt "
          + initialRestartCnt + " finalRestartCnt " + finalRestartCnt);
      if ((finalRestartCnt - initialRestartCnt) == 1) {
        LoggerHelper.getLocal().log(Level.INFO, "WLS liveness probe test is successful.");
        break;
      }
      LoggerHelper.getLocal().log(Level.INFO, "Waiting for liveness probe to restart the pod");
      if ((currentTime - startTime) > maxWaitMillis) {
        throw new RuntimeException(
            "WLS liveness probe is not working within " + maxWaitMillis / 1000 + " seconds");
      }
      Thread.sleep(5 * 1000);
    }
  }
/**
   * First, kill the mgd server process in the container three times to cause the node manager to
   * mark the server 'failed not restartable'. This in turn is detected by the liveness probe, which
   * initiates a pod restart.
   *
   * @param domainUid  uid
   * @param serverName server name
   * @param namespace  namespace
   * @throws Exception exception
   */
First, kill the mgd server process in the container three times to cause the node manager to
mark the server 'failed not restartable'. This in turn is detected by the liveness probe, which
initiates a pod restart.

@param domainUid  uid
@param serverName server name
@param namespace  namespace
@throws Exception exception
First kill the mgd server process in the container three times to cause the node manager to mark the server ' failed not restartable ' . This in turn is detected by the liveness probe which initiates a pod restart . @param domainUid uid @param serverName server name @param namespace namespace @throws Exception exception
public static void testWlsLivenessProbe(String domainUid, String serverName,
                                          String namespace, String userProjectsDir)
      throws Exception {
    String podName = domainUid + "-" + serverName;
    int initialRestartCnt = getPodRestartCount(podName, namespace);
    String filePath = userProjectsDir + "/weblogic-domains/" + domainUid + "/killserver.sh";
    FileWriter fw = new FileWriter(filePath);
    fw.write("#!/bin/bash\n");
    fw.write("kill -9 `jps | grep Server | awk '{print $1}'`");
    fw.close();
    new File(filePath).setExecutable(true, false);
    copyFileViaCat(filePath, "/shared/killserver.sh", podName, namespace);
    for (int i = 0; i < 3; i++) {
      ExecResult result =
          kubectlexecNoCheck(
              podName,
              namespace,
              "-- bash -c 'chmod +x /shared/killserver.sh && /shared/killserver.sh'");
      LoggerHelper.getLocal().log(Level.INFO, "kill server process command exitValue "
          + result.exitValue());
      LoggerHelper.getLocal().log(Level.INFO,
          "kill server process command result " + result.stdout() + " stderr " + result.stderr());
      Thread.sleep(2 * 1000);
    }
    kubectlexecNoCheck(podName, namespace, "/shared/killserver.sh");
    long startTime = System.currentTimeMillis();
    long maxWaitMillis = 180 * 1000;
    while (true) {
      final long currentTime = System.currentTimeMillis();
      int finalRestartCnt = getPodRestartCount(podName, namespace);
      LoggerHelper.getLocal().log(Level.INFO, "initialRestartCnt "
          + initialRestartCnt + " finalRestartCnt " + finalRestartCnt);
      if ((finalRestartCnt - initialRestartCnt) == 1) {
        LoggerHelper.getLocal().log(Level.INFO, "WLS liveness probe test is successful.");
        break;
      }
      LoggerHelper.getLocal().log(Level.INFO, "Waiting for liveness probe to restart the pod");
      if ((currentTime - startTime) > maxWaitMillis) {
        throw new RuntimeException(
            "WLS liveness probe is not working within " + maxWaitMillis / 1000 + " seconds");
      }
      Thread.sleep(5 * 1000);
    }
  }
public static void testWlsLivenessProbe ( String domainUid , String serverName , String namespace , String userProjectsDir ) throws Exception { String podName = domainUid + "-" + serverName ; int initialRestartCnt = getPodRestartCount ( podName , namespace ) ; String filePath = userProjectsDir + "/weblogic-domains/" + domainUid + "/killserver.sh" ; FileWriter fw = new FileWriter ( filePath ) ; fw . write ( "#!/bin/bash\n" ) ; fw . write ( "kill -9 `jps | grep Server | awk '{print $1}'`" ) ; fw . close ( ) ; new File ( filePath ) . setExecutable ( true , false ) ; copyFileViaCat ( filePath , "/shared/killserver.sh" , podName , namespace ) ; for ( int i = 0 ; i < 3 ; i ++ ) { ExecResult result = kubectlexecNoCheck ( podName , namespace , "-- bash -c 'chmod +x /shared/killserver.sh && /shared/killserver.sh'" ) ; LoggerHelper . getLocal ( ) . log ( Level . INFO , "kill server process command exitValue " + result . exitValue ( ) ) ; LoggerHelper . getLocal ( ) . log ( Level . INFO , "kill server process command result " + result . stdout ( ) + " stderr " + result . stderr ( ) ) ; Thread . sleep ( 2 * 1000 ) ; } kubectlexecNoCheck ( podName , namespace , "/shared/killserver.sh" ) ; long startTime = System . currentTimeMillis ( ) ; long maxWaitMillis = 180 * 1000 ; while ( true ) { final long currentTime = System . currentTimeMillis ( ) ; int finalRestartCnt = getPodRestartCount ( podName , namespace ) ; LoggerHelper . getLocal ( ) . log ( Level . INFO , "initialRestartCnt " + initialRestartCnt + " finalRestartCnt " + finalRestartCnt ) ; if ( ( finalRestartCnt - initialRestartCnt ) == 1 ) { LoggerHelper . getLocal ( ) . log ( Level . INFO , "WLS liveness probe test is successful." ) ; break ; } LoggerHelper . getLocal ( ) . log ( Level . INFO , "Waiting for liveness probe to restart the pod" ) ; if ( ( currentTime - startTime ) > maxWaitMillis ) { throw new RuntimeException ( "WLS liveness probe is not working within " + maxWaitMillis / 1000 + " seconds" ) ; } Thread . sleep ( 5 * 1000 ) ; } }
First, kill the mgd server process in the container three times to cause the node manager to
 mark the server 'failed not restartable'.
First kill the mgd server process in the container three times to cause the node manager to mark the server ' failed not restartable ' .
// create file to kill server process // copy file to pod // kill server process 3 times // one more time so that liveness probe restarts