mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

el_kaboing
01.07.2006 83b0cc9a33af29ab2f10e3ce7c9e48d60923fdd6
Implemented an isAlive() method for polling the OpenDS as it is starting. The isAlive() method determines whether the OpenDS has started by sending a simple search query. 
1 files added
3 files modified
322 ■■■■ changed files
opends/tests/integration-tests-testng/src/server/org/opends/server/OpenDSIntegrationTests.java 49 ●●●● patch | view | raw | blame | history
opends/tests/integration-tests-testng/src/server/org/opends/server/OpenDSMgr.java 75 ●●●●● patch | view | raw | blame | history
opends/tests/integration-tests-testng/src/server/org/opends/server/integration/backend/ImportTests.java 178 ●●●●● patch | view | raw | blame | history
opends/tests/integration-tests-testng/src/server/org/opends/server/integration/backend/RestoreTests.java 20 ●●●● patch | view | raw | blame | history
opends/tests/integration-tests-testng/src/server/org/opends/server/OpenDSIntegrationTests.java
@@ -27,8 +27,9 @@
package org.opends.server;
import java.io.*;
//import org.opends.server.OpenDSAdmin;
import  org.opends.server.tools.StopDS;
import org.opends.server.OpenDSMgr;
import org.opends.server.tools.StopDS;
import org.opends.server.tools.LDAPSearch;
/**
 * This class defines a base test case that should be subclassed by all
@@ -41,7 +42,7 @@
  // The print stream to use for printing error messages.
  private PrintStream errorStream;
  protected OpenDSTestOutput ds_output = new OpenDSTestOutput();
  //protected OpenDSAdmin dsAdmin = null;
  protected OpenDSMgr dsMgr = null;
  /**
   * Creates a new instance of this test case with the provided name.
@@ -89,6 +90,8 @@
    System.out.println("Return code is " + Integer.toString(retCode) + ", expecting " + Integer.toString(expCode));
    if (retCode != expCode )
    {
      if (retCode == 999)
    System.out.println("OpenDS could not restart");
      // throw a fail in the testng framewok
      assert retCode==expCode;
    }
@@ -105,25 +108,41 @@
    return outStr;
  }
  public void startOpenDS(String dsee_home, String port) throws Exception
  public int startOpenDS(String dsee_home, String hostname, String port, String bindDN, String bindPW, String logDir) throws Exception
  {
    int isAliveCounter = 0;
    String osName = new String(System.getProperty("os.name"));
    String exec_cmd = "";
    System.out.println("OpenDS is starting.....");
    if (osName.indexOf("Windows") >= 0)  // For Windows
    {
      exec_cmd = "CMD /C " + dsee_home + "\\bin\\start-ds";
      dsMgr = new OpenDSMgr(dsee_home, port);
      dsMgr.start();
    }
    else
    {
      exec_cmd = dsee_home + "/bin/start-ds.sh -nodetach";
      String exec_cmd = dsee_home + "/bin/start-ds.sh -nodetach";
      Runtime rtime = Runtime.getRuntime();
      Process child = rtime.exec(exec_cmd);
    }
    Runtime rtime = Runtime.getRuntime();
    Process child = rtime.exec(exec_cmd);
    Thread.sleep(30000);
    ds_output.redirectOutput(logDir, "Redirect.txt");
    while(isAlive(hostname, port, bindDN, bindPW) != 0)
    {
      if(isAliveCounter % 50 == 0)
      {
        ds_output.resetOutput();
        System.out.println("OpenDS has not yet started.....");
        ds_output.redirectOutput(logDir, "Redirect.txt");
      }
      if(isAliveCounter++ > 5000)
        return 1;
    }
    ds_output.resetOutput();
    System.out.println("OpenDS has started.");
    return 0;
  }
  public void stopOpenDS(String dsee_home, String port) throws Exception
@@ -134,5 +153,11 @@
    System.out.println("OpenDS has stopped.");
  }
}
  public int isAlive(String hostname, String port, String bindDN, String bindPW)
  {
    String isAlive_args[] = {"-h", hostname, "-p", port, "-D", bindDN, "-w", bindPW, "-b", "", "-s", "base", "(objectclass=*)"};
    return(LDAPSearch.mainSearch(isAlive_args));
  }
}
opends/tests/integration-tests-testng/src/server/org/opends/server/OpenDSMgr.java
New file
@@ -0,0 +1,75 @@
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at
 * trunk/opends/resource/legal-notices/OpenDS.LICENSE
 * or https://OpenDS.dev.java.net/OpenDS.LICENSE.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at
 * trunk/opends/resource/legal-notices/OpenDS.LICENSE.  If applicable,
 * add the following below this CDDL HEADER, with the fields enclosed
 * by brackets "[]" replaced with your own identifying * information:
 *      Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 *
 *
 *      Portions Copyright 2006 Sun Microsystems, Inc.
 */
