-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Passage de HTTPoison à Req pour ResourceHistoryJob (#3585)
* Fix broken config * Save useful script * Create a secondary path * Implement req downloader * Extract headers & implement req version * Switch to req * Stop passing the full HTTP body around Optimize for memory consumption, since this is what we want, and the file is already stored on disk. * Run mix format * Run mix format * Fix broken code * Backport S3 streaming from #3560 * Enable streaming * Update go.exs * Rollback a part of the changes * Start adding a Req wrapper (save my research) * Add req to shared (where the wrapper will reside) * Rework behaviour * Setup Mox for testing * Mix format * Call the wrapper to allow testing * Adapt one test * Remove outdated TODO * Extract method before reuse * Extract method before reuse * Adapt other test from http poison to req * Adapt another test * Support non-200 return codes & adapt test * Add moduledoc (credo) * Fix credo warning * Remove TODO (I verified the merge was OK) * Add moduledoc * Remove TODO - there is no problem here The :line_or_bytes option is only relevant when reading a file, after doc (https://hexdocs.pm/elixir/File.html#stream!/3) check. We're only doing a write here. * Change method visibility to help me test without S3 * Start iterating on script to detect url regressions in more detail * You had one job * Add note * Use a state file to properly analyse status codes * Update go.exs * Load & display * Avoid code eval * Parallelize the downloads a bit * Save WIP * Validate that all "OK on both sides" are actually equivalent * Split not all ok and all ok * Finalyse analysis * Update go.exs * Add fix for wojtekmach/req#270 * Update req_httpoison_testing.exs * Apply feedback * Add note * Improve Req headers extraction - support multiple values, by concatenating them - filter them first (reduce unecessary processing) - add new tests - adapt broken existing tests * Remove dead code * Add space after comma --------- Co-authored-by: Antoine Augusti <[email protected]>
- Loading branch information
1 parent
35bd484
commit 6b6690e
Showing
9 changed files
with
333 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
defmodule Transport.Req.Behaviour do | ||
@moduledoc """ | ||
At time of writing, Req does not introduce a behaviour allowing us to "Mox", as described here: | ||
- https://github.com/wojtekmach/req/issues/143 | ||
- https://github.com/wojtekmach/req/issues/246 | ||
We introduce an "above-level" wrapper with only the specific bits we are interested in, | ||
in order to allow the use of Mox during tests. | ||
""" | ||
|
||
# Ref: https://github.com/wojtekmach/req/blob/b40de7b7a0e7cc97a2c398ffcc42aa14962f3963/lib/req.ex#L545 | ||
@type url() :: URI.t() | String.t() | ||
# Simplified version for our needs | ||
@callback get(url(), options :: keyword()) :: {:ok, Req.Response.t()} | {:error, Exception.t()} | ||
end | ||
|
||
defmodule Transport.Req do | ||
@moduledoc """ | ||
The wrapper for the behaviour, which acts as a central access point for `Req` operations. | ||
By default the implementation is itself & delegates to `Req` directly. During tests, a Mox | ||
# is configured instead | ||
""" | ||
def impl, do: Application.get_env(:transport, :req_impl, __MODULE__) | ||
|
||
@behaviour Transport.Req.Behaviour | ||
defdelegate get(url, options), to: Req | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
Mox.defmock(Transport.HTTPoison.Mock, for: HTTPoison.Base) | ||
Mox.defmock(Transport.Req.Mock, for: Transport.Req.Behaviour) | ||
Mox.defmock(Transport.Shared.Schemas.Mock, for: Transport.Shared.Schemas.Wrapper) | ||
Mox.defmock(Shared.Validation.GBFSValidator.Mock, for: Shared.Validation.GBFSValidator.Wrapper) | ||
Mox.defmock(Transport.DataVisualization.Mock, for: Transport.DataVisualization) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/bash | ||
set -e | ||
diff <(jq --sort-keys 'del(.timeStamp)' $1) <(jq --sort-keys 'del(.timeStamp)' $2) 2>&1 |
Oops, something went wrong.