Author: kwright
Date: Wed Jan 23 19:50:11 2013
New Revision: 1437662

URL: http://svn.apache.org/viewvc?rev=1437662&view=rev
Log:
Add Solr test with Solr emulator, to prove that Solr is why sockets are getting 
forcibly closed, not SolrJ.

Added:
    
manifoldcf/trunk/tests/solr/src/test/java/org/apache/manifoldcf/solr_tests/BaseDerby.java
   (with props)
    
manifoldcf/trunk/tests/solr/src/test/java/org/apache/manifoldcf/solr_tests/SolrCrawlDerbyIT.java
   (with props)
Modified:
    
manifoldcf/trunk/tests/solr/src/test/java/org/apache/manifoldcf/solr_tests/MockSolrService.java
    
manifoldcf/trunk/tests/solr/src/test/java/org/apache/manifoldcf/solr_tests/SolrTester.java

Added: 
manifoldcf/trunk/tests/solr/src/test/java/org/apache/manifoldcf/solr_tests/BaseDerby.java
URL: 
http://svn.apache.org/viewvc/manifoldcf/trunk/tests/solr/src/test/java/org/apache/manifoldcf/solr_tests/BaseDerby.java?rev=1437662&view=auto
==============================================================================
--- 
manifoldcf/trunk/tests/solr/src/test/java/org/apache/manifoldcf/solr_tests/BaseDerby.java
 (added)
+++ 
manifoldcf/trunk/tests/solr/src/test/java/org/apache/manifoldcf/solr_tests/BaseDerby.java
 Wed Jan 23 19:50:11 2013
@@ -0,0 +1,52 @@
+/* $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.solr_tests;
+
+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.*;
+
+/** Tests that run the "agents daemon" should be derived from this */
+public class BaseDerby extends org.apache.manifoldcf.crawler.tests.BaseITDerby
+{
+  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[]{"Solr Output"};
+  }
+  
+  protected String[] getOutputClasses()
+  {
+    return new 
String[]{"org.apache.manifoldcf.agents.output.solr.SolrConnector"};
+  }
+}

Propchange: 
manifoldcf/trunk/tests/solr/src/test/java/org/apache/manifoldcf/solr_tests/BaseDerby.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
manifoldcf/trunk/tests/solr/src/test/java/org/apache/manifoldcf/solr_tests/BaseDerby.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: 
manifoldcf/trunk/tests/solr/src/test/java/org/apache/manifoldcf/solr_tests/MockSolrService.java
URL: 
http://svn.apache.org/viewvc/manifoldcf/trunk/tests/solr/src/test/java/org/apache/manifoldcf/solr_tests/MockSolrService.java?rev=1437662&r1=1437661&r2=1437662&view=diff
==============================================================================
--- 
manifoldcf/trunk/tests/solr/src/test/java/org/apache/manifoldcf/solr_tests/MockSolrService.java
 (original)
+++ 
manifoldcf/trunk/tests/solr/src/test/java/org/apache/manifoldcf/solr_tests/MockSolrService.java
 Wed Jan 23 19:50:11 2013
@@ -43,7 +43,8 @@ public class MockSolrService
     server.setThreadPool(new QueuedThreadPool(35));
     servlet = new SolrServlet();
     ServletContextHandler context = new 
ServletContextHandler(ServletContextHandler.SESSIONS);
-    context.setContextPath("/");
+    
context.setInitParameter("org.eclipse.jetty.servlet.SessionIdPathParameterName","none");
+    context.setContextPath("/solr");
     server.setHandler(context);
     context.addServlet(new ServletHolder(servlet), "/*");
   }
@@ -88,7 +89,9 @@ public class MockSolrService
           generateDeleteResponse(res);
         }
         else
+        {
           generateMissingPageResponse(res);
+        }
       }
       catch (IOException e)
       {
@@ -105,6 +108,7 @@ public class MockSolrService
       res.setContentType("text/xml; charset=utf-8");
       res.getWriter().printf("<solr>\n");
       res.getWriter().printf("</solr>\n");
+      res.getWriter().flush();
     }
     
     protected static void generateUpdateResponse(HttpServletResponse res)
@@ -115,6 +119,7 @@ public class MockSolrService
       res.getWriter().printf("<result>\n");
       res.getWriter().printf("  <doc name=\"something\"/>\n");
       res.getWriter().printf("</result>\n");
+      res.getWriter().flush();
     }
     
     protected static void generateDeleteResponse(HttpServletResponse res)
@@ -125,6 +130,7 @@ public class MockSolrService
       res.getWriter().printf("<result>\n");
       res.getWriter().printf("  <doc name=\"something\"/>\n");
       res.getWriter().printf("</result>\n");
+      res.getWriter().flush();
     }
     
     protected static void generateMissingPageResponse(HttpServletResponse res)

Added: 
manifoldcf/trunk/tests/solr/src/test/java/org/apache/manifoldcf/solr_tests/SolrCrawlDerbyIT.java
URL: 
http://svn.apache.org/viewvc/manifoldcf/trunk/tests/solr/src/test/java/org/apache/manifoldcf/solr_tests/SolrCrawlDerbyIT.java?rev=1437662&view=auto
==============================================================================
--- 
manifoldcf/trunk/tests/solr/src/test/java/org/apache/manifoldcf/solr_tests/SolrCrawlDerbyIT.java
 (added)
+++ 
manifoldcf/trunk/tests/solr/src/test/java/org/apache/manifoldcf/solr_tests/SolrCrawlDerbyIT.java
 Wed Jan 23 19:50:11 2013
@@ -0,0 +1,77 @@
+/* $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.solr_tests;
+
+import java.io.*;
+import java.util.*;
+import org.junit.*;
+
+/** This is a very basic sanity check */
+public class SolrCrawlDerbyIT extends BaseDerby
+{
+
+  protected SolrTester tester;
+  protected MockSolrService solrService = null;
+  
+  public SolrCrawlDerbyIT()
+  {
+    tester = new SolrTester(mcfInstance);
+  }
+  
+  // Setup and teardown the mock wiki service
+  
+  @Before
+  public void createSolrService()
+    throws Exception
+  {
+    System.out.println("Creating mock service");
+    solrService = new MockSolrService();
+    solrService.start();
+    System.out.println("Mock service created");
+  }
+  
+  @After
+  public void shutdownSolrService()
+    throws Exception
+  {
+    if (solrService != null)
+      solrService.stop();
+  }
+
+  @Before
+  public void setupTestArea()
+    throws Exception
+  {
+    tester.setupTestArea();
+  }
+  
+  @After
+  public void teardownTestArea()
+    throws Exception
+  {
+    tester.teardownTestArea();
+  }
+  
+  @Test
+  public void simpleCrawl()
+    throws Exception
+  {
+    tester.executeTest();
+  }
+}

Propchange: 
manifoldcf/trunk/tests/solr/src/test/java/org/apache/manifoldcf/solr_tests/SolrCrawlDerbyIT.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
manifoldcf/trunk/tests/solr/src/test/java/org/apache/manifoldcf/solr_tests/SolrCrawlDerbyIT.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: 
manifoldcf/trunk/tests/solr/src/test/java/org/apache/manifoldcf/solr_tests/SolrTester.java
URL: 
http://svn.apache.org/viewvc/manifoldcf/trunk/tests/solr/src/test/java/org/apache/manifoldcf/solr_tests/SolrTester.java?rev=1437662&r1=1437661&r2=1437662&view=diff
==============================================================================
--- 
manifoldcf/trunk/tests/solr/src/test/java/org/apache/manifoldcf/solr_tests/SolrTester.java
 (original)
+++ 
manifoldcf/trunk/tests/solr/src/test/java/org/apache/manifoldcf/solr_tests/SolrTester.java
 Wed Jan 23 19:50:11 2013
@@ -54,15 +54,8 @@ public class SolrTester
       int i1 = 0;
       while (i1 < 10)
       {
-        String fileName1 = fileName0 + "/dir-" + i1;
-        FileHelper.createDirectory(new File(fileName1));
-        int i2 = 0;
-        while (i2 < 10)
-        {
-          String fileName2 = fileName1 + "/file-"+i2;
-          FileHelper.createFile(new File(fileName2),"Test file 
"+i0+":"+i1+":"+i2);
-          i2++;
-        }
+        String fileName1 = fileName0 + "/file-"+i1;
+        FileHelper.createFile(new File(fileName1),"Test file "+i0+":"+i1);
         i1++;
       }
       i0++;
@@ -155,20 +148,31 @@ public class SolrTester
     // Now, start the job, and wait until it completes.
     long startTime = System.currentTimeMillis();
     jobManager.manualStart(job.getID());
-    instance.waitJobInactiveNative(jobManager,job.getID(),18000L);
+    instance.waitJobInactiveNative(jobManager,job.getID(),300000L);
     System.err.println("Crawl required "+new 
Long(System.currentTimeMillis()-startTime).toString()+" milliseconds");
 
-    // Look in the connection history for anything other than an OK
-    // MHL
-    
     // Check to be sure we actually processed the right number of documents.
     JobStatus status = jobManager.getStatus(job.getID());
     if (status.getDocumentsProcessed() != 111)
       throw new ManifoldCFException("Wrong number of documents processed - 
expected 111, saw "+new Long(status.getDocumentsProcessed()).toString());
-      
+    
+    // Look in the connection history for anything other than an OK
+    FilterCriteria fc = new FilterCriteria(new String[]{"document ingest (Solr 
Connection)"},null,null,null,null);
+    SortOrder sc = new SortOrder();
+    IResultSet result = mgr.genHistorySimple("File Connection",fc,sc,0,10000);
+    for (int i = 0; i < result.getRowCount(); i++)
+    {
+      IResultRow row = result.getRow(i);
+      String activity = (String)row.getValue("activity");
+      String resultCode = (String)row.getValue("resultcode");
+      String resultDetails = (String)row.getValue("resultdesc");
+      if (activity.startsWith("document ingest") && !resultCode.equals("OK"))
+        throw new ManifoldCFException("An indexing operation ("+activity+") 
failed with result code "+resultCode+" details 
"+((resultDetails==null)?"none":resultDetails));
+    }
+
     // Now, delete the job.
     jobManager.deleteJob(job.getID());
-    instance.waitJobDeletedNative(jobManager,job.getID(),18000L);
+    instance.waitJobDeletedNative(jobManager,job.getID(),300000L);
       
     // Cleanup is automatic by the base class, so we can feel free to leave 
jobs and connections lying around.
   }


Reply via email to