Closed jamie-digital closed 4 years ago
The test should be hermetic (it uses record/replay). It works for me:
`` $ cd blob/gcsblob $ go test -v ... PASS ok gocloud.dev/blob/gcsblob 13.786s $
The URL in our record file for the first test is
https://www.googleapis.com/storage/v1/b/go-cloud-blob-test-bucket/o?alt=json\u0026delimiter=\u0026maxResults=1000\u0026pageToken=\u0026prefix=blob-for-list\u0026prettyPrint=false\u0026projection=full\u0026versions=false
compared to your error message
https://storage.googleapis.com/storage/v1/b/go-cloud-blob-test-bucket/o?alt=json&delimiter=&maxResults=1000&pageToken=&prefix=blob-for-list&prettyPrint=false&projection=full&versions=false
Some of those differences are due to encoding, but the most obvious delta is the hostname www.googleapis.com
vs storage.googleapis.com
.
Can you make sure you are using cloud.google.com/go v0.44.3
? Maybe try starting with a fresh Go install. I think both of those hostnames will work in real life, but the record/replay is matching exact hostnames.
When I run the tests from within the module, it works fine:
$ cd gocloud.dev/blob/gcsblob
$ go test -v
=== RUN TestConformance
=== RUN TestConformance/TestList
=== RUN TestConformance/TestList/no_objects
TestConformance/TestList/no_objects: setup.go:98: Replaying from golden file testdata/TestConformance/TestList/no_objects.replay
...
PASS
But when I run the tests from outside the module it fails:
$ cd mymodule
$ go test gocloud.dev/blob/gcsblob -v
=== RUN TestConformance
=== RUN TestConformance/TestList
=== RUN TestConformance/TestList/no_objects
TestConformance/TestList/no_objects: setup.go:98: Replaying from golden file testdata/TestConformance/TestList/no_objects.replay
2020/03/12 15:38:45 ERROR: martian: failed to round trip: no matching request for &{Method:GET URL:https://storage.googleapis.com/storage/v1/b/go-cloud-blob-test-bucket/o?alt=json&delimiter=&maxResults=1000&pageToken=&prefix=blob-for-list&prettyPrint=false&projection=full&versions=false Proto:HTTP/1.1 ProtoMajor:1 ProtoMinor:1 Header:map[Accept-Encoding:[gzip] User-Agent:[google-api-go-client/0.5 go-cloud/blob/0.1.0] X-Goog-Api-Client:[gl-go/1.14.0 gccl/20200228]] Body:<nil> GetBody:<nil> ContentLength:0 TransferEncoding:[] Close:false Host:storage.googleapis.com Form:map[] PostForm:map[] MultipartForm:<nil> Trailer:map[] RemoteAddr:127.0.0.1:59175 RequestURI:/storage/v1/b/go-cloud-blob-test-bucket/o?alt=json&delimiter=&maxResults=1000&pageToken=&prefix=blob-for-list&prettyPrint=false&projection=full&versions=false TLS:0xc0005b2000 Cancel:<nil> Response:<nil> ctx:<nil>}
2020/03/12 15:38:45 ERROR: martian: failed to round trip: no matching request for &{Method:GET URL:https://storage.googleapis.com/storage/v1/b/go-cloud-blob-test-bucket/o?alt=json&delimiter=&maxResults=1000&pageToken=&prefix=blob-for-list&prettyPrint=false&projection=full&versions=false Proto:HTTP/1.1 ProtoMajor:1 ProtoMinor:1 Header:map[Accept-Encoding:[gzip] User-Agent:[google-api-go-client/0.5 go-cloud/blob/0.1.0] X-Goog-Api-Client:[gl-go/1.14.0 gccl/20200228]] Body:<nil> GetBody:<nil> ContentLength:0 TransferEncoding:[] Close:false Host:storage.googleapis.com Form:map[] PostForm:map[] MultipartForm:<nil> Trailer:map[] RemoteAddr:127.0.0.1:59175 RequestURI:/storage/v1/b/go-cloud-blob-test-bucket/o?alt=json&delimiter=&maxResults=1000&pageToken=&prefix=blob-for-list&prettyPrint=false&projection=full&versions=false TLS:<nil> Cancel:<nil> Response:<nil> ctx:<nil>}
2020/03/12 15:38:47 ERROR: martian: failed to round trip: no matching request for &{Method:GET URL:https://storage.googleapis.com/storage/v1/b/go-cloud-blob-test-bucket/o?alt=json&delimiter=&maxResults=1000&pageToken=&prefix=blob-for-list&prettyPrint=false&projection=full&versions=false Proto:HTTP/1.1 ProtoMajor:1 ProtoMinor:1 Header:map[Accept-Encoding:[gzip] User-Agent:[google-api-go-client/0.5 go-cloud/blob/0.1.0] X-Goog-Api-Client:[gl-go/1.14.0 gccl/20200228]] Body:<nil> GetBody:<nil> ContentLength:0 TransferEncoding:[] Close:false Host:storage.googleapis.com Form:map[] PostForm:map[] MultipartForm:<nil> Trailer:map[] RemoteAddr:127.0.0.1:59175 RequestURI:/storage/v1/b/go-cloud-blob-test-bucket/o?alt=json&delimiter=&maxResults=1000&pageToken=&prefix=blob-for-list&prettyPrint=false&projection=full&versions=false TLS:<nil> Cancel:<nil> Response:<nil> ctx:<nil>}
2020/03/12 15:38:50 ERROR: martian: failed to round trip: no matching request for &{Method:GET URL:https://storage.googleapis.com/storage/v1/b/go-cloud-blob-test-bucket/o?alt=json&delimiter=&maxResults=1000&pageToken=&prefix=blob-for-list&prettyPrint=false&projection=full&versions=false Proto:HTTP/1.1 ProtoMajor:1 ProtoMinor:1 Header:map[Accept-Encoding:[gzip] User-Agent:[google-api-go-client/0.5 go-cloud/blob/0.1.0] X-Goog-Api-Client:[gl-go/1.14.0 gccl/20200228]] Body:<nil> GetBody:<nil> ContentLength:0 TransferEncoding:[] Close:false Host:storage.googleapis.com Form:map[] PostForm:map[] MultipartForm:<nil> Trailer:map[] RemoteAddr:127.0.0.1:59175 RequestURI:/storage/v1/b/go-cloud-blob-test-bucket/o?alt=json&delimiter=&maxResults=1000&pageToken=&prefix=blob-for-list&prettyPrint=false&projection=full&versions=false TLS:<nil> Cancel:<nil> Response:<nil> ctx:<nil>}
...
FAIL
I just saw your second comment. I'm using cloud.google.com/go v0.54.0
. Going back to v0.44.0 doesn't seem to change anything though. I'll try a fresh module.
Dropping cloud.google.com/go
from my go.mod completely resolved the issue, so I worked back through the versions looking for a change in behaviour. At cloud.google.com/go v0.52.0
the looping behaviour goes away but some of the tests fail:
--- FAIL: TestConformance (1.14s)
--- PASS: TestConformance/TestList (0.45s)
--- PASS: TestConformance/TestList/no_objects (0.40s)
--- PASS: TestConformance/TestList/exactly_1_object_due_to_prefix (0.01s)
--- PASS: TestConformance/TestList/no_pagination (0.01s)
--- PASS: TestConformance/TestList/by_1 (0.01s)
--- PASS: TestConformance/TestList/by_2 (0.01s)
--- PASS: TestConformance/TestList/by_3 (0.01s)
--- PASS: TestConformance/TestList/PaginationConsistencyAfterInsert (0.01s)
--- PASS: TestConformance/TestList/PaginationConsistencyAfterDelete (0.01s)
--- PASS: TestConformance/TestListWeirdKeys (0.01s)
--- PASS: TestConformance/TestListDelimiters (0.04s)
--- PASS: TestConformance/TestListDelimiters/fwdslash (0.01s)
--- PASS: TestConformance/TestListDelimiters/backslash (0.01s)
--- PASS: TestConformance/TestListDelimiters/abc (0.02s)
--- FAIL: TestConformance/TestRead (0.07s)
--- PASS: TestConformance/TestRead/read_of_nonexistent_key_fails (0.01s)
--- PASS: TestConformance/TestRead/negative_offset_fails (0.00s)
--- PASS: TestConformance/TestRead/length_0_read (0.01s)
--- PASS: TestConformance/TestRead/read_from_positive_offset_to_end (0.01s)
--- PASS: TestConformance/TestRead/read_a_part_in_middle (0.01s)
--- PASS: TestConformance/TestRead/read_in_full (0.01s)
--- FAIL: TestConformance/TestRead/read_in_full_with_negative_length_not_-1 (0.01s)
--- PASS: TestConformance/TestAttributes (0.01s)
--- FAIL: TestConformance/TestWrite (0.12s)
--- PASS: TestConformance/TestWrite/write_to_empty_key_fails (0.01s)
--- PASS: TestConformance/TestWrite/no_write_then_close_results_in_empty_blob (0.01s)
--- PASS: TestConformance/TestWrite/no_write_then_close_results_in_empty_blob,_blob_existed (0.01s)
--- PASS: TestConformance/TestWrite/invalid_ContentType_fails (0.00s)
--- PASS: TestConformance/TestWrite/ContentType_is_discovered_if_not_provided (0.01s)
--- PASS: TestConformance/TestWrite/write_with_explicit_ContentType_overrides_discovery (0.01s)
--- FAIL: TestConformance/TestWrite/Content_md5_match (0.01s)
--- PASS: TestConformance/TestWrite/Content_md5_did_not_match (0.01s)
--- PASS: TestConformance/TestWrite/Content_md5_did_not_match,_blob_existed (0.01s)
--- PASS: TestConformance/TestWrite/a_small_text_file (0.01s)
--- PASS: TestConformance/TestWrite/a_large_jpg_file (0.01s)
--- PASS: TestConformance/TestWrite/a_large_jpg_file_written_in_two_chunks (0.01s)
--- PASS: TestConformance/TestCanceledWrite (0.03s)
--- PASS: TestConformance/TestCanceledWrite/EmptyContentType (0.01s)
--- PASS: TestConformance/TestCanceledWrite/NonEmptyContentType (0.01s)
--- PASS: TestConformance/TestCanceledWrite/BlobExists (0.01s)
--- PASS: TestConformance/TestConcurrentWriteAndRead (0.05s)
--- PASS: TestConformance/TestMetadata (0.03s)
--- PASS: TestConformance/TestMetadata/empty (0.01s)
--- PASS: TestConformance/TestMetadata/empty_key_fails (0.00s)
--- PASS: TestConformance/TestMetadata/duplicate_case-insensitive_key_fails (0.00s)
--- PASS: TestConformance/TestMetadata/valid_metadata (0.01s)
--- PASS: TestConformance/TestMetadata/valid_metadata_with_empty_body (0.01s)
--- PASS: TestConformance/TestMetadata/valid_metadata_with_content_type (0.01s)
--- PASS: TestConformance/TestMetadata/weird_metadata_keys (0.01s)
--- PASS: TestConformance/TestMetadata/non-utf8_metadata_key (0.00s)
--- PASS: TestConformance/TestMetadata/non-utf8_metadata_value (0.00s)
--- PASS: TestConformance/TestMD5 (0.01s)
--- PASS: TestConformance/TestCopy (0.02s)
--- PASS: TestConformance/TestCopy/NonExistentSourceFails (0.00s)
--- PASS: TestConformance/TestCopy/Works (0.01s)
--- PASS: TestConformance/TestDelete (0.01s)
--- PASS: TestConformance/TestDelete/NonExistentFails (0.00s)
--- PASS: TestConformance/TestDelete/Works (0.01s)
--- PASS: TestConformance/TestKeys (0.20s)
--- PASS: TestConformance/TestKeys/non-UTF8_fails (0.00s)
--- PASS: TestConformance/TestKeys/backslashes (0.01s)
--- PASS: TestConformance/TestKeys/unicode (0.01s)
--- PASS: TestConformance/TestKeys/ascii-5 (0.01s)
--- PASS: TestConformance/TestKeys/dotdotbackslash (0.01s)
--- PASS: TestConformance/TestKeys/spaces (0.01s)
--- PASS: TestConformance/TestKeys/ascii-3 (0.01s)
--- PASS: TestConformance/TestKeys/ascii-8 (0.01s)
--- PASS: TestConformance/TestKeys/dotdotslash (0.01s)
--- PASS: TestConformance/TestKeys/repeatedbackslashes (0.01s)
--- PASS: TestConformance/TestKeys/startwithdigit (0.01s)
--- PASS: TestConformance/TestKeys/fwdslashes (0.01s)
--- PASS: TestConformance/TestKeys/repeatedfwdslashes (0.01s)
--- PASS: TestConformance/TestKeys/quote (0.01s)
--- PASS: TestConformance/TestKeys/ascii-1 (0.01s)
--- PASS: TestConformance/TestKeys/ascii-2 (0.01s)
--- PASS: TestConformance/TestKeys/ascii-4 (0.01s)
--- PASS: TestConformance/TestKeys/ascii-6 (0.01s)
--- PASS: TestConformance/TestKeys/ascii-7 (0.01s)
--- PASS: TestConformance/TestSignedURL (0.05s)
--- PASS: TestConformance/TestAs (0.03s)
--- PASS: TestConformance/TestAs/verify_ContentLanguage_can_be_written_and_read_through_As (0.02s)
--- PASS: TestConformance/TestAs/verify_As_returns_false_when_passed_nil (0.02s)
Going further back, the same issues continue until v0.44.0
, where everything works again (not sure why it wasn't working when I made my previous comment). That would suggest cloud.google.com/go v0.45.0
breaks something and cloud.google.com/go v0.52.0
breaks it further.
Good thought on checking the cloud.google.com/go
version!
I doubt that those cloud.google.com/go
versions break anything if you use them live. They just changed some implementation details that happen to be recorded in the record/replay file. This kind of test is fragile against that kind of change.
If you want to dig deeper and/or confirm that, you can try running the tests with -record
mode; you'll have to create a test bucket and update the code to point to it, and some env variables as well, so this is not super easy. https://github.com/google/go-cloud/blob/master/internal/docs/design.md#record-mode as more info.
Would it be possible to modify the test to give up after a few attempts? I accept that the test is somewhat brittle, and I've set my CI pipeline to ignore this test's failures, but it feels a bit wasteful for it to keep retrying until it gets killed after 10 mins.
Describe the bug
Testing blob/gcsblob runs for the full test timeout (10m by default) before giving up, due to a failed request. This may be caused by a corporate HTTP proxy not being used (and therefore the traffic being blocked).
To Reproduce
In module mode:
Test logs
Expected behavior
Tests pass in a timely fashion. If connectivity isn't working, the test should give up after a limited number of attempts, rather than retrying until the test times out.
Version
v0.19.0
Additional context
This may be caused by a corporate HTTP proxy not being used (and therefore the traffic being blocked). Running on Go1.14 darwin amd64