forked from karmi/retire
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[karmi#209] Added support for creating index aliases with configurati…
…on, cleaned up * You can do `@index.add_alias 'index-aliased', :routing => '1'` now * Fixed incorrect curl-formatted logs from alias operations * More consistent naming * Fixed expectations for Ruby 1.8 * Added integration test Fixes karmi#209.
- Loading branch information
Showing
3 changed files
with
100 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
require 'test_helper' | ||
|
||
module Tire | ||
|
||
class IndexAliasesIntegrationTest < Test::Unit::TestCase | ||
include Test::Integration | ||
|
||
context "With a filtered alias" do | ||
setup do | ||
|
||
@index = Tire.index 'index-original' do | ||
delete | ||
create | ||
end | ||
|
||
end | ||
|
||
teardown { Tire.index('index-original').delete } | ||
|
||
should "create the alias" do | ||
@index.add_alias 'index-aliased' | ||
assert_equal 1, @index.aliases.size | ||
end | ||
|
||
should "find only portion of documents in the filtered alias" do | ||
Tire.index 'index-original' do | ||
add_alias 'index-aliased', :filter => { :term => { :user => 'anne' } } | ||
store :title => 'Document 1', :user => 'anne' | ||
store :title => 'Document 2', :user => 'mary' | ||
|
||
refresh | ||
end | ||
|
||
assert_equal 2, Tire.search('index-original') { query { all } }.results.size | ||
assert_equal 1, Tire.search('index-aliased') { query { all } }.results.size | ||
end | ||
|
||
should "remove the alias" do | ||
@index.add_alias 'index-aliased' | ||
assert_equal 1, @index.aliases.size | ||
|
||
@index.remove_alias 'index-aliased' | ||
assert_equal 0, @index.aliases.size | ||
|
||
assert_raise Tire::Search::SearchRequestFailed do | ||
Tire.search('index-aliased') { query { all } }.results | ||
end | ||
end | ||
|
||
should "retrieve a list of aliases for an index" do | ||
@index.add_alias 'index-aliased' | ||
|
||
assert_equal ['index-aliased'], @index.aliases | ||
end | ||
|
||
should "retrieve the properties of an alias" do | ||
@index.add_alias 'index-aliased', :routing => '1' | ||
|
||
assert_equal( | ||
{ 'index_routing' => '1', | ||
'search_routing' => '1' }, | ||
@index.aliases('index-aliased') ) | ||
end | ||
end | ||
|
||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters