elasticsearch-api 0.4.5 → 0.4.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Rakefile CHANGED
@@ -1,15 +1,26 @@
1
1
  require "bundler/gem_tasks"
2
2
 
3
- __current__ = Pathname( File.expand_path('..', __FILE__) )
3
+ def __current__
4
+ Pathname( File.expand_path('..', __FILE__) )
5
+ end
6
+
7
+ def git_specs(command, options={})
8
+ sh "git --git-dir=#{__current__.join('../support/elasticsearch/.git')} --work-tree=#{__current__.join('../support/elasticsearch')} #{command}", options
9
+ end
4
10
 
5
- desc "Run unit tests"
6
- task :default => 'test:unit'
7
- task :test => 'test:unit'
11
+ task(:default) { system "rake --tasks" }
12
+ task :test => 'test:unit'
8
13
 
9
14
  # ----- Test tasks ------------------------------------------------------------
10
15
 
11
16
  require 'rake/testtask'
12
17
  namespace :test do
18
+
19
+ desc "Update the repository with YAML tests"
20
+ task :update do
21
+ git_specs "fetch origin --verbose", :verbose => true
22
+ end
23
+
13
24
  task :ci_reporter do
14
25
  ENV['CI_REPORTS'] ||= 'tmp/reports'
15
26
  if defined?(RUBY_VERSION) && RUBY_VERSION < '1.9'
@@ -33,7 +44,19 @@ namespace :test do
33
44
  task :integration do
34
45
  require 'elasticsearch'
35
46
 
36
- current_branch = `git --git-dir=#{__current__.join('../support/elasticsearch/.git')} --work-tree=#{__current__.join('../support/elasticsearch')} branch --no-color`.split("\n").select { |b| b =~ /^\*/ }.first.gsub(/^\*\s*/, '')
47
+ branches = `git --git-dir=#{__current__.join('../support/elasticsearch/.git')} --work-tree=#{__current__.join('../support/elasticsearch')} branch --no-color`
48
+
49
+ current_branch = branches
50
+ .split("\n")
51
+ .select { |b| b =~ /^\*/ }
52
+ .reject { |b| b =~ /detached/ }
53
+ .map { |b| b.gsub(/^\*\s*/, '') }
54
+ .first
55
+
56
+ unless current_branch
57
+ STDERR.puts "[!] Unable to determine current branch, defaulting to 'master'"
58
+ current_branch = 'master'
59
+ end
37
60
 
38
61
  # Define the task
39
62
  t = Rake::TestTask.new(:integration) do |test|
@@ -42,6 +65,7 @@ namespace :test do
42
65
  test.test_files = FileList["test/integration/yaml_test_runner.rb", "test/integration/**/*_test.rb"]
43
66
  end
44
67
 
68
+ # Check if a test cluster is running
45
69
  begin
46
70
  client = Elasticsearch::Client.new host: "localhost:#{ENV['TEST_CLUSTER_PORT'] || 9250}"
47
71
  es_version_info = client.info['version']
@@ -52,12 +76,24 @@ namespace :test do
52
76
  cluster_running = false
53
77
  end
54
78
 
55
- checkout_server_build = ENV['TEST_NO_SPEC_CHECKOUT'].nil? ? true : false
56
- checkout_build_hash = ENV['TEST_BUILD_HASH'] || build_hash
79
+ checkout_specs_version = ENV['TEST_NO_CHECKOUT'].nil? ? true : false
80
+ checkout_build_hash = ENV['TEST_BUILD_REF'] || build_hash
57
81
 
58
82
  begin
59
- # Checkout the branch corresponding to the build
60
- sh "git --git-dir=#{__current__.join('../support/elasticsearch/.git')} --work-tree=#{__current__.join('../support/elasticsearch')} checkout #{checkout_build_hash} --force --quiet" if cluster_running && checkout_server_build
83
+ unless checkout_specs_version
84
+ STDERR.puts '-'*80, "YAML tests: Not switching, TEST_NO_CHECKOUT=y", '-'*80
85
+ end
86
+
87
+ if checkout_specs_version && !checkout_build_hash
88
+ STDERR.puts "[!] Cannot determine checkout build hash -- server not running or TEST_BUILD_REF not specified"
89
+ exit(1)
90
+ end
91
+
92
+ if checkout_specs_version && checkout_build_hash
93
+ # Checkout the commit corresponding to the running server build, or passed TEST_BUILD_REF
94
+ STDERR.puts '-'*80, "YAML tests: Switching to [\e[1m#{checkout_build_hash}\e[0m]", '-'*80
95
+ git_specs "checkout #{checkout_build_hash} --force --quiet"
96
+ end
61
97
 
