elastomer-client 6.2.1 → 6.2.2
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/README.md +10 -0
- data/docker/compose.yaml +29 -1
- data/docker/elasticsearch-follow.yml +14 -0
- data/docker/elasticsearch8plus.yml +1 -0
- data/lib/elastomer_client/client/ccr.rb +139 -0
- data/lib/elastomer_client/client/reindex.rb +2 -2
- data/lib/elastomer_client/version.rb +1 -1
- data/script/setup-ccr +89 -0
- data/test/client/ccr_test.rb +149 -0
- data/test/client/reindex_test.rb +6 -5
- data/test/test_helper.rb +13 -0
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 96e8ae346cfe62276c448747cca8b9959c835aa4d52b1681c1f5b52474f45778
|
4
|
+
data.tar.gz: e4c470563171f93f51c74b5f5fa0c3d696c3b0386183d949ad104ac46f95ef3b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 779b6def22ad36824d81dfdd1a2ee659aacba776fb3ea4c4530f88ac6e39dd1379c7414406e56b5edd11fdb0d8a4b528c26437204cae19eeaa62437b6fcdff63
|
7
|
+
data.tar.gz: 07fd71595562ff808e4a28ba22025397566c85b6ac36f272f8f71d769f08e956e9174564a8494d4d45091db79662fcd658a0b4390a538a10ca00e669c47f11b6
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -142,6 +142,11 @@ To run ES 5 and ES 8:
|
|
142
142
|
docker compose --project-directory docker --profile all up
|
143
143
|
```
|
144
144
|
|
145
|
+
To run in ES8 cross cluster replication mode:
|
146
|
+
```
|
147
|
+
script/setup-ccr up "{non-production license}"
|
148
|
+
```
|
149
|
+
|
145
150
|
To run only ES 8:
|
146
151
|
```
|
147
152
|
docker compose --project-directory docker --profile es8 up
|
@@ -159,6 +164,11 @@ ES 8
|
|
159
164
|
ES_PORT=9208 rake test
|
160
165
|
```
|
161
166
|
|
167
|
+
CCR tests:
|
168
|
+
```
|
169
|
+
ES_PORT=9208 ES_REPLICA_PORT=9209 rake test
|
170
|
+
```
|
171
|
+
|
162
172
|
ES 5
|
163
173
|
```
|
164
174
|
ES_PORT=9205 rake test
|
data/docker/compose.yaml
CHANGED
@@ -4,7 +4,7 @@ services:
|
|
4
4
|
elasticsearch8.13:
|
5
5
|
image: docker.elastic.co/elasticsearch/elasticsearch:8.13.2
|
6
6
|
container_name: es8.13
|
7
|
-
profiles: ["es8", "all"]
|
7
|
+
profiles: ["es8", "ccr", "all"]
|
8
8
|
environment:
|
9
9
|
- cluster.name=elastomer8.13
|
10
10
|
- bootstrap.memory_lock=true
|
@@ -12,6 +12,7 @@ services:
|
|
12
12
|
- xpack.security.enabled=false
|
13
13
|
- xpack.watcher.enabled=false
|
14
14
|
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
|
15
|
+
- node.roles=[master,data,remote_cluster_client]
|
15
16
|
ulimits:
|
16
17
|
memlock:
|
17
18
|
soft: -1
|
@@ -28,6 +29,33 @@ services:
|
|
28
29
|
ports:
|
29
30
|
- 127.0.0.1:${ES_8_PORT:-9208}:9200
|
30
31
|
|
32
|
+
elasticsearchFollower:
|
33
|
+
image: docker.elastic.co/elasticsearch/elasticsearch:8.13.2
|
34
|
+
container_name: es-follow
|
35
|
+
profiles: ["ccr"]
|
36
|
+
environment:
|
37
|
+
- cluster.name=es-follow
|
38
|
+
- bootstrap.memory_lock=true
|
39
|
+
- discovery.type=single-node
|
40
|
+
- xpack.security.enabled=false
|
41
|
+
- xpack.watcher.enabled=false
|
42
|
+
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
|
43
|
+
- node.roles=[master,data,remote_cluster_client]
|
44
|
+
ulimits:
|
45
|
+
memlock:
|
46
|
+
soft: -1
|
47
|
+
hard: -1
|
48
|
+
nofile:
|
49
|
+
soft: 65536
|
50
|
+
hard: 65536
|
51
|
+
mem_limit: 2g
|
52
|
+
cap_add:
|
53
|
+
- IPC_LOCK
|
54
|
+
volumes:
|
55
|
+
- ./elasticsearch-follow.yml:/usr/share/elasticsearch/config/elasticsearch.yml
|
56
|
+
ports:
|
57
|
+
- 127.0.0.1:${ES_8_PORT:-9209}:9201
|
58
|
+
|
31
59
|
elasticsearch5.6:
|
32
60
|
image: docker.elastic.co/elasticsearch/elasticsearch:5.6.4
|
33
61
|
container_name: es5.6
|
@@ -0,0 +1,14 @@
|
|
1
|
+
cluster.name: "es-follow"
|
2
|
+
|
3
|
+
network.host: 0.0.0.0
|
4
|
+
|
5
|
+
path:
|
6
|
+
data: /usr/share/elasticsearch/data
|
7
|
+
logs: /usr/share/elasticsearch/logs
|
8
|
+
repo: /usr/share/elasticsearch/repos
|
9
|
+
|
10
|
+
transport.port: 9301
|
11
|
+
http.port: 9201
|
12
|
+
remote_cluster.port: 9444
|
13
|
+
http.max_content_length: 50mb
|
14
|
+
ingest.geoip.downloader.enabled: false
|
@@ -0,0 +1,139 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ElastomerClient
|
4
|
+
class Client
|
5
|
+
|
6
|
+
# Returns a CCR instance
|
7
|
+
def ccr
|
8
|
+
Ccr.new(self)
|
9
|
+
end
|
10
|
+
|
11
|
+
class Ccr
|
12
|
+
# Create a new Ccr for initiating requests for cross cluster replication.
|
13
|
+
# More context: https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-apis.html
|
14
|
+
#
|
15
|
+
# client - ElastomerClient::Client used for HTTP requests to the server
|
16
|
+
def initialize(client)
|
17
|
+
@client = client
|
18
|
+
end
|
19
|
+
|
20
|
+
attr_reader :client
|
21
|
+
|
22
|
+
# Gets the parameters and status for each follower index.
|
23
|
+
#
|
24
|
+
# index_pattern - String name of the index pattern to get follower info for
|
25
|
+
# params - Hash of query parameters
|
26
|
+
#
|
27
|
+
# Examples
|
28
|
+
#
|
29
|
+
# ccr.get_follower_info("follower_index")
|
30
|
+
# ccr.get_follower_info("*")
|
31
|
+
#
|
32
|
+
# See https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-put-follow.html
|
33
|
+
def get_follower_info(index_pattern, params = {})
|
34
|
+
response = client.get "/#{index_pattern}/_ccr/info", params.merge(action: "get_follower_info", rest_api: "ccr")
|
35
|
+
response.body
|
36
|
+
end
|
37
|
+
|
38
|
+
# Creates a new follower index for the provided leader index on the remote cluster.
|
39
|
+
#
|
40
|
+
# follower_index - String name of the follower index to create
|
41
|
+
# body - Hash of the request body
|
42
|
+
# :remote_cluster - String name of the remote cluster. Required.
|
43
|
+
# :leader_index - String name of the leader index. Required.
|
44
|
+
# params - Hash of query parameters
|
45
|
+
#
|
46
|
+
# Examples
|
47
|
+
#
|
48
|
+
# ccr.follow("follower_index", { leader_index: "leader_index", remote_cluster: "leader" })
|
49
|
+
#
|
50
|
+
# See https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-put-follow.html
|
51
|
+
def follow(follower_index, body, params = {})
|
52
|
+
response = client.put "/#{follower_index}/_ccr/follow", params.merge(body:, action: "follow", rest_api: "ccr")
|
53
|
+
response.body
|
54
|
+
end
|
55
|
+
|
56
|
+
# Creates a new auto-follow pattern for the provided remote cluster.
|
57
|
+
#
|
58
|
+
# pattern_name - String name of the auto-follow pattern to create
|
59
|
+
# body - Hash of the request body
|
60
|
+
# :remote_cluster - String name of the remote cluster. Required.
|
61
|
+
# :leader_index_patterns - An array of simple index patterns to match against indices in the remote cluster
|
62
|
+
# :leader_index_exclusion_patterns - An array of simple index patterns that can be used to exclude indices from being auto-followed.
|
63
|
+
# :follow_index_pattern - The name of follower index. The template {{leader_index}} can be used to derive
|
64
|
+
# the name of the follower index from the name of the leader index.
|
65
|
+
# params - Hash of query parameters
|
66
|
+
|
67
|
+
# Examples
|
68
|
+
|
69
|
+
# ccr.auto_follow("follower_pattern", { remote_cluster: "leader", leader_index_patterns: ["leader_index*"],
|
70
|
+
# follow_index_pattern: "{{leader_index}}-follower" })
|
71
|
+
|
72
|
+
# See https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-put-auto-follow-pattern.html
|
73
|
+
|
74
|
+
def auto_follow(pattern_name, body, params = {})
|
75
|
+
response = client.put "/_ccr/auto_follow/#{pattern_name}", params.merge(body:, action: "create_auto_follow_pattern", rest_api: "ccr")
|
76
|
+
response.body
|
77
|
+
end
|
78
|
+
|
79
|
+
# Deletes the auto-follow pattern for the provided remote cluster.
|
80
|
+
#
|
81
|
+
# pattern_name - String name of the auto-follow pattern to delete
|
82
|
+
# params - Hash of query parameters
|
83
|
+
#
|
84
|
+
# Examples
|
85
|
+
#
|
86
|
+
# ccr.delete_auto_follow("follower_pattern")
|
87
|
+
#
|
88
|
+
# See https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-delete-auto-follow-pattern.html
|
89
|
+
|
90
|
+
def delete_auto_follow(pattern_name, params = {})
|
91
|
+
response = client.delete "/_ccr/auto_follow/#{pattern_name}", params.merge(action: "delete_auto_follow_pattern", rest_api: "ccr")
|
92
|
+
response.body
|
93
|
+
end
|
94
|
+
|
95
|
+
# Gets cross-cluster replication auto-follow patterns
|
96
|
+
#
|
97
|
+
# params - Hash of query parameters
|
98
|
+
# :pattern_name - (Optional) String name of the auto-follow pattern. Returns all patterns if not specified
|
99
|
+
# Examples
|
100
|
+
#
|
101
|
+
# ccr.get_auto_follow
|
102
|
+
#
|
103
|
+
# See https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-get-auto-follow-pattern.html
|
104
|
+
|
105
|
+
def get_auto_follow(params = {})
|
106
|
+
response = client.get "/_ccr/auto_follow{/pattern_name}", params.merge(action: "get_auto_follow_pattern", rest_api: "ccr")
|
107
|
+
response.body
|
108
|
+
end
|
109
|
+
|
110
|
+
# Pauses a follower index.
|
111
|
+
#
|
112
|
+
# follower_index - String name of the follower index to pause
|
113
|
+
# params - Hash of the request body
|
114
|
+
#
|
115
|
+
# Examples
|
116
|
+
# ccr.pause_follow("follower_index")
|
117
|
+
#
|
118
|
+
# See https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-post-pause-follow.html
|
119
|
+
def pause_follow(follower_index, params = {})
|
120
|
+
response = client.post "/#{follower_index}/_ccr/pause_follow", params.merge(action: "pause_follow", rest_api: "ccr")
|
121
|
+
response.body
|
122
|
+
end
|
123
|
+
|
124
|
+
# Unfollows a leader index given a follower index.
|
125
|
+
# The follower index must be paused and closed before unfollowing.
|
126
|
+
#
|
127
|
+
# follower_index - String name of the follower index to unfollow
|
128
|
+
# params - Hash of the request body
|
129
|
+
#
|
130
|
+
# Examples
|
131
|
+
# ccr.unfollow("follower_index")
|
132
|
+
# See https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-post-unfollow.html
|
133
|
+
def unfollow(follower_index, params = {})
|
134
|
+
response = client.post "/#{follower_index}/_ccr/unfollow", params.merge(action: "unfollow", rest_api: "ccr")
|
135
|
+
response.body
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
@@ -20,12 +20,12 @@ module ElastomerClient
|
|
20
20
|
attr_reader :client
|
21
21
|
|
22
22
|
def reindex(body, params = {})
|
23
|
-
response = client.post "/_reindex", params.merge(
|
23
|
+
response = client.post "/_reindex", params.merge(body:, action: "reindex", rest_api: "reindex")
|
24
24
|
response.body
|
25
25
|
end
|
26
26
|
|
27
27
|
def rethrottle(task_id, params = {})
|
28
|
-
response = client.post "/_reindex/#{task_id}/_rethrottle", params.merge(
|
28
|
+
response = client.post "/_reindex/#{task_id}/_rethrottle", params.merge(action: "rethrottle", rest_api: "reindex")
|
29
29
|
response.body
|
30
30
|
end
|
31
31
|
|
data/script/setup-ccr
ADDED
@@ -0,0 +1,89 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
|
3
|
+
# Function to display help
|
4
|
+
show_help() {
|
5
|
+
echo "Usage: $0 [option] [license]"
|
6
|
+
echo "Options:"
|
7
|
+
echo " up - Start the clusters and apply the license"
|
8
|
+
echo " down - Shut down the clusters"
|
9
|
+
echo " help - Display this help message"
|
10
|
+
}
|
11
|
+
|
12
|
+
# Function to apply the license to a cluster
|
13
|
+
apply_license() {
|
14
|
+
local port=$1
|
15
|
+
local license="$2"
|
16
|
+
local response_file=$(mktemp)
|
17
|
+
local http_code
|
18
|
+
http_code=$(curl -s -o "$response_file" -w "%{http_code}" -X PUT "http://localhost:$port/_license?pretty" -H "Content-Type: application/json" -d "$license")
|
19
|
+
|
20
|
+
if [ "$http_code" -ne 200 ]; then
|
21
|
+
echo "Failed to apply license to cluster on port $port. HTTP status code: $http_code"
|
22
|
+
echo "Error response: $(cat "$response_file")"
|
23
|
+
rm "$response_file"
|
24
|
+
exit 1
|
25
|
+
fi
|
26
|
+
}
|
27
|
+
|
28
|
+
# Function to shut down the clusters
|
29
|
+
shutdown_clusters() {
|
30
|
+
docker compose --project-directory docker --profile ccr down
|
31
|
+
echo "Clusters shut down."
|
32
|
+
}
|
33
|
+
|
34
|
+
# Check for options
|
35
|
+
case "$1" in
|
36
|
+
up)
|
37
|
+
|
38
|
+
# Get the directory of the current script
|
39
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
40
|
+
|
41
|
+
# Start the clusters
|
42
|
+
docker compose --project-directory docker --profile ccr up -d
|
43
|
+
|
44
|
+
# Wait for both clusters to be online
|
45
|
+
export ES_PORT=9208
|
46
|
+
"$SCRIPT_DIR/poll-for-es"
|
47
|
+
export ES_PORT=9209
|
48
|
+
"$SCRIPT_DIR/poll-for-es"
|
49
|
+
|
50
|
+
# Apply the license to both clusters
|
51
|
+
LICENSE=$2
|
52
|
+
if [ -z "$LICENSE" ]; then
|
53
|
+
echo "License key is required as the second argument."
|
54
|
+
exit 1
|
55
|
+
fi
|
56
|
+
|
57
|
+
echo "Applying license to cluster on port 9208..."
|
58
|
+
apply_license 9208 "$LICENSE"
|
59
|
+
echo "Applying license to cluster on port 9209..."
|
60
|
+
apply_license 9209 "$LICENSE"
|
61
|
+
echo "License applied to both clusters."
|
62
|
+
|
63
|
+
# Set up the remote connection between the clusters
|
64
|
+
curl -X PUT "http://localhost:9209/_cluster/settings" -H "Content-Type: application/json" -d '{
|
65
|
+
"persistent": {
|
66
|
+
"cluster": {
|
67
|
+
"remote": {
|
68
|
+
"leader": {
|
69
|
+
"seeds": ["es8.13:9300"]
|
70
|
+
}
|
71
|
+
}
|
72
|
+
}
|
73
|
+
}
|
74
|
+
}'
|
75
|
+
|
76
|
+
echo "Clusters setup completed."
|
77
|
+
;;
|
78
|
+
down)
|
79
|
+
shutdown_clusters
|
80
|
+
;;
|
81
|
+
help)
|
82
|
+
show_help
|
83
|
+
;;
|
84
|
+
*)
|
85
|
+
echo "Invalid option: $1"
|
86
|
+
show_help
|
87
|
+
exit 1
|
88
|
+
;;
|
89
|
+
esac
|
@@ -0,0 +1,149 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "../test_helper"
|
4
|
+
|
5
|
+
describe ElastomerClient::Client::Ccr do
|
6
|
+
before do
|
7
|
+
skip "Cannot test Ccr API without a replica cluster" unless $replica_client.available?
|
8
|
+
|
9
|
+
begin
|
10
|
+
ccr.delete_auto_follow("follower_pattern")
|
11
|
+
rescue StandardError
|
12
|
+
puts "No auto-follow pattern to delete"
|
13
|
+
end
|
14
|
+
|
15
|
+
@leader_index = $client.index("leader_index")
|
16
|
+
@follower_index = $replica_client.index("follower_index")
|
17
|
+
@auto_followed_index = $client.index("followed_index")
|
18
|
+
@auto_follower_index = $replica_client.index("followed_index-follower")
|
19
|
+
|
20
|
+
if @leader_index.exists?
|
21
|
+
@leader_index.delete
|
22
|
+
end
|
23
|
+
if @auto_followed_index.exists?
|
24
|
+
@auto_followed_index.delete
|
25
|
+
end
|
26
|
+
if @follower_index.exists?
|
27
|
+
@follower_index.delete
|
28
|
+
end
|
29
|
+
if @auto_follower_index.exists?
|
30
|
+
@auto_follower_index.delete
|
31
|
+
end
|
32
|
+
|
33
|
+
@leader_index.create(default_index_settings)
|
34
|
+
wait_for_index(@leader_index.name, "green")
|
35
|
+
end
|
36
|
+
|
37
|
+
after do
|
38
|
+
@leader_index.delete if @leader_index.exists?
|
39
|
+
@follower_index.delete if @follower_index.exists?
|
40
|
+
@auto_followed_index.delete if @auto_followed_index.exists?
|
41
|
+
@auto_follower_index.delete if @auto_follower_index.exists?
|
42
|
+
|
43
|
+
begin
|
44
|
+
ccr.delete_auto_follow("follower_pattern")
|
45
|
+
rescue StandardError
|
46
|
+
puts "No auto-follow pattern to delete"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def follow_index(follower_index_name, leader_index_name)
|
51
|
+
ccr = $replica_client.ccr
|
52
|
+
response = ccr.follow(follower_index_name, { leader_index: leader_index_name, remote_cluster: "leader" })
|
53
|
+
wait_for_index(follower_index_name, "green")
|
54
|
+
response
|
55
|
+
end
|
56
|
+
|
57
|
+
def pause_follow(follower_index_name)
|
58
|
+
ccr = $replica_client.ccr
|
59
|
+
response = ccr.pause_follow(follower_index_name)
|
60
|
+
wait_for_index(follower_index_name, "green")
|
61
|
+
response
|
62
|
+
end
|
63
|
+
|
64
|
+
def unfollow_index(follower_index_name)
|
65
|
+
ccr = $replica_client.ccr
|
66
|
+
response = ccr.unfollow(follower_index_name)
|
67
|
+
wait_for_index(follower_index_name, "green")
|
68
|
+
response
|
69
|
+
end
|
70
|
+
|
71
|
+
def create_document(index, type, document)
|
72
|
+
response = index.docs.index(document_wrapper(type, document))
|
73
|
+
index.refresh
|
74
|
+
response
|
75
|
+
end
|
76
|
+
|
77
|
+
it "successfully follows a leader index" do
|
78
|
+
create_document(@leader_index, "book", { _id: 1, title: "Book 1" })
|
79
|
+
follow_index(@follower_index.name, @leader_index.name)
|
80
|
+
|
81
|
+
doc = @follower_index.docs.get(id: 1, type: "book")
|
82
|
+
|
83
|
+
assert_equal "Book 1", doc["_source"]["title"]
|
84
|
+
end
|
85
|
+
|
86
|
+
it "successfully gets info for all follower indices" do
|
87
|
+
follow_index(@follower_index.name, @leader_index.name)
|
88
|
+
|
89
|
+
response = $replica_client.ccr.get_follower_info("*")
|
90
|
+
|
91
|
+
assert_equal response["follower_indices"][0]["follower_index"], @follower_index.name
|
92
|
+
assert_equal response["follower_indices"][0]["leader_index"], @leader_index.name
|
93
|
+
end
|
94
|
+
|
95
|
+
it "successfully pauses a follower index" do
|
96
|
+
follow_index(@follower_index.name, @leader_index.name)
|
97
|
+
|
98
|
+
response = pause_follow(@follower_index.name)
|
99
|
+
|
100
|
+
assert response["acknowledged"]
|
101
|
+
|
102
|
+
create_document(@leader_index, "book", { _id: 2, title: "Book 2" })
|
103
|
+
|
104
|
+
doc = @follower_index.docs.get(id: 2, type: "book")
|
105
|
+
|
106
|
+
refute doc["found"]
|
107
|
+
end
|
108
|
+
|
109
|
+
it "successfully unfollow a leader index" do
|
110
|
+
follow_index(@follower_index.name, @leader_index.name)
|
111
|
+
|
112
|
+
pause_follow(@follower_index.name)
|
113
|
+
|
114
|
+
@follower_index.close
|
115
|
+
|
116
|
+
response = unfollow_index(@follower_index.name)
|
117
|
+
|
118
|
+
assert response["acknowledged"]
|
119
|
+
|
120
|
+
@follower_index.open
|
121
|
+
|
122
|
+
wait_for_index(@follower_index.name, "green")
|
123
|
+
|
124
|
+
create_document(@leader_index, "book", { _id: 2, title: "Book 2" })
|
125
|
+
|
126
|
+
doc = @follower_index.docs.get(id: 2, type: "book")
|
127
|
+
|
128
|
+
refute doc["found"]
|
129
|
+
end
|
130
|
+
|
131
|
+
it "successfully implements an auto-follow policy" do
|
132
|
+
ccr = $replica_client.ccr
|
133
|
+
|
134
|
+
ccr.auto_follow("follower_pattern", { remote_cluster: "leader", leader_index_patterns: ["*"], follow_index_pattern: "{{leader_index}}-follower" })
|
135
|
+
|
136
|
+
@auto_followed_index.create(default_index_settings)
|
137
|
+
wait_for_index(@auto_followed_index.name, "green")
|
138
|
+
|
139
|
+
@auto_follower_index = $replica_client.index("followed_index-follower")
|
140
|
+
wait_for_index(@auto_follower_index.name, "green")
|
141
|
+
|
142
|
+
resp = ccr.get_auto_follow(pattern_name: "follower_pattern")
|
143
|
+
|
144
|
+
assert_equal "follower_pattern", resp["patterns"].first["name"]
|
145
|
+
|
146
|
+
assert_predicate @auto_follower_index, :exists?
|
147
|
+
end
|
148
|
+
|
149
|
+
end
|
data/test/client/reindex_test.rb
CHANGED
@@ -57,15 +57,16 @@ describe ElastomerClient::Client::Reindex do
|
|
57
57
|
}
|
58
58
|
response = reindex.reindex(body, requests_per_second: 0.01, wait_for_completion: false)
|
59
59
|
task_id = response["task"]
|
60
|
+
node_id = task_id.split(":").first
|
61
|
+
task_number = task_id.split(":").last.to_i
|
60
62
|
|
61
|
-
reindex.rethrottle(task_id, requests_per_second: 1)
|
63
|
+
response = reindex.rethrottle(task_id, requests_per_second: 1)
|
62
64
|
|
63
|
-
|
64
|
-
node_id = task_id.split(":").first
|
65
|
-
task_id = task_id.split(":").last.to_i
|
65
|
+
assert_equal 1, response["nodes"][node_id]["tasks"][task_id]["status"]["requests_per_second"]
|
66
66
|
|
67
67
|
# wait for the task to complete
|
68
|
-
tasks
|
68
|
+
tasks = $client.tasks
|
69
|
+
tasks.wait_by_id(node_id, task_number, "30s")
|
69
70
|
|
70
71
|
# Verify that the document has been reindexed
|
71
72
|
doc = @dest_index.docs.get(id: 1, type: "book")
|
data/test/test_helper.rb
CHANGED
@@ -46,6 +46,19 @@ raise "No server available at #{$client.url}" unless $client.available?
|
|
46
46
|
|
47
47
|
puts "Elasticsearch version is #{$client.version}"
|
48
48
|
|
49
|
+
# Create client instance for replica cluster
|
50
|
+
$replica_client_params = {
|
51
|
+
port: ENV.fetch("ES_REPLICA_PORT", 9201),
|
52
|
+
read_timeout: 10,
|
53
|
+
open_timeout: 1,
|
54
|
+
opaque_id: false,
|
55
|
+
strict_params: true,
|
56
|
+
compress_body: true
|
57
|
+
}
|
58
|
+
$replica_client = ElastomerClient::Client.new(**$replica_client_params)
|
59
|
+
|
60
|
+
puts "Replica server is unavailable at #{$replica_client.url}" unless $replica_client.available?
|
61
|
+
|
49
62
|
# remove any lingering test indices from the cluster
|
50
63
|
Minitest.after_run do
|
51
64
|
$client.cluster.indices.keys.each do |name|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: elastomer-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 6.2.
|
4
|
+
version: 6.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tim Pease
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2025-02-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: addressable
|
@@ -105,6 +105,7 @@ files:
|
|
105
105
|
- README.md
|
106
106
|
- Rakefile
|
107
107
|
- docker/compose.yaml
|
108
|
+
- docker/elasticsearch-follow.yml
|
108
109
|
- docker/elasticsearch.yml
|
109
110
|
- docker/elasticsearch8plus.yml
|
110
111
|
- docs/README.md
|
@@ -121,6 +122,7 @@ files:
|
|
121
122
|
- elastomer-client.gemspec
|
122
123
|
- lib/elastomer_client/client.rb
|
123
124
|
- lib/elastomer_client/client/bulk.rb
|
125
|
+
- lib/elastomer_client/client/ccr.rb
|
124
126
|
- lib/elastomer_client/client/cluster.rb
|
125
127
|
- lib/elastomer_client/client/delete_by_query.rb
|
126
128
|
- lib/elastomer_client/client/docs.rb
|
@@ -157,8 +159,10 @@ files:
|
|
157
159
|
- script/console
|
158
160
|
- script/generate-rest-api-spec
|
159
161
|
- script/poll-for-es
|
162
|
+
- script/setup-ccr
|
160
163
|
- test/assertions.rb
|
161
164
|
- test/client/bulk_test.rb
|
165
|
+
- test/client/ccr_test.rb
|
162
166
|
- test/client/cluster_test.rb
|
163
167
|
- test/client/docs_test.rb
|
164
168
|
- test/client/errors_test.rb
|
@@ -213,6 +217,7 @@ summary: A library for interacting with Elasticsearch
|
|
213
217
|
test_files:
|
214
218
|
- test/assertions.rb
|
215
219
|
- test/client/bulk_test.rb
|
220
|
+
- test/client/ccr_test.rb
|
216
221
|
- test/client/cluster_test.rb
|
217
222
|
- test/client/docs_test.rb
|
218
223
|
- test/client/errors_test.rb
|