riddle 2.1.0 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (176) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +8 -5
  3. data/Gemfile +10 -0
  4. data/HISTORY +4 -0
  5. data/README.markdown +1 -1
  6. data/lib/riddle.rb +1 -0
  7. data/lib/riddle/0.9.9/configuration/searchd.rb +1 -1
  8. data/lib/riddle/client.rb +4 -1
  9. data/lib/riddle/client/message.rb +15 -14
  10. data/lib/riddle/configuration/parser.rb +1 -0
  11. data/lib/riddle/configuration/section.rb +9 -9
  12. data/lib/riddle/configuration/source.rb +5 -5
  13. data/lib/riddle/query/select.rb +3 -2
  14. data/riddle.gemspec +2 -4
  15. metadata +4 -329
  16. data/spec/fixtures/.gitignore +0 -2
  17. data/spec/fixtures/data/0.9.9/anchor.bin +0 -0
  18. data/spec/fixtures/data/0.9.9/any.bin +0 -0
  19. data/spec/fixtures/data/0.9.9/boolean.bin +0 -0
  20. data/spec/fixtures/data/0.9.9/comment.bin +0 -0
  21. data/spec/fixtures/data/0.9.9/distinct.bin +0 -0
  22. data/spec/fixtures/data/0.9.9/field_weights.bin +0 -0
  23. data/spec/fixtures/data/0.9.9/filter.bin +0 -0
  24. data/spec/fixtures/data/0.9.9/filter_array.bin +0 -0
  25. data/spec/fixtures/data/0.9.9/filter_array_exclude.bin +0 -0
  26. data/spec/fixtures/data/0.9.9/filter_boolean.bin +0 -0
  27. data/spec/fixtures/data/0.9.9/filter_floats.bin +0 -0
  28. data/spec/fixtures/data/0.9.9/filter_floats_exclude.bin +0 -0
  29. data/spec/fixtures/data/0.9.9/filter_range.bin +0 -0
  30. data/spec/fixtures/data/0.9.9/filter_range_exclude.bin +0 -0
  31. data/spec/fixtures/data/0.9.9/group.bin +0 -0
  32. data/spec/fixtures/data/0.9.9/index.bin +0 -0
  33. data/spec/fixtures/data/0.9.9/index_weights.bin +0 -0
  34. data/spec/fixtures/data/0.9.9/keywords_with_hits.bin +0 -0
  35. data/spec/fixtures/data/0.9.9/keywords_without_hits.bin +0 -0
  36. data/spec/fixtures/data/0.9.9/overrides.bin +0 -0
  37. data/spec/fixtures/data/0.9.9/phrase.bin +0 -0
  38. data/spec/fixtures/data/0.9.9/rank_mode.bin +0 -0
  39. data/spec/fixtures/data/0.9.9/select.bin +0 -0
  40. data/spec/fixtures/data/0.9.9/simple.bin +0 -0
  41. data/spec/fixtures/data/0.9.9/sort.bin +0 -0
  42. data/spec/fixtures/data/0.9.9/update_simple.bin +0 -0
  43. data/spec/fixtures/data/0.9.9/weights.bin +0 -0
  44. data/spec/fixtures/data/1.10/anchor.bin +0 -0
  45. data/spec/fixtures/data/1.10/any.bin +0 -0
  46. data/spec/fixtures/data/1.10/boolean.bin +0 -0
  47. data/spec/fixtures/data/1.10/comment.bin +0 -0
  48. data/spec/fixtures/data/1.10/distinct.bin +0 -0
  49. data/spec/fixtures/data/1.10/field_weights.bin +0 -0
  50. data/spec/fixtures/data/1.10/filter.bin +0 -0
  51. data/spec/fixtures/data/1.10/filter_array.bin +0 -0
  52. data/spec/fixtures/data/1.10/filter_array_exclude.bin +0 -0
  53. data/spec/fixtures/data/1.10/filter_boolean.bin +0 -0
  54. data/spec/fixtures/data/1.10/filter_floats.bin +0 -0
  55. data/spec/fixtures/data/1.10/filter_floats_exclude.bin +0 -0
  56. data/spec/fixtures/data/1.10/filter_range.bin +0 -0
  57. data/spec/fixtures/data/1.10/filter_range_exclude.bin +0 -0
  58. data/spec/fixtures/data/1.10/group.bin +0 -0
  59. data/spec/fixtures/data/1.10/index.bin +0 -0
  60. data/spec/fixtures/data/1.10/index_weights.bin +0 -0
  61. data/spec/fixtures/data/1.10/keywords_with_hits.bin +0 -0
  62. data/spec/fixtures/data/1.10/keywords_without_hits.bin +0 -0
  63. data/spec/fixtures/data/1.10/overrides.bin +0 -0
  64. data/spec/fixtures/data/1.10/phrase.bin +0 -0
  65. data/spec/fixtures/data/1.10/rank_mode.bin +0 -0
  66. data/spec/fixtures/data/1.10/select.bin +0 -0
  67. data/spec/fixtures/data/1.10/simple.bin +0 -0
  68. data/spec/fixtures/data/1.10/sort.bin +0 -0
  69. data/spec/fixtures/data/1.10/update_simple.bin +0 -0
  70. data/spec/fixtures/data/1.10/weights.bin +0 -0
  71. data/spec/fixtures/data/2.0.1/anchor.bin +0 -0
  72. data/spec/fixtures/data/2.0.1/any.bin +0 -0
  73. data/spec/fixtures/data/2.0.1/boolean.bin +0 -0
  74. data/spec/fixtures/data/2.0.1/comment.bin +0 -0
  75. data/spec/fixtures/data/2.0.1/distinct.bin +0 -0
  76. data/spec/fixtures/data/2.0.1/field_weights.bin +0 -0
  77. data/spec/fixtures/data/2.0.1/filter.bin +0 -0
  78. data/spec/fixtures/data/2.0.1/filter_array.bin +0 -0
  79. data/spec/fixtures/data/2.0.1/filter_array_exclude.bin +0 -0
  80. data/spec/fixtures/data/2.0.1/filter_boolean.bin +0 -0
  81. data/spec/fixtures/data/2.0.1/filter_floats.bin +0 -0
  82. data/spec/fixtures/data/2.0.1/filter_floats_exclude.bin +0 -0
  83. data/spec/fixtures/data/2.0.1/filter_range.bin +0 -0
  84. data/spec/fixtures/data/2.0.1/filter_range_exclude.bin +0 -0
  85. data/spec/fixtures/data/2.0.1/group.bin +0 -0
  86. data/spec/fixtures/data/2.0.1/index.bin +0 -0
  87. data/spec/fixtures/data/2.0.1/index_weights.bin +0 -0
  88. data/spec/fixtures/data/2.0.1/keywords_with_hits.bin +0 -0
  89. data/spec/fixtures/data/2.0.1/keywords_without_hits.bin +0 -0
  90. data/spec/fixtures/data/2.0.1/overrides.bin +0 -0
  91. data/spec/fixtures/data/2.0.1/phrase.bin +0 -0
  92. data/spec/fixtures/data/2.0.1/rank_mode.bin +0 -0
  93. data/spec/fixtures/data/2.0.1/select.bin +0 -0
  94. data/spec/fixtures/data/2.0.1/simple.bin +0 -0
  95. data/spec/fixtures/data/2.0.1/sort.bin +0 -0
  96. data/spec/fixtures/data/2.0.1/update_simple.bin +0 -0
  97. data/spec/fixtures/data/2.0.1/weights.bin +0 -0
  98. data/spec/fixtures/data/2.1.0/anchor.bin +0 -0
  99. data/spec/fixtures/data/2.1.0/any.bin +0 -0
  100. data/spec/fixtures/data/2.1.0/boolean.bin +0 -0
  101. data/spec/fixtures/data/2.1.0/comment.bin +0 -0
  102. data/spec/fixtures/data/2.1.0/distinct.bin +0 -0
  103. data/spec/fixtures/data/2.1.0/field_weights.bin +0 -0
  104. data/spec/fixtures/data/2.1.0/filter.bin +0 -0
  105. data/spec/fixtures/data/2.1.0/filter_array.bin +0 -0
  106. data/spec/fixtures/data/2.1.0/filter_array_exclude.bin +0 -0
  107. data/spec/fixtures/data/2.1.0/filter_boolean.bin +0 -0
  108. data/spec/fixtures/data/2.1.0/filter_floats.bin +0 -0
  109. data/spec/fixtures/data/2.1.0/filter_floats_exclude.bin +0 -0
  110. data/spec/fixtures/data/2.1.0/filter_range.bin +0 -0
  111. data/spec/fixtures/data/2.1.0/filter_range_exclude.bin +0 -0
  112. data/spec/fixtures/data/2.1.0/group.bin +0 -0
  113. data/spec/fixtures/data/2.1.0/index.bin +0 -0
  114. data/spec/fixtures/data/2.1.0/index_weights.bin +0 -0
  115. data/spec/fixtures/data/2.1.0/keywords_with_hits.bin +0 -0
  116. data/spec/fixtures/data/2.1.0/keywords_without_hits.bin +0 -0
  117. data/spec/fixtures/data/2.1.0/overrides.bin +0 -0
  118. data/spec/fixtures/data/2.1.0/phrase.bin +0 -0
  119. data/spec/fixtures/data/2.1.0/rank_mode.bin +0 -0
  120. data/spec/fixtures/data/2.1.0/select.bin +0 -0
  121. data/spec/fixtures/data/2.1.0/simple.bin +0 -0
  122. data/spec/fixtures/data/2.1.0/sort.bin +0 -0
  123. data/spec/fixtures/data/2.1.0/update_simple.bin +0 -0
  124. data/spec/fixtures/data/2.1.0/weights.bin +0 -0
  125. data/spec/fixtures/data_generator.0.9.8.php +0 -208
  126. data/spec/fixtures/data_generator.0.9.9.php +0 -5
  127. data/spec/fixtures/data_generator.1.10.php +0 -5
  128. data/spec/fixtures/data_generator.2.0.1.php +0 -5
  129. data/spec/fixtures/data_generator.2.1.0.php +0 -5
  130. data/spec/fixtures/data_generator.php +0 -223
  131. data/spec/fixtures/sphinxapi.0.9.8.php +0 -1228
  132. data/spec/fixtures/sphinxapi.0.9.9.php +0 -1646
  133. data/spec/fixtures/sphinxapi.1.10.php +0 -1728
  134. data/spec/fixtures/sphinxapi.2.0.1.php +0 -1731
  135. data/spec/fixtures/sphinxapi.2.1.0.php +0 -1752
  136. data/spec/fixtures/sql/conf.example.yml +0 -3
  137. data/spec/fixtures/sql/data.sql +0 -25000
  138. data/spec/fixtures/sql/data.tsv +0 -25000
  139. data/spec/fixtures/sql/structure.sql +0 -16
  140. data/spec/functional/connection_spec.rb +0 -64
  141. data/spec/functional/escaping_spec.rb +0 -49
  142. data/spec/functional/excerpt_spec.rb +0 -139
  143. data/spec/functional/keywords_spec.rb +0 -40
  144. data/spec/functional/persistance_spec.rb +0 -17
  145. data/spec/functional/search_spec.rb +0 -67
  146. data/spec/functional/status_spec.rb +0 -21
  147. data/spec/functional/update_spec.rb +0 -41
  148. data/spec/riddle/auto_version_spec.rb +0 -95
  149. data/spec/riddle/client_spec.rb +0 -11
  150. data/spec/riddle/configuration_spec.rb +0 -28
  151. data/spec/riddle/controller_spec.rb +0 -39
  152. data/spec/riddle/query/delete_spec.rb +0 -18
  153. data/spec/riddle/query/insert_spec.rb +0 -25
  154. data/spec/riddle/query/select_spec.rb +0 -226
  155. data/spec/riddle/query_spec.rb +0 -97
  156. data/spec/riddle_spec.rb +0 -27
  157. data/spec/spec_helper.rb +0 -34
  158. data/spec/support/binary_fixtures.rb +0 -18
  159. data/spec/support/sphinx.rb +0 -137
  160. data/spec/unit/client_spec.rb +0 -290
  161. data/spec/unit/configuration/common_spec.rb +0 -60
  162. data/spec/unit/configuration/distributed_index_spec.rb +0 -58
  163. data/spec/unit/configuration/index_spec.rb +0 -124
  164. data/spec/unit/configuration/indexer_spec.rb +0 -73
  165. data/spec/unit/configuration/realtime_index_spec.rb +0 -65
  166. data/spec/unit/configuration/searchd_spec.rb +0 -228
  167. data/spec/unit/configuration/source_spec.rb +0 -5
  168. data/spec/unit/configuration/sql_source_spec.rb +0 -137
  169. data/spec/unit/configuration/template_index_spec.rb +0 -91
  170. data/spec/unit/configuration/tsv_source_spec.rb +0 -53
  171. data/spec/unit/configuration/xml_source_spec.rb +0 -51
  172. data/spec/unit/configuration_spec.rb +0 -25
  173. data/spec/unit/filter_spec.rb +0 -38
  174. data/spec/unit/message_spec.rb +0 -94
  175. data/spec/unit/response_spec.rb +0 -64
  176. data/spec/unit/riddle_spec.rb +0 -17
