[Commits] Rev 2835: added a sphinxse test suite in http://bazaar.launchpad.net/~maria-captains/maria/5.2/

At http://bazaar.launchpad.net/~maria-captains/maria/5.2/ ------------------------------------------------------------ revno: 2835 revision-id: sergii@pisem.net-20100806142412-jg9whbisr8brnhxz parent: sergii@pisem.net-20100806130745-mc2jc1941bgazpg6 committer: Sergei Golubchik <sergii@pisem.net> branch nick: 5.2 timestamp: Fri 2010-08-06 18:24:12 +0400 message: added a sphinxse test suite === added directory 'mysql-test/suite/sphinx' === added file 'mysql-test/suite/sphinx/my.cnf' --- a/mysql-test/suite/sphinx/my.cnf 1970-01-01 00:00:00 +0000 +++ b/mysql-test/suite/sphinx/my.cnf 2010-08-06 14:24:12 +0000 @@ -0,0 +1,33 @@ +!include include/default_my.cnf + +[source src1] +type = xmlpipe2 +xmlpipe_command = cat suite/sphinx/testdata.xml + +[index test1] +source = src1 +docinfo = extern +charset_type = utf-8 +path = @mysqld.1.#vardir/searchd/test1 + +[indexer] +mem_limit = 32M + +[searchd] +read_timeout = 5 +max_children = 30 +max_matches = 1000 +seamless_rotate = 1 +preopen_indexes = 0 +unlink_old = 1 +log = @mysqld.1.#vardir/searchd/sphinx-searchd.log +query_log = @mysqld.1.#vardir/searchd/sphinx-query.log +#log-error = @mysqld.1.#vardir/searchd/sphinx.log +pid_file = @mysqld.1.#vardir/run/searchd.pid + +[ENV] +# +# by mere mentioning @searchd.port a new port number is allocated +# and port=<this number> is added to the [searchd] section +# +SPHINXSEARCH_PORT = @searchd.port === added file 'mysql-test/suite/sphinx/sphinx.result' --- a/mysql-test/suite/sphinx/sphinx.result 1970-01-01 00:00:00 +0000 +++ b/mysql-test/suite/sphinx/sphinx.result 2010-08-06 14:24:12 +0000 @@ -0,0 +1,41 @@ +INSTALL PLUGIN sphinx SONAME "ha_sphinx.so"; +create table ts ( id bigint unsigned not null, w int not null, q varchar(255) not null, index(q) ) engine=sphinx connection="sphinx://127.0.0.1:SPHINXSEARCH_PORT/*"; +select * from ts where q='test'; +id w q +1 2 test +2 2 test +4 1 test +drop table ts; +create table ts ( id bigint unsigned not null, w int not null, q varchar(255) not null, index(q) ) engine=sphinx connection="sphinx://127.0.0.1:SPHINXSEARCH_PORT/*"; +select * from ts where q='test;filter=gid,1;mode=extended'; +id w q +1 2421 test;filter=gid,1;mode=extended +2 2421 test;filter=gid,1;mode=extended +select * from ts where q='test|one;mode=extended'; +id w q +1 3595 test|one;mode=extended +2 2460 test|one;mode=extended +4 1471 test|one;mode=extended +select * from ts where q='test;offset=1;limit=1'; +id w q +2 2 test;offset=1;limit=1 +alter table ts connection="sphinx://127.0.0.1:SPHINXSEARCH_PORT/test1"; +select id, w from ts where q='one'; +id w +1 2 +drop table ts; +create table ts ( id bigint unsigned not null, w int not null, q varchar(255) not null, gid int not null, _sph_count int not null, index(q) ) engine=sphinx connection="sphinx://127.0.0.1:SPHINXSEARCH_PORT/test1"; +select * from ts; +id w q gid _sph_count +select * from ts where q=''; +id w q gid _sph_count +1 1 1 0 +2 1 1 0 +3 1 2 0 +4 1 2 0 +select * from ts where q=';groupby=attr:gid'; +id w q gid _sph_count +3 1 ;groupby=attr:gid 2 2 +1 1 ;groupby=attr:gid 1 2 +drop table ts; +UNINSTALL PLUGIN sphinx; === added file 'mysql-test/suite/sphinx/sphinx.test' --- a/mysql-test/suite/sphinx/sphinx.test 1970-01-01 00:00:00 +0000 +++ b/mysql-test/suite/sphinx/sphinx.test 2010-08-06 14:24:12 +0000 @@ -0,0 +1,32 @@ +if (`SELECT "$HAVE_SPHINX" < "0000.0009.0009"`) { + skip Need Sphinx version 0.9.9 or later; +} +if (`SELECT "$HA_SPHINX_SO" = ""`) { + skip No SphinxSE plugin; +} + +eval INSTALL PLUGIN sphinx SONAME "$HA_SPHINX_SO"; + +--replace_result $SPHINXSEARCH_PORT SPHINXSEARCH_PORT +eval create table ts ( id bigint unsigned not null, w int not null, q varchar(255) not null, index(q) ) engine=sphinx connection="sphinx://127.0.0.1:$SPHINXSEARCH_PORT/*"; +select * from ts where q='test'; +drop table ts; + +--replace_result $SPHINXSEARCH_PORT SPHINXSEARCH_PORT +eval create table ts ( id bigint unsigned not null, w int not null, q varchar(255) not null, index(q) ) engine=sphinx connection="sphinx://127.0.0.1:$SPHINXSEARCH_PORT/*"; +select * from ts where q='test;filter=gid,1;mode=extended'; +select * from ts where q='test|one;mode=extended'; +select * from ts where q='test;offset=1;limit=1'; +--replace_result $SPHINXSEARCH_PORT SPHINXSEARCH_PORT +eval alter table ts connection="sphinx://127.0.0.1:$SPHINXSEARCH_PORT/test1"; +select id, w from ts where q='one'; +drop table ts; + +--replace_result $SPHINXSEARCH_PORT SPHINXSEARCH_PORT +eval create table ts ( id bigint unsigned not null, w int not null, q varchar(255) not null, gid int not null, _sph_count int not null, index(q) ) engine=sphinx connection="sphinx://127.0.0.1:$SPHINXSEARCH_PORT/test1"; +select * from ts; +select * from ts where q=''; +select * from ts where q=';groupby=attr:gid'; +drop table ts; + +UNINSTALL PLUGIN sphinx; === added file 'mysql-test/suite/sphinx/suite.pm' --- a/mysql-test/suite/sphinx/suite.pm 1970-01-01 00:00:00 +0000 +++ b/mysql-test/suite/sphinx/suite.pm 2010-08-06 14:24:12 +0000 @@ -0,0 +1,116 @@ +package My::Suite::Sphinx; + +use My::SafeProcess; +use My::File::Path; +use mtr_report; + +@ISA = qw(My::Suite); + +use Carp; +$Carp::Verbose=1; + +############# initialization ###################### +sub locate_sphinx_binary { + my ($name)= @_; + my $res; + my @list= map "$_/$name", split /:/, $ENV{PATH}; + my $env_override= $ENV{"SPHINXSEARCH_\U$name"}; + @list= ($env_override) if $env_override; + for (@list) { return $_ if -x $_; } +} + +# Look for Sphinx binaries. +my $exe_sphinx_indexer = &locate_sphinx_binary('indexer'); +my $exe_sphinx_searchd = &locate_sphinx_binary('searchd'); + +if ($exe_sphinx_indexer and $exe_sphinx_searchd) +{ + local $_ = `"$exe_sphinx_searchd" --help`; + $ENV{HAVE_SPHINX}= sprintf "%04d.%04d.%04d", (/([0-9]+)\.([0-9]+)\.([0-9]+)/); +} + +############# action methods ###################### + +sub write_sphinx_conf { + my ($config) = @_; # My::Config + my $res; + + foreach my $group ($config->groups()) { + my $name= $group->{name}; + # Only the ones relevant to Sphinx search. + next unless ($name eq 'indexer' or $name eq 'searchd' or + $name =~ /^(source|index) \w+$/); + $res .= "$name\n{\n"; + foreach my $option ($group->options()) { + $res .= $option->name(); + my $value= $option->value(); + if (defined $value) { + $res .= "=$value"; + } + $res .= "\n"; + } + $res .= "}\n\n"; + } + $res; +} + +sub searchd_start { + my ($sphinx, $test) = @_; # My::Config::Group, My::Test + + return unless $exe_sphinx_indexer and $exe_sphinx_searchd; + + # First we must run the indexer to create the data. + my $sphinx_data_dir= "$::opt_vardir/" . $sphinx->name(); + mkpath($sphinx_data_dir); + my $sphinx_log= $sphinx->value('#log-error'); + my $sphinx_config= "$::opt_vardir/my_sphinx.conf"; + my $cmd= "\"$exe_sphinx_indexer\" --config \"$sphinx_config\" test1 > \"$sphinx_log\" 2>&1"; + &::mtr_verbose("cmd: $cmd"); + system $cmd; + + # Then start the searchd daemon. + my $args; + &::mtr_init_args(\$args); + &::mtr_add_arg($args, "--config"); + &::mtr_add_arg($args, $sphinx_config); + &::mtr_add_arg($args, "--console"); + &::mtr_add_arg($args, "--pidfile"); + + $sphinx->{'proc'}= My::SafeProcess->new + ( + name => 'sphinx-' . $sphinx->name(), + path => $exe_sphinx_searchd, + args => \$args, + output => $sphinx_log, + error => $sphinx_log, + append => 1, + nocore => 1, + ); + &::mtr_verbose("Started $sphinx->{proc}"); +} + +sub searchd_wait { + my ($sphinx) = @_; # My::Config::Group + + return not &::sleep_until_file_created($sphinx->value('pid_file'), 20, + $sphinx->{'proc'}) +} + +############# declaration methods ###################### + +sub config_files() { + ( 'my_sphinx.conf' => \&write_sphinx_conf ) +} + +sub servers { + ( qr/^searchd$/ => { + SORT => 400, + START => \&searchd_start, + WAIT => \&searchd_wait, + } + ) +} + +############# return an object ###################### +bless { }; + === added file 'mysql-test/suite/sphinx/testdata.xml' --- a/mysql-test/suite/sphinx/testdata.xml 1970-01-01 00:00:00 +0000 +++ b/mysql-test/suite/sphinx/testdata.xml 2010-08-06 14:24:12 +0000 @@ -0,0 +1,35 @@ +<?xml version="1.0" encoding="utf-8"?> +<sphinx:docset> + +<sphinx:schema> +<sphinx:field name="title"/> +<sphinx:field name="content"/> +<sphinx:attr name="gid" type="int"/> +</sphinx:schema> + +<sphinx:document id="1"> +<title>test one</title> +<content>this is my test document number one. also checking search within phrases.</content> +<gid>1</gid> +</sphinx:document> + +<sphinx:document id="2"> +<title>test two</title> +<content>this is my test document number two</content> +<gid>1</gid> +</sphinx:document> + +<sphinx:document id="3"> +<title>another doc</title> +<content>this is another group</content> +<gid>2</gid> +</sphinx:document> + +<sphinx:document id="4"> +<title>doc number four</title> +<content>this is to test groups</content> +<gid>2</gid> +</sphinx:document> + +</sphinx:docset> +
participants (1)
-
serg@askmonty.org