From ddeac0cde16846d4bf53b2a7677e803ce4f64dca Mon Sep 17 00:00:00 2001 From: Fabian Becker Date: Tue, 25 Feb 2025 14:03:20 +0100 Subject: [PATCH 1/2] Update dependencies refs #76 --- .circleci/config.yml | 2 +- config/config.exs | 4 +- config/dev.exs | 2 +- config/test.exs | 4 +- lib/elastix/bulk.ex | 7 +- lib/elastix/json.ex | 15 +-- lib/elastix/snapshot/snapshot.ex | 18 +++- mix.exs | 17 ++-- mix.lock | 44 ++++----- test/elastix/bulk_test.exs | 23 +++-- test/elastix/http_test.exs | 7 -- test/elastix/mapping_test.exs | 5 +- test/elastix/snapshot/snapshot_test.exs | 122 ++++++++++-------------- 13 files changed, 121 insertions(+), 149 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index c192260..7b63fbd 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -31,6 +31,7 @@ jobs: environment: - discovery.type=single-node - xpack.security.enabled=false + - path.repo=/tmp "elasticsearch-5.5": <<: *shared @@ -58,7 +59,6 @@ jobs: environment: - xpack.security.enabled=false - workflows: version: 2 build: diff --git a/config/config.exs b/config/config.exs index c39c04f..a87a99e 100644 --- a/config/config.exs +++ b/config/config.exs @@ -1,6 +1,6 @@ # This file is responsible for configuring your application # and its dependencies with the aid of the Mix.Config module. -use Mix.Config +import Config # This configuration is loaded before any dependency and is restricted # to this project. If another project depends on this project, this @@ -22,4 +22,4 @@ use Mix.Config # here (which is why it is important to import them last). # # import_config "#{Mix.env}.exs" -if Mix.env() == :test || Mix.env() == :dev, do: import_config("#{Mix.env()}.exs") +if Mix.env() in [:test, :dev], do: import_config("#{Mix.env()}.exs") diff --git a/config/dev.exs b/config/dev.exs index e5f95aa..422fe80 100644 --- a/config/dev.exs +++ b/config/dev.exs @@ -1,4 +1,4 @@ -use Mix.Config +import Config config :mix_test_watch, tasks: [ diff --git a/config/test.exs b/config/test.exs index 9cb3ef2..8cd1ae9 100644 --- a/config/test.exs +++ b/config/test.exs @@ -1,6 +1,6 @@ -use Mix.Config +import Config config :elastix, - test_url: "http://127.0.0.1:9200", + test_url: "http://127.0.0.1:8200", test_index: "elastix_test_index", test_index_2: "elastix_test_index_2" diff --git a/lib/elastix/bulk.ex b/lib/elastix/bulk.ex index 7292d05..c5c83eb 100644 --- a/lib/elastix/bulk.ex +++ b/lib/elastix/bulk.ex @@ -56,7 +56,11 @@ defmodule Elastix.Bulk do (elastic_url <> make_path(Keyword.get(options, :index), Keyword.get(options, :type), query_params)) - |> HTTP.put(Enum.map(lines, fn line -> JSON.encode!(line) <> "\n" end), [], httpoison_options) + |> HTTP.put( + Enum.map(lines, fn line -> JSON.encode!(line) <> "\n" end), + [], + httpoison_options + ) end @doc """ @@ -70,7 +74,6 @@ defmodule Elastix.Bulk do query_params :: Keyword.t() ) :: HTTP.resp() def post_raw(elastic_url, raw_data, options \\ [], query_params \\ []) do - httpoison_options = Keyword.get(options, :httpoison_options, []) (elastic_url <> diff --git a/lib/elastix/json.ex b/lib/elastix/json.ex index 26c6e23..b621a0c 100644 --- a/lib/elastix/json.ex +++ b/lib/elastix/json.ex @@ -47,21 +47,10 @@ defmodule Elastix.JSON do @doc false defp json_options do - # Support :poison_options config for backward-compatibility - case Elastix.config(:poison_options) do - nil -> - Elastix.config(:json_options, []) - - opts -> - IO.warn( - "Using :poison_options is deprecated and might not work in future releases; use :json_options instead." - ) - - opts - end + Elastix.config(:json_options, []) end defp codec do - Elastix.config(:json_codec, Poison) + Elastix.config(:json_codec, Jason) end end diff --git a/lib/elastix/snapshot/snapshot.ex b/lib/elastix/snapshot/snapshot.ex index 1da3ebc..bcde965 100644 --- a/lib/elastix/snapshot/snapshot.ex +++ b/lib/elastix/snapshot/snapshot.ex @@ -13,7 +13,14 @@ defmodule Elastix.Snapshot.Snapshot do """ @spec create(String.t(), String.t(), String.t(), Map.t(), [tuple()], Keyword.t()) :: {:ok, %HTTPoison.Response{}} - def create(elastic_url, repo_name, snapshot_name, data \\ %{}, query_params \\ [], options \\ []) do + def create( + elastic_url, + repo_name, + snapshot_name, + data \\ %{}, + query_params \\ [], + options \\ [] + ) do elastic_url |> prepare_url(make_path(repo_name, snapshot_name, query_params)) |> HTTP.put(JSON.encode!(data), [], _make_httpoison_options(options)) @@ -35,7 +42,8 @@ defmodule Elastix.Snapshot.Snapshot do snapsot. If repo_name is specified, will retrieve the status of all snapshots in that repository. Otherwise, will retrieve the status of all snapshots. """ - @spec status(String.t(), String.t(), String.t(), Keyword.t()) :: {:ok, %HTTPoison.Response{}} + @spec status(String.t(), String.t(), String.t(), Keyword.t()) :: + {:ok, %HTTPoison.Response{}} def status(elastic_url, repo_name \\ "", snapshot_name \\ "", options \\ []) do elastic_url |> prepare_url([make_path(repo_name, snapshot_name), "_status"]) @@ -48,7 +56,8 @@ defmodule Elastix.Snapshot.Snapshot do all snapshots in that repository. Otherwise, will retrieve information about all snapshots. """ - @spec get(String.t(), String.t(), String.t(), Keyword.t()) :: {:ok, %HTTPoison.Response{}} + @spec get(String.t(), String.t(), String.t(), Keyword.t()) :: + {:ok, %HTTPoison.Response{}} def get(elastic_url, repo_name \\ "", snapshot_name \\ "_all", options \\ []) do elastic_url |> prepare_url(make_path(repo_name, snapshot_name)) @@ -69,7 +78,8 @@ defmodule Elastix.Snapshot.Snapshot do {:ok, %HTTPoison.Response{...}} """ - @spec delete(String.t(), String.t(), String.t(), Keyword.t()) :: {:ok, %HTTPoison.Response{}} + @spec delete(String.t(), String.t(), String.t(), Keyword.t()) :: + {:ok, %HTTPoison.Response{}} def delete(elastic_url, repo_name, snapshot_name, options \\ []) do elastic_url |> prepare_url(make_path(repo_name, snapshot_name)) diff --git a/mix.exs b/mix.exs index 29c8c79..95c55e1 100644 --- a/mix.exs +++ b/mix.exs @@ -21,18 +21,17 @@ defmodule Elastix.Mixfile do def application do [ - applications: [:logger, :httpoison, :retry] + extra_applications: [:logger, :httpoison] ] end defp deps do [ - {:ex_doc, ">= 0.0.0", only: :dev, runtime: false}, - {:credo, "~> 0.6", only: [:dev, :test]}, - {:mix_test_watch, "~> 0.3", only: [:test, :dev]}, - {:poison, "~> 3.0 or ~> 4.0", optional: true}, - {:httpoison, "~> 1.4"}, - {:retry, "~> 0.8"} + {:ex_doc, "~> 0.27", only: :dev, runtime: false}, + {:credo, "~> 1.7", only: [:dev, :test]}, + {:jason, "~> 1.4", optional: true}, + {:httpoison, "~> 2.2"}, + {:retry, "~> 0.8", only: [:dev, :test]} ] end @@ -40,8 +39,8 @@ defmodule Elastix.Mixfile do [ description: "A DSL-free Elastic / Elasticsearch client for Elixir.", files: ["lib", "mix.exs", "README.md", "CHANGELOG.md", "LICENSE"], - maintainers: ["El Werbitzky", "evuez "], - licenses: ["WTFPL-2"], + maintainers: ["El Werbitzky", "evuez ", "Fabian Becker"], + licenses: ["MIT"], links: %{ "Changelog" => "https://hexdocs.pm/elastix/changelog.html", "GitHub" => @source_url diff --git a/mix.lock b/mix.lock index 26207b9..6260c0c 100644 --- a/mix.lock +++ b/mix.lock @@ -1,27 +1,23 @@ %{ - "bunt": {:hex, :bunt, "0.2.0", "951c6e801e8b1d2cbe58ebbd3e616a869061ddadcc4863d0a2182541acae9a38", [:mix], [], "hexpm", "7af5c7e09fe1d40f76c8e4f9dd2be7cebd83909f31fee7cd0e9eadc567da8353"}, - "certifi": {:hex, :certifi, "2.4.2", "75424ff0f3baaccfd34b1214184b6ef616d89e420b258bb0a5ea7d7bc628f7f0", [:rebar3], [{:parse_trans, "~>3.3", [hex: :parse_trans, repo: "hexpm", optional: false]}], "hexpm", "01d479edba0569a7b7a2c8bf923feeb6dc6a358edc2965ef69aea9ba288bb243"}, - "credo": {:hex, :credo, "0.9.0", "5d1b494e4f2dc672b8318e027bd833dda69be71eaac6eedd994678be74ef7cb4", [:mix], [{:bunt, "~> 0.2.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:poison, ">= 0.0.0", [hex: :poison, repo: "hexpm", optional: false]}], "hexpm", "61de62970f70111434b84ec272cc969ac693af1f3e112f23f1ef055e57e838e1"}, - "earmark": {:hex, :earmark, "1.2.4", "99b637c62a4d65a20a9fb674b8cffb8baa771c04605a80c911c4418c69b75439", [:mix], [], "hexpm", "1b34655872366414f69dd987cb121c049f76984b6ac69f52fff6d8fd64d29cfd"}, - "earmark_parser": {:hex, :earmark_parser, "1.4.12", "b245e875ec0a311a342320da0551da407d9d2b65d98f7a9597ae078615af3449", [:mix], [], "hexpm", "711e2cc4d64abb7d566d43f54b78f7dc129308a63bc103fbd88550d2174b3160"}, - "ex_doc": {:hex, :ex_doc, "0.24.2", "e4c26603830c1a2286dae45f4412a4d1980e1e89dc779fcd0181ed1d5a05c8d9", [:mix], [{:earmark_parser, "~> 1.4.0", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1", [hex: :makeup_erlang, repo: "hexpm", optional: false]}], "hexpm", "e134e1d9e821b8d9e4244687fb2ace58d479b67b282de5158333b0d57c6fb7da"}, - "fs": {:hex, :fs, "0.9.2", "ed17036c26c3f70ac49781ed9220a50c36775c6ca2cf8182d123b6566e49ec59", [:rebar], [], "hexpm", "9a00246e8af58cdf465ae7c48fd6fd7ba2e43300413dfcc25447ecd3bf76f0c1"}, - "hackney": {:hex, :hackney, "1.14.3", "b5f6f5dcc4f1fba340762738759209e21914516df6be440d85772542d4a5e412", [:rebar3], [{:certifi, "2.4.2", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "6.0.0", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "1.0.1", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "1.0.2", [hex: :mimerl, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "1.1.4", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}], "hexpm", "ed15491f324aa0e95647dca8ef4340418dac479d1204d57e455d52dcfba3f705"}, - "httpoison": {:hex, :httpoison, "1.4.0", "e0b3c2ad6fa573134e42194d13e925acfa8f89d138bc621ffb7b1989e6d22e73", [:mix], [{:hackney, "~> 1.8", [hex: :hackney, repo: "hexpm", optional: false]}], "hexpm", "37b6f39cb92136ee72276f4bf4da81495e7935d720c3a15daf1553953153e3f7"}, - "httpotion": {:hex, :httpotion, "2.1.0"}, - "ibrowse": {:git, "git://github.com/cmullaparthi/ibrowse.git", "d2e369ff42666c3574b8b7ec26f69027895c4d94", [tag: "v4.1.1"]}, - "idna": {:hex, :idna, "6.0.0", "689c46cbcdf3524c44d5f3dde8001f364cd7608a99556d8fbd8239a5798d4c10", [:rebar3], [{:unicode_util_compat, "0.4.1", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm", "4bdd305eb64e18b0273864920695cb18d7a2021f31a11b9c5fbcd9a253f936e2"}, - "makeup": {:hex, :makeup, "1.0.5", "d5a830bc42c9800ce07dd97fa94669dfb93d3bf5fcf6ea7a0c67b2e0e4a7f26c", [:mix], [{:nimble_parsec, "~> 0.5 or ~> 1.0", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "cfa158c02d3f5c0c665d0af11512fed3fba0144cf1aadee0f2ce17747fba2ca9"}, - "makeup_elixir": {:hex, :makeup_elixir, "0.15.1", "b5888c880d17d1cc3e598f05cdb5b5a91b7b17ac4eaf5f297cb697663a1094dd", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.1", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "db68c173234b07ab2a07f645a5acdc117b9f99d69ebf521821d89690ae6c6ec8"}, - "makeup_erlang": {:hex, :makeup_erlang, "0.1.1", "3fcb7f09eb9d98dc4d208f49cc955a34218fc41ff6b84df7c75b3e6e533cc65f", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "174d0809e98a4ef0b3309256cbf97101c6ec01c4ab0b23e926a9e17df2077cbb"}, + "bunt": {:hex, :bunt, "1.0.0", "081c2c665f086849e6d57900292b3a161727ab40431219529f13c4ddcf3e7a44", [:mix], [], "hexpm", "dc5f86aa08a5f6fa6b8096f0735c4e76d54ae5c9fa2c143e5a1fc7c1cd9bb6b5"}, + "certifi": {:hex, :certifi, "2.14.0", "ed3bef654e69cde5e6c022df8070a579a79e8ba2368a00acf3d75b82d9aceeed", [:rebar3], [], "hexpm", "ea59d87ef89da429b8e905264fdec3419f84f2215bb3d81e07a18aac919026c3"}, + "credo": {:hex, :credo, "1.7.11", "d3e805f7ddf6c9c854fd36f089649d7cf6ba74c42bc3795d587814e3c9847102", [:mix], [{:bunt, "~> 0.2.1 or ~> 1.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:file_system, "~> 0.2 or ~> 1.0", [hex: :file_system, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "56826b4306843253a66e47ae45e98e7d284ee1f95d53d1612bb483f88a8cf219"}, + "earmark_parser": {:hex, :earmark_parser, "1.4.43", "34b2f401fe473080e39ff2b90feb8ddfeef7639f8ee0bbf71bb41911831d77c5", [:mix], [], "hexpm", "970a3cd19503f5e8e527a190662be2cee5d98eed1ff72ed9b3d1a3d466692de8"}, + "ex_doc": {:hex, :ex_doc, "0.37.2", "2a3aa7014094f0e4e286a82aa5194a34dd17057160988b8509b15aa6c292720c", [:mix], [{:earmark_parser, "~> 1.4.42", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_c, ">= 0.1.0", [hex: :makeup_c, repo: "hexpm", optional: true]}, {:makeup_elixir, "~> 0.14 or ~> 1.0", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1 or ~> 1.0", [hex: :makeup_erlang, repo: "hexpm", optional: false]}, {:makeup_html, ">= 0.1.0", [hex: :makeup_html, repo: "hexpm", optional: true]}], "hexpm", "4dfa56075ce4887e4e8b1dcc121cd5fcb0f02b00391fd367ff5336d98fa49049"}, + "file_system": {:hex, :file_system, "1.1.0", "08d232062284546c6c34426997dd7ef6ec9f8bbd090eb91780283c9016840e8f", [:mix], [], "hexpm", "bfcf81244f416871f2a2e15c1b515287faa5db9c6bcf290222206d120b3d43f6"}, + "hackney": {:hex, :hackney, "1.23.0", "55cc09077112bcb4a69e54be46ed9bc55537763a96cd4a80a221663a7eafd767", [:rebar3], [{:certifi, "~> 2.14.0", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "~> 6.1.0", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "~> 1.0.0", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "~> 1.1", [hex: :mimerl, repo: "hexpm", optional: false]}, {:parse_trans, "3.4.1", [hex: :parse_trans, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "~> 1.1.0", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}, {:unicode_util_compat, "~> 0.7.0", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm", "6cd1c04cd15c81e5a493f167b226a15f0938a84fc8f0736ebe4ddcab65c0b44e"}, + "httpoison": {:hex, :httpoison, "2.2.2", "15420e9e5bbb505b931b2f589dc8be0c3b21e2a91a2c6ba882d99bf8f3ad499d", [:mix], [{:hackney, "~> 1.21", [hex: :hackney, repo: "hexpm", optional: false]}], "hexpm", "de7ac49fe2ffd89219972fdf39b268582f6f7f68d8cd29b4482dacca1ce82324"}, + "idna": {:hex, :idna, "6.1.1", "8a63070e9f7d0c62eb9d9fcb360a7de382448200fbbd1b106cc96d3d8099df8d", [:rebar3], [{:unicode_util_compat, "~> 0.7.0", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm", "92376eb7894412ed19ac475e4a86f7b413c1b9fbb5bd16dccd57934157944cea"}, + "jason": {:hex, :jason, "1.4.4", "b9226785a9aa77b6857ca22832cffa5d5011a667207eb2a0ad56adb5db443b8a", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "c5eb0cab91f094599f94d55bc63409236a8ec69a21a67814529e8d5f6cc90b3b"}, + "makeup": {:hex, :makeup, "1.2.1", "e90ac1c65589ef354378def3ba19d401e739ee7ee06fb47f94c687016e3713d1", [:mix], [{:nimble_parsec, "~> 1.4", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "d36484867b0bae0fea568d10131197a4c2e47056a6fbe84922bf6ba71c8d17ce"}, + "makeup_elixir": {:hex, :makeup_elixir, "1.0.1", "e928a4f984e795e41e3abd27bfc09f51db16ab8ba1aebdba2b3a575437efafc2", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.2.3 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "7284900d412a3e5cfd97fdaed4f5ed389b8f2b4cb49efc0eb3bd10e2febf9507"}, + "makeup_erlang": {:hex, :makeup_erlang, "1.0.2", "03e1804074b3aa64d5fad7aa64601ed0fb395337b982d9bcf04029d68d51b6a7", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "af33ff7ef368d5893e4a267933e7744e46ce3cf1f61e2dccf53a111ed3aa3727"}, "metrics": {:hex, :metrics, "1.0.1", "25f094dea2cda98213cecc3aeff09e940299d950904393b2a29d191c346a8486", [:rebar3], [], "hexpm", "69b09adddc4f74a40716ae54d140f93beb0fb8978d8636eaded0c31b6f099f16"}, - "mimerl": {:hex, :mimerl, "1.0.2", "993f9b0e084083405ed8252b99460c4f0563e41729ab42d9074fd5e52439be88", [:rebar3], [], "hexpm", "7a4c8e1115a2732a67d7624e28cf6c9f30c66711a9e92928e745c255887ba465"}, - "mix_test_watch": {:hex, :mix_test_watch, "0.5.0", "2c322d119a4795c3431380fca2bca5afa4dc07324bd3c0b9f6b2efbdd99f5ed3", [:mix], [{:fs, "~> 0.9.1", [hex: :fs, repo: "hexpm", optional: false]}], "hexpm", "90501b4ad90268127d1765c678a07872c921aebc672bd5fe218b00400bfb51b0"}, - "nimble_parsec": {:hex, :nimble_parsec, "1.1.0", "3a6fca1550363552e54c216debb6a9e95bd8d32348938e13de5eda962c0d7f89", [:mix], [], "hexpm", "08eb32d66b706e913ff748f11694b17981c0b04a33ef470e33e11b3d3ac8f54b"}, - "parse_trans": {:hex, :parse_trans, "3.3.0", "09765507a3c7590a784615cfd421d101aec25098d50b89d7aa1d66646bc571c1", [:rebar3], [], "hexpm", "17ef63abde837ad30680ea7f857dd9e7ced9476cdd7b0394432af4bfc241b960"}, - "poison": {:hex, :poison, "4.0.1", "bcb755a16fac91cad79bfe9fc3585bb07b9331e50cfe3420a24bcc2d735709ae", [:mix], [], "hexpm", "ba8836feea4b394bb718a161fc59a288fe0109b5006d6bdf97b6badfcf6f0f25"}, - "retry": {:hex, :retry, "0.8.1", "46bd45c98dcba126bee04967d60f84ac13b854dfedaf6c2fb3b7f0cae884e090", [:mix], [], "hexpm", "a9f217e097a250f386b93bb7c2231b5668a70e04ed5ce8b9a90816b3a3acffba"}, - "ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.4", "f0eafff810d2041e93f915ef59899c923f4568f4585904d010387ed74988e77b", [:make, :mix, :rebar3], [], "hexpm", "603561dc0fd62f4f2ea9b890f4e20e1a0d388746d6e20557cafb1b16950de88c"}, - "ssl_verify_hostname": {:hex, :ssl_verify_hostname, "1.0.5", "2e73e068cd6393526f9fa6d399353d7c9477d6886ba005f323b592d389fb47be", [:make], []}, - "unicode_util_compat": {:hex, :unicode_util_compat, "0.4.1", "d869e4c68901dd9531385bb0c8c40444ebf624e60b6962d95952775cac5e90cd", [:rebar3], [], "hexpm", "1d1848c40487cdb0b30e8ed975e34e025860c02e419cb615d255849f3427439d"}, + "mimerl": {:hex, :mimerl, "1.3.0", "d0cd9fc04b9061f82490f6581e0128379830e78535e017f7780f37fea7545726", [:rebar3], [], "hexpm", "a1e15a50d1887217de95f0b9b0793e32853f7c258a5cd227650889b38839fe9d"}, + "mix_test_watch": {:hex, :mix_test_watch, "1.2.0", "1f9acd9e1104f62f280e30fc2243ae5e6d8ddc2f7f4dc9bceb454b9a41c82b42", [:mix], [{:file_system, "~> 0.2 or ~> 1.0", [hex: :file_system, repo: "hexpm", optional: false]}], "hexpm", "278dc955c20b3fb9a3168b5c2493c2e5cffad133548d307e0a50c7f2cfbf34f6"}, + "nimble_parsec": {:hex, :nimble_parsec, "1.4.2", "8efba0122db06df95bfaa78f791344a89352ba04baedd3849593bfce4d0dc1c6", [:mix], [], "hexpm", "4b21398942dda052b403bbe1da991ccd03a053668d147d53fb8c4e0efe09c973"}, + "parse_trans": {:hex, :parse_trans, "3.4.1", "6e6aa8167cb44cc8f39441d05193be6e6f4e7c2946cb2759f015f8c56b76e5ff", [:rebar3], [], "hexpm", "620a406ce75dada827b82e453c19cf06776be266f5a67cff34e1ef2cbb60e49a"}, + "retry": {:hex, :retry, "0.18.0", "dc58ebe22c95aa00bc2459f9e0c5400e6005541cf8539925af0aa027dc860543", [:mix], [], "hexpm", "9483959cc7bf69c9e576d9dfb2b678b71c045d3e6f39ab7c9aa1489df4492d73"}, + "ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.7", "354c321cf377240c7b8716899e182ce4890c5938111a1296add3ec74cf1715df", [:make, :mix, :rebar3], [], "hexpm", "fe4c190e8f37401d30167c8c405eda19469f34577987c76dde613e838bbc67f8"}, + "unicode_util_compat": {:hex, :unicode_util_compat, "0.7.0", "bc84380c9ab48177092f43ac89e4dfa2c6d62b40b8bd132b1059ecc7232f9a78", [:rebar3], [], "hexpm", "25eee6d67df61960cf6a794239566599b09e17e668d3700247bc498638152521"}, } diff --git a/test/elastix/bulk_test.exs b/test/elastix/bulk_test.exs index a7bd875..5d04c4d 100644 --- a/test/elastix/bulk_test.exs +++ b/test/elastix/bulk_test.exs @@ -29,13 +29,18 @@ defmodule Elastix.BulkTest do test "bulk accepts httpoison options" do lines = [ - %{index: %{_id: "1"}}, - %{field: "value1"}, - %{index: %{_id: "2"}}, - %{field: "value2"} - ] + %{index: %{_id: "1"}}, + %{field: "value1"}, + %{index: %{_id: "2"}}, + %{field: "value2"} + ] + {:error, %HTTPoison.Error{reason: :timeout}} = - Bulk.post @test_url, lines, index: @test_index, type: "message", httpoison_options: [recv_timeout: 0] + Bulk.post(@test_url, lines, + index: @test_index, + type: "message", + httpoison_options: [recv_timeout: 0] + ) end describe "test bulks with index and type in URL" do @@ -65,7 +70,7 @@ defmodule Elastix.BulkTest do {:ok, response} = Bulk.post_raw( @test_url, - Enum.map(lines, fn line -> Poison.encode!(line) <> "\n" end), + Enum.map(lines, fn line -> Jason.encode!(line) <> "\n" end), index: @test_index, type: "message" ) @@ -120,7 +125,7 @@ defmodule Elastix.BulkTest do {:ok, response} = Bulk.post_raw( @test_url, - Enum.map(lines, fn line -> Poison.encode!(line) <> "\n" end), + Enum.map(lines, fn line -> Jason.encode!(line) <> "\n" end), index: @test_index ) @@ -173,7 +178,7 @@ defmodule Elastix.BulkTest do {:ok, response} = Bulk.post_raw( @test_url, - Enum.map(lines, fn line -> Poison.encode!(line) <> "\n" end) + Enum.map(lines, fn line -> Jason.encode!(line) <> "\n" end) ) assert response.status_code == 200 diff --git a/test/elastix/http_test.exs b/test/elastix/http_test.exs index 57b95a2..a21e475 100644 --- a/test/elastix/http_test.exs +++ b/test/elastix/http_test.exs @@ -44,13 +44,6 @@ defmodule Elastix.HTTPTest do assert HTTP.process_response_body(body) == body end - test "process_response_body parsed the body into an atom key map if configured" do - body = "{\"some\":\"json\"}" - Application.put_env(:elastix, :poison_options, keys: :atoms) - assert HTTP.process_response_body(body) == %{some: "json"} - Application.delete_env(:elastix, :poison_options) - end - test "adding custom headers" do Application.put_env( :elastix, diff --git a/test/elastix/mapping_test.exs b/test/elastix/mapping_test.exs index 0699a3d..82785d2 100644 --- a/test/elastix/mapping_test.exs +++ b/test/elastix/mapping_test.exs @@ -35,7 +35,10 @@ defmodule Elastix.MappingTest do %HTTPoison.Response{body: %{"version" => %{"number" => v}}, status_code: 200} = Elastix.HTTP.get!(@test_url) - v |> String.split([".", "-"]) |> Enum.take(3) |> Enum.map(&String.to_integer/1) + v + |> String.split([".", "-"]) + |> Enum.take(3) + |> Enum.map(&String.to_integer/1) |> List.to_tuple() end diff --git a/test/elastix/snapshot/snapshot_test.exs b/test/elastix/snapshot/snapshot_test.exs index 8dd8709..9ef0473 100644 --- a/test/elastix/snapshot/snapshot_test.exs +++ b/test/elastix/snapshot/snapshot_test.exs @@ -81,25 +81,20 @@ defmodule Elastix.Snapshot.SnapshotTest do wait_for_completion: true ) - wait lin_backoff(500, 1) |> expiry(5_000) do - ( - {:ok, %{body: %{"snapshots" => snapshots}}} = - Snapshot.status(@test_url, @test_repository, "elastix_test_snapshot_2") - - snapshot = List.first(snapshots) - snapshot["state"] == "SUCCESS" - ) - - then - - ( + wait linear_backoff(500, 1) |> expiry(5_000) do + {:ok, %{body: %{"snapshots" => snapshots}}} = + Snapshot.status(@test_url, @test_repository, "elastix_test_snapshot_2") + + snapshot = List.first(snapshots) + snapshot["state"] == "SUCCESS" + after + _ -> {:ok, %{body: %{"snapshots" => snapshots}}} = Snapshot.get(@test_url, @test_repository, "elastix_test_snapshot_2") snapshot = List.first(snapshots) assert Enum.member?(snapshot["indices"], "elastix_test_index_1") assert Enum.member?(snapshot["indices"], "elastix_test_index_2") - ) end end @@ -112,25 +107,20 @@ defmodule Elastix.Snapshot.SnapshotTest do wait_for_completion: true ) - wait lin_backoff(500, 1) |> expiry(5_000) do - ( - {:ok, %{body: %{"snapshots" => snapshots}}} = - Snapshot.status(@test_url, @test_repository, "elastix_test_snapshot_1") + wait linear_backoff(500, 1) |> expiry(5_000) do + {:ok, %{body: %{"snapshots" => snapshots}}} = + Snapshot.status(@test_url, @test_repository, "elastix_test_snapshot_1") - snapshot = List.first(snapshots) - snapshot["state"] == "SUCCESS" - ) - - then - - ( + snapshot = List.first(snapshots) + snapshot["state"] == "SUCCESS" + after + _ -> {:ok, %{body: %{"snapshots" => snapshots}}} = Snapshot.get(@test_url, @test_repository, "elastix_test_snapshot_1") snapshot = List.first(snapshots) assert Enum.member?(snapshot["indices"], "elastix_test_index_1") refute Enum.member?(snapshot["indices"], "elastix_test_index_2") - ) end end end @@ -145,39 +135,31 @@ defmodule Elastix.Snapshot.SnapshotTest do wait_for_completion: true ) - wait lin_backoff(500, 1) |> expiry(5_000) do - ( - {:ok, %{body: %{"snapshots" => snapshots}}} = - Snapshot.status(@test_url, @test_repository, "elastix_test_snapshot_4") + wait linear_backoff(500, 1) |> expiry(5_000) do + {:ok, %{body: %{"snapshots" => snapshots}}} = + Snapshot.status(@test_url, @test_repository, "elastix_test_snapshot_4") - snapshot = List.first(snapshots) - snapshot["state"] == "SUCCESS" - ) - - then - - ( + snapshot = List.first(snapshots) + snapshot["state"] == "SUCCESS" + after + _ -> Index.close(@test_url, "elastix_test_index_1") Index.close(@test_url, "elastix_test_index_2") Index.delete(@test_url, "elastix_test_index_1") Index.delete(@test_url, "elastix_test_index_2") - ) end - wait lin_backoff(500, 1) |> expiry(5_000) do - ( - {:ok, %{status_code: 404}} = Index.get(@test_url, "elastix_test_index_1") - {:ok, %{status_code: 404}} = Index.get(@test_url, "elastix_test_index_2") - ) - - then - - Snapshot.restore(@test_url, @test_repository, "elastix_test_snapshot_4", %{ - partial: true - }) + wait linear_backoff(500, 1) |> expiry(5_000) do + {:ok, %{status_code: 404}} = Index.get(@test_url, "elastix_test_index_1") + {:ok, %{status_code: 404}} = Index.get(@test_url, "elastix_test_index_2") + after + _ -> + Snapshot.restore(@test_url, @test_repository, "elastix_test_snapshot_4", %{ + partial: true + }) end - wait lin_backoff(500, 1) |> expiry(5_000) do + wait linear_backoff(500, 1) |> expiry(5_000) do {:ok, %{status_code: 200}} = Index.get(@test_url, "elastix_test_index_1") {:ok, %{status_code: 200}} = Index.get(@test_url, "elastix_test_index_2") end @@ -192,39 +174,31 @@ defmodule Elastix.Snapshot.SnapshotTest do wait_for_completion: true ) - wait lin_backoff(500, 1) |> expiry(5_000) do - ( - {:ok, %{status_code: 200, body: %{"snapshots" => snapshots}}} = - Snapshot.status(@test_url, @test_repository, "elastix_test_snapshot_3") - - snapshot = List.first(snapshots) - snapshot["state"] == "SUCCESS" - ) - - then + wait linear_backoff(500, 1) |> expiry(5_000) do + {:ok, %{status_code: 200, body: %{"snapshots" => snapshots}}} = + Snapshot.status(@test_url, @test_repository, "elastix_test_snapshot_3") - ( + snapshot = List.first(snapshots) + snapshot["state"] == "SUCCESS" + after + _ -> Index.close(@test_url, "elastix_test_index_3") Index.close(@test_url, "elastix_test_index_4") Index.delete(@test_url, "elastix_test_index_3") Index.delete(@test_url, "elastix_test_index_4") - ) end - wait lin_backoff(500, 1) |> expiry(5_000) do - ( - {:ok, %{status_code: 404}} = Index.get(@test_url, "elastix_test_index_3") - {:ok, %{status_code: 404}} = Index.get(@test_url, "elastix_test_index_4") - ) - - then - - Snapshot.restore(@test_url, @test_repository, "elastix_test_snapshot_3", %{ - indices: "elastix_test_index_3" - }) + wait linear_backoff(500, 1) |> expiry(5_000) do + {:ok, %{status_code: 404}} = Index.get(@test_url, "elastix_test_index_3") + {:ok, %{status_code: 404}} = Index.get(@test_url, "elastix_test_index_4") + after + _ -> + Snapshot.restore(@test_url, @test_repository, "elastix_test_snapshot_3", %{ + indices: "elastix_test_index_3" + }) end - wait lin_backoff(500, 1) |> expiry(5_000) do + wait linear_backoff(500, 1) |> expiry(5_000) do {:ok, %{status_code: 200}} = Index.get(@test_url, "elastix_test_index_3") {:ok, %{status_code: 404}} = Index.get(@test_url, "elastix_test_index_4") end @@ -250,7 +224,7 @@ defmodule Elastix.Snapshot.SnapshotTest do indices: "elastix_test_index_5" }) - wait lin_backoff(500, 1) |> expiry(5_000) do + wait linear_backoff(500, 1) |> expiry(5_000) do {:ok, %{status_code: 200}} = Snapshot.status(@test_url, @test_repository, "elastix_test_snapshot_5") end From 039d4c2e15576e0095ed0680dc038ab26253c9fb Mon Sep 17 00:00:00 2001 From: Fabian Becker Date: Tue, 25 Feb 2025 14:09:27 +0100 Subject: [PATCH 2/2] Migrate to Github Actions refs #76 --- .circleci/config.yml | 69 ---------------------------------------- .github/workflows/ci.yml | 36 +++++++++++++++++++++ .travis.yml | 17 ---------- config/test.exs | 2 +- 4 files changed, 37 insertions(+), 87 deletions(-) delete mode 100644 .circleci/config.yml create mode 100644 .github/workflows/ci.yml delete mode 100644 .travis.yml diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 7b63fbd..0000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,69 +0,0 @@ -# Elixir CircleCI 2.0 configuration file -# -# Check https://circleci.com/docs/2.0/language-elixir/ for more details -version: 2 -shared: &shared - working_directory: ~/repo - steps: - - checkout - - - run: mix local.hex --force - - run: mix local.rebar --force - - - run: mix deps.get - - run: MIX_ENV=test mix compile - - # Wait for Elasticsearch - - run: - command: | - while ! curl -sS --fail http://localhost:9200 > /dev/null 2>&1; do - sleep 1 - done - - - run: MIX_ENV=test mix test - -jobs: - "elasticsearch-5.6": - <<: *shared - docker: - - image: elixir:latest - - image: docker.elastic.co/elasticsearch/elasticsearch:5.6.2 - environment: - - discovery.type=single-node - - xpack.security.enabled=false - - path.repo=/tmp - - "elasticsearch-5.5": - <<: *shared - docker: - - image: elixir:latest - - image: docker.elastic.co/elasticsearch/elasticsearch:5.5.3 - environment: - - discovery.type=single-node - - xpack.security.enabled=false - - "elasticsearch-5.4": - <<: *shared - docker: - - image: elixir:latest - - image: docker.elastic.co/elasticsearch/elasticsearch:5.4.3 - environment: - - discovery.type=single-node - - xpack.security.enabled=false - - "elasticsearch-5.3": - <<: *shared - docker: - - image: elixir:latest - - image: docker.elastic.co/elasticsearch/elasticsearch:5.3.3 - environment: - - xpack.security.enabled=false - -workflows: - version: 2 - build: - jobs: - - "elasticsearch-5.6" - - "elasticsearch-5.5" - - "elasticsearch-5.4" - - "elasticsearch-5.3" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..0bb81ea --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,36 @@ +on: push +name: Build & Test +env: + MIX_ENV: test + +jobs: + test: + runs-on: ubuntu-latest + name: Ex${{matrix.elixir}}/OTP${{matrix.otp}} + strategy: + matrix: + elixir: ["1.17.3", "1.18.2"] + otp: ["25.3.2", "26.2.5", "27.2.4"] + services: + elasticsearch: + image: docker.elastic.co/elasticsearch/elasticsearch:5.6.2 + options: >- + -e "discovery.type=single-node" + -e "xpack.security.enabled=false" + -e "path.repo=/tmp" + --health-cmd "curl -f http://localhost:9200/_cluster/health" + --health-interval 10s + --health-timeout 5s + --health-retries 10 + ports: + - 9200:9200 + - 9300:9300 + steps: + - uses: actions/checkout@v4 + - uses: erlef/setup-beam@v1 + with: + otp-version: ${{matrix.otp}} + elixir-version: ${{matrix.elixir}} + - run: mix deps.get + - run: mix compile --warnings-as-errors + - run: mix test diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index c29b25c..0000000 --- a/.travis.yml +++ /dev/null @@ -1,17 +0,0 @@ -sudo: false -dist: trusty -language: elixir -elixir: - - 1.6.1 - - 1.7.4 - - 1.8.2 - - 1.9.4 -services: - - elasticsearch -before_script: - - 'echo "path.repo: /tmp" | sudo tee -a /etc/elasticsearch/elasticsearch.yml' - - 'sudo service elasticsearch restart' - - mix credo --strict -script: "mix test" -notifications: - email: werbitzky@gmail.com diff --git a/config/test.exs b/config/test.exs index 8cd1ae9..88be3ed 100644 --- a/config/test.exs +++ b/config/test.exs @@ -1,6 +1,6 @@ import Config config :elastix, - test_url: "http://127.0.0.1:8200", + test_url: "http://127.0.0.1:9200", test_index: "elastix_test_index", test_index_2: "elastix_test_index_2"