MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / TEST

Function TEST

tensorflow/core/platform/cloud/gcs_file_system_test.cc:54–98  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

52};
53
54TEST(GcsFileSystemTest, NewRandomAccessFile_NoBlockCache) {
55 std::vector<HttpRequest*> requests(
56 {new FakeHttpRequest(
57 "Uri: https://storage.googleapis.com/bucket/random_access.txt\n"
58 "Auth Token: fake_token\n"
59 "Range: 0-5\n"
60 "Timeouts: 5 1 20\n",
61 "012345"),
62 new FakeHttpRequest(
63 "Uri: https://storage.googleapis.com/bucket/random_access.txt\n"
64 "Auth Token: fake_token\n"
65 "Range: 6-11\n"
66 "Timeouts: 5 1 20\n",
67 "6789")});
68 GcsFileSystem fs(std::unique_ptr<AuthProvider>(new FakeAuthProvider),
69 std::unique_ptr<HttpRequest::Factory>(
70 new FakeHttpRequestFactory(&requests)),
71 std::unique_ptr<ZoneProvider>(new FakeZoneProvider),
72 0 /* block size */, 0 /* max bytes */, 0 /* max staleness */,
73 0 /* stat cache max age */, 0 /* stat cache max entries */,
74 0 /* matching paths cache max age */,
75 0 /* matching paths cache max entries */, kTestRetryConfig,
76 kTestTimeoutConfig, *kAllowedLocationsDefault,
77 nullptr /* gcs additional header */);
78
79 std::unique_ptr<RandomAccessFile> file;
80 TF_EXPECT_OK(fs.NewRandomAccessFile("gs://bucket/random_access.txt", &file));
81
82 StringPiece filename;
83 TF_EXPECT_OK(file->Name(&filename));
84 EXPECT_EQ(filename, "gs://bucket/random_access.txt");
85
86 char scratch[6];
87 StringPiece result;
88
89 // Read the first chunk.
90 TF_EXPECT_OK(file->Read(0, sizeof(scratch), &result, scratch));
91 EXPECT_EQ("012345", result);
92
93 // Read the second chunk.
94 EXPECT_EQ(
95 errors::Code::OUT_OF_RANGE,
96 file->Read(sizeof(scratch), sizeof(scratch), &result, scratch).code());
97 EXPECT_EQ("6789", result);
98}
99
100TEST(GcsFileSystemTest, NewRandomAccessFile_Buffered) {
101 std::vector<HttpRequest*> requests({

Callers

nothing calls this directly

Calls 15

UnavailableFunction · 0.85
FailedPreconditionFunction · 0.85
RetryConfigClass · 0.85
NotFoundFunction · 0.85
allowed_locationsMethod · 0.80
CreateHttpRequestMethod · 0.80
timeoutsMethod · 0.80
stat_cache_max_ageMethod · 0.80

Tested by

no test coverage detected