mattmartian
I have set up local stack within docker-compose so that I can do integration testing with s3, however with my setup I seem to be running into a nxdomain error that I can’t seem to figure out, below is my setup and some of my code for testing - am I missing something or doing something wrong? I know that I was originally using host networking but switched to bridge network
cross posted here: LocalStack Discuss Archive
error
#0 16.15 20:51:48.018 application=ex_aws domain=elixir file=lib/ex_aws/request.ex function=request_and_retry/7 line=78 mfa=ExAws.Request.request_and_retry/7 module=ExAws.Request pid=<0.591.0> [warn] ExAws: HTTP ERROR: :nxdomain for URL: "http://localstack:4566/test-bucket/" ATTEMPT: 9
#0 18.28
#0 18.28 20:51:50.156 application=ex_aws domain=elixir file=lib/ex_aws/request.ex function=request_and_retry/7 line=78 mfa=ExAws.Request.request_and_retry/7 module=ExAws.Request pid=<0.591.0> [warn] ExAws: HTTP ERROR: :nxdomain for URL: "http://localstack:4566/test-bucket/" ATTEMPT: 10
#0 18.31
#0 18.31
#0 18.31 1) test get_object/2 get existing file from s3 (S3Test)
#0 18.31 test/s3_test.exs:12
#0 18.31 ** (ExAws.Error) ExAws Request Error!
#0 18.31
#0 18.31 {:error, :nxdomain}
#0 18.31
#0 18.31 code: ExAws.request!(ExAws.S3.put_bucket("test-bucket", "us-west-2"))
#0 18.31 stacktrace:
#0 18.31 (ex_aws 2.3.2) lib/ex_aws.ex:89: ExAws.request!/2
#0 18.31 test/s3_test.exs:28: (test)
config/test.exs
config :ex_aws,
access_key_id: "test",
secret_access_key: "test",
region: "us-west-2"
config :ex_aws, :s3,
scheme: "http://",
host: "localstack",
port: 4566,
region: "us-west-2"
s3_test.exs
test "get existing file from s3" do
# Create some random bytes to store in the file.
contents = :crypto.strong_rand_bytes(100)
# We set up an on_exit callback to empty and then delete the bucket
# when the test exit, so that the next test has a clean slate.
on_exit(fn ->
"test-bucket"
|> ExAws.S3.list_objects()
|> ExAws.stream!()
|> Enum.each(&ExAws.request!(ExAws.S3.delete_object("test-bucket", &1.key)))
ExAws.request!(ExAws.S3.delete_bucket("test-bucket"))
end)
# Create bucket.
ExAws.request!(ExAws.S3.put_bucket("test-bucket", "us-west-2"))
# Upload a file.
ExAws.request!(ExAws.S3.put_object("test-bucket", "my/random/file", contents))
# Now, we run our code and assert on its behavior.
{:ok, object} = S3Helper.get_object("test-bucket", "my/random/file")
assert(Map.has_key?(object, :status_code) and object.status_code == 200)
end
s3 logic
@ex_aws_mod Application.compile_env(:tls_worker, [:test_doubles, :ex_aws], ExAws)
def get_object(bucket, path) do
ExAws.S3.get_object(bucket, path)
|> @ex_aws_mod.request(region: Application.get_env(:ex_aws, :region))
end
docker-compose
version: "3"
services:
test:
build:
context: .
dockerfile: Dockerfile.test
args:
MIX_ENV: test
ENVIRONMENT: test
volumes:
- /app
working_dir: /app
command: MIX_ENV=test mix test
depends_on:
- localstack
networks:
- test
stdin_open: true
tty: true
localstack:
container_name: "${LOCALSTACK_DOCKER_NAME-localstack_main}"
image: localstack/localstack
environment:
- AWS_DEFAULT_REGION="us-west-2"
- SERVICES="s3"
- EDGE_PORT="4566"
networks:
- test
ports:
- "4566:4566"
volumes:
- "${LOCALSTACK_VOLUME_DIR:-./volume}:/var/lib/localstack"
- "/var/run/docker.sock:/var/run/docker.sock"
networks:
test:
driver: bridge
Trending in Questions
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
Hello!
Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app.
I creat...
New
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
So my question is quite simple and i have found no conclusive answer on forum, google or AI.
Should we use :erlang.float for Integer to ...
New
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New
I’m trying to set up Emacs with elixir-ls via lsp-mode and credo via Flycheck. This should mostly be preconfigured as Flycheck picks up c...
New
Other Trending Topics
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hobbes is a low-level distributed database for the Elixir programming language.
Hobbes provides a simple, safe, and scalable storage lay...
New
Hi there! We created Gust: A task orchestrator inspired by Airflow.
For those who have never heard about Aiflow, it’s a Python-based wor...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve.
They are GUI (Emerge) and State management (S...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #blog-post
- #elixirconf-us
- #elixir-ls
- #ai
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming










Showing Posts 1 to 2- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
jarlah
This is not an answer to your problem, but personally I would rather try to use Testcontainers ceph container module. Instead of setting this up outside the tests
dimitarvp
Have you noticed that you configure
localstackbe your host but the error in the terminal says that the domain/host iselixir?