elasticsearch-node 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/.travis.yml +9 -0
- data/COPYING.md +27 -0
- data/Gemfile +6 -0
- data/README.md +93 -0
- data/Rakefile +31 -0
- data/bin/install_elasticsearch +14 -0
- data/configs/testing/config/elasticsearch.yml +32 -0
- data/configs/testing/config/logging.yml +31 -0
- data/elasticsearch-node.gemspec +26 -0
- data/fetch_es.rb +8 -0
- data/lib/elasticsearch-node/client_provider.rb +22 -0
- data/lib/elasticsearch-node/embedded.rb +57 -0
- data/lib/elasticsearch-node/external.rb +73 -0
- data/lib/elasticsearch-node/remote.rb +24 -0
- data/lib/elasticsearch-node/version.rb +5 -0
- data/lib/elasticsearch-node.rb +40 -0
- data/test/nodes/client_provider_test.rb +56 -0
- data/test/nodes/embedded_test.rb +17 -0
- data/test/nodes/external_test.rb +29 -0
- data/test/test_helper.rb +3 -0
- metadata +93 -0
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/COPYING.md
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
ElasticSearch
|
2
|
+
Copyright 2009-2011 Elastic Search and Shay Banon
|
3
|
+
|
4
|
+
See full details in elasticsearch/LICENSE.txt and elasticsearch/NOTICE.txt.
|
5
|
+
|
6
|
+
Ruby portions are licensed under MIT:
|
7
|
+
|
8
|
+
Copyright (c) 2011 Florian Gilcher <florian.gilcher@asquera.de>, Felix Gilcher <felix.gilcher@asquera.de>
|
9
|
+
|
10
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
11
|
+
a copy of this software and associated documentation files (the
|
12
|
+
"Software"), to deal in the Software without restriction, including
|
13
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
14
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
15
|
+
permit persons to whom the Software is furnished to do so, subject to
|
16
|
+
the following conditions:
|
17
|
+
|
18
|
+
The above copyright notice and this permission notice shall be
|
19
|
+
included in all copies or substantial portions of the Software.
|
20
|
+
|
21
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
22
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
23
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
24
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
25
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
26
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
27
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,93 @@
|
|
1
|
+
# elasticsearch-node
|
2
|
+
|
3
|
+
[![Build Status](https://secure.travis-ci.org/Asquera/elasticsearch-node.png?branch=master)](http://travis-ci.org/Asquera/elasticsearch-node)
|
4
|
+
|
5
|
+
`elasticsearch-node` is a Ruby library to start, manipulate and shutdown elasticsearch nodes in a controlled fashion. On JRuby, it also provides a native binding to this functionality. Its very handy in testing environments.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
```
|
10
|
+
gem install elasticsearch-node
|
11
|
+
```
|
12
|
+
|
13
|
+
After installation, make sure to run:
|
14
|
+
|
15
|
+
```
|
16
|
+
install_elasticsearch
|
17
|
+
```
|
18
|
+
|
19
|
+
For legacy versions, use:
|
20
|
+
|
21
|
+
```
|
22
|
+
ES_VERSION=0.18.7
|
23
|
+
```
|
24
|
+
|
25
|
+
## Usage
|
26
|
+
|
27
|
+
```
|
28
|
+
require 'elasticsearch-node/external'
|
29
|
+
require 'elasticsearch-node/embedded'
|
30
|
+
require 'elasticsearch-node/remote'
|
31
|
+
|
32
|
+
external = ElasticSearch::Node::External "gateway.type" => "none"
|
33
|
+
embedded = ElasticSearch::Node::Embedded "gateway.type" => "none"
|
34
|
+
remote = ElasticSearch::Node::Remote '127.0.0.1', 9200
|
35
|
+
|
36
|
+
[external, embedded, remote].each do |node|
|
37
|
+
puts node.ip
|
38
|
+
puts node.port
|
39
|
+
end
|
40
|
+
|
41
|
+
embedded.client
|
42
|
+
```
|
43
|
+
|
44
|
+
`elasticsearch-node` provides 3 types of nodes: `External`, `Embedded` and `Remote`. They differ in capabilities:
|
45
|
+
|
46
|
+
* `External` nodes are started as an external process and can be started, configured and shut down
|
47
|
+
* `Embedded` nodes are only available on JRuby and start and embedded Elasticsearch instance. In addition to the capabilities of external nodes, embedded nodes expose the `client` method, which returns a vanilla Elasticsearch client
|
48
|
+
* `Remote` nodes a standin for nodes not under control by this process: they are only configured using port and ip and have not further capabilities.
|
49
|
+
|
50
|
+
## Clients
|
51
|
+
|
52
|
+
`elasticsearch-node` also provides a protocol to associate clients with nodes. See this example:
|
53
|
+
|
54
|
+
```
|
55
|
+
n = ElasticSearch::Node::External.new do
|
56
|
+
def client
|
57
|
+
conn = Faraday.new(:url => "http://#{self.ip}:#{self.port}") do |builder|
|
58
|
+
builder.adapter :net_http
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
n.client #=> <#Faraday::Connection...
|
64
|
+
|
65
|
+
# or alternatively:
|
66
|
+
|
67
|
+
module HTTPClient
|
68
|
+
def client
|
69
|
+
conn = Faraday.new(:url => "http://#{self.ip}:#{self.port}") do |builder|
|
70
|
+
builder.adapter :net_http
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
n = ElasticSearch::Node::External.new :client_module => HTTPClient
|
76
|
+
```
|
77
|
+
|
78
|
+
This allows client implementations to be independent of which kind of nodes they run on (as long as they don't rely on those features).
|
79
|
+
|
80
|
+
## Final Remarks
|
81
|
+
|
82
|
+
Please be aware that this library does not add any `at_exit`-hooks to your application. Shutdown must be taken care of, as elasticsearch takes some seconds to shut down and killing it can lead to data corruption. In most cases, its as easy as:
|
83
|
+
|
84
|
+
at_exit { node.close }
|
85
|
+
|
86
|
+
## Flaws
|
87
|
+
|
88
|
+
* No windows support at the moment.
|
89
|
+
* No 1.8 support at the moment.
|
90
|
+
|
91
|
+
### License
|
92
|
+
|
93
|
+
See `COPYING.md` for all details.
|
data/Rakefile
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'rubygems' unless defined?(Gem)
|
2
|
+
require 'rubygems/specification'
|
3
|
+
require 'rake/gempackagetask'
|
4
|
+
require 'rake/testtask'
|
5
|
+
|
6
|
+
def gemspec
|
7
|
+
@gemspec ||= begin
|
8
|
+
file = File.expand_path("elasticsearch-node.gemspec")
|
9
|
+
::Gem::Specification.load(file)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
desc "Validates the gemspec"
|
14
|
+
task :gemspec do
|
15
|
+
gemspec.validate
|
16
|
+
end
|
17
|
+
|
18
|
+
Rake::GemPackageTask.new(gemspec) do |pkg|
|
19
|
+
pkg.gem_spec = gemspec
|
20
|
+
end
|
21
|
+
|
22
|
+
task :package => :gemspec
|
23
|
+
|
24
|
+
Rake::TestTask.new(:test) do |test|
|
25
|
+
test.libs << "test"
|
26
|
+
test.pattern = 'test/**/*_test.rb'
|
27
|
+
|
28
|
+
test.verbose = true
|
29
|
+
end
|
30
|
+
|
31
|
+
task :default => :test
|
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
es_version = ENV['ES_VERSION'] || "0.19.1"
|
4
|
+
|
5
|
+
puts "Installing elasticsearch-#{es_version}.
|
6
|
+
To install a different version, specify it using the ES_VERSION environment variable.
|
7
|
+
ES_VERSION=0.18.7 install_elasticsearch"
|
8
|
+
|
9
|
+
Dir.chdir(File.dirname(File.dirname(__FILE__)))
|
10
|
+
|
11
|
+
`curl https://github.com/downloads/elasticsearch/elasticsearch/elasticsearch-#{es_version}.tar.gz -L -o elasticsearch.tar.gz`
|
12
|
+
`tar xvf elasticsearch.tar.gz`
|
13
|
+
#mv elasticsearch-$ES_VERSION elasticsearch
|
14
|
+
File.unlink "elasticsearch.tar.gz"
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# The cluster name
|
2
|
+
#cluster.name: elasticsearch
|
3
|
+
|
4
|
+
gateway.type: none
|
5
|
+
|
6
|
+
# Path Settings
|
7
|
+
#path.conf: "/Users/skade/Code/elsearch/elsearch-node/configs/testing/config"
|
8
|
+
#path.data: /path/to/data
|
9
|
+
#path.work: /path/to/work
|
10
|
+
#path.logs: /path/to/logs
|
11
|
+
|
12
|
+
# Force all memory to be locked, forcing the JVM to never swap
|
13
|
+
#bootstrap.mlockall: true
|
14
|
+
|
15
|
+
# Gateway Settings
|
16
|
+
# Controls when to start the initial recovery process when starting a new cluster
|
17
|
+
# allowing for better reused of existing data during recovery.
|
18
|
+
#gateway.recover_after_nodes: 1
|
19
|
+
#gateway.recover_after_time: 5m
|
20
|
+
#gateway.expected_nodes: 2
|
21
|
+
|
22
|
+
# Controls the minimum number of master eligible nodes this node should "see"
|
23
|
+
# in order to operate within the cluster.
|
24
|
+
# Set this to a higher value (2-4) when running more than 2 nodes in the cluster
|
25
|
+
#discovery.zen.minimum_master_nodes: 1
|
26
|
+
|
27
|
+
# The time to wait for ping responses from other nodes when doing node discovery
|
28
|
+
#discovery.zen.ping.timeout: 3s
|
29
|
+
|
30
|
+
# Unicast Discovery (disable multicast)
|
31
|
+
#discovery.zen.ping.multicast.enabled: false
|
32
|
+
#discovery.zen.ping.unicast.hosts: ["host1", "host2"]
|
@@ -0,0 +1,31 @@
|
|
1
|
+
rootLogger: INFO, console, file
|
2
|
+
logger:
|
3
|
+
# log action execution errors for easier debugging
|
4
|
+
action: DEBUG
|
5
|
+
# reduce the logging for aws, too much is logged under the default INFO
|
6
|
+
com.amazonaws: WARN
|
7
|
+
|
8
|
+
# gateway
|
9
|
+
gateway: DEBUG
|
10
|
+
index.gateway: DEBUG
|
11
|
+
|
12
|
+
# peer shard recovery
|
13
|
+
index.shard.recovery: DEBUG
|
14
|
+
|
15
|
+
# discovery
|
16
|
+
discovery: TRACE
|
17
|
+
|
18
|
+
appender:
|
19
|
+
console:
|
20
|
+
type: console
|
21
|
+
layout:
|
22
|
+
type: consolePattern
|
23
|
+
conversionPattern: "[%d{ISO8601}][%-5p][%-25c] %m%n"
|
24
|
+
|
25
|
+
file:
|
26
|
+
type: dailyRollingFile
|
27
|
+
file: ${path.logs}/${cluster.name}.log
|
28
|
+
datePattern: "'.'yyyy-MM-dd"
|
29
|
+
layout:
|
30
|
+
type: pattern
|
31
|
+
conversionPattern: "[%d{ISO8601}][%-5p][%-25c] %m%n"
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "elasticsearch-node/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "elasticsearch-node"
|
7
|
+
s.version = Elsearch::Node::VERSION
|
8
|
+
s.authors = ["Florian Gilcher"]
|
9
|
+
s.email = ["florian.gilcher@asquera.de"]
|
10
|
+
s.homepage = "http://github.com/Asquera/elasticsearch-node"
|
11
|
+
s.summary = %q{Helper gem to install and start an elasticsearch node}
|
12
|
+
s.description = %q{Helper gem to install and start an elasticsearch node}
|
13
|
+
|
14
|
+
s.rubyforge_project = "elasticsearch-node"
|
15
|
+
|
16
|
+
s.files = (
|
17
|
+
`git ls-files`.split("\n") +
|
18
|
+
Dir["elasticsearch/{bin,config,lib,README.textile,NOTICE.txt,LICENSE.txt}"]
|
19
|
+
).uniq
|
20
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
21
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
22
|
+
s.require_paths = ["lib"]
|
23
|
+
|
24
|
+
s.add_development_dependency "riot"
|
25
|
+
s.add_development_dependency "faraday"
|
26
|
+
end
|
data/fetch_es.rb
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
es_version = ENV['ES_VERSION'] || "0.19.1"
|
4
|
+
|
5
|
+
`curl https://github.com/downloads/elasticsearch/elasticsearch/elasticsearch-#{es_version}.tar.gz -L -o elasticsearch.tar.gz`
|
6
|
+
`tar xvf elasticsearch.tar.gz`
|
7
|
+
#mv elasticsearch-$ES_VERSION elasticsearch
|
8
|
+
File.unlink "elasticsearch-#{es_version}.tar.gz"
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module ElasticSearch
|
2
|
+
module ClientProvider
|
3
|
+
def self.included(base)
|
4
|
+
base.extend(ClassMethods)
|
5
|
+
end
|
6
|
+
|
7
|
+
module ClassMethods
|
8
|
+
attr_accessor :default_client_module
|
9
|
+
end
|
10
|
+
|
11
|
+
def initialize(opts = {}, &block)
|
12
|
+
if block
|
13
|
+
mod = Module.new(&block)
|
14
|
+
extend mod
|
15
|
+
elsif opts[:client_module]
|
16
|
+
extend opts[:client_module]
|
17
|
+
elsif self.class.default_client_module
|
18
|
+
extend self.class.default_client_module
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require 'elasticsearch-node'
|
2
|
+
require 'jruby'
|
3
|
+
|
4
|
+
Dir["#{ElasticSearch::Node.lib}/*.jar"].each do |jar|
|
5
|
+
require jar
|
6
|
+
end
|
7
|
+
|
8
|
+
module ElasticSearch
|
9
|
+
module Node
|
10
|
+
class Embedded
|
11
|
+
include ElasticSearch::ClientProvider
|
12
|
+
|
13
|
+
def initialize(opts = {})
|
14
|
+
node_builder = org.elasticsearch.node.NodeBuilder.nodeBuilder.loadConfigSettings(true)
|
15
|
+
settings_builder = org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder
|
16
|
+
|
17
|
+
if opts[:config]
|
18
|
+
settings_builder.put("path.home", opts[:config])
|
19
|
+
end
|
20
|
+
|
21
|
+
settings_builder.put(opts[:settings]) if opts[:settings]
|
22
|
+
|
23
|
+
tuple = org.elasticsearch.node.internal.InternalSettingsPerparer.prepareSettings(settings_builder.build, true)
|
24
|
+
org.elasticsearch.common.logging.log4j.LogConfigurator.configure(tuple.v1());
|
25
|
+
@node = node_builder.settings(settings_builder).node
|
26
|
+
super(opts)
|
27
|
+
end
|
28
|
+
|
29
|
+
def port
|
30
|
+
Integer(socket_address.port)
|
31
|
+
end
|
32
|
+
|
33
|
+
def ip
|
34
|
+
socket_address.host_string
|
35
|
+
end
|
36
|
+
|
37
|
+
def client
|
38
|
+
@node.client
|
39
|
+
end
|
40
|
+
|
41
|
+
def close
|
42
|
+
@node.close
|
43
|
+
end
|
44
|
+
|
45
|
+
private
|
46
|
+
|
47
|
+
def http_server
|
48
|
+
@node.injector.getInstance(org.elasticsearch.http.HttpServer.java_class)
|
49
|
+
end
|
50
|
+
|
51
|
+
def socket_address
|
52
|
+
http_server.info.address.publishAddress.address
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
require 'elasticsearch-node'
|
2
|
+
|
3
|
+
module ElasticSearch
|
4
|
+
module Node
|
5
|
+
class External
|
6
|
+
include ElasticSearch::ClientProvider
|
7
|
+
|
8
|
+
attr_accessor :pid
|
9
|
+
|
10
|
+
def initialize(opts = {})
|
11
|
+
if opts[:config]
|
12
|
+
ENV["ES_HOME"] = ElasticSearch::Node.config(opts[:config])
|
13
|
+
end
|
14
|
+
|
15
|
+
commandline = opts.map {|opt,value| "-Des.#{opt}=#{value}" }.join(" ")
|
16
|
+
|
17
|
+
capture_ip_and_port do
|
18
|
+
self.pid = Kernel.spawn("#{Node.binary} -f #{commandline}", :out => :out, :err => :err)
|
19
|
+
end
|
20
|
+
|
21
|
+
super(opts)
|
22
|
+
end
|
23
|
+
|
24
|
+
def port
|
25
|
+
unless @port
|
26
|
+
parse_ip_and_port
|
27
|
+
end
|
28
|
+
|
29
|
+
@port
|
30
|
+
end
|
31
|
+
|
32
|
+
def ip
|
33
|
+
unless @ip
|
34
|
+
parse_ip_and_port
|
35
|
+
end
|
36
|
+
|
37
|
+
@ip
|
38
|
+
end
|
39
|
+
|
40
|
+
def close
|
41
|
+
$stderr.puts "Killing ElasticSearch node: #{pid}"
|
42
|
+
Process.kill 15, pid
|
43
|
+
begin
|
44
|
+
Process.waitpid pid
|
45
|
+
rescue Errno::ECHILD
|
46
|
+
# Possible, if process is already gone
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
private
|
51
|
+
def capture_ip_and_port(&block)
|
52
|
+
read, write = IO.pipe
|
53
|
+
|
54
|
+
old_stdout = $stdout.dup
|
55
|
+
$stdout.reopen(write)
|
56
|
+
|
57
|
+
yield
|
58
|
+
|
59
|
+
read.each do |line|
|
60
|
+
old_stdout << line
|
61
|
+
|
62
|
+
if line =~ /\[http\s*\].*\/(.*):([0-9]+)/
|
63
|
+
@ip = $1
|
64
|
+
@port = Integer($2)
|
65
|
+
break
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
$stdout.reopen(old_stdout)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module ElasticSearch
|
2
|
+
module Node
|
3
|
+
class Remote
|
4
|
+
include ElasticSearch::ClientProvider
|
5
|
+
|
6
|
+
attr_accessor :port, :ip
|
7
|
+
|
8
|
+
def initialize(port, ip)
|
9
|
+
this.port = port
|
10
|
+
this.ip = ip
|
11
|
+
end
|
12
|
+
|
13
|
+
def port
|
14
|
+
Integer(@port)
|
15
|
+
end
|
16
|
+
|
17
|
+
def close
|
18
|
+
raise "Remote Nodes cannot be closed directly, please use a shutdown request"
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require "elasticsearch-node/version"
|
2
|
+
require 'elasticsearch-node/client_provider'
|
3
|
+
|
4
|
+
module ElasticSearch
|
5
|
+
module Node
|
6
|
+
attr_accessor :version
|
7
|
+
|
8
|
+
def self.root(*args)
|
9
|
+
File.join(File.dirname(__FILE__), "..", *args)
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.path
|
13
|
+
File.expand_path(File.join(root, "elasticsearch-#{version}"))
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.binary
|
17
|
+
File.join(path, 'bin', 'elasticsearch')
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.version
|
21
|
+
`#{binary} -v`
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.lib
|
25
|
+
File.join(path, 'lib')
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.config(name)
|
29
|
+
root('configs', name.to_s, "config")
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.default_config(name)
|
33
|
+
ENV["ES_JAVA_OPTS"] = "-Des.path.conf=#{self.config(name)}"
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.version
|
37
|
+
@version || ENV["ES_VERSION"] || "0.19.1"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'elasticsearch-node/external'
|
3
|
+
|
4
|
+
module DefaultClient
|
5
|
+
def client
|
6
|
+
conn = Faraday.new(:url => "http://#{self.ip}:#{self.port}") do |builder|
|
7
|
+
builder.adapter :net_http
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
context "An external node" do
|
13
|
+
context "with inline client definition" do
|
14
|
+
setup do
|
15
|
+
ElasticSearch::Node::External.new do
|
16
|
+
def client
|
17
|
+
conn = Faraday.new(:url => "http://#{self.ip}:#{self.port}") do |builder|
|
18
|
+
builder.adapter :net_http
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
teardown do
|
25
|
+
topic.close
|
26
|
+
end
|
27
|
+
|
28
|
+
asserts(:client).kind_of?(Faraday::Connection)
|
29
|
+
end
|
30
|
+
|
31
|
+
context "with client module as option" do
|
32
|
+
setup do
|
33
|
+
ElasticSearch::Node::External.new(:client_module => DefaultClient)
|
34
|
+
end
|
35
|
+
|
36
|
+
teardown do
|
37
|
+
topic.close
|
38
|
+
end
|
39
|
+
|
40
|
+
asserts(:client).kind_of?(Faraday::Connection)
|
41
|
+
end
|
42
|
+
|
43
|
+
context "with default module" do
|
44
|
+
setup do
|
45
|
+
ElasticSearch::Node::External.default_client_module = DefaultClient
|
46
|
+
ElasticSearch::Node::External.new
|
47
|
+
end
|
48
|
+
|
49
|
+
teardown do
|
50
|
+
ElasticSearch::Node::External.default_client_module = nil
|
51
|
+
topic.close
|
52
|
+
end
|
53
|
+
|
54
|
+
asserts(:client).kind_of?(Faraday::Connection)
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
if 'jruby' == RUBY_ENGINE
|
2
|
+
require 'test_helper'
|
3
|
+
require 'elasticsearch-node/embedded'
|
4
|
+
|
5
|
+
context "An embedded node" do
|
6
|
+
setup do
|
7
|
+
ElasticSearch::Node::Embedded.new(:config => File.expand_path('configs/testing'))
|
8
|
+
end
|
9
|
+
|
10
|
+
teardown do
|
11
|
+
topic.close
|
12
|
+
end
|
13
|
+
|
14
|
+
asserts(:ip).kind_of?(String)
|
15
|
+
asserts(:port).kind_of?(Integer)
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'elasticsearch-node/external'
|
3
|
+
|
4
|
+
context "An external node" do
|
5
|
+
setup do
|
6
|
+
ElasticSearch::Node::External.new
|
7
|
+
end
|
8
|
+
|
9
|
+
teardown do
|
10
|
+
topic.close
|
11
|
+
end
|
12
|
+
|
13
|
+
asserts(:ip).kind_of?(String)
|
14
|
+
asserts(:port).kind_of?(Integer)
|
15
|
+
end
|
16
|
+
|
17
|
+
context "A configured external node" do
|
18
|
+
setup do
|
19
|
+
ElasticSearch::Node::External.new("node.name" => "foobar", "http.port" => 10000)
|
20
|
+
end
|
21
|
+
|
22
|
+
teardown do
|
23
|
+
topic.close
|
24
|
+
end
|
25
|
+
|
26
|
+
asserts(:ip).kind_of?(String)
|
27
|
+
asserts(:port).kind_of?(Integer)
|
28
|
+
asserts(:port).equals(10000)
|
29
|
+
end
|
data/test/test_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,93 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: elasticsearch-node
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.6.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Florian Gilcher
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-04-01 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: riot
|
16
|
+
requirement: &2165532760 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *2165532760
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: faraday
|
27
|
+
requirement: &2165532100 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :development
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *2165532100
|
36
|
+
description: Helper gem to install and start an elasticsearch node
|
37
|
+
email:
|
38
|
+
- florian.gilcher@asquera.de
|
39
|
+
executables:
|
40
|
+
- install_elasticsearch
|
41
|
+
extensions: []
|
42
|
+
extra_rdoc_files: []
|
43
|
+
files:
|
44
|
+
- .gitignore
|
45
|
+
- .travis.yml
|
46
|
+
- COPYING.md
|
47
|
+
- Gemfile
|
48
|
+
- README.md
|
49
|
+
- Rakefile
|
50
|
+
- bin/install_elasticsearch
|
51
|
+
- configs/testing/config/elasticsearch.yml
|
52
|
+
- configs/testing/config/logging.yml
|
53
|
+
- elasticsearch-node.gemspec
|
54
|
+
- fetch_es.rb
|
55
|
+
- lib/elasticsearch-node.rb
|
56
|
+
- lib/elasticsearch-node/client_provider.rb
|
57
|
+
- lib/elasticsearch-node/embedded.rb
|
58
|
+
- lib/elasticsearch-node/external.rb
|
59
|
+
- lib/elasticsearch-node/remote.rb
|
60
|
+
- lib/elasticsearch-node/version.rb
|
61
|
+
- test/nodes/client_provider_test.rb
|
62
|
+
- test/nodes/embedded_test.rb
|
63
|
+
- test/nodes/external_test.rb
|
64
|
+
- test/test_helper.rb
|
65
|
+
homepage: http://github.com/Asquera/elasticsearch-node
|
66
|
+
licenses: []
|
67
|
+
post_install_message:
|
68
|
+
rdoc_options: []
|
69
|
+
require_paths:
|
70
|
+
- lib
|
71
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
73
|
+
requirements:
|
74
|
+
- - ! '>='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
78
|
+
none: false
|
79
|
+
requirements:
|
80
|
+
- - ! '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
requirements: []
|
84
|
+
rubyforge_project: elasticsearch-node
|
85
|
+
rubygems_version: 1.8.7
|
86
|
+
signing_key:
|
87
|
+
specification_version: 3
|
88
|
+
summary: Helper gem to install and start an elasticsearch node
|
89
|
+
test_files:
|
90
|
+
- test/nodes/client_provider_test.rb
|
91
|
+
- test/nodes/embedded_test.rb
|
92
|
+
- test/nodes/external_test.rb
|
93
|
+
- test/test_helper.rb
|