@@ -1,60 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Riddle::Configuration::Common do
4
- it "should always be valid" do
5
- common = Riddle::Configuration::Common.new
6
- common.should be_valid
7
- end
8
-
9
- it "should support Sphinx's common settings" do
10
- settings = %w( lemmatizer_base on_json_attr_error json_autoconv_numbers
11
- json_autoconv_keynames rlp_root rlp_environment rlp_max_batch_size
12
- rlp_max_batch_docs )
13
- common = Riddle::Configuration::Common.new
14
-
15
- settings.each do |setting|
16
- common.should respond_to(setting.to_sym)
17
- common.should respond_to("#{setting}=".to_sym)
18
- end
19
- end
20
-
21
- it "should render a correct configuration" do
22
- common = Riddle::Configuration::Common.new
23
- common.common_sphinx_configuration = true
24
-
25
- common.render.should == <<-COMMON
26
- common
27
- {
28
- }
29
- COMMON
30
-
31
- common.lemmatizer_base = "/tmp"
32
- common.render.should == <<-COMMON
33
- common
34
- {
35
- lemmatizer_base = /tmp
36
- }
37
- COMMON
38
- end
39
-
40
- it "should not be present when common_sphinx_configuration is not set" do
41
- common = Riddle::Configuration::Common.new
42
- common.render.should be_nil
43
- end
44
-
45
- it "should not be present when common_sphinx_configuration is false" do
46
- common = Riddle::Configuration::Common.new
47
- common.common_sphinx_configuration = false
48
- common.render.should be_nil
49
- end
50
-
51
- it "should render when common_sphinx_configuration is true" do
52
- common = Riddle::Configuration::Common.new
53
- common.common_sphinx_configuration = true
54
- common.render.should == <<-COMMON
55
- common
56
- {
57
- }
58
- COMMON
59
- end
60
- end
@@ -1,58 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Riddle::Configuration::DistributedIndex do
4
- it "should not be valid without any indices" do
5
- index = Riddle::Configuration::DistributedIndex.new("dist1")
6
- index.should_not be_valid
7
- end
8
-
9
- it "should be valid with just local indices" do
10
- index = Riddle::Configuration::DistributedIndex.new("dist1")
11
- index.local_indices << "local_one"
12
- index.should be_valid
13
- end
14
-
15
- it "should be valid with just remote indices" do
16
- index = Riddle::Configuration::DistributedIndex.new("dist1")
17
- index.remote_indices << Riddle::Configuration::RemoteIndex.new("local", 3312, "remote_one")
18
- index.should be_valid
19
- end
20
-
21
- it "should be of type 'distributed'" do
22
- index = Riddle::Configuration::DistributedIndex.new("dist1")
23
- index.type.should == 'distributed'
24
- end
25
-
26
- it "should raise a ConfigurationError if rendering when not valid" do
27
- index = Riddle::Configuration::DistributedIndex.new("dist1")
28
- lambda { index.render }.should raise_error(Riddle::Configuration::ConfigurationError)
29
- end
30
-
31
- it "should render correctly if supplied settings are valid" do
32
- index = Riddle::Configuration::DistributedIndex.new("dist1")
33
-
34
- index.local_indices << "test1" << "test1stemmed"
35
- index.remote_indices <<
36
- Riddle::Configuration::RemoteIndex.new("localhost", 3313, "remote1") <<
37
- Riddle::Configuration::RemoteIndex.new("localhost", 3314, "remote2") <<
38
- Riddle::Configuration::RemoteIndex.new("localhost", 3314, "remote3")
39
- index.agent_blackhole << "testbox:3312:testindex1,testindex2"
40
-
41
- index.agent_connect_timeout = 1000
42
- index.agent_query_timeout = 3000
43
-
44
- index.render.should == <<-DISTINDEX
45
- index dist1
46
- {
47
- type = distributed
48
- local = test1
49
- local = test1stemmed
50
- agent = localhost:3313:remote1
51
- agent = localhost:3314:remote2,remote3
52
- agent_blackhole = testbox:3312:testindex1,testindex2
53
- agent_connect_timeout = 1000
54
- agent_query_timeout = 3000
55
- }
56
- DISTINDEX
57
- end
58
- end
@@ -1,124 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Riddle::Configuration::DistributedIndex do
4
- it "should be invalid without a name, sources or path if there's no parent" do
5
- index = Riddle::Configuration::Index.new(nil)
6
- index.should_not be_valid
7
-
8
- index.name = "test1"
9
- index.should_not be_valid
10
-
11
- index.sources << Riddle::Configuration::SQLSource.new("source", "mysql")
12
- index.should_not be_valid
13
-
14
- index.path = "a/path"
15
- index.should be_valid
16
-
17
- index.name = nil
18
- index.should_not be_valid
19
-
20
- index.name = "test1"
21
- index.sources.clear
22
- index.should_not be_valid
23
- end
24
-
25
- it "should be invalid without a name but not sources or path if it has a parent" do
26
- index = Riddle::Configuration::Index.new(nil)
27
- index.should_not be_valid
28
-
29
- index.name = "test1stemmed"
30
- index.should_not be_valid
31
-
32
- index.parent = "test1"
33
- index.should be_valid
34
- end
35
-
36
- it "should raise a ConfigurationError if rendering when not valid" do
37
- index = Riddle::Configuration::Index.new("test1")
38
- lambda { index.render }.should raise_error(Riddle::Configuration::ConfigurationError)
39
- end
40
-
41
- it "should render correctly if supplied settings are valid" do
42
- source = Riddle::Configuration::XMLSource.new("src1", "xmlpipe")
43
- source.xmlpipe_command = "ls /dev/null"
44
-
45
- index = Riddle::Configuration::Index.new("test1", source)
46
- index.path = "/var/data/test1"
47
- index.docinfo = "extern"
48
- index.mlock = 0
49
- index.morphologies << "stem_en" << "stem_ru" << "soundex"
50
- index.min_stemming_len = 1
51
- index.stopword_files << "/var/data/stopwords.txt" << "/var/data/stopwords2.txt"
52
- index.wordform_files << "/var/data/wordforms.txt"
53
- index.exception_files << "/var/data/exceptions.txt"
54
- index.min_word_len = 1
55
- index.charset_type = "utf-8"
56
- index.charset_table = "0..9, A..Z->a..z, _, a..z, U+410..U+42F->U+430..U+44F, U+430..U+44F"
57
- index.ignore_characters << "U+00AD"
58
- index.min_prefix_len = 0
59
- index.min_infix_len = 0
60
- index.prefix_field_names << "filename"
61
- index.infix_field_names << "url" << "domain"
62
- index.enable_star = true
63
- index.ngram_len = 1
64
- index.ngram_characters << "U+3000..U+2FA1F"
65
- index.phrase_boundaries << "." << "?" << "!" << "U+2026"
66
- index.phrase_boundary_step = 100
67
- index.html_strip = 0
68
- index.html_index_attrs = "img=alt,title; a=title"
69
- index.html_remove_element_tags << "style" << "script"
70
- index.preopen = 1
71
- index.ondisk_dict = 1
72
- index.inplace_enable = 1
73
- index.inplace_hit_gap = 0
74
- index.inplace_docinfo_gap = 0
75
- index.inplace_reloc_factor = 0.1
76
- index.inplace_write_factor = 0.1
77
- index.index_exact_words = 1
78
-
79
- index.render.should == <<-INDEX
80
- source src1
81
- {
82
- type = xmlpipe
83
- xmlpipe_command = ls /dev/null
84
- }
85
-
86
- index test1
87
- {
88
- path = /var/data/test1
89
- docinfo = extern
90
- mlock = 0
91
- morphology = stem_en, stem_ru, soundex
92
- min_stemming_len = 1
93
- stopwords = /var/data/stopwords.txt /var/data/stopwords2.txt
94
- wordforms = /var/data/wordforms.txt
95
- exceptions = /var/data/exceptions.txt
96
- min_word_len = 1
97
- charset_type = utf-8
98
- charset_table = 0..9, A..Z->a..z, _, a..z, U+410..U+42F->U+430..U+44F, U+430..U+44F
99
- ignore_chars = U+00AD
100
- min_prefix_len = 0
101
- min_infix_len = 0
102
- prefix_fields = filename
103
- infix_fields = url, domain
104
- enable_star = 1
105
- ngram_len = 1
106
- ngram_chars = U+3000..U+2FA1F
107
- phrase_boundary = ., ?, !, U+2026
108
- phrase_boundary_step = 100
109
- html_strip = 0
110
- html_index_attrs = img=alt,title; a=title
111
- html_remove_elements = style, script
112
- preopen = 1
113
- ondisk_dict = 1
114
- inplace_enable = 1
115
- inplace_hit_gap = 0
116
- inplace_docinfo_gap = 0
117
- inplace_reloc_factor = 0.1
118
- inplace_write_factor = 0.1
119
- index_exact_words = 1
120
- source = src1
121
- }
122
- INDEX
123
- end
124
- end
@@ -1,73 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Riddle::Configuration::Indexer do
4
- it "should always be valid" do
5
- indexer = Riddle::Configuration::Indexer.new
6
- indexer.should be_valid
7
- end
8
-
9
- it "should support Sphinx's indexer settings" do
10
- settings = %w( mem_limit max_iops max_iosize )
11
- indexer = Riddle::Configuration::Indexer.new
12
-
13
- settings.each do |setting|
14
- indexer.should respond_to(setting.to_sym)
15
- indexer.should respond_to("#{setting}=".to_sym)
16
- end
17
- end
18
-
19
- it "should render a correct configuration" do
20
- indexer = Riddle::Configuration::Indexer.new
21
-
22
- indexer.render.should == <<-INDEXER
23
- indexer
24
- {
25
- }
26
- INDEXER
27
-
28
- indexer.mem_limit = "32M"
29
- indexer.render.should == <<-INDEXER
30
- indexer
31
- {
32
- mem_limit = 32M
33
- }
34
- INDEXER
35
- end
36
-
37
- it "should render shared settings when common_sphinx_configuration is not set" do
38
- indexer = Riddle::Configuration::Indexer.new
39
- indexer.rlp_root = '/tmp'
40
-
41
- indexer.render.should == <<-INDEXER
42
- indexer
43
- {
44
- rlp_root = /tmp
45
- }
46
- INDEXER
47
- end
48
-
49
- it "should render shared settings when common_sphinx_configuration is false" do
50
- indexer = Riddle::Configuration::Indexer.new
51
- indexer.common_sphinx_configuration = false
52
- indexer.rlp_root = '/tmp'
53
-
54
- indexer.render.should == <<-INDEXER
55
- indexer
56
- {
57
- rlp_root = /tmp
58
- }
59
- INDEXER
60
- end
61
-
62
- it "should not render shared settings when common_sphinx_configuration is true" do
63
- indexer = Riddle::Configuration::Indexer.new
64
- indexer.common_sphinx_configuration = true
65
- indexer.rlp_root = '/tmp'
66
-
67
- indexer.render.should == <<-INDEXER
68
- indexer
69
- {
70
- }
71
- INDEXER
72
- end
73
- end
@@ -1,65 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Riddle::Configuration::RealtimeIndex do
4
- let(:index) { Riddle::Configuration::RealtimeIndex.new('rt1') }
5
-
6
- describe '#valid?' do
7
- it "should not be valid without a name" do
8
- index.name = nil
9
- index.path = 'foo'
10
- index.should_not be_valid
11
- end
12
-
13
- it "should not be valid without a path" do
14
- index.path = nil
15
- index.should_not be_valid
16
- end
17
-
18
- it "should be valid with a name and path" do
19
- index.path = 'foo'
20
- index.should be_valid
21
- end
22
- end
23
-
24
- describe '#type' do
25
- it "should be 'rt'" do
26
- index.type.should == 'rt'
27
- end
28
- end
29
-
30
- describe '#render' do
31
- it "should raise a ConfigurationError if rendering when not valid" do
32
- lambda {
33
- index.render
34
- }.should raise_error(Riddle::Configuration::ConfigurationError)
35
- end
36
-
37
- it "should render correctly if supplied settings are valid" do
38
- index.path = '/var/data/rt'
39
- index.rt_mem_limit = '512M'
40
- index.rt_field << 'title' << 'content'
41
-
42
- index.rt_attr_uint << 'gid'
43
- index.rt_attr_bigint << 'guid'
44
- index.rt_attr_float << 'gpa'
45
- index.rt_attr_timestamp << 'ts_added'
46
- index.rt_attr_string << 'author'
47
-
48
- index.render.should == <<-RTINDEX
49
- index rt1
50
- {
51
- type = rt
52
- path = /var/data/rt
53
- rt_mem_limit = 512M
54
- rt_field = title
55
- rt_field = content
56
- rt_attr_uint = gid
57
- rt_attr_bigint = guid
58
- rt_attr_float = gpa
59
- rt_attr_timestamp = ts_added
60
- rt_attr_string = author
61
- }
62
- RTINDEX
63
- end
64
- end
65
- end
@@ -1,228 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Riddle::Configuration::Searchd do
4
- if Riddle.loaded_version.to_f >= 0.9
5
- it "should be invalid without a listen or pid_file" do
6
- searchd = Riddle::Configuration::Searchd.new
7
- searchd.should_not be_valid
8
-
9
- searchd.port = 3312
10
- searchd.should_not be_valid
11
-
12
- searchd.pid_file = "file.pid"
13
- searchd.should be_valid
14
-
15
- searchd.port = nil
16
- searchd.listen = nil
17
- searchd.should_not be_valid
18
-
19
- searchd.listen = "localhost:3312"
20
- searchd.should be_valid
21
- end
22
- else
23
- it "should be invalid without a port or pid_file" do
24
- searchd = Riddle::Configuration::Searchd.new
25
- searchd.should_not be_valid
26
-
27
- searchd.port = 3312
28
- searchd.should_not be_valid
29
-
30
- searchd.pid_file = "file.pid"
31
- searchd.should be_valid
32
-
33
- searchd.port = nil
34
- searchd.should_not be_valid
35
- end
36
- end
37
-
38
- it "should raise a ConfigurationError if rendering but not valid" do
39
- searchd = Riddle::Configuration::Searchd.new
40
- searchd.should_not be_valid
41
- lambda { searchd.render }.should raise_error(Riddle::Configuration::ConfigurationError)
42
- end
43
-
44
- it "should support Sphinx's searchd settings" do
45
- settings = %w( listen address port log query_log read_timeout
46
- client_timeout max_children pid_file max_matches seamless_rotate
47
- preopen_indexes unlink_old attr_flush_period ondisk_dict_default
48
- max_packet_size mva_updates_pool crash_log_path max_filters
49
- max_filter_values )
50
- searchd = Riddle::Configuration::Searchd.new
51
-
52
- settings.each do |setting|
53
- searchd.should respond_to(setting.to_sym)
54
- searchd.should respond_to("#{setting}=".to_sym)
55
- end
56
- end
57
-
58
- it "should support setting listen to a port number" do
59
- searchd = Riddle::Configuration::Searchd.new
60
- searchd.port = 3312
61
- searchd.pid_file = "file.pid"
62
- searchd.listen = 3312
63
-
64
- if Riddle.loaded_version.to_f >= 0.9
65
- searchd.render.should == <<-SEARCHD
66
- searchd
67
- {
68
- listen = 3312
69
- pid_file = file.pid
70
- }
71
- SEARCHD
72
- else
73
- searchd.render.should == <<-SEARCHD
74
- searchd
75
- {
76
- port = 3312
77
- pid_file = file.pid
78
- }
79
- SEARCHD
80
- end
81
- end
82
-
83
- it "should render a correct configuration with valid settings" do
84
- searchd = Riddle::Configuration::Searchd.new
85
- searchd.port = 3312
86
- searchd.pid_file = "file.pid"
87
-
88
- if Riddle.loaded_version.to_f >= 0.9
89
- searchd.render.should == <<-SEARCHD
90
- searchd
91
- {
92
- listen = 3312
93
- pid_file = file.pid
94
- }
95
- SEARCHD
96
- else
97
- searchd.render.should == <<-SEARCHD
98
- searchd
99
- {
100
- port = 3312
101
- pid_file = file.pid
102
- }
103
- SEARCHD
104
- end
105
- end
106
-
107
- it "should render with a client key if one is provided" do
108
- searchd = Riddle::Configuration::Searchd.new
109
- searchd.port = 3312
110
- searchd.pid_file = 'file.pid'
111
- searchd.client_key = 'secret'
112
-
113
- if Riddle.loaded_version.to_f >= 0.9
114
- searchd.render.should == <<-SEARCHD
115
- searchd
116
- {
117
- listen = 3312
118
- pid_file = file.pid
119
- client_key = secret
120
- }
121
- SEARCHD
122
- else
123
- searchd.render.should == <<-SEARCHD
124
- searchd
125
- {
126
- port = 3312
127
- pid_file = file.pid
128
- client_key = secret
129
- }
130
- SEARCHD
131
- end
132
- end
133
-
134
- if Riddle.loaded_version.to_f >= 0.9
135
- it "should render with mysql41 on the default port if true" do
136
- searchd = Riddle::Configuration::Searchd.new
137
- searchd.mysql41 = true
138
- searchd.pid_file = 'file.pid'
139
-
140
- searchd.render.should == <<-SEARCHD
141
- searchd
142
- {
143
- listen = 9306:mysql41
144
- pid_file = file.pid
145
- }
146
- SEARCHD
147
- end
148
-
149
- it "should render with mysql41 on a given port" do
150
- searchd = Riddle::Configuration::Searchd.new
151
- searchd.mysql41 = 9307
152
- searchd.pid_file = 'file.pid'
153
-
154
- searchd.render.should == <<-SEARCHD
155
- searchd
156
- {
157
- listen = 9307:mysql41
158
- pid_file = file.pid
159
- }
160
- SEARCHD
161
- end
162
-
163
- it "allows for both normal and mysql41 connections" do
164
- searchd = Riddle::Configuration::Searchd.new
165
- searchd.mysql41 = true
166
- searchd.port = 9312
167
- searchd.pid_file = 'file.pid'
168
-
169
- searchd.render.should == <<-SEARCHD
170
- searchd
171
- {
172
- listen = 9312
173
- listen = 9306:mysql41
174
- pid_file = file.pid
175
- }
176
- SEARCHD
177
- end
178
-
179
- it "uses given address for mysql41 connections" do
180
- searchd = Riddle::Configuration::Searchd.new
181
- searchd.mysql41 = true
182
- searchd.address = '127.0.0.1'
183
- searchd.pid_file = 'file.pid'
184
-
185
- searchd.render.should == <<-SEARCHD
186
- searchd
187
- {
188
- listen = 127.0.0.1:9306:mysql41
189
- pid_file = file.pid
190
- }
191
- SEARCHD
192
- end
193
-
194
- it "applies the given address to both normal and mysql41 connections" do
195
- searchd = Riddle::Configuration::Searchd.new
196
- searchd.mysql41 = true
197
- searchd.port = 9312
198
- searchd.address = 'sphinx.server.local'
199
- searchd.pid_file = 'file.pid'
200
-
201
- searchd.render.should == <<-SEARCHD
202
- searchd
203
- {
204
- listen = sphinx.server.local:9312
205
- listen = sphinx.server.local:9306:mysql41
206
- pid_file = file.pid
207
- }
208
- SEARCHD
209
- end
210
-
211
- it 'maintains the address and port settings without rendering them' do
212
- searchd = Riddle::Configuration::Searchd.new
213
- searchd.port = 9312
214
- searchd.address = 'sphinx.server.local'
215
- searchd.pid_file = 'file.pid'
216
-
217
- searchd.render.should == <<-SEARCHD
218
- searchd
219
- {
220
- listen = sphinx.server.local:9312
221
- pid_file = file.pid
222
- }
223
- SEARCHD
224
- searchd.address.should == 'sphinx.server.local'
225
- searchd.port.should == 9312
226
- end
227
- end
228
- end