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 2011/09/16 19:02:38 UTC
svn commit: r1171669 - in /incubator/lcf/trunk: ./
loadtests/filesystem/src/test/java/org/
loadtests/filesystem/src/test/java/org/apache/
loadtests/filesystem/src/test/java/org/apache/manifoldcf/
loadtests/filesystem/src/test/java/org/apache/manifoldcf...
Author: kwright
Date: Fri Sep 16 17:02:37 2011
New Revision: 1171669
URL: http://svn.apache.org/viewvc?rev=1171669&view=rev
Log:
First cut at load test, running under Postgresql. Part of CONNECTORS-87.
Added:
incubator/lcf/trunk/loadtests/filesystem/src/test/java/org/
incubator/lcf/trunk/loadtests/filesystem/src/test/java/org/apache/
incubator/lcf/trunk/loadtests/filesystem/src/test/java/org/apache/manifoldcf/
incubator/lcf/trunk/loadtests/filesystem/src/test/java/org/apache/manifoldcf/filesystem_loadtests/
incubator/lcf/trunk/loadtests/filesystem/src/test/java/org/apache/manifoldcf/filesystem_loadtests/BasePostgresql.java (with props)
incubator/lcf/trunk/loadtests/filesystem/src/test/java/org/apache/manifoldcf/filesystem_loadtests/BigCrawlPostgresqlTest.java (with props)
Modified:
incubator/lcf/trunk/build.xml
Modified: incubator/lcf/trunk/build.xml
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/build.xml?rev=1171669&r1=1171668&r2=1171669&view=diff
==============================================================================
--- incubator/lcf/trunk/build.xml (original)
+++ incubator/lcf/trunk/build.xml Fri Sep 16 17:02:37 2011
@@ -2295,7 +2295,9 @@
</classpath>
<formatter type="brief" usefile="false"/>
+ <test name="org.apache.manifoldcf.filesystem_loadtests.BigCrawlPostgresqlTest" todir="test-postgresql-output/filesystem"/>
<!-- MHL -->
+
</junit>
</target>
Added: incubator/lcf/trunk/loadtests/filesystem/src/test/java/org/apache/manifoldcf/filesystem_loadtests/BasePostgresql.java
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/loadtests/filesystem/src/test/java/org/apache/manifoldcf/filesystem_loadtests/BasePostgresql.java?rev=1171669&view=auto
==============================================================================
--- incubator/lcf/trunk/loadtests/filesystem/src/test/java/org/apache/manifoldcf/filesystem_loadtests/BasePostgresql.java (added)
+++ incubator/lcf/trunk/loadtests/filesystem/src/test/java/org/apache/manifoldcf/filesystem_loadtests/BasePostgresql.java Fri Sep 16 17:02:37 2011
@@ -0,0 +1,523 @@
+/* $Id$ */
+
+/**
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements. See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.apache.manifoldcf.filesystem_loadtests;
+
+import org.apache.manifoldcf.core.interfaces.*;
+import org.apache.manifoldcf.agents.interfaces.*;
+import org.apache.manifoldcf.crawler.interfaces.*;
+import org.apache.manifoldcf.crawler.system.ManifoldCF;
+
+import java.io.*;
+import java.util.*;
+import org.junit.*;
+
+import org.mortbay.jetty.Handler;
+import org.mortbay.jetty.Server;
+import org.mortbay.jetty.Connector;
+import org.mortbay.jetty.webapp.WebAppContext;
+import org.mortbay.jetty.servlet.Context;
+import org.mortbay.jetty.servlet.FilterHolder;
+import org.mortbay.log.Logger;
+
+import org.apache.commons.httpclient.*;
+import org.apache.commons.httpclient.methods.*;
+
+/** Tests that run the "agents daemon" should be derived from this */
+public class BasePostgresql extends org.apache.manifoldcf.crawler.tests.ConnectorBasePostgresql
+{
+ public static final String agentShutdownSignal = "agent-process";
+ public static final int testPort = 8346;
+
+ protected DaemonThread daemonThread = null;
+ protected Server server = null;
+
+ protected String[] getConnectorNames()
+ {
+ return new String[]{"File Connector"};
+ }
+
+ protected String[] getConnectorClasses()
+ {
+ return new String[]{"org.apache.manifoldcf.crawler.connectors.filesystem.FileConnector"};
+ }
+
+ protected String[] getOutputNames()
+ {
+ return new String[]{"Null Output"};
+ }
+
+ protected String[] getOutputClasses()
+ {
+ return new String[]{"org.apache.manifoldcf.agents.output.nullconnector.NullConnector"};
+ }
+
+ protected void createDirectory(File f)
+ throws Exception
+ {
+ if (f.mkdirs() == false)
+ throw new Exception("Failed to create directory "+f.toString());
+ }
+
+ protected void removeDirectory(File f)
+ throws Exception
+ {
+ File[] files = f.listFiles();
+ if (files != null)
+ {
+ int i = 0;
+ while (i < files.length)
+ {
+ File subfile = files[i++];
+ if (subfile.isDirectory())
+ removeDirectory(subfile);
+ else
+ subfile.delete();
+ }
+ }
+ f.delete();
+ }
+
+ protected void createFile(File f, String contents)
+ throws Exception
+ {
+ OutputStream os = new FileOutputStream(f);
+ try
+ {
+ Writer w = new OutputStreamWriter(os,"utf-8");
+ try
+ {
+ w.write(contents);
+ }
+ finally
+ {
+ w.flush();
+ }
+ }
+ finally
+ {
+ os.close();
+ }
+ }
+
+ protected void removeFile(File f)
+ throws Exception
+ {
+ if (f.delete() == false)
+ throw new Exception("Failed to delete file "+f.toString());
+ }
+
+ protected void changeFile(File f, String newContents)
+ throws Exception
+ {
+ removeFile(f);
+ createFile(f,newContents);
+ }
+
+ // API support
+
+ // These methods allow communication with the ManifoldCF api webapp, via the locally-instantiated jetty
+
+ /** Construct a command url.
+ */
+ protected String makeAPIURL(String command)
+ {
+ return "http://localhost:"+Integer.toString(testPort)+"/mcf-api-service/json/"+command;
+ }
+
+ /** Perform an json API GET operation.
+ *@param apiURL is the operation.
+ *@param expectedResponse is the expected response code.
+ *@return the json response.
+ */
+ protected String performAPIGetOperation(String apiURL, int expectedResponse)
+ throws Exception
+ {
+ HttpClient client = new HttpClient();
+ GetMethod method = new GetMethod(apiURL);
+ int response = client.executeMethod(method);
+ byte[] responseData = method.getResponseBody();
+ String responseString = new String(responseData,"utf-8");
+ if (response != expectedResponse)
+ throw new Exception("API http error; expected "+Integer.toString(expectedResponse)+", saw "+Integer.toString(response)+": "+responseString);
+ // We presume that the data is utf-8, since that's what the API uses throughout.
+ return responseString;
+ }
+
+ /** Perform an json API DELETE operation.
+ *@param apiURL is the operation.
+ *@param expectedResponse is the expected response code.
+ *@return the json response.
+ */
+ protected String performAPIDeleteOperation(String apiURL, int expectedResponse)
+ throws Exception
+ {
+ HttpClient client = new HttpClient();
+ DeleteMethod method = new DeleteMethod(apiURL);
+ int response = client.executeMethod(method);
+ byte[] responseData = method.getResponseBody();
+ String responseString = new String(responseData,"utf-8");
+ if (response != expectedResponse)
+ throw new Exception("API http error; expected "+Integer.toString(expectedResponse)+", saw "+Integer.toString(response)+": "+responseString);
+ // We presume that the data is utf-8, since that's what the API uses throughout.
+ return responseString;
+ }
+
+ /** Perform an json API PUT operation.
+ *@param apiURL is the operation.
+ *@param input is the input JSON.
+ *@param expectedResponse is the expected response code.
+ *@return the json response.
+ */
+ protected String performAPIPutOperation(String apiURL, int expectedResponse, String input)
+ throws Exception
+ {
+ HttpClient client = new HttpClient();
+ PutMethod method = new PutMethod(apiURL);
+ method.setRequestHeader("Content-type", "text/plain; charset=UTF-8");
+ method.setRequestBody(input);
+ int response = client.executeMethod(method);
+ byte[] responseData = method.getResponseBody();
+ String responseString = new String(responseData,"utf-8");
+ if (response != expectedResponse)
+ throw new Exception("API http error; expected "+Integer.toString(expectedResponse)+", saw "+Integer.toString(response)+": "+responseString);
+ // We presume that the data is utf-8, since that's what the API uses throughout.
+ return responseString;
+ }
+
+ /** Perform an json API POST operation.
+ *@param apiURL is the operation.
+ *@param input is the input JSON.
+ *@param expectedResponse is the expected response code.
+ *@return the json response.
+ */
+ protected String performAPIPostOperation(String apiURL, int expectedResponse, String input)
+ throws Exception
+ {
+ HttpClient client = new HttpClient();
+ PostMethod method = new PostMethod(apiURL);
+ method.setRequestHeader("Content-type", "text/plain; charset=UTF-8");
+ method.setRequestBody(input);
+ int response = client.executeMethod(method);
+ byte[] responseData = method.getResponseBody();
+ String responseString = new String(responseData,"utf-8");
+ if (response != expectedResponse)
+ throw new Exception("API http error; expected "+Integer.toString(expectedResponse)+", saw "+Integer.toString(response)+": "+responseString);
+ // We presume that the data is utf-8, since that's what the API uses throughout.
+ return responseString;
+ }
+
+ /** Perform a json GET API operation, using Configuration structures to represent the json. This is for testing convenience,
+ * mostly.
+ */
+ protected Configuration performAPIGetOperationViaNodes(String command, int expectedResponse)
+ throws Exception
+ {
+ String result = performAPIGetOperation(makeAPIURL(command),expectedResponse);
+ Configuration cfg = new Configuration();
+ cfg.fromJSON(result);
+ return cfg;
+ }
+
+ /** Perform a json DELETE API operation, using Configuration structures to represent the json. This is for testing convenience,
+ * mostly.
+ */
+ protected Configuration performAPIDeleteOperationViaNodes(String command, int expectedResponse)
+ throws Exception
+ {
+ String result = performAPIDeleteOperation(makeAPIURL(command),expectedResponse);
+ Configuration cfg = new Configuration();
+ cfg.fromJSON(result);
+ return cfg;
+ }
+
+ /** Perform a json PUT API operation, using Configuration structures to represent the json. This is for testing convenience,
+ * mostly.
+ */
+ protected Configuration performAPIPutOperationViaNodes(String command, int expectedResponse, Configuration argument)
+ throws Exception
+ {
+ String argumentJson;
+ if (argument != null)
+ argumentJson = argument.toJSON();
+ else
+ argumentJson = null;
+
+ String result = performAPIPutOperation(makeAPIURL(command),expectedResponse,argumentJson);
+ Configuration cfg = new Configuration();
+ cfg.fromJSON(result);
+ return cfg;
+ }
+
+ /** Perform a json POST API operation, using Configuration structures to represent the json. This is for testing convenience,
+ * mostly.
+ */
+ protected Configuration performAPIPostOperationViaNodes(String command, int expectedResponse, Configuration argument)
+ throws Exception
+ {
+ String argumentJson;
+ if (argument != null)
+ argumentJson = argument.toJSON();
+ else
+ argumentJson = null;
+
+ String result = performAPIPostOperation(makeAPIURL(command),expectedResponse,argumentJson);
+ Configuration cfg = new Configuration();
+ cfg.fromJSON(result);
+ return cfg;
+ }
+
+ // Setup/teardown
+
+ @Before
+ public void setUp()
+ throws Exception
+ {
+ super.setUp();
+ // Start jetty
+ server = new Server( testPort );
+ server.setStopAtShutdown( true );
+
+
+ String crawlerWarPath = "../../framework/dist/web/war/mcf-crawler-ui.war";
+ String authorityserviceWarPath = "../../framework/dist/web/war/mcf-authority-service.war";
+ String apiWarPath = "../../framework/dist/web/war/mcf-api-service.war";
+
+ if (System.getProperty("crawlerWarPath") != null)
+ crawlerWarPath = System.getProperty("crawlerWarPath");
+ if (System.getProperty("authorityserviceWarPath") != null)
+ authorityserviceWarPath = System.getProperty("authorityserviceWarPath");
+ if (System.getProperty("apiWarPath") != null)
+ apiWarPath = System.getProperty("apiWarPath");
+
+ // Initialize the servlets
+ WebAppContext lcfCrawlerUI = new WebAppContext(crawlerWarPath,"/mcf-crawler-ui");
+ // This will cause jetty to ignore all of the framework and jdbc jars in the war, which is what we want.
+ lcfCrawlerUI.setParentLoaderPriority(true);
+ server.addHandler(lcfCrawlerUI);
+ WebAppContext lcfAuthorityService = new WebAppContext(authorityserviceWarPath,"/mcf-authority-service");
+ // This will cause jetty to ignore all of the framework and jdbc jars in the war, which is what we want.
+ lcfAuthorityService.setParentLoaderPriority(true);
+ server.addHandler(lcfAuthorityService);
+ WebAppContext lcfApi = new WebAppContext(apiWarPath,"/mcf-api-service");
+ lcfApi.setParentLoaderPriority(true);
+ server.addHandler(lcfApi);
+ server.start();
+
+ // If all worked, then we can start the daemon.
+ // Clear the agents shutdown signal.
+ IThreadContext tc = ThreadContextFactory.make();
+ ILockManager lockManager = LockManagerFactory.make(tc);
+ lockManager.clearGlobalFlag(agentShutdownSignal);
+
+ daemonThread = new DaemonThread();
+ daemonThread.start();
+ }
+
+ @After
+ public void cleanUp()
+ throws Exception
+ {
+ initialize();
+ if (isInitialized())
+ {
+ Exception currentException = null;
+ IThreadContext tc = ThreadContextFactory.make();
+
+ // Delete all jobs (and wait for them to go away)
+ if (daemonThread != null)
+ {
+ IJobManager jobManager = JobManagerFactory.make(tc);
+
+ // Get a list of the current active jobs
+ IJobDescription[] jobs = jobManager.getAllJobs();
+ int i = 0;
+ while (i < jobs.length)
+ {
+ IJobDescription desc = jobs[i++];
+ // Abort this job, if it is running
+ try
+ {
+ jobManager.manualAbort(desc.getID());
+ }
+ catch (ManifoldCFException e)
+ {
+ // This generally means that the job was not running
+ }
+ }
+ i = 0;
+ while (i < jobs.length)
+ {
+ IJobDescription desc = jobs[i++];
+ // Wait for this job to stop
+ while (true)
+ {
+ JobStatus status = jobManager.getStatus(desc.getID());
+ if (status != null)
+ {
+ int statusValue = status.getStatus();
+ switch (statusValue)
+ {
+ case JobStatus.JOBSTATUS_NOTYETRUN:
+ case JobStatus.JOBSTATUS_COMPLETED:
+ case JobStatus.JOBSTATUS_ERROR:
+ break;
+ default:
+ ManifoldCF.sleep(10000);
+ continue;
+ }
+ }
+ break;
+ }
+ }
+
+ // Now, delete them all
+ i = 0;
+ while (i < jobs.length)
+ {
+ IJobDescription desc = jobs[i++];
+ try
+ {
+ jobManager.deleteJob(desc.getID());
+ }
+ catch (ManifoldCFException e)
+ {
+ // This usually means that the job is already being deleted
+ }
+ }
+
+ i = 0;
+ while (i < jobs.length)
+ {
+ IJobDescription desc = jobs[i++];
+ // Wait for this job to disappear
+ while (true)
+ {
+ JobStatus status = jobManager.getStatus(desc.getID());
+ if (status != null)
+ {
+ ManifoldCF.sleep(10000);
+ continue;
+ }
+ break;
+ }
+ }
+
+ // Shut down daemon
+ ILockManager lockManager = LockManagerFactory.make(tc);
+ lockManager.setGlobalFlag(agentShutdownSignal);
+
+ // Wait for daemon thread to exit.
+ while (true)
+ {
+ if (daemonThread.isAlive())
+ {
+ Thread.sleep(1000L);
+ continue;
+ }
+ break;
+ }
+
+ Exception e = daemonThread.getDaemonException();
+ if (e != null)
+ currentException = e;
+ }
+
+ if (server != null)
+ {
+ server.stop();
+ server.join();
+ server = null;
+ }
+
+ // Clean up everything else
+ try
+ {
+ super.cleanUp();
+ }
+ catch (Exception e)
+ {
+ if (currentException == null)
+ currentException = e;
+ }
+ if (currentException != null)
+ throw currentException;
+ }
+ }
+
+ protected static class DaemonThread extends Thread
+ {
+ protected Exception daemonException = null;
+
+ public DaemonThread()
+ {
+ setName("Daemon thread");
+ }
+
+ public void run()
+ {
+ IThreadContext tc = ThreadContextFactory.make();
+ // Now, start the server, and then wait for the shutdown signal. On shutdown, we have to actually do the cleanup,
+ // because the JVM isn't going away.
+ try
+ {
+ ILockManager lockManager = LockManagerFactory.make(tc);
+ while (true)
+ {
+ // Any shutdown signal yet?
+ if (lockManager.checkGlobalFlag(agentShutdownSignal))
+ break;
+
+ // Start whatever agents need to be started
+ ManifoldCF.startAgents(tc);
+
+ try
+ {
+ ManifoldCF.sleep(5000);
+ }
+ catch (InterruptedException e)
+ {
+ break;
+ }
+ }
+ }
+ catch (ManifoldCFException e)
+ {
+ daemonException = e;
+ }
+ finally
+ {
+ try
+ {
+ ManifoldCF.stopAgents(tc);
+ }
+ catch (ManifoldCFException e)
+ {
+ daemonException = e;
+ }
+ }
+ }
+
+ public Exception getDaemonException()
+ {
+ return daemonException;
+ }
+
+ }
+
+}
Propchange: incubator/lcf/trunk/loadtests/filesystem/src/test/java/org/apache/manifoldcf/filesystem_loadtests/BasePostgresql.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/lcf/trunk/loadtests/filesystem/src/test/java/org/apache/manifoldcf/filesystem_loadtests/BasePostgresql.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: incubator/lcf/trunk/loadtests/filesystem/src/test/java/org/apache/manifoldcf/filesystem_loadtests/BigCrawlPostgresqlTest.java
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/loadtests/filesystem/src/test/java/org/apache/manifoldcf/filesystem_loadtests/BigCrawlPostgresqlTest.java?rev=1171669&view=auto
==============================================================================
--- incubator/lcf/trunk/loadtests/filesystem/src/test/java/org/apache/manifoldcf/filesystem_loadtests/BigCrawlPostgresqlTest.java (added)
+++ incubator/lcf/trunk/loadtests/filesystem/src/test/java/org/apache/manifoldcf/filesystem_loadtests/BigCrawlPostgresqlTest.java Fri Sep 16 17:02:37 2011
@@ -0,0 +1,236 @@
+/* $Id$ */
+
+/**
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements. See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.apache.manifoldcf.filesystem_loadtests;
+
+import org.apache.manifoldcf.core.interfaces.*;
+import org.apache.manifoldcf.agents.interfaces.*;
+import org.apache.manifoldcf.crawler.interfaces.*;
+import org.apache.manifoldcf.crawler.system.ManifoldCF;
+
+import java.io.*;
+import java.util.*;
+import org.junit.*;
+
+/** This is a very basic sanity check */
+public class BigCrawlPostgresqlTest extends BasePostgresql
+{
+
+ @Before
+ public void createTestArea()
+ throws Exception
+ {
+ try
+ {
+ File f = new File("testdata");
+ removeDirectory(f);
+ createDirectory(f);
+ // Create the test data files.
+ String baseFileName = "testdata/";
+ int i0 = 0;
+ while (i0 < 10)
+ {
+ String fileName0 = baseFileName + "/dir-" + i0;
+ createDirectory(new File(fileName0));
+ int i1 = 0;
+ while (i1 < 10)
+ {
+ String fileName1 = fileName0 + "/dir-" + i1;
+ createDirectory(new File(fileName1));
+ int i2 = 0;
+ while (i2 < 10)
+ {
+ String fileName2 = fileName1 + "/dir-" + i2;
+ createDirectory(new File(fileName2));
+ int i3 = 0;
+ while (i3 < 10)
+ {
+ String fileName3 = fileName2 + "/dir-" + i3;
+ createDirectory(new File(fileName3));
+ int i4 = 0;
+ while (i4 < 10)
+ {
+ String fileName4 = fileName3 + "/file-"+i4;
+ createFile(new File(fileName4),"Test file "+i0+":"+i1+":"+i2+":"+i3+":"+i4);
+ i4++;
+ }
+ i3++;
+ }
+ i2++;
+ }
+ i1++;
+ }
+ i0++;
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ throw e;
+ }
+ }
+
+ @After
+ public void removeTestArea()
+ throws Exception
+ {
+ try
+ {
+ File f = new File("testdata");
+ removeDirectory(f);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ throw e;
+ }
+ }
+
+ @Test
+ public void sanityCheck()
+ throws Exception
+ {
+ try
+ {
+ // Hey, we were able to install the file system connector etc.
+ // Now, create a local test job and run it.
+ IThreadContext tc = ThreadContextFactory.make();
+
+ // Create a basic file system connection, and save it.
+ IRepositoryConnectionManager mgr = RepositoryConnectionManagerFactory.make(tc);
+ IRepositoryConnection conn = mgr.create();
+ conn.setName("File Connection");
+ conn.setDescription("File Connection");
+ conn.setClassName("org.apache.manifoldcf.crawler.connectors.filesystem.FileConnector");
+ conn.setMaxConnections(100);
+ // Now, save
+ mgr.save(conn);
+
+ // Create a basic null output connection, and save it.
+ IOutputConnectionManager outputMgr = OutputConnectionManagerFactory.make(tc);
+ IOutputConnection outputConn = outputMgr.create();
+ outputConn.setName("Null Connection");
+ outputConn.setDescription("Null Connection");
+ outputConn.setClassName("org.apache.manifoldcf.agents.output.nullconnector.NullConnector");
+ outputConn.setMaxConnections(100);
+ // Now, save
+ outputMgr.save(outputConn);
+
+ // Create a job.
+ IJobManager jobManager = JobManagerFactory.make(tc);
+ IJobDescription job = jobManager.createJob();
+ job.setDescription("Test Job");
+ job.setConnectionName("File Connection");
+ job.setOutputConnectionName("Null Connection");
+ job.setType(job.TYPE_SPECIFIED);
+ job.setStartMethod(job.START_DISABLE);
+ job.setHopcountMode(job.HOPCOUNT_NEVERDELETE);
+
+ // Now, set up the document specification.
+ DocumentSpecification ds = job.getSpecification();
+ // Crawl everything underneath the 'testdata' area
+ File testDataFile = new File("testdata").getCanonicalFile();
+ if (!testDataFile.exists())
+ throw new ManifoldCFException("Test data area not found! Looking in "+testDataFile.toString());
+ if (!testDataFile.isDirectory())
+ throw new ManifoldCFException("Test data area not a directory! Looking in "+testDataFile.toString());
+ SpecificationNode sn = new SpecificationNode("startpoint");
+ sn.setAttribute("path",testDataFile.toString());
+ SpecificationNode n = new SpecificationNode("include");
+ n.setAttribute("type","file");
+ n.setAttribute("match","*");
+ sn.addChild(sn.getChildCount(),n);
+ n = new SpecificationNode("include");
+ n.setAttribute("type","directory");
+ n.setAttribute("match","*");
+ sn.addChild(sn.getChildCount(),n);
+ ds.addChild(ds.getChildCount(),sn);
+
+ // Set up the output specification.
+ OutputSpecification os = job.getOutputSpecification();
+ // Null output connections have no output specification, so this is a no-op.
+
+ // Save the job.
+ jobManager.save(job);
+
+ // Now, start the job, and wait until it completes.
+ jobManager.manualStart(job.getID());
+ waitJobInactive(jobManager,job.getID(),18000000L);
+
+ // Check to be sure we actually processed the right number of documents.
+ JobStatus status = jobManager.getStatus(job.getID());
+ // The test data area has 3 documents and one directory, and we have to count the root directory too.
+ if (status.getDocumentsProcessed() != 111111)
+ throw new ManifoldCFException("Wrong number of documents processed - expected 111111, saw "+new Long(status.getDocumentsProcessed()).toString());
+
+ // Now, delete the job.
+ jobManager.deleteJob(job.getID());
+ waitJobDeleted(jobManager,job.getID(),18000000L);
+
+ // Cleanup is automatic by the base class, so we can feel free to leave jobs and connections lying around.
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ throw e;
+ }
+ }
+
+ protected void waitJobInactive(IJobManager jobManager, Long jobID, long maxTime)
+ throws ManifoldCFException, InterruptedException
+ {
+ long startTime = System.currentTimeMillis();
+ while (System.currentTimeMillis() < startTime + maxTime)
+ {
+ JobStatus status = jobManager.getStatus(jobID);
+ if (status == null)
+ throw new ManifoldCFException("No such job: '"+jobID+"'");
+ int statusValue = status.getStatus();
+ switch (statusValue)
+ {
+ case JobStatus.JOBSTATUS_NOTYETRUN:
+ throw new ManifoldCFException("Job was never started.");
+ case JobStatus.JOBSTATUS_COMPLETED:
+ break;
+ case JobStatus.JOBSTATUS_ERROR:
+ throw new ManifoldCFException("Job reports error status: "+status.getErrorText());
+ default:
+ ManifoldCF.sleep(1000L);
+ continue;
+ }
+ return;
+ }
+ throw new ManifoldCFException("ManifoldCF did not terminate in the allotted time of "+new Long(maxTime).toString()+" milliseconds");
+ }
+
+ protected void waitJobDeleted(IJobManager jobManager, Long jobID, long maxTime)
+ throws ManifoldCFException, InterruptedException
+ {
+ long startTime = System.currentTimeMillis();
+ while (System.currentTimeMillis() < startTime + maxTime)
+ {
+ JobStatus status = jobManager.getStatus(jobID);
+ if (status == null)
+ return;
+ ManifoldCF.sleep(1000L);
+ }
+ throw new ManifoldCFException("ManifoldCF did not delete in the allotted time of "+new Long(maxTime).toString()+" milliseconds");
+ }
+
+
+}
Propchange: incubator/lcf/trunk/loadtests/filesystem/src/test/java/org/apache/manifoldcf/filesystem_loadtests/BigCrawlPostgresqlTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/lcf/trunk/loadtests/filesystem/src/test/java/org/apache/manifoldcf/filesystem_loadtests/BigCrawlPostgresqlTest.java
------------------------------------------------------------------------------
svn:keywords = Id