62
98
  # Path to the API specs
63
99
  ENV['TEST_REST_API_SPEC'] = __current__.join('../support/elasticsearch/rest-api-spec/test/').to_s
@@ -74,14 +110,15 @@ namespace :test do
74
110
  end
75
111
 
76
112
  ensure
77
- sh "git --git-dir=#{__current__.join('../support/elasticsearch/.git')} --work-tree=#{__current__.join('../support/elasticsearch')} checkout #{current_branch}", :verbose => false if cluster_running && checkout_server_build
113
+ git_specs "checkout --force --quiet #{current_branch}" if checkout_specs_version
78
114
  end
79
115
  end
80
116
 
81
- Rake::TestTask.new(:all) do |test|
117
+ desc "Run unit and integration tests"
118
+ task :all do
82
119
  Rake::Task['test:ci_reporter'].invoke if ENV['CI']
83
- test.libs << 'lib' << 'test'
84
- test.test_files = FileList["test/unit/**/*_test.rb", "test/integration/**/*_test.rb", "test/integration/yaml_test_runner.rb"]
120
+ Rake::Task['test:unit'].invoke
121
+ Rake::Task['test:integration'].invoke
85
122
  end
86
123
 
87
124
  namespace :cluster do
@@ -38,7 +38,6 @@ Gem::Specification.new do |s|
38
38
  s.add_development_dependency "ci_reporter"
39
39
 
40
40
  # Gems for testing integrations
41
- s.add_development_dependency "multi_json"
42
41
  s.add_development_dependency "jbuilder"
43
42
  s.add_development_dependency "jsonify"
44
43
  s.add_development_dependency "hashie"
@@ -33,7 +33,7 @@ module Elasticsearch
33
33
  :type ]
34
34
 
35
35
  method = 'GET'
36
- path = Utils.__pathify '_cluster/nodes', Utils.__listify(arguments[:node_id]), 'hot_threads'
36
+ path = Utils.__pathify '_nodes', Utils.__listify(arguments[:node_id]), 'hot_threads'
37
37
 
38
38
  params = Utils.__validate_and_extract_params arguments, valid_params
39
39
  body = nil
@@ -46,7 +46,7 @@ module Elasticsearch
46
46
  :transport ]
47
47
 
48
48
  method = 'GET'
49
- path = Utils.__pathify '_cluster/nodes', Utils.__listify(arguments[:node_id])
49
+ path = Utils.__pathify '_nodes', Utils.__listify(arguments[:node_id])
50
50
 
51
51
  params = Utils.__validate_and_extract_params arguments, valid_params
52
52
  body = nil
@@ -23,7 +23,7 @@ module Elasticsearch
23
23
  :exit ]
24
24
 
25
25
  method = 'POST'
26
- path = Utils.__pathify '_cluster/nodes', Utils.__listify(arguments[:node_id]), '_shutdown'
26
+ path = Utils.__pathify '_nodes', Utils.__listify(arguments[:node_id]), '_shutdown'
27
27
 
28
28
  params = Utils.__validate_and_extract_params arguments, valid_params
29
29
  body = nil
@@ -1,5 +1,5 @@
1
1
  module Elasticsearch
2
2
  module API
3
- VERSION = "0.4.5"
3
+ VERSION = "0.4.6"
4
4
  end
5
5
  end
@@ -10,7 +10,7 @@ module Elasticsearch
10
10
  should "perform correct request" do
11
11
  subject.expects(:perform_request).with do |method, url, params, body|
12
12
  assert_equal 'GET', method
13
- assert_equal '_cluster/nodes/hot_threads', url
13
+ assert_equal '_nodes/hot_threads', url
14
14
  assert_equal Hash.new, params
15
15
  assert_nil body
16
16
  true
@@ -21,7 +21,7 @@ module Elasticsearch
21
21
 
22
22
  should "send :node_id correctly" do
