[Rt-commit] rt branch, 3.9-fts, updated. rt-3.9.4-44-gb82cf71

Ruslan Zakirov ruz at bestpractical.com
Wed Oct 13 16:54:29 EDT 2010


The branch, 3.9-fts has been updated
       via  b82cf713dbce7e63db029b6a4b23bfdaa08be2e9 (commit)
       via  64ed1846f775d632f04951f7d84abe77606d785b (commit)
       via  dcde0c73e1077c3da13c2968a6d4250557ac1bc0 (commit)
       via  e48ba8460fc8019f513c4a5849b57ea5973bd514 (commit)
       via  86b9bac290acf62e7e341759227806034feba3cd (commit)
       via  dcddaa297a548b4f8fe179f27992504ff95327ac (commit)
       via  47faac81e705c6757b705d4f00bedd2d66906e8e (commit)
       via  a01bff5561c5f538e080503617b7475b8bb24033 (commit)
       via  53ee8972e5ad80f2dcc15011a51c5a913c3b58f6 (commit)
       via  e757284de3812314910b300cd59ce785f8247267 (commit)
      from  35347d98aa7f2d1b85640cb78039426861640f20 (commit)

Summary of changes:
 .gitignore                      |    1 +
 Makefile.in                     |    1 +
 configure.ac                    |    1 +
 lib/RT/Interface/CLI.pm         |   15 ++-
 sbin/rt-fulltext-indexer.in     |  384 +++++++++++++++++++++++++++++++++++++++
 sbin/rt-setup-fulltext-index.in |   97 ++++++----
 t/fts/indexed_pg.t              |   31 +++-
 7 files changed, 484 insertions(+), 46 deletions(-)
 create mode 100644 sbin/rt-fulltext-indexer.in

- Log -----------------------------------------------------------------
commit e757284de3812314910b300cd59ce785f8247267
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Tue Oct 12 23:24:15 2010 +0400

    register indexer script in makefile and configure

diff --git a/Makefile.in b/Makefile.in
index fda6efc..3026dcc 100755
--- a/Makefile.in
+++ b/Makefile.in
@@ -165,6 +165,7 @@ SYSTEM_BINARIES		=	rt-attributes-viewer \
 				rt-dump-database \
 				rt-setup-database \
 				rt-setup-fulltext-index \
+				rt-fulltext-indexer \
 				rt-email-digest \
 				rt-email-dashboards \
 				rt-email-group-admin \