package org.opends.server;
import java.io.*;
import org.opends.server.tools.StopDS;
public class OpenDSMgr
       extends Thread
{
  private String dsee_home;
  private String port;
  public OpenDSMgr(String in_dsee_home, String in_port)
  {
    dsee_home = in_dsee_home;
    port = in_port;
  }
  public void run()
  {
    try
    {
      startDS();
    }
    catch(Exception e)
    {
      e.printStackTrace();
    }
  }
  public void startDS() throws Exception
  {
    String osName = new String(System.getProperty("os.name"));
    String exec_cmd = "";
    if (osName.indexOf("Windows") >= 0)  // For Windows
    {
      exec_cmd = "CMD /C " + dsee_home + "\\bin\\start-ds";
      System.out.println(exec_cmd);
    }
    else
    {
      exec_cmd = dsee_home + "/bin/start-ds.sh -nodetach";
    }
    Runtime rtime = Runtime.getRuntime();
    Process child = rtime.exec(exec_cmd);
  }
}
opends/tests/integration-tests-testng/src/server/org/opends/server/integration/backend/ImportTests.java
@@ -36,9 +36,9 @@
@Test
public class ImportTests extends BackendTests
{
  @Parameters({ "integration_test_home", "port", "logDir", "dsee_home", "backupDir" })
  @Parameters({ "hostname", "port", "bindDN", "bindPW", "integration_test_home", "logDir", "dsee_home", "backupDir" })
  @Test(alwaysRun=true, dependsOnMethods = { "org.opends.server.integration.backend.BackupTasksTests.testBackupTasks1" })
  public void testImport1(String integration_test_home, String port, String logDir, String dsee_home, String backupDir) throws Exception
  public void testImport1(String hostname, String port, String bindDN, String bindPW, String integration_test_home, String logDir, String dsee_home, String backupDir) throws Exception
  {
    System.out.println("*********************************************");
    System.out.println("Import Test 1");
@@ -52,9 +52,14 @@
    ds_output.resetOutput();
    int expCode = 0;
    if(retCode == expCode)
    {
      if(startOpenDS(dsee_home, hostname, port, bindDN, bindPW, logDir) != 0)
      {
    retCode = 999;
      }
    }
    compareExitCode(retCode, expCode);
    startOpenDS(dsee_home, port);
  }
  @Parameters({ "hostname", "port", "bindDN", "bindPW", "integration_test_home", "logDir" })
@@ -91,9 +96,9 @@
    compareExitCode(retCode, expCode);
  }
  @Parameters({ "integration_test_home", "port", "logDir", "dsee_home", "backupDir" })
  @Parameters({ "hostname", "port", "bindDN", "bindPW", "integration_test_home", "logDir", "dsee_home", "backupDir" })
  @Test(alwaysRun=true, dependsOnMethods = { "org.opends.server.integration.backend.ImportTests.testImport1_check2" })
  public void testImport2(String integration_test_home, String port, String logDir, String dsee_home, String backupDir) throws Exception
  public void testImport2(String hostname, String port, String bindDN, String bindPW, String integration_test_home, String logDir, String dsee_home, String backupDir) throws Exception
  {
    System.out.println("*********************************************");
    System.out.println("Import Test 2");
@@ -106,9 +111,14 @@
    ds_output.resetOutput();
    int expCode = 0;
    if(retCode == expCode)
    {
      if(startOpenDS(dsee_home, hostname, port, bindDN, bindPW, logDir) != 0)
      {
    retCode = 999;
      }
    }
    compareExitCode(retCode, expCode);
    startOpenDS(dsee_home, port);
  }
  @Parameters({ "hostname", "port", "bindDN", "bindPW", "integration_test_home", "logDir" })