23
23
  subject.expects(:perform_request).with do |method, url, params, body|
24
- assert_equal '_cluster/nodes/foo/hot_threads', url
24
+ assert_equal '_nodes/foo/hot_threads', url
25
25
  true
26
26
  end.returns(FakeResponse.new)
27
27
 
@@ -30,7 +30,7 @@ module Elasticsearch
30
30
 
31
31
  should "URL-escape the parts" do
32
32
  subject.expects(:perform_request).with do |method, url, params, body|
33
- assert_equal '_cluster/nodes/foo%5Ebar/hot_threads', url
33
+ assert_equal '_nodes/foo%5Ebar/hot_threads', url
34
34
  true
35
35
  end.returns(FakeResponse.new)
36
36
 
@@ -10,7 +10,7 @@ module Elasticsearch
10
10
  should "perform correct request" do
11
11
  subject.expects(:perform_request).with do |method, url, params, body|
12
12
  assert_equal 'GET', method
13
- assert_equal '_cluster/nodes', url
13
+ assert_equal '_nodes', url
14
14
  assert_equal Hash.new, params
15
15
  assert_nil body
16
16
  true
@@ -21,7 +21,7 @@ module Elasticsearch
21
21
 
22
22
  should "send :node_id correctly" do
23
23
  subject.expects(:perform_request).with do |method, url, params, body|
24
- assert_equal '_cluster/nodes/foo', url
24
+ assert_equal '_nodes/foo', url
25
25
  true
26
26
  end.returns(FakeResponse.new)
27
27
 
@@ -30,7 +30,7 @@ module Elasticsearch
30
30
 
31
31
  should "send multiple :node_id-s correctly" do
32
32
  subject.expects(:perform_request).with do |method, url, params, body|
33
- assert_equal '_cluster/nodes/A,B,C', url
33
+ assert_equal '_nodes/A,B,C', url
34
34
  true
35
35
  end.returns(FakeResponse.new).twice
36
36
 
@@ -10,7 +10,7 @@ module Elasticsearch
10
10
  should "perform correct request" do
11
11
  subject.expects(:perform_request).with do |method, url, params, body|
12
12
  assert_equal 'POST', method
13
- assert_equal '_cluster/nodes/_shutdown', url
13
+ assert_equal '_nodes/_shutdown', url
14
14
  assert_equal Hash.new, params
15
15
  assert_nil body
16
16
  true
@@ -21,7 +21,7 @@ module Elasticsearch
21
21
 
22
22
  should "send :node_id correctly" do
23
23
  subject.expects(:perform_request).with do |method, url, params, body|
24
- assert_equal '_cluster/nodes/foo/_shutdown', url
24
+ assert_equal '_nodes/foo/_shutdown', url
25
25
  true
26
26
  end.returns(FakeResponse.new)
27
27
 
@@ -30,7 +30,7 @@ module Elasticsearch
30
30
 
31
31
  should "send multiple :node_id-s correctly" do
32
32
  subject.expects(:perform_request).with do |method, url, params, body|
33
- assert_equal '_cluster/nodes/A,B,C/_shutdown', url
33
+ assert_equal '_nodes/A,B,C/_shutdown', url
34
34
  true
35
35
  end.returns(FakeResponse.new).twice
36
36
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: elasticsearch-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.5
4
+ version: 0.4.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-01-08 00:00:00.000000000 Z
12
+ date: 2014-01-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: multi_json
@@ -219,22 +219,6 @@ dependencies:
219
219
  - - ! '>='
220
220
  - !ruby/object:Gem::Version
221
221
  version: '0'
222
- - !ruby/object:Gem::Dependency
223
- name: multi_json
224
- requirement: !ruby/object:Gem::Requirement
225
- none: false
226
- requirements:
227
- - - ! '>='
228
- - !ruby/object:Gem::Version
229
- version: '0'
230
- type: :development
231
- prerelease: false
232
- version_requirements: !ruby/object:Gem::Requirement
233
- none: false
234
- requirements:
235
- - - ! '>='
236
- - !ruby/object:Gem::Version
237
- version: '0'
238
222
  - !ruby/object:Gem::Dependency
239
223
  name: jbuilder
240
224
  requirement: !ruby/object:Gem::Requirement