diff --git a/configure.ac b/configure.ac
index 3b50f69..b826c1d 100755
--- a/configure.ac
+++ b/configure.ac
@@ -414,6 +414,7 @@ AC_CONFIG_FILES([
                  sbin/rt-email-group-admin
                  sbin/rt-server
                  sbin/rt-setup-fulltext-index
+                 sbin/rt-fulltext-indexer
                  bin/fastcgi_server
                  bin/mason_handler.fcgi
                  bin/mason_handler.scgi

commit 53ee8972e5ad80f2dcc15011a51c5a913c3b58f6
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Tue Oct 12 23:27:01 2010 +0400

    ShowHelp in RT::Interface::CLI

diff --git a/lib/RT/Interface/CLI.pm b/lib/RT/Interface/CLI.pm
index d9a17d5..b57e0c3 100755
--- a/lib/RT/Interface/CLI.pm
+++ b/lib/RT/Interface/CLI.pm
@@ -246,7 +246,20 @@ sub debug {
     }	
 }
 
-
+sub ShowHelp {
+    my $self = shift;
+    my %args = @_;
+    require Pod::Usage;
+    Pod::Usage::pod2usage(
+        -message => $args{'Message'},
+        -exitval => $args{'ExitValue'} || 0, 
+        -verbose => 99,
+        -sections => $args{'Sections'} || ($args{'ExitValue'}
+            ? 'NAME|USAGE'
+            : 'NAME|USAGE|OPTIONS|DESCRIPTION'
+        ),
+    );
+}
 
 RT::Base->_ImportOverlays();
 

commit a01bff5561c5f538e080503617b7475b8bb24033
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Tue Oct 12 23:28:46 2010 +0400

    no more $ora_prefix

diff --git a/sbin/rt-setup-fulltext-index.in b/sbin/rt-setup-fulltext-index.in
index e04660a..4325d85 100644
--- a/sbin/rt-setup-fulltext-index.in
+++ b/sbin/rt-setup-fulltext-index.in
@@ -368,7 +368,7 @@ sub ora_create_word_list {
 sub ora_create_stop_list {
     my $file = shift || 'etc/stopwords/en.txt';
 
-    my $name = $ora_prefix .'stop_list';
+    my $name = $DEFAULT{'prefix'} .'stop_list';
     do_error_is_ok( $dbh => 'begin ctx_ddl.drop_stoplist(?); end;', $name );
     
     $dbh->do(
@@ -391,7 +391,7 @@ sub ora_create_stop_list {
 
 sub ora_create_section_group {
     my %args = @_;
-    my $name = $ora_prefix .'section_group';
+    my $name = $DEFAULT{'prefix'} .'section_group';
     do_error_is_ok( $dbh => 'begin ctx_ddl.drop_section_group(?); end;', $name );
     $dbh->do(
         'begin ctx_ddl.create_section_group(?, ?);  end;',
@@ -487,7 +487,7 @@ sub ora_create_format_column {
 
 sub ora_create_preference {
     my %info = @_;
-    my $name = $ora_prefix . $info{'name'};
+    my $name = $DEFAULT{'prefix'} . $info{'name'};
     do_error_is_ok( $dbh => 'begin ctx_ddl.drop_preference(?); end;', $name );
     $dbh->do(
         'begin ctx_ddl.create_preference(?, ?);  end;',

commit 47faac81e705c6757b705d4f00bedd2d66906e8e
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Tue Oct 12 23:29:22 2010 +0400

    use ShowHelp

diff --git a/sbin/rt-setup-fulltext-index.in b/sbin/rt-setup-fulltext-index.in
index 4325d85..f32ce08 100644
--- a/sbin/rt-setup-fulltext-index.in
+++ b/sbin/rt-setup-fulltext-index.in
@@ -579,14 +579,12 @@ sub warning  { $RT::Logger->warning( @_ ); verbose(@_); 1 }
 
 sub show_help {
     my $error = shift;
-    require Pod::Usage;
-    Pod::Usage::pod2usage(
-        -message => "",
-        -exitval => $error || 0, 
-        -verbose => 99,
-        -sections => $error
+    RT::Interface::CLI->ShowHelp(
+        ExitValue => $error,
+        Sections => $error
             ? 'NAME|'. lc($DB{'type'}) .'/USAGE'
-            : 'NAME|'. lc($DB{'type'}),
+            : 'NAME|'. lc($DB{'type'})
+        ,
     );
 }
 

commit dcddaa297a548b4f8fe179f27992504ff95327ac
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Tue Oct 12 23:30:11 2010 +0400

    insert_schema_as_dba function

diff --git a/sbin/rt-setup-fulltext-index.in b/sbin/rt-setup-fulltext-index.in
index f32ce08..d7ff334 100644
--- a/sbin/rt-setup-fulltext-index.in
+++ b/sbin/rt-setup-fulltext-index.in
@@ -606,14 +606,24 @@ END
 }
 
 sub insert_schema {
+    return _insert_schema( $dbh, "Going to do the following change in the DB:", @_);
+}
+
+sub insert_schema_as_dba {
+    return _insert_schema( dba_handle(), "Going to do the following change in the DB:", @_);
+}
+
+sub _insert_schema {
+    my $dbh = shift;
+    my $message = shift;
     my $schema = shift;
-    print "Going to do the following change in the DB:\n";
+    print "$message\n";
     print $schema;
     return if $OPT{'dryrun'};
 
     my $res = $dbh->do( $schema );
     unless ( $res ) {
-        die "Couldn't create the table: ". $dbh->errstr;
+        die "Couldn't run DDL query: ". $dbh->errstr;
     }
 }
 

commit 86b9bac290acf62e7e341759227806034feba3cd
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Tue Oct 12 23:32:37 2010 +0400

    init earlier for functions from RT::Interface::CLI

diff --git a/sbin/rt-setup-fulltext-index.in b/sbin/rt-setup-fulltext-index.in
index d7ff334..240923f 100644
--- a/sbin/rt-setup-fulltext-index.in
+++ b/sbin/rt-setup-fulltext-index.in
@@ -74,8 +74,12 @@ BEGIN {
     }
 }
 
-use RT;
-RT::LoadConfig();
+BEGIN {
+    use RT;
+    RT::LoadConfig();
+    RT::Init();
+};
+use RT::Interface::CLI ();
 
 my %DB = (
     type           => scalar RT->Config->Get('DatabaseType'),
@@ -121,7 +125,6 @@ if ( $OPT{'help'} || (!$DB{'admin'} && $DB{'type'} eq 'Oracle' ) ) {
     show_help( !$OPT{'help'} );
 }
 
-RT::Init();
 
 my $dbh = $RT::Handle->dbh;
 $dbh->{'RaiseError'} = 1;

commit e48ba8460fc8019f513c4a5849b57ea5973bd514
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Tue Oct 12 23:33:25 2010 +0400

    improve index creation on Pg
    
    * allow to pick Attachments as table
    * allow to pick column
    * create index right in the script

diff --git a/sbin/rt-setup-fulltext-index.in b/sbin/rt-setup-fulltext-index.in
index 240923f..348a2d4 100644
--- a/sbin/rt-setup-fulltext-index.in
+++ b/sbin/rt-setup-fulltext-index.in
@@ -223,37 +223,45 @@ elsif ( $DB{'type'} eq 'Pg' ) {
     my $dbh = $RT::Handle->dbh;
 
     my $table = prompt(
-        message => 'Enter name of a DB table that will be used to connect to the sphinx server',
+        message =>
+            'Enter name of a DB table that will be used to store Pg tsvector.'
+            . ' Attachments table can be used.'
+        ,
         default => $DEFAULT{'table'},
         silent  => !$OPT{'ask'},
     );
+    my $column = prompt(
+        message => 'Enter name of a column that will be used to store Pg tsvector',
+        default => $DEFAULT{'column'},
+        silent  => !$OPT{'ask'},
+    );
 
-    my $schema = <<END;
-CREATE TABLE $table (
-    id      INTEGER NOT NULL,
-    $DEFAULT{'column'} tsvector
-)
-END
-
-    print_rt_config( table => $table, column => $DEFAULT{'column'} );
-
-    insert_schema( $schema );
-
-    print <<END;
-Now you have to create an index on the column. You have choice
-between GiST or GIN, the first is times slower to search, but
-it takes less place and faster to update. Anyway, both are faster
-then searches without them.
-
-Either run:
-
-    CREATE INDEX $DEFAULT{column}_idx ON $table USING gin($DEFAULT{'column'});
+    my $schema;
+    if ( lc($table) eq 'attachments' ) {
+        $schema = "ALTER TABLE $table ADD COLUMN $column tsvector";
+    } else {
+        $schema = "CREATE TABLE $table ( "
+            ."id INTEGER NOT NULL,"
+            ."$column tsvector )";
+    }
 
-or
+    print_rt_config( table => $table, column => $column );
 
-    CREATE INDEX $DEFAULT{column}_idx ON $table USING gist($DEFAULT{'column'});
+    insert_schema_as_dba( $schema );
 
-END
+    my $index_type;
+    do {
+        $index_type = lc prompt(
+            message =>
+                'You have choice between GiST or GIN index,'
+                .' the first is times slower to search, but'
+                .' it takes less place and faster to update.'
+            ,
+            default => 'GiST',
+            silent  => !$OPT{'ask'},
+        );
+    } while ( $index_type ne 'gist' && $index_type ne 'gin' );
+    insert_schema_as_dba("CREATE INDEX ${column}_idx ON $table USING $index_type($column)");
 }
 elsif ( $DB{'type'} eq 'Oracle' ) {
     {

commit dcde0c73e1077c3da13c2968a6d4250557ac1bc0
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Wed Oct 13 22:58:32 2010 +0400

    sbin/rt-fulltext-indexer script

diff --git a/sbin/rt-fulltext-indexer.in b/sbin/rt-fulltext-indexer.in
new file mode 100644
index 0000000..4585846
--- /dev/null
+++ b/sbin/rt-fulltext-indexer.in
@@ -0,0 +1,384 @@
+#!@PERL@
+# BEGIN BPS TAGGED BLOCK {{{
+# 
+# COPYRIGHT:
+# 
+# This software is Copyright (c) 1996-2008 Best Practical Solutions, LLC
+#                                          <jesse at bestpractical.com>
+# 
+# (Except where explicitly superseded by other copyright notices)
+# 
+# 
+# LICENSE:
+# 
+# This work is made available to you under the terms of Version 2 of
+# the GNU General Public License. A copy of that license should have
+# been provided with this software, but in any event can be snarfed
+# from www.gnu.org.
+# 
+# This work is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301 or visit their web page on the internet at
+# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
+# 
+# 
+# CONTRIBUTION SUBMISSION POLICY:
+# 
+# (The following paragraph is not intended to limit the rights granted
+# to you to modify and distribute this software under the terms of
+# the GNU General Public License and is only of importance to you if
+# you choose to contribute your changes and enhancements to the
+# community by submitting them to Best Practical Solutions, LLC.)
+# 
+# By intentionally submitting any modifications, corrections or
+# derivatives to this work, or any other work intended for use with
+# Request Tracker, to Best Practical Solutions, LLC, you confirm that
+# you are the copyright holder for those contributions and you grant
+# Best Practical Solutions,  LLC a nonexclusive, worldwide, irrevocable,
+# royalty-free, perpetual, license to use, copy, create derivative
+# works based on those contributions, and sublicense and distribute
+# those contributions and any derivatives thereof.
+# 
+# END BPS TAGGED BLOCK }}}
+use strict;
+use warnings;
+no warnings 'once';
+
+# fix lib paths, some may be relative
+BEGIN {
+    require File::Spec;
+    my @libs = ("@RT_LIB_PATH@", "@LOCAL_LIB_PATH@");
+    my $bin_path;
+
+    for my $lib (@libs) {
+        unless ( File::Spec->file_name_is_absolute($lib) ) {
+            unless ($bin_path) {
+                if ( File::Spec->file_name_is_absolute(__FILE__) ) {
+                    $bin_path = ( File::Spec->splitpath(__FILE__) )[1];
+                }
+                else {
+                    require FindBin;
+                    no warnings "once";
+                    $bin_path = $FindBin::Bin;
+                }
+            }
+            $lib = File::Spec->catfile( $bin_path, File::Spec->updir, $lib );
+        }
+        unshift @INC, $lib;
+    }
+}
+
+BEGIN {
+    use RT;
+    RT::LoadConfig();
+    RT::Init();
+};
+use RT::Interface::CLI ();
+
+my %OPT = (
+    help        => 0,
+);
+
+use Getopt::Long qw(GetOptions);
+GetOptions(
+    'h|help!'        => \$OPT{'help'},
+
+);
+
+if ( $OPT{'help'} ) {
+    RT::Interface::CLI->ShowHelp;
+}
+
+my $fts_config = RT->Config->Get('FullTextSearch') || {};
+unless ( $fts_config->{'Enable'} ) {
+    print STDERR "Full text search disabled in the RT config."
+        ." Read documentation for %FullTextSearch config option.";
+    exit 1;
+}
+unless ( $fts_config->{'Indexed'} ) {
+    print STDERR "Full text search is enabled in the RT config,"
+        ." however full text search works without special index,"
+        ." so this tool is not required."
+        ." Read documentation for %FullTextSearch config option.";
+    exit 1;
+}
+
+my $db_type = RT->Config->Get('DatabaseType');
+
+my @types = qw(text html);
+foreach my $type ( @types ) {
+    my $attaches = attachments($type);
+    $attaches->Limit(
+        FIELD => 'id',
+        OPERATOR => '>',
+        VALUE => last_indexed($type)
+    );
+    $attaches->OrderBy( FIELD => 'id', ORDER => 'asc' );
+    $attaches->RowsPerPage( $OPT{'limit'} || 100 );
+
+    my $found = 0;
+    while ( my $a = $attaches->Next ) {
+        print "bla\n";
+        debug("Found attachment #". $a->id );
+        next if filter( $type, $a );
+        debug("Attachment #". $a->id ." hasn't been filtered" );
+        my $txt = extract($type, $a) or next;
+        debug("Extracted text from attachment #". $a->id );
+        $found++;
+        process( $type, $a, $txt );
+        debug("Processed attachment #". $a->id );
+    }
+    finalize( $type, $attaches ) if $found;
+    clean( $type );
+}
+
+sub attachments {
+    my $type = shift;
+    my $res = RT::Attachments->new( RT->SystemUser );
+
+    my $txn_alias = $res->JoinTransactions;
+    $res->Limit( ALIAS => $txn_alias, FIELD => 'ObjectType', VALUE => 'RT::Ticket' );
+    my $ticket_alias = $res->Join(
+        ALIAS1 => $txn_alias, FIELD1 => 'ObjectId',
+        TABLE2 => 'Tickets', FIELD2 => 'id'
+    );
+    $res->Limit(
+        ALIAS => $ticket_alias,
+        FIELD => 'Status',
+        OPERATOR => '!=',
+        VALUE => 'deleted'
+    );
+
+    return goto_specific(
+        suffix => $type,
+        error => "Don't know how to find $type attachments",
+        arguments => [$res],
+    );
+}
+
+sub last_indexed {
+    my ($type) = (@_);
+    return goto_specific(
+        suffix => $db_type,
+        error => "Don't know how to find last indexed $type attachment for $db_type DB",
+        arguments => \@_,
+    );
+}
+
+sub filter {
+    my $type = shift;
+    return goto_specific(
+        suffix    => $type,
+        arguments => \@_,
+    );
+}
+
+sub extract {
+    my $type = shift;
+    return goto_specific(
+        suffix    => $type,
+        error     => "No way to convert $type attachment into text",
+        arguments => \@_,
+    );
+}
+
+sub process {
+    return goto_specific(
+        suffix    => $db_type,
+        error     => "No processer for $db_type DB",
+        arguments => \@_,
+    );
+}
+
+sub finalize {
+    return goto_specific(
+        suffix    => $db_type,
+        arguments => \@_,
+    );
+}
+
+sub clean {
+    return goto_specific(
+        prefix    => $db_type,
+        arguments => \@_,
+    );
+}
+
+{
+sub last_indexed_mysql {
+    my $type = shift;
+    my $attr = $RT::System->FirstAttribute('LastIndexedAttachments');
+    return 0 unless $attr;
+    return 0 unless exists $attr->{ $type };
+    return $attr->{ $type } || 0;
+}
+
+sub process_mysql {
+    my ($type, $attachment, $text) = (@_);
+
+    my $doc = sphinx_template();
+
+    my $element = $doc->createElement('sphinx:document');
+    $element->setAttribute( id => $attachment->id );
+    $element->appendTextChild( content => $$text );
+
+    $doc->documentElement->appendChild( $element );
+}
+
+my $doc = undef;
+sub sphinx_template {
+    return $doc if $doc;
+
+    require XML::LibXML;
+    $doc = XML::LibXML::Document->new('1.0', 'UTF-8');
+    my $root = $doc->createElement('sphinx:docset');
+    $doc->setDocumentElement( $root );
+
+    my $schema = $doc->createElement('sphinx:schema');
+    $root->appendChild( $schema );
+    foreach ( qw(content) ) {
+        my $field = $doc->createElement('sphinx:field');
+        $field->setAttribute( name => $_ );
+        $schema->appendChild( $field );
+    }
+
+    return $doc;
+}
+
+sub finalize_mysql {
+    my ($type, $attachments) = @_;
+    sphinx_template()->toFH(*STDOUT, 1);
+}
+
+sub clean_mysql {
+    $doc = undef;
+}
+
+}
+
+sub last_indexed_pg {
+    my $type = shift;
+    my $attachments = attachments( $type );
+    my $alias = 'main';
+    if ( $fts_config->{'Table'} && lc $fts_config->{'Table'} ne 'Attachments' ) {
+        $alias = $attachments->Join(
+            TYPE    => 'left',
+            FIELD1 => 'id',
+            TABLE2  => $fts_config->{'table'},
+            FIELD2 => 'id',
+        );
+    }
+    $attachments->Limit(
+        ALIAS => $alias,
+        FIELD => $fts_config->{'Column'},
+        OPERATOR => 'IS NOT',
+        VALUE => 'NULL',
+    );
+    $attachments->OrderBy( FIELD => 'id', ORDER => 'desc' );
+    my $res = $attachments->First;
+    return 0 unless $res;
+    return $res->id;
+}
+
+sub process_pg {
+    my ($type, $attachment, $text) = (@_);
+
+    my $dbh = $RT::Handle->dbh;
+    my $table = $fts_config->{'Table'};
+    my $column = $fts_config->{'Column'};
+
+    my $query;
+    if ( $table ) {
+        if ( my ($id) = $dbh->selectrow_array("SELECT id FROM $table WHERE id = ?", undef, $attachment->id) ) {
+            $query = "UPDATE $table SET $column = to_tsvector(?) WHERE id = ?";
+        } else {
+            $query = "INSERT INTO $table($column, id) VALUES(to_tsvector(?), ?)";
+        }
+    } else {
+        $query = "UPDATE Attachments SET $column = to_tsvector(?) WHERE id = ?";
+    }
+
+    my $status = $dbh->do( $query, undef, $$text, $attachment->id );
+    unless ( $status ) {
+        die "error: ". $dbh->errstr;
+    }
+}
+
+sub attachments_text {
+    my $res = shift;
+    $res->Limit( FIELD => 'content_type', VALUE => 'text/plain' );
+    return $res;
+}
+
+sub extract_text {
+    my $attachment = shift;
+    my $text = $attachment->Content;
+    return undef unless defined $text && length($text);
+    return \$text;
+}
+
+sub attachments_html {
+    my $res = shift;
+    $res->Limit( FIELD => 'ContentType', VALUE => 'text/html' );
+    return $res;
+}
+
+sub filter_html {
+    my $attachment = shift;
+    if ( my $parent = $attachment->Parent ) {
+# skip html parts that are alternatives
+        return 1 if $parent->id
+            && $parent->ContentType eq 'mulitpart/alternative';
+    }
+    return 0;
+}
+
+sub extract_html {
+    my $attachment = shift;
+    my $text = $attachment->Content;
+    return undef unless defined $text && length($text);
+# TODO: html -> text
+    return \$text;
+}
+
+sub goto_specific {
+    my %args = (@_);
+
+    my $func = (caller(1))[3];
+    $func =~ s/.*:://;
+    my $call = $func ."_". lc $args{'suffix'};
+    unless ( defined &$call ) {
+        return undef unless $args{'error'};
+        require Carp; Carp::croak( $args{'error'} );
+    }
+    @_ = @{ $args{'arguments'} };
+    goto &$call;
+}
+
+
+# helper functions
+sub verbose  { print _(@_), "\n" if $OPT{verbose} || $OPT{verbose}; 1 }
+sub debug    { print _(@_), "\n" if $OPT{debug}; 1 }
+sub error    { $RT::Logger->error(_(@_)); verbose(@_); 1 }
+sub warning  { $RT::Logger->warn(_(@_)); verbose(@_); 1 }
+
+=head1 NAME
+
+rt-fulltext-indexer - Indexer for full text search
+
+=head1 SYNOPSIS
+
+    /opt/rt3/local/sbin/rt-fulltext-indexer --help
+
+    /opt/rt3/local/sbin/rt-fulltext-indexer --limit 100
+
+=head1 DESCRIPTION
+
+=cut
+

commit 64ed1846f775d632f04951f7d84abe77606d785b
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Wed Oct 13 23:00:14 2010 +0400

    complete test file

diff --git a/t/fts/indexed_pg.t b/t/fts/indexed_pg.t
index 51c585d..1bd9204 100644
--- a/t/fts/indexed_pg.t
+++ b/t/fts/indexed_pg.t
@@ -5,12 +5,12 @@ use warnings;
 
 use RT::Test tests => undef;
 plan skip_all => 'Not Pg' unless RT->Config->Get('DatabaseType') eq 'Pg';
-plan tests => 100;
-
-setup_indexing();
+plan tests => 9;
 
 RT->Config->Set( FullTextSearch => Enable => 1, Indexed => 1 );
 
+setup_indexing();
+
 my $q = RT::Test->load_or_create_queue( Name => 'General' );
 ok $q && $q->id, 'loaded or created queue';
 my $queue = $q->Name;
@@ -19,19 +19,38 @@ my ($total, @data, @tickets, @test, @conditions) = (0, ());
 
 sub setup_indexing {
     my %args = (
-        command => $RT::SbinPath .'/rt-setup-fulltext-index',
+        'no-ask'       => 1,
+        command        => $RT::SbinPath .'/rt-setup-fulltext-index',
+        dba            => $ENV{'RT_DBA_USER'},
+        'dba-password' => $ENV{'RT_DBA_PASSWORD'},
     );
     my ($exit_code, $output) = RT::Test->run_and_capture( %args );
     ok(!$exit_code, "setted up index") or diag "output: $output";
+
+    %args = (
+        command => $RT::SbinPath .'/rt-fulltext-indexer',
+    );
+    ($exit_code, $output) = RT::Test->run_and_capture( %args );
+    ok(!$exit_code, "setted up index") or diag "output: $output";
 }
 
 sub add_tix_from_data {
     my @res = ();
     while (@data) {
         my $t = RT::Ticket->new(RT->SystemUser);
-        my ( $id, undef $msg ) = $t->Create(
+        my %args = %{ shift(@data) };
+
+        if ( my $content = delete $args{'Content'} ) {
+            $args{'MIMEObj'} = MIME::Entity->build(
+                From    => $args{'Requestor'},
+                To      => $q->CorrespondAddress,
+                Subject => $args{'Subject'},
+                Data    => $content,
+            );
+        }
+        my ( $id, undef, $msg ) = $t->Create(
             Queue => $q->id,
-            %{ shift(@data) },
+            %args,
         );
         ok( $id, "ticket created" ) or diag("error: $msg");
         push @res, $t;

commit b82cf713dbce7e63db029b6a4b23bfdaa08be2e9
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Wed Oct 13 23:00:33 2010 +0400

    gitignore

diff --git a/.gitignore b/.gitignore
index 365790d..ca9e04b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -29,6 +29,7 @@ sbin/rt-server
 sbin/rt-session-viewer
 sbin/rt-setup-database
 sbin/rt-setup-fulltext-index
+sbin/rt-fulltext-indexer
 sbin/rt-shredder
 sbin/rt-test-dependencies
 sbin/rt-validator

-----------------------------------------------------------------------


More information about the Rt-commit mailing list