@@ -145,9 +155,9 @@
    compareExitCode(retCode, expCode);
  }
  @Parameters({ "integration_test_home", "port", "logDir", "dsee_home", "backupDir" })
  @Parameters({ "hostname", "port", "bindDN", "bindPW", "integration_test_home", "logDir", "dsee_home", "backupDir" })
  @Test(alwaysRun=true, dependsOnMethods = { "org.opends.server.integration.backend.ImportTests.testImport2_check2" })
  public void testImport3(String integration_test_home, String port, String logDir, String dsee_home, String backupDir) throws Exception
  public void testImport3(String hostname, String port, String bindDN, String bindPW, String integration_test_home, String logDir, String dsee_home, String backupDir) throws Exception
  {
    System.out.println("*********************************************");
    System.out.println("Import Test 3");
@@ -161,9 +171,14 @@
    ds_output.resetOutput();
    int expCode = 0;
    if(retCode == expCode)
    {
      if(startOpenDS(dsee_home, hostname, port, bindDN, bindPW, logDir) != 0)
      {
    retCode = 999;
      }
    }
    compareExitCode(retCode, expCode);
    startOpenDS(dsee_home, port);
  }
  @Parameters({ "hostname", "port", "bindDN", "bindPW", "integration_test_home", "logDir" })
@@ -200,9 +215,9 @@
    compareExitCode(retCode, expCode);
  }
  @Parameters({ "integration_test_home", "port", "logDir", "dsee_home", "backupDir" })
  @Parameters({ "hostname", "port", "bindDN", "bindPW", "integration_test_home", "logDir", "dsee_home", "backupDir" })
  @Test(alwaysRun=true, dependsOnMethods = { "org.opends.server.integration.backend.ImportTests.testImport3_check2" })
  public void testImport4(String integration_test_home, String port, String logDir, String dsee_home, String backupDir) throws Exception
  public void testImport4(String hostname, String port, String bindDN, String bindPW, String integration_test_home, String logDir, String dsee_home, String backupDir) throws Exception
  {
    System.out.println("*********************************************");
    System.out.println("Import Test 4");
@@ -216,9 +231,14 @@
    ds_output.resetOutput();
    int expCode = 0;
    if(retCode == expCode)
    {
      if(startOpenDS(dsee_home, hostname, port, bindDN, bindPW, logDir) != 0)
      {
    retCode = 999;
      }
    }
    compareExitCode(retCode, expCode);
    startOpenDS(dsee_home, port);
  }
  @Parameters({ "hostname", "port", "bindDN", "bindPW", "integration_test_home", "logDir" })
@@ -255,9 +275,9 @@
    compareExitCode(retCode, expCode);
  }
  @Parameters({ "integration_test_home", "port", "logDir", "dsee_home", "backupDir" })
  @Parameters({ "hostname", "port", "bindDN", "bindPW", "integration_test_home", "logDir", "dsee_home", "backupDir" })
  @Test(alwaysRun=true, dependsOnMethods = { "org.opends.server.integration.backend.ImportTests.testImport4_check2" })
  public void testImport5(String integration_test_home, String port, String logDir, String dsee_home, String backupDir) throws Exception
  public void testImport5(String hostname, String port, String bindDN, String bindPW, String integration_test_home, String logDir, String dsee_home, String backupDir) throws Exception
  {
    System.out.println("*********************************************");
    System.out.println("Import Test 5");
@@ -271,9 +291,14 @@
    ds_output.resetOutput();
    int expCode = 0;
    if(retCode == expCode)
    {
      if(startOpenDS(dsee_home, hostname, port, bindDN, bindPW, logDir) != 0)
      {
    retCode = 999;
      }
    }
    compareExitCode(retCode, expCode);
    startOpenDS(dsee_home, port);
  }
  @Parameters({ "hostname", "port", "bindDN", "bindPW", "integration_test_home", "logDir" })
