# IngestTest

The `IngestTest` action instructs CFS to ingest data for testing purposes. You can use this action to perform tests on a small volume of data and verify the output from the import process.

`IngestTest` is similar to the `Ingest` action, but has the following differences which make it suitable for testing:

- `IngestTest` is a synchronous action, and the document data is returned in the ACI response.
- Indexing, whether as a result of ingestion or as a result of an import task, is disabled.
- Update and Delete commands are disabled (you cannot use the `updates` and `removes` action parameters like you can with the `Ingest` action).

- Any writer tasks that have been configured (`IdxWriter`, `XmlWriter`, `JsonWriter`, `CsvWriter`, `SqlWriter`) are disabled.

- Logging to the import log stream is disabled. The log messages are redirected to the action response.
- The global Lua variable `is_test` is set to `true`. You can use this variable in your Lua scripts to prevent certain parts of your scripts from running when you use the `IngestTest` action.

TIP: CFS includes an XSL template to help you send `IngestTest` actions. Open a web browser and navigate to `http://host:7000/action=IngestTest&Template=IngestTest` (where `host` is the machine where CFS is running and `7000` is the CFS ACI port).

Micro Focus does not support the XSL template, it is provided only as an example of a template that you could build.

## Syntax

    /action=IngestTest
    	   [&config=<base64_encoded_config>]
    	    &adds=<adds_xml>

## Parameters

Parameter Name | Description
--- | ---
`config` | An optional base64 encoded configuration file. If this parameter is set, then the CFS configuration file is ignored and the encoded configuration options are used instead.
adds | An XML string containing the documents to be ingested by CFS. You can specify any combination of document content, metadata, and source files. Micro Focus recommends that you restrict use of the `IngestTest` action to small numbers of documents.

## Example

The following command is an example `IngestTest` action. The `config` action parameter contains a base64 encoded configuration that runs a single Lua post task (`script.lua`):

    /action=IngestTest
            &config=W0ltcG9ydFRhc2tzXQpQb3N0MD1MdWE6c2NyaXB0Lmx1YQ==
            &adds=<adds><add><document><reference>MyRef</reference>
    	       <xmlmetadata><type>file</type></xmlmetadata></document>
                  <source filename='test.txt' lifetime='permanent'/></add></adds>

You must URL encode the action before you can send it to CFS.

## Response

The example action above runs a single Lua post-import task (`script.lua`). If you use the following script:

    function handler( document )
       document:setFieldValue("LUA_CALLED", "true")
       return true;
    end

...the response to the action is:

    <autnresponse xmlns:autn="http://schemas.autonomy.com/aci/">
       <action>INGESTTEST</action>
          <response>SUCCESS</response>
          <responsedata>
             <documents>
                <document>
                   <reference>MyRef</reference>
                   <xmlmetadata>
                      <Content-Type>text/plain</Content-Type>
    		   <DocumentAttributes>0</DocumentAttributes>
    		   <DocumentClass>1</DocumentClass>
    		   <DocumentSize>16</DocumentSize>
    		   <DocumentType>2</DocumentType>
    		   <DRECHILDCOUNT>0</DRECHILDCOUNT>
    		   <DREFILENAME>test.txt</DREFILENAME>
    		   <DREORIGINALNAME>test.txt</DREORIGINALNAME>
    		   <DREROOTFAMILYREFERENCE>MyRef</DREROOTFAMILYREFERENCE>
    		   <DREROOTFAMILYREFERENCE_ID>d4811c706f1b17ed6c13a5c2da1abf0d</DREROOTFAMILYREFERENCE_ID>
    		   <FAMILYSORT>d4811c706f1b17ed6c13a5c2da1abf0d-0</FAMILYSORT>
    		   <FileAccessedTime>1384861016</FileAccessedTime>
    		   <FileCreatedTime>1384861016</FileCreatedTime>
    		   <FileImportedTime>1384861319</FileImportedTime>
    		   <FileModifiedTime>1384861040</FileModifiedTime>
    		   <ImportMagicExtension>txt</ImportMagicExtension>
    		   <ImportOriginalEncoding>ASCII</ImportOriginalEncoding>
    		   <ImportVersion>2</ImportVersion>
    		   <InfoFlag>0</InfoFlag>
    		   <ISFILEFILTERABLE>1</ISFILEFILTERABLE>
    		   <KeyviewVersion>10200</KeyviewVersion>
    		   <LUA_CALLED>true</LUA_CALLED>
    		   <type>file</type>
    		   <UUID>d4811c706f1b17ed6c13a5c2da1abf0d</UUID>
    		   <VersionNumber>0</VersionNumber>
    		</xmlmetadata>
    		<pages content="test.txt content"/>
             </document>
          </documents>
          <logging>
             <log time="2013-11-19T11:41:59" level="30" message="Starting Import Service"/>
             <log time="2013-11-19T11:41:59" level="30" message="ImportService configured to use 1 threads"/>
             <log time="2013-11-19T11:41:59" level="30" message="Temporary files will be stored in: temp"/>
             <log time="2013-11-19T11:41:59" level="30" message="Importing [MyRef]"/>
             <log time="2013-11-19T11:41:59" level="30" message="Detected encoding as ASCII [MyRef]"/>
          </logging>
       </responsedata>
    </autnresponse>

If the action specifies multiple documents, or processes a container file, the response will contain multiple `<document>` elements.

_FT_HTML5_bannerTitle.htm