integration-tests/src/test/java/oracle/kubernetes/operator/utils/TestUtils.java
public static void checkServiceCreated(String serviceName, String domainNS, int maxIterations) throws Exception {
    int i = 0;
    StringBuffer cmd = new StringBuffer();
    cmd.append("kubectl get service ").append(serviceName).append(" -n ").append(domainNS);

    // check for service
    while (i < maxIterations) {
      ExecResult result = ExecCommand.exec(cmd.toString());

      // service might not have been created
      if (result.exitValue() != 0
          || (result.exitValue() == 0 && !result.stdout().contains(serviceName))) {
        LoggerHelper.getLocal().log(Level.INFO, "Output for " + cmd + "\n" + result.stdout() + "\n " + result.stderr());

        // check for last iteration
        if (i == (maxIterations - 1)) {
          throw new RuntimeException("FAILURE: service is not created, exiting!");
        }
        LoggerHelper.getLocal().log(Level.INFO,
            "Service is not created Ite ["
                + i
                + "/"
                + maxIterations
                + "], sleeping "
                + BaseTest.getWaitTimePod()
                + " seconds more");
        Thread.sleep(BaseTest.getWaitTimePod() * 1000);
        i++;
      } else {
        LoggerHelper.getLocal().log(Level.INFO, "Service " + serviceName + " is Created");
        break;
      }
    }
  }
/**
   * Checks that service is created.
   *
   * @param serviceName service name
   * @param domainNS    namespace
   * @param maxIterations max iterations count
   * @throws RuntimeException if service is not created
   */
Checks that service is created.
@param serviceName service name
@param domainNS    namespace
@param maxIterations max iterations count
@throws RuntimeException if service is not created
Checks that service is created . @param serviceName service name @param domainNS namespace @param maxIterations max iterations count @throws RuntimeException if service is not created
public static void checkServiceCreated(String serviceName, String domainNS, int maxIterations) throws Exception {
    int i = 0;
    StringBuffer cmd = new StringBuffer();
    cmd.append("kubectl get service ").append(serviceName).append(" -n ").append(domainNS);
    while (i < maxIterations) {
      ExecResult result = ExecCommand.exec(cmd.toString());
      if (result.exitValue() != 0
          || (result.exitValue() == 0 && !result.stdout().contains(serviceName))) {
        LoggerHelper.getLocal().log(Level.INFO, "Output for " + cmd + "\n" + result.stdout() + "\n " + result.stderr());
        if (i == (maxIterations - 1)) {
          throw new RuntimeException("FAILURE: service is not created, exiting!");
        }
        LoggerHelper.getLocal().log(Level.INFO,
            "Service is not created Ite ["
                + i
                + "/"
                + maxIterations
                + "], sleeping "
                + BaseTest.getWaitTimePod()
                + " seconds more");
        Thread.sleep(BaseTest.getWaitTimePod() * 1000);
        i++;
      } else {
        LoggerHelper.getLocal().log(Level.INFO, "Service " + serviceName + " is Created");
        break;
      }
    }
  }
public static void checkServiceCreated ( String serviceName , String domainNS , int maxIterations ) throws Exception { int i = 0 ; StringBuffer cmd = new StringBuffer ( ) ; cmd . append ( "kubectl get service " ) . append ( serviceName ) . append ( " -n " ) . append ( domainNS ) ; while ( i < maxIterations ) { ExecResult result = ExecCommand . exec ( cmd . toString ( ) ) ; if ( result . exitValue ( ) != 0 || ( result . exitValue ( ) == 0 && ! result . stdout ( ) . contains ( serviceName ) ) ) { LoggerHelper . getLocal ( ) . log ( Level . INFO , "Output for " + cmd + "\n" + result . stdout ( ) + "\n " + result . stderr ( ) ) ; if ( i == ( maxIterations - 1 ) ) { throw new RuntimeException ( "FAILURE: service is not created, exiting!" ) ; } LoggerHelper . getLocal ( ) . log ( Level . INFO , "Service is not created Ite [" + i + "/" + maxIterations + "], sleeping " + BaseTest . getWaitTimePod ( ) + " seconds more" ) ; Thread . sleep ( BaseTest . getWaitTimePod ( ) * 1000 ) ; i ++ ; } else { LoggerHelper . getLocal ( ) . log ( Level . INFO , "Service " + serviceName + " is Created" ) ; break ; } } }
Checks that service is created.
Checks that service is created .
// check for service // service might not have been created // check for last iteration