Skip to content

Commit

Permalink
Перенёс тесты в отдельную папку, отдельный конфиг, tsv-источник
Browse files Browse the repository at this point in the history
  • Loading branch information
Serge Shirokov committed Dec 5, 2014
1 parent 5910c01 commit 3083154
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 13 deletions.
3 changes: 3 additions & 0 deletions tests/bands.tsv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
1 Led Zeppelin Some description. 35,23,16 5
2 Daft Punk Some more strange description. 12 7
3 Brainstorm No, not the Magic card. 1 9
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions purels.js → tests/purels.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
var limestone = require("./limestone").SphinxClient();
var limestone = require("../limestone").SphinxClient();

var testString = 'test';
var testString = 'Punk';

// 9312 is standard Sphinx port
limestone.connect(9312, function(err) {
Expand All @@ -10,7 +10,7 @@ limestone.connect(9312, function(err) {
process.exit();
}
console.log('Connected, sending query');
limestone.query({'query':testString, maxmatches:1, 'fieldweights': {'name': 80, 'body': 30}}, function(err, answer) {
limestone.query({'query':testString, maxmatches:1, 'fieldweights': {'name': 80, 'desc': 30}}, function(err, answer) {
limestone.disconnect();
console.log("Extended search for '" + testString + "' yielded " + answer.match_count + " results: " + JSON.stringify(answer));
});
Expand Down
59 changes: 59 additions & 0 deletions tests/sphinx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#
# Minimal Sphinx configuration sample (clean, simple, functional)
#
source tsv_test
{
type = tsvpipe
}
source src1
{
type = tsvpipe
tsvpipe_command = cat D:\Source\Repos\limestone\tests\bands.tsv
tsvpipe_field = name
tsvpipe_field = desc
tsvpipe_attr_multi = genre_tags
tsvpipe_attr_uint = singer_id
}


index test1
{
source = src1
path = D:\WORK\Sphinx\test
}


#index testrt
#{
# type = rt
# rt_mem_limit = 128M
#
# path = @CONFDIR@/data/testrt
#
# rt_field = title
# rt_field = content
# rt_attr_uint = gid
#}


indexer
{
mem_limit = 128M
}


searchd
{
listen = 9312
listen = 9306:mysql41
log = D:\WORK\logs\searchd.log
query_log = D:\WORK\logs\sphinx-query.log
read_timeout = 5
max_children = 30
pid_file = D:\WORK\Sphinx\sphinx.pid
seamless_rotate = 1
preopen_indexes = 1
unlink_old = 1
workers = threads # for RT to work
binlog_path = D:\WORK\Sphinx\data
}
20 changes: 10 additions & 10 deletions testfilters.js → tests/testfilters.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
var limestone = require("./limestone").SphinxClient();
var limestone = require("../limestone").SphinxClient();

// 9312 is standard Sphinx port
//
var filter = {
'type': 0, // VALUES
'attr': 'author_id',
'values':[1,4]
'attr': 'singer_id',
'values':[5,7]
};

var filter_range = {
'type':1, // RANGE
'attr':'author_id',
'min':1,
'max':3
'attr':'singer_id',
'min':6,
'max':10
}

limestone.connect(9312, function(err) {
if (!err) {
limestone.query({'query':'document', indices:'testpipe2', filters:[filter]}, function(err, answer){
limestone.query({'query':'document', indices:'test1', filters:[filter]}, function(err, answer){
if (!err) {
console.log("Extended search for 'test' on authors 1 and 4 yielded " + answer.match_count + " results: " + JSON.stringify(answer));
console.log("Extended search for 'test' on authors 5 and 7 yielded " + answer.match_count + " results: " + JSON.stringify(answer));
// limestone.disconnect();
limestone.query({'query':'document', indices:'testpipe2', filters:[filter_range]}, function(err, answer){
limestone.query({'query':'document', indices:'test1', filters:[filter_range]}, function(err, answer){
if (!err) {
console.log("Extended search for 'test' on authors 1..3 yielded " + answer.match_count + " results: " + JSON.stringify(answer));
console.log("Extended search for 'test' on authors 6..10 yielded " + answer.match_count + " results: " + JSON.stringify(answer));
limestone.disconnect();
} else {
console.log('Request 2 error: ' + err);
Expand Down

0 comments on commit 3083154

Please sign in to comment.