You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@manifoldcf.apache.org by kw...@apache.org on 2013/12/02 19:45:41 UTC
svn commit: r1547144 - in
/manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests:
ManifoldCFInstance.java SchedulerHSQLDBTest.java SchedulerTester.java
Author: kwright
Date: Mon Dec 2 18:45:41 2013
New Revision: 1547144
URL: http://svn.apache.org/r1547144
Log:
Add multi-daemon testing code (which currently fails)
Modified:
manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/ManifoldCFInstance.java
manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/SchedulerHSQLDBTest.java
manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/SchedulerTester.java
Modified: manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/ManifoldCFInstance.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/ManifoldCFInstance.java?rev=1547144&r1=1547143&r2=1547144&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/ManifoldCFInstance.java (original)
+++ manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/ManifoldCFInstance.java Mon Dec 2 18:45:41 2013
@@ -686,30 +686,48 @@ public class ManifoldCFInstance
}
}
- if (!singleWar)
+ try
+ {
+ stopNoCleanup();
+ }
+ catch (Exception e)
{
- // Shut down daemon
- AgentsDaemon.assertAgentsShutdownSignal(tc);
+ if (currentException == null)
+ currentException = e;
+ }
+ }
+ }
+
+ public void stopNoCleanup()
+ throws Exception
+ {
+ if (daemonThread != null)
+ {
+ Exception currentException = null;
+
+ // Shut down daemon - but only ONE daemon
+ //AgentsDaemon.assertAgentsShutdownSignal(tc);
- // Wait for daemon thread to exit.
- while (true)
+ // Wait for daemon thread to exit.
+ while (true)
+ {
+ daemonThread.interrupt();
+ if (daemonThread.isAlive())
{
- if (daemonThread.isAlive())
- {
- Thread.sleep(1000L);
- continue;
- }
- break;
+ Thread.sleep(1000L);
+ continue;
}
-
- Exception e = daemonThread.getDaemonException();
- if (e != null)
- currentException = e;
+ break;
}
-
+
+ Exception e = daemonThread.getDaemonException();
+ if (e != null || !(e instanceof InterruptedException))
+ currentException = e;
+
if (currentException != null)
throw currentException;
}
+
}
public void unload()
Modified: manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/SchedulerHSQLDBTest.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/SchedulerHSQLDBTest.java?rev=1547144&r1=1547143&r2=1547144&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/SchedulerHSQLDBTest.java (original)
+++ manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/SchedulerHSQLDBTest.java Mon Dec 2 18:45:41 2013
@@ -28,15 +28,18 @@ import org.junit.*;
/** This is a test of the scheduler. If the test succeeds, it is because
* the scheduler has properly distributed requests for all bins evenly. */
-public class SchedulerHSQLDBTest extends BaseITHSQLDB
+public class SchedulerHSQLDBTest extends ConnectorBaseHSQLDB
{
-
+ protected final ManifoldCFInstance mcfInstance1;
+ protected final ManifoldCFInstance mcfInstance2;
protected SchedulerTester tester;
public SchedulerHSQLDBTest()
{
- super(false,false);
- tester = new SchedulerTester(mcfInstance);
+ super();
+ mcfInstance1 = new ManifoldCFInstance("A",false,false);
+ mcfInstance2 = new ManifoldCFInstance("B",false,false);
+ tester = new SchedulerTester(mcfInstance1,mcfInstance2);
}
@Override
@@ -70,5 +73,68 @@ public class SchedulerHSQLDBTest extends
tester.executeTest();
}
+ @Before
+ public void setUp()
+ throws Exception
+ {
+ initializeSystem();
+ try
+ {
+ localReset();
+ }
+ catch (Exception e)
+ {
+ System.out.println("Warning: Preclean failed: "+e.getMessage());
+ }
+ try
+ {
+ localSetUp();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ throw e;
+ }
+ }
+
+ @After
+ public void cleanUp()
+ throws Exception
+ {
+ Exception currentException = null;
+ // Last, shut down the web applications.
+ // If this is done too soon it closes the database before the rest of the cleanup happens.
+ try
+ {
+ mcfInstance1.unload();
+ }
+ catch (Exception e)
+ {
+ if (currentException == null)
+ currentException = e;
+ }
+ try
+ {
+ mcfInstance2.unload();
+ }
+ catch (Exception e)
+ {
+ if (currentException == null)
+ currentException = e;
+ }
+ try
+ {
+ localCleanUp();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ throw e;
+ }
+ if (currentException != null)
+ throw currentException;
+ cleanupSystem();
+ }
+
}
Modified: manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/SchedulerTester.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/SchedulerTester.java?rev=1547144&r1=1547143&r2=1547144&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/SchedulerTester.java (original)
+++ manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/SchedulerTester.java Mon Dec 2 18:45:41 2013
@@ -29,16 +29,20 @@ import java.util.*;
/** This is a very basic sanity check */
public class SchedulerTester
{
- protected ManifoldCFInstance instance;
+ protected final ManifoldCFInstance instance1;
+ protected final ManifoldCFInstance instance2;
- public SchedulerTester(ManifoldCFInstance instance)
+ public SchedulerTester(ManifoldCFInstance instance1, ManifoldCFInstance instance2)
{
- this.instance = instance;
+ this.instance1 = instance1;
+ this.instance2 = instance2;
}
public void executeTest()
throws Exception
{
+ instance1.start();
+
// Hey, we were able to install the file system connector etc.
// Now, create a local test job and run it.
IThreadContext tc = ThreadContextFactory.make();
@@ -78,20 +82,31 @@ public class SchedulerTester
// Now, start the job, and wait until it is running.
jobManager.manualStart(job.getID());
- instance.waitJobRunningNative(jobManager,job.getID(),30000L);
+ instance1.waitJobRunningNative(jobManager,job.getID(),30000L);
+
+ // Start the second instance.
+ instance2.start();
+ // Wait long enough for the stuffing etc to take place once
+ Thread.sleep(5000L);
+ // Terminate instance1. Instance2 should keep going.
+ instance1.stopNoCleanup();
// Wait for the job to become inactive. The time should be at least long enough to handle
// 100 documents per bin, but not significantly greater than that. Let's say 120 seconds.
long startTime = System.currentTimeMillis();
- instance.waitJobInactiveNative(jobManager,job.getID(),150000L);
+ instance2.waitJobInactiveNative(jobManager,job.getID(),150000L);
long endTime = System.currentTimeMillis();
if (jobManager.getStatus(job.getID()).getDocumentsProcessed() != 10+10*200)
throw new Exception("Expected 2010 documents, saw "+jobManager.getStatus(job.getID()).getDocumentsProcessed());
if (endTime-startTime < 96000L)
throw new Exception("Job finished too quickly; throttling clearly failed");
System.out.println("Crawl took "+(endTime-startTime)+" milliseconds");
+
// Now, delete the job.
jobManager.deleteJob(job.getID());
- instance.waitJobDeletedNative(jobManager,job.getID(),120000L);
+ instance2.waitJobDeletedNative(jobManager,job.getID(),120000L);
+
+ // Shut down instance2
+ instance2.stop();
}
}