@@ -310,9 +335,9 @@
    compareExitCode(retCode, expCode);
  }
  @Parameters({ "integration_test_home", "port", "logDir", "dsee_home", "backupDir" })
  @Parameters({ "hostname", "port", "bindDN", "bindPW", "integration_test_home", "logDir", "dsee_home", "backupDir" })
  @Test(alwaysRun=true, dependsOnMethods = { "org.opends.server.integration.backend.ImportTests.testImport5_check2" })
  public void testImport6(String integration_test_home, String port, String logDir, String dsee_home, String backupDir) throws Exception
  public void testImport6(String hostname, String port, String bindDN, String bindPW, String integration_test_home, String logDir, String dsee_home, String backupDir) throws Exception
  {
    System.out.println("*********************************************");
    System.out.println("Import Test 6");
@@ -326,9 +351,14 @@
    ds_output.resetOutput();
    int expCode = 0;
    if(retCode == expCode)
    {
      if(startOpenDS(dsee_home, hostname, port, bindDN, bindPW, logDir) != 0)
      {
    retCode = 999;
      }
    }
    compareExitCode(retCode, expCode);
    startOpenDS(dsee_home, port);
  }
  @Parameters({ "hostname", "port", "bindDN", "bindPW", "integration_test_home", "logDir" })
@@ -365,9 +395,9 @@
    compareExitCode(retCode, expCode);
  }
  @Parameters({ "integration_test_home", "port", "logDir", "dsee_home", "backupDir" })
  @Parameters({ "hostname", "port", "bindDN", "bindPW", "integration_test_home", "logDir", "dsee_home", "backupDir" })
  @Test(alwaysRun=true, dependsOnMethods = { "org.opends.server.integration.backend.ImportTests.testImport6_check2" })
  public void testImport7(String integration_test_home, String port, String logDir, String dsee_home, String backupDir) throws Exception
  public void testImport7(String hostname, String port, String bindDN, String bindPW, String integration_test_home, String logDir, String dsee_home, String backupDir) throws Exception
  {
    System.out.println("*********************************************");
    System.out.println("Import Test 7");
@@ -381,9 +411,14 @@
    ds_output.resetOutput();
    int expCode = 0;
    if(retCode == expCode)
    {
      if(startOpenDS(dsee_home, hostname, port, bindDN, bindPW, logDir) != 0)
      {
    retCode = 999;
      }
    }
    compareExitCode(retCode, expCode);
    startOpenDS(dsee_home, port);
  }
  @Parameters({ "hostname", "port", "bindDN", "bindPW", "integration_test_home", "logDir" })
@@ -420,9 +455,9 @@
    compareExitCode(retCode, expCode);
  }
  @Parameters({ "integration_test_home", "port", "logDir", "dsee_home", "backupDir" })
  @Parameters({ "hostname", "port", "bindDN", "bindPW", "integration_test_home", "logDir", "dsee_home", "backupDir" })
  @Test(alwaysRun=true, dependsOnMethods = { "org.opends.server.integration.backend.ImportTests.testImport7_check2" })
  public void testImport8(String integration_test_home, String port, String logDir, String dsee_home, String backupDir) throws Exception
  public void testImport8(String hostname, String port, String bindDN, String bindPW, String integration_test_home, String logDir, String dsee_home, String backupDir) throws Exception
  {
    System.out.println("*********************************************");
    System.out.println("Import Test 8");
@@ -436,9 +471,14 @@
    ds_output.resetOutput();
    int expCode = 0;
    if(retCode == expCode)
    {
      if(startOpenDS(dsee_home, hostname, port, bindDN, bindPW, logDir) != 0)
      {
    retCode = 999;
      }
    }
    compareExitCode(retCode, expCode);
    startOpenDS(dsee_home, port);
  }
  @Parameters({ "hostname", "port", "bindDN", "bindPW", "integration_test_home", "logDir" })
