From f67652533cd76adedc822b5527458b9e20286d72 Mon Sep 17 00:00:00 2001 From: Curtis Vogt Date: Wed, 29 Sep 2021 09:05:32 -0500 Subject: [PATCH 1/3] Test `isopen` on `response_stream` --- test/issues.jl | 27 ++++++++++++++++++++++++--- test/minio.jl | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 3 deletions(-) diff --git a/test/issues.jl b/test/issues.jl index dfdeef8dc9..6d99332dde 100644 --- a/test/issues.jl +++ b/test/issues.jl @@ -88,10 +88,31 @@ try try S3.put_object(BUCKET_NAME, file_name) + + # Note: Avoid using `eof` for these tests can hang when using an unclosed `Base.BufferStream` + stream = S3.get_object(BUCKET_NAME, file_name, Dict("return_stream" => true)) - println("test #466") # So we know if this is the reason for tests hanging. - @test eof(stream) # This will hang if #466 not fixed and using HTTP.jl v0.9.15+ - println("#466 fixed") + if AWS.DEFAULT_BACKEND[] isa AWS.HTTPBackend + @test !isopen(stream) + else + @test isopen(stream) + end + + stream = Base.BufferStream() + S3.get_object(BUCKET_NAME, file_name, Dict("response_stream" => stream)) + if AWS.DEFAULT_BACKEND[] isa AWS.HTTPBackend + @test !isopen(stream) + else + @test !isopen(stream) + end + + stream = Base.BufferStream() + S3.get_object(BUCKET_NAME, file_name, Dict("response_stream" => stream, "return_stream" => true)) + if AWS.DEFAULT_BACKEND[] isa AWS.HTTPBackend + @test !isopen(stream) + else + @test isopen(stream) + end finally S3.delete_object(BUCKET_NAME, file_name) end diff --git a/test/minio.jl b/test/minio.jl index 921fe0a14c..20f75f92be 100644 --- a/test/minio.jl +++ b/test/minio.jl @@ -62,6 +62,41 @@ try @test sort(getindex.(objs_prefix["Contents"], "Key")) == ["empty", "myobject"] @test objs_prefix["CommonPrefixes"]["Prefix"] == "foo/" + @testset "issue 466" begin + file_name = "hang.txt" + + try + S3.put_object("anewbucket", file_name) + + # Note: Using `eof` for these tests can hang when using an unclosed `Base.BufferStream` + + stream = S3.get_object("anewbucket", file_name, Dict("return_stream" => true)) + if AWS.DEFAULT_BACKEND[] isa AWS.HTTPBackend + @test !isopen(stream) + else + @test isopen(stream) + end + + stream = Base.BufferStream() + S3.get_object("anewbucket", file_name, Dict("response_stream" => stream)) + if AWS.DEFAULT_BACKEND[] isa AWS.HTTPBackend + @test !isopen(stream) + else + @test !isopen(stream) + end + + stream = Base.BufferStream() + S3.get_object("anewbucket", file_name, Dict("response_stream" => stream, "return_stream" => true)) + if AWS.DEFAULT_BACKEND[] isa AWS.HTTPBackend + @test !isopen(stream) + else + @test isopen(stream) + end + finally + S3.delete_object("anewbucket", file_name) + end + end + finally # Delete all objects and the bucket objs = S3.list_objects_v2("anewbucket") From d6aeacca911f6ab4021391183276d783c4d9a56d Mon Sep 17 00:00:00 2001 From: Curtis Vogt Date: Wed, 29 Sep 2021 09:11:22 -0500 Subject: [PATCH 2/3] fixup! Test `isopen` on `response_stream` --- test/issues.jl | 2 +- test/minio.jl | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/test/issues.jl b/test/issues.jl index 6d99332dde..eca06979c6 100644 --- a/test/issues.jl +++ b/test/issues.jl @@ -103,7 +103,7 @@ try if AWS.DEFAULT_BACKEND[] isa AWS.HTTPBackend @test !isopen(stream) else - @test !isopen(stream) + @test_broken isopen(stream) end stream = Base.BufferStream() diff --git a/test/minio.jl b/test/minio.jl index 20f75f92be..4e1d0bf215 100644 --- a/test/minio.jl +++ b/test/minio.jl @@ -62,6 +62,9 @@ try @test sort(getindex.(objs_prefix["Contents"], "Key")) == ["empty", "myobject"] @test objs_prefix["CommonPrefixes"]["Prefix"] == "foo/" + # Duplicated testset from "test/issues.jl". Useful for testing outside the CI. Ideally, + # the tests should be revised such that local testing works without having to duplicate + # testsets. @testset "issue 466" begin file_name = "hang.txt" @@ -82,7 +85,7 @@ try if AWS.DEFAULT_BACKEND[] isa AWS.HTTPBackend @test !isopen(stream) else - @test !isopen(stream) + @test_broken isopen(stream) end stream = Base.BufferStream() From 6457586a071115f00764a620c679b42b314edf04 Mon Sep 17 00:00:00 2001 From: Curtis Vogt Date: Wed, 29 Sep 2021 09:12:10 -0500 Subject: [PATCH 3/3] Appease formatter --- test/issues.jl | 6 +++++- test/minio.jl | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/test/issues.jl b/test/issues.jl index eca06979c6..aec25996a2 100644 --- a/test/issues.jl +++ b/test/issues.jl @@ -107,7 +107,11 @@ try end stream = Base.BufferStream() - S3.get_object(BUCKET_NAME, file_name, Dict("response_stream" => stream, "return_stream" => true)) + S3.get_object( + BUCKET_NAME, + file_name, + Dict("response_stream" => stream, "return_stream" => true), + ) if AWS.DEFAULT_BACKEND[] isa AWS.HTTPBackend @test !isopen(stream) else diff --git a/test/minio.jl b/test/minio.jl index 4e1d0bf215..ab41ab7b12 100644 --- a/test/minio.jl +++ b/test/minio.jl @@ -89,7 +89,11 @@ try end stream = Base.BufferStream() - S3.get_object("anewbucket", file_name, Dict("response_stream" => stream, "return_stream" => true)) + S3.get_object( + "anewbucket", + file_name, + Dict("response_stream" => stream, "return_stream" => true), + ) if AWS.DEFAULT_BACKEND[] isa AWS.HTTPBackend @test !isopen(stream) else