Skip to content

Commit fa38cae

Browse files
committed
Add InvalidBlockList validation test
1 parent 6e1be15 commit fa38cae

File tree

2 files changed

+64
-2
lines changed

2 files changed

+64
-2
lines changed

test/azure_blobs_exception_tests.jl

+62
Original file line numberDiff line numberDiff line change
@@ -594,6 +594,63 @@ end # @testitem
594594
return nrequests[]
595595
end
596596

597+
function test_invalid_block_list()
598+
nrequests = Ref(0)
599+
uploadid = nothing
600+
(port, tcp_server) = Sockets.listenany(8081)
601+
http_server = HTTP.serve!(tcp_server) do request::HTTP.Request
602+
nrequests[] += 1
603+
if request.method == "PUT"
604+
if occursin("comp=blocklist", request.target)
605+
uploadid_value = HTTP.header(request, "x-ms-meta-uploadid")
606+
if !isnothing(uploadid_value)
607+
uploadid = "x-ms-meta-uploadid" => uploadid_value
608+
end
609+
return HTTP.Response(400, "InvalidBlockList")
610+
else
611+
return HTTP.Response(200, [
612+
"Content-Length" => "0",
613+
"Last-Modified" => "Tue, 15 Oct 2019 12:45:26 GMT",
614+
"ETag" => "123"
615+
], "")
616+
end
617+
elseif request.method == "HEAD"
618+
return HTTP.Response(200, [
619+
uploadid,
620+
"Content-Length" => "0",
621+
"Last-Modified" => "Tue, 15 Oct 2019 12:45:26 GMT",
622+
"ETag" => "123"
623+
], "")
624+
else
625+
return HTTP.Response(404, "Not Found")
626+
end
627+
end
628+
629+
baseurl = "http://127.0.0.1:$port/$account/$container/"
630+
conf = AzureConfig(;
631+
storage_account_name=account,
632+
container_name=container,
633+
storage_account_key=shared_key_from_azurite,
634+
host=baseurl,
635+
opts=ClientOptions(;
636+
max_retries=max_retries,
637+
retry_timeout_secs=retry_timeout_secs,
638+
request_timeout_secs
639+
)
640+
)
641+
642+
try
643+
put_object(zeros(UInt8, 11 * 1024 * 1024), "blob", conf)
644+
@test true
645+
catch e
646+
@test false
647+
finally
648+
Threads.@spawn HTTP.forceclose(http_server)
649+
end
650+
# wait(http_server)
651+
return nrequests[]
652+
end
653+
597654
@testset "400: Bad Request" begin
598655
# Returned when there's an error in the request URI, headers, or body. The response body
599656
# contains an error message explaining what the specific problem is.
@@ -762,4 +819,9 @@ end # @testitem
762819
nrequests = test_cancellation()
763820
@test nrequests == 1
764821
end
822+
823+
@testset "InvalidBlockList" begin
824+
nrequests = test_invalid_block_list()
825+
@test nrequests == 4
826+
end
765827
end

test/snowflake_stage_exception_tests.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -89,15 +89,15 @@
8989
@test false # Should have thrown an error
9090
catch e
9191
@test e isa RustyObjectStore.PutException
92-
@test occursin("Connection refused", e.msg)
92+
@test occursin("Connection refused", e.msg) || occursin("Unable to access master token file", e.msg)
9393
end
9494

9595
try
9696
get_object!(buffer, "still_doesnt_exist.csv", _stale_config)
9797
@test false # Should have thrown an error
9898
catch e
9999
@test e isa RustyObjectStore.GetException
100-
@test occursin("Connection refused", e.msg)
100+
@test occursin("Connection refused", e.msg) || occursin("Unable to access master token file", e.msg)
101101
end
102102
end
103103

0 commit comments

Comments
 (0)