Skip to content

Commit abf5dce

Browse files
committed
[XPACK] Adds tests and shortcut for open and close point in time
1 parent 832648b commit abf5dce

File tree

3 files changed

+103
-3
lines changed

3 files changed

+103
-3
lines changed

elasticsearch-xpack/lib/elasticsearch/xpack.rb

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
# specific language governing permissions and limitations
1616
# under the License.
1717

18-
require "elasticsearch/api"
19-
require "elasticsearch/xpack/version"
20-
require "elasticsearch/xpack/api/actions/params_registry"
18+
require 'elasticsearch/api'
19+
require 'elasticsearch/xpack/version'
20+
require 'elasticsearch/xpack/api/actions/params_registry'
2121

2222
Dir[ File.expand_path('../xpack/api/actions/**/params_registry.rb', __FILE__) ].each { |f| require f }
2323
Dir[ File.expand_path('../xpack/api/actions/**/*.rb', __FILE__) ].each { |f| require f }
@@ -132,6 +132,14 @@ def eql
132132
def snapshot_lifecycle_management
133133
@snapshot_lifecycle_management ||= xpack.snapshot_lifecycle_management
134134
end
135+
136+
def open_point_in_time(arguments = {})
137+
xpack.open_point_in_time(arguments)
138+
end
139+
140+
def close_point_in_time(arguments = {})
141+
xpack.close_point_in_time(arguments)
142+
end
135143
end
136144
end
137145
end if defined?(Elasticsearch::Transport::Client)
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Licensed to Elasticsearch B.V. under one or more contributor
2+
# license agreements. See the NOTICE file distributed with
3+
# this work for additional information regarding copyright
4+
# ownership. Elasticsearch B.V. licenses this file to you under
5+
# the Apache License, Version 2.0 (the "License"); you may
6+
# not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
require 'test_helper'
19+
20+
module Elasticsearch
21+
module Test
22+
class XPackClosePointInTimeTest < Minitest::Test
23+
context 'XPack: Close Point In Time' do
24+
subject { FakeClient.new }
25+
26+
should 'perform correct request' do
27+
subject.expects(:perform_request).with do |method, url, params, body|
28+
assert_equal 'DELETE', method
29+
assert_equal '_pit', url
30+
assert_equal({}, params)
31+
assert_nil body
32+
true
33+
end.returns(FakeResponse.new)
34+
35+
subject.xpack.close_point_in_time
36+
end
37+
end
38+
end
39+
end
40+
end
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Licensed to Elasticsearch B.V. under one or more contributor
2+
# license agreements. See the NOTICE file distributed with
3+
# this work for additional information regarding copyright
4+
# ownership. Elasticsearch B.V. licenses this file to you under
5+
# the Apache License, Version 2.0 (the "License"); you may
6+
# not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
require 'test_helper'
19+
20+
module Elasticsearch
21+
module Test
22+
class XPackOpenPointInTimeTest < Minitest::Test
23+
context 'XPack: Open Point In Time' do
24+
subject { FakeClient.new }
25+
26+
should 'perform correct request without index' do
27+
subject.expects(:perform_request).with do |method, url, params, body|
28+
assert_equal 'POST', method
29+
assert_equal '_pit', url
30+
assert_equal({}, params)
31+
assert_nil body
32+
true
33+
end.returns(FakeResponse.new)
34+
35+
subject.xpack.open_point_in_time
36+
end
37+
38+
should 'perform correct request with index' do
39+
subject.expects(:perform_request).with do |method, url, params, body|
40+
assert_equal 'POST', method
41+
assert_equal 'foo/_pit', url
42+
assert_equal({}, params)
43+
assert_nil body
44+
true
45+
end.returns(FakeResponse.new)
46+
47+
subject.xpack.open_point_in_time(index: 'foo')
48+
end
49+
end
50+
end
51+
end
52+
end

0 commit comments

Comments
 (0)