@@ -475,9 +515,9 @@
    compareExitCode(retCode, expCode);
  }
  @Parameters({ "integration_test_home", "port", "logDir", "dsee_home", "backupDir" })
  @Parameters({ "hostname", "port", "bindDN", "bindPW", "integration_test_home", "logDir", "dsee_home", "backupDir" })
  @Test(alwaysRun=true, dependsOnMethods = { "org.opends.server.integration.backend.ImportTests.testImport8_check2" })
  public void testImport9(String integration_test_home, String port, String logDir, String dsee_home, String backupDir) throws Exception
  public void testImport9(String hostname, String port, String bindDN, String bindPW, String integration_test_home, String logDir, String dsee_home, String backupDir) throws Exception
  {
    System.out.println("*********************************************");
    System.out.println("Import Test 9");
@@ -491,9 +531,14 @@
    ds_output.resetOutput();
    int expCode = 0;
    if(retCode == expCode)
    {
      if(startOpenDS(dsee_home, hostname, port, bindDN, bindPW, logDir) != 0)
      {
    retCode = 999;
      }
    }
    compareExitCode(retCode, expCode);
    startOpenDS(dsee_home, port);
  }
  @Parameters({ "hostname", "port", "bindDN", "bindPW", "integration_test_home", "logDir" })
@@ -547,9 +592,9 @@
    compareExitCode(retCode, expCode);
  }
  @Parameters({ "integration_test_home", "port", "logDir", "dsee_home", "backupDir" })
  @Parameters({ "hostname", "port", "bindDN", "bindPW", "integration_test_home", "logDir", "dsee_home", "backupDir" })
  @Test(alwaysRun=true, dependsOnMethods = { "org.opends.server.integration.backend.ImportTests.testImport9_check3" })
  public void testImport10(String integration_test_home, String port, String logDir, String dsee_home, String backupDir) throws Exception
  public void testImport10(String hostname, String port, String bindDN, String bindPW, String integration_test_home, String logDir, String dsee_home, String backupDir) throws Exception
  {
    System.out.println("*********************************************");
    System.out.println("Import Test 10");
@@ -564,9 +609,14 @@
    ds_output.resetOutput();
    int expCode = 0;
    if(retCode == expCode)
    {
      if(startOpenDS(dsee_home, hostname, port, bindDN, bindPW, logDir) != 0)
      {
    retCode = 999;
      }
    }
    compareExitCode(retCode, expCode);
    startOpenDS(dsee_home, port);
  }
  @Parameters({ "hostname", "port", "bindDN", "bindPW", "integration_test_home", "logDir" })
@@ -603,9 +653,9 @@
    compareExitCode(retCode, expCode);
  }
  @Parameters({ "integration_test_home", "port", "logDir", "dsee_home", "backupDir" })
  @Parameters({ "hostname", "port", "bindDN", "bindPW", "integration_test_home", "logDir", "dsee_home", "backupDir" })
  @Test(alwaysRun=true, dependsOnMethods = { "org.opends.server.integration.backend.ImportTests.testImport10_check2" })
  public void testImport11(String integration_test_home, String port, String logDir, String dsee_home, String backupDir) throws Exception
  public void testImport11(String hostname, String port, String bindDN, String bindPW, String integration_test_home, String logDir, String dsee_home, String backupDir) throws Exception
  {
    System.out.println("*********************************************");
    System.out.println("Import Test 11");
@@ -620,9 +670,14 @@
    ds_output.resetOutput();
    int expCode = 0;
    if(retCode == expCode)
    {
      if(startOpenDS(dsee_home, hostname, port, bindDN, bindPW, logDir) != 0)
      {
    retCode = 999;
      }
    }
    compareExitCode(retCode, expCode);
    startOpenDS(dsee_home, port);
  }
  @Parameters({ "hostname", "port", "bindDN", "bindPW", "integration_test_home", "logDir" })
