elastomer-client 3.2.3 → 6.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (114) hide show
  1. checksums.yaml +4 -4
  2. data/.devcontainer/devcontainer.json +46 -0
  3. data/.devcontainer/postCreateCommand.sh +4 -0
  4. data/.github/dependabot.yaml +11 -0
  5. data/.github/workflows/main.yml +45 -0
  6. data/.github/workflows/rubocop.yml +15 -0
  7. data/.gitignore +1 -1
  8. data/.rubocop.yml +13 -65
  9. data/.ruby-version +1 -0
  10. data/CHANGELOG.md +76 -0
  11. data/Gemfile +18 -1
  12. data/README.md +110 -51
  13. data/Rakefile +3 -1
  14. data/docker/compose.yaml +71 -0
  15. data/docker/elasticsearch8plus.yml +13 -0
  16. data/docs/README.md +4 -5
  17. data/docs/bulk_indexing.md +1 -1
  18. data/docs/client.md +20 -33
  19. data/docs/cluster.md +8 -8
  20. data/docs/docs.md +5 -5
  21. data/docs/index.md +4 -4
  22. data/docs/multi_search.md +1 -1
  23. data/docs/notifications.md +3 -3
  24. data/docs/scan_scroll.md +1 -1
  25. data/docs/snapshots.md +1 -1
  26. data/docs/templates.md +1 -1
  27. data/elastomer-client.gemspec +7 -16
  28. data/lib/{elastomer → elastomer_client}/client/bulk.rb +70 -47
  29. data/lib/{elastomer → elastomer_client}/client/cluster.rb +18 -16
  30. data/lib/{elastomer → elastomer_client}/client/delete_by_query.rb +6 -4
  31. data/lib/{elastomer → elastomer_client}/client/docs.rb +82 -72
  32. data/lib/{elastomer → elastomer_client}/client/errors.rb +7 -17
  33. data/lib/{elastomer → elastomer_client}/client/index.rb +55 -79
  34. data/lib/{elastomer → elastomer_client}/client/multi_percolate.rb +7 -5
  35. data/lib/{elastomer → elastomer_client}/client/multi_search.rb +5 -3
  36. data/lib/{elastomer → elastomer_client}/client/native_delete_by_query.rb +6 -6
  37. data/lib/{elastomer → elastomer_client}/client/nodes.rb +11 -10
  38. data/lib/{elastomer → elastomer_client}/client/percolator.rb +9 -10
  39. data/lib/elastomer_client/client/reindex.rb +34 -0
  40. data/lib/{elastomer → elastomer_client}/client/repository.rb +7 -5
  41. data/lib/{elastomer → elastomer_client}/client/rest_api_spec/api_spec.rb +7 -6
  42. data/lib/{elastomer → elastomer_client}/client/rest_api_spec/api_spec_v5_6.rb +1 -1
  43. data/lib/elastomer_client/client/rest_api_spec/api_spec_v8_13.rb +7567 -0
  44. data/lib/elastomer_client/client/rest_api_spec/api_spec_v8_7.rb +6553 -0
  45. data/lib/{elastomer → elastomer_client}/client/rest_api_spec/rest_api.rb +5 -3
  46. data/lib/{elastomer → elastomer_client}/client/rest_api_spec.rb +3 -2
  47. data/lib/{elastomer → elastomer_client}/client/scroller.rb +17 -16
  48. data/lib/{elastomer → elastomer_client}/client/snapshot.rb +10 -8
  49. data/lib/{elastomer → elastomer_client}/client/tasks.rb +9 -13
  50. data/lib/{elastomer → elastomer_client}/client/template.rb +10 -9
  51. data/lib/elastomer_client/client/update_by_query.rb +50 -0
  52. data/lib/{elastomer → elastomer_client}/client.rb +51 -62
  53. data/lib/{elastomer → elastomer_client}/core_ext/time.rb +2 -0
  54. data/lib/{elastomer → elastomer_client}/middleware/compress.rb +2 -2
  55. data/lib/{elastomer → elastomer_client}/middleware/encode_json.rb +4 -2
  56. data/lib/{elastomer → elastomer_client}/middleware/limit_size.rb +5 -3
  57. data/lib/{elastomer → elastomer_client}/middleware/opaque_id.rb +10 -7
  58. data/lib/{elastomer → elastomer_client}/middleware/parse_json.rb +5 -3
  59. data/lib/{elastomer → elastomer_client}/notifications.rb +17 -15
  60. data/lib/elastomer_client/version.rb +9 -0
  61. data/lib/elastomer_client/version_support.rb +24 -0
  62. data/script/bootstrap +4 -2
  63. data/script/console +3 -1
  64. data/script/generate-rest-api-spec +77 -22
  65. data/test/assertions.rb +32 -39
  66. data/test/client/bulk_test.rb +166 -141
  67. data/test/client/cluster_test.rb +35 -13
  68. data/test/client/docs_test.rb +387 -274
  69. data/test/client/errors_test.rb +38 -40
  70. data/test/client/index_test.rb +243 -202
  71. data/test/client/multi_percolate_test.rb +46 -41
  72. data/test/client/multi_search_test.rb +122 -67
  73. data/test/client/native_delete_by_query_test.rb +96 -88
  74. data/test/client/nodes_test.rb +21 -10
  75. data/test/client/percolator_test.rb +19 -14
  76. data/test/client/reindex_test.rb +100 -0
  77. data/test/client/repository_test.rb +31 -19
  78. data/test/client/rest_api_spec/api_spec_test.rb +13 -11
  79. data/test/client/rest_api_spec/rest_api_test.rb +9 -7
  80. data/test/client/scroller_test.rb +44 -70
  81. data/test/client/snapshot_test.rb +38 -21
  82. data/test/client/stubbed_client_test.rb +7 -4
  83. data/test/client/tasks_test.rb +12 -17
  84. data/test/client/template_test.rb +34 -13
  85. data/test/client/update_by_query_test.rb +137 -0
  86. data/test/client_test.rb +158 -92
  87. data/test/core_ext/time_test.rb +14 -12
  88. data/test/middleware/encode_json_test.rb +18 -7
  89. data/test/middleware/opaque_id_test.rb +18 -14
  90. data/test/middleware/parse_json_test.rb +17 -9
  91. data/test/mock_response.rb +30 -0
  92. data/test/notifications_test.rb +15 -8
  93. data/test/test_helper.rb +40 -97
  94. data/test/version_support_test.rb +13 -78
  95. metadata +60 -208
  96. data/.overcommit.yml +0 -5
  97. data/.travis.yml +0 -34
  98. data/docker/docker-compose.cibuild.yml +0 -8
  99. data/docker/docker-compose.es24.yml +0 -34
  100. data/docker/docker-compose.es56.yml +0 -37
  101. data/docs/warmers.md +0 -3
  102. data/lib/elastomer/client/app_delete_by_query.rb +0 -144
  103. data/lib/elastomer/client/rest_api_spec/api_spec_v2_3.rb +0 -2232
  104. data/lib/elastomer/client/rest_api_spec/api_spec_v2_4.rb +0 -2250
  105. data/lib/elastomer/client/warmer.rb +0 -98
  106. data/lib/elastomer/version.rb +0 -7
  107. data/lib/elastomer/version_support.rb +0 -182
  108. data/script/cibuild +0 -103
  109. data/script/cibuild-elastomer-client +0 -1
  110. data/script/cibuild-elastomer-client-es24 +0 -8
  111. data/script/cibuild-elastomer-client-es56 +0 -8
  112. data/test/client/app_delete_by_query_test.rb +0 -192
  113. data/test/client/es_5_x_warmer_test.rb +0 -13
  114. data/test/client/warmer_test.rb +0 -60
@@ -1,19 +1,24 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative "../test_helper"
2
4
 
3
- describe Elastomer::Client::Error do
5
+ describe ElastomerClient::Client::Error do
4
6
 
5
7
  it "is instantiated with a simple message" do
6
- err = Elastomer::Client::Error.new "something went wrong"
8
+ err = ElastomerClient::Client::Error.new "something went wrong"
9
+
7
10
  assert_equal "something went wrong", err.message
8
11
  end
9
12
 
10
13
  it "is instantiated from an HTTP response" do
11
- response = Faraday::Response.new(:body => "UTF8Error invalid middle-byte")
12
- err = Elastomer::Client::Error.new(response)
14
+ response = Faraday::Response.new(body: "UTF8Error invalid middle-byte")
15
+ err = ElastomerClient::Client::Error.new(response)
16
+
13
17
  assert_equal "UTF8Error invalid middle-byte", err.message
14
18
 
15
- response = Faraday::Response.new(:body => {"error" => "IndexMissingException"})
16
- err = Elastomer::Client::Error.new(response)
19
+ response = Faraday::Response.new(body: {"error" => "IndexMissingException"})
20
+ err = ElastomerClient::Client::Error.new(response)
21
+
17
22
  assert_equal "IndexMissingException", err.message
18
23
  assert_equal "IndexMissingException", err.error
19
24
 
@@ -34,64 +39,57 @@ describe Elastomer::Client::Error do
34
39
  },
35
40
  "status" => 404
36
41
  }
37
- response = Faraday::Response.new(:body => body)
38
- err = Elastomer::Client::Error.new(response)
42
+ response = Faraday::Response.new(body:)
43
+ err = ElastomerClient::Client::Error.new(response)
44
+
39
45
  assert_equal body["error"].to_s, err.message
40
46
  assert_equal body["error"], err.error
41
47
  end
42
48
 
43
49
  it "is instantiated from another exception" do
44
- err = Faraday::Error::ConnectionFailed.new "could not connect to host"
50
+ err = Faraday::ConnectionFailed.new "could not connect to host"
45
51
  err.set_backtrace %w[one two three four]
46
52
 
47
- err = Elastomer::Client::Error.new(err, "POST", "/index/doc")
53
+ err = ElastomerClient::Client::Error.new(err, "POST", "/index/doc")
54
+
48
55
  assert_equal "could not connect to host :: POST /index/doc", err.message
49
56
  assert_equal %w[one two three four], err.backtrace
50
57
  end
51
58
 
52
59
  it "is fatal by default" do
53
- assert Elastomer::Client::Error.fatal, "client errors are fatal by default"
60
+ assert ElastomerClient::Client::Error.fatal, "client errors are fatal by default"
61
+
62
+ error = ElastomerClient::Client::Error.new "oops!"
54
63
 
55
- error = Elastomer::Client::Error.new "oops!"
56
- assert !error.retry?, "client errors are not retryable by default"
64
+ refute_predicate error, :retry?, "client errors are not retryable by default"
57
65
  end
58
66
 
59
67
  it "supports .fatal? alias" do
60
- assert Elastomer::Client::Error.fatal?, "client errors support .fatal?"
68
+ assert_predicate ElastomerClient::Client::Error, :fatal?, "client errors support .fatal?"
61
69
  end
62
70
 
63
71
  it "has some fatal subclasses" do
64
- assert Elastomer::Client::ResourceNotFound.fatal, "Resource not found is fatal"
65
- assert Elastomer::Client::ParsingError.fatal, "Parsing error is fatal"
66
- assert Elastomer::Client::SSLError.fatal, "SSL error is fatal"
67
- assert Elastomer::Client::RequestError.fatal, "Request error is fatal"
68
- assert Elastomer::Client::DocumentAlreadyExistsError.fatal, "DocumentAlreadyExistsError error is fatal"
72
+ assert ElastomerClient::Client::ResourceNotFound.fatal, "Resource not found is fatal"
73
+ assert ElastomerClient::Client::ParsingError.fatal, "Parsing error is fatal"
74
+ assert ElastomerClient::Client::SSLError.fatal, "SSL error is fatal"
75
+ assert ElastomerClient::Client::RequestError.fatal, "Request error is fatal"
76
+ assert ElastomerClient::Client::DocumentAlreadyExistsError.fatal, "DocumentAlreadyExistsError error is fatal"
69
77
  end
70
78
 
71
79
  it "has some non-fatal subclasses" do
72
- assert !Elastomer::Client::TimeoutError.fatal, "Timeouts are not fatal"
73
- assert !Elastomer::Client::ConnectionFailed.fatal, "Connection failures are not fatal"
74
- assert !Elastomer::Client::ServerError.fatal, "Server errors are not fatal"
75
- assert !Elastomer::Client::RejectedExecutionError.fatal, "Rejected execution errors are not fatal"
80
+ refute ElastomerClient::Client::TimeoutError.fatal, "Timeouts are not fatal"
81
+ refute ElastomerClient::Client::ConnectionFailed.fatal, "Connection failures are not fatal"
82
+ refute ElastomerClient::Client::ServerError.fatal, "Server errors are not fatal"
83
+ refute ElastomerClient::Client::RejectedExecutionError.fatal, "Rejected execution errors are not fatal"
76
84
  end
77
85
 
78
- if parameter_validation?
79
- it "wraps illegal argument exceptions" do
80
- begin
81
- $client.get("/_cluster/health?consistency=all")
82
- assert false, "IllegalArgument exception was not raised"
83
- rescue Elastomer::Client::IllegalArgument => err
84
- assert_match(/request \[\/_cluster\/health\] contains unrecognized parameter: \[consistency\]/, err.message)
85
- end
86
- end
87
- else
88
- it "does not raise illegal argument exceptions" do
89
- begin
90
- $client.get("/_cluster/health?consistency=all")
91
- assert true, "Exception was not raised"
92
- rescue Elastomer::Client::Error => err
93
- assert false, "Exception #{err} was raised"
94
- end
86
+ it "wraps illegal argument exceptions" do
87
+ begin
88
+ $client.get("/_cluster/health?consistency=all")
89
+
90
+ assert false, "IllegalArgument exception was not raised"
91
+ rescue ElastomerClient::Client::IllegalArgument => err
92
+ assert_match(/request \[\/_cluster\/health\] contains unrecognized parameter: \[consistency\]/, err.message)
95
93
  end
96
94
  end
97
95
  end