@@ -659,9 +714,9 @@
    compareExitCode(retCode, expCode);
  }
  @Parameters({ "integration_test_home", "port", "logDir", "dsee_home", "backupDir" })
  @Parameters({ "hostname", "port", "bindDN", "bindPW", "integration_test_home", "logDir", "dsee_home", "backupDir" })
  @Test(alwaysRun=true, dependsOnMethods = { "org.opends.server.integration.backend.ImportTests.testImport11_check2" })
  public void testImport12(String integration_test_home, String port, String logDir, String dsee_home, String backupDir) throws Exception
  public void testImport12(String hostname, String port, String bindDN, String bindPW, String integration_test_home, String logDir, String dsee_home, String backupDir) throws Exception
  {
    System.out.println("*********************************************");
    System.out.println("Import Test 12");
@@ -676,9 +731,14 @@
    ds_output.resetOutput();
    int expCode = 0;
    if(retCode == expCode)
    {
      if(startOpenDS(dsee_home, hostname, port, bindDN, bindPW, logDir) != 0)
      {
    retCode = 999;
      }
    }
    compareExitCode(retCode, expCode);
    startOpenDS(dsee_home, port);
  }
  @Parameters({ "hostname", "port", "bindDN", "bindPW", "integration_test_home", "logDir" })
@@ -755,9 +815,14 @@
    ds_output.resetOutput();
    int expCode = 0;
    if(retCode == expCode)
    {
      if(startOpenDS(dsee_home, hostname, port, bindDN, bindPW, logDir) != 0)
      {
    retCode = 999;
      }
    }
    compareExitCode(retCode, expCode);
    startOpenDS(dsee_home, port);
  }
  @Parameters({ "hostname", "port", "bindDN", "bindPW", "integration_test_home", "logDir" })
@@ -811,9 +876,9 @@
    compareExitCode(retCode, expCode);
  }
  @Parameters({ "integration_test_home", "port", "logDir", "dsee_home", "backupDir" })
  @Parameters({ "hostname", "port", "bindDN", "bindPW", "integration_test_home", "logDir", "dsee_home", "backupDir" })
  @Test(alwaysRun=true, dependsOnMethods = { "org.opends.server.integration.backend.ImportTests.testImport13_check3" })
  public void testImport14(String integration_test_home, String port, String logDir, String dsee_home, String backupDir) throws Exception
  public void testImport14(String hostname, String port, String bindDN, String bindPW, String integration_test_home, String logDir, String dsee_home, String backupDir) throws Exception
  {
    System.out.println("*********************************************");
    System.out.println("Import Test 14");
@@ -827,9 +892,14 @@
    ds_output.resetOutput();
    int expCode = 0;
    if(retCode == expCode)
    {
      if(startOpenDS(dsee_home, hostname, port, bindDN, bindPW, logDir) != 0)
      {
    retCode = 999;
      }
    }
    compareExitCode(retCode, expCode);
    startOpenDS(dsee_home, port);
  }
  @Parameters({ "hostname", "port", "bindDN", "bindPW", "integration_test_home", "logDir" })
opends/tests/integration-tests-testng/src/server/org/opends/server/integration/backend/RestoreTests.java
@@ -54,9 +54,15 @@
    ds_output.resetOutput();
    int expCode = 0;
    compareExitCode(retCode, expCode);
    if(retCode == expCode)
    {
      if(startOpenDS(dsee_home, hostname, port, bindDN, bindPW, logDir) != 0)
      {
        retCode = 999;
      }
    }
    startOpenDS(dsee_home, port);
    compareExitCode(retCode, expCode);
  }
  @Parameters({ "hostname", "port", "bindDN", "bindPW", "integration_test_home", "logDir", "dsee_home" })
@@ -75,9 +81,15 @@
    ds_output.resetOutput();
    int expCode = 0;
    compareExitCode(retCode, expCode);
    if(retCode == expCode)
    {
      if(startOpenDS(dsee_home, hostname, port, bindDN, bindPW, logDir) != 0)
      {
        retCode = 999;
      }
    }
    startOpenDS(dsee_home, port);
    compareExitCode(retCode, expCode);
  }
}