pitrou commented on a change in pull request #11375: URL: https://github.com/apache/arrow/pull/11375#discussion_r727093192
########## File path: cpp/src/arrow/filesystem/gcsfs.cc ########## @@ -70,7 +131,9 @@ bool GcsFileSystem::Equals(const FileSystem& other) const { } Result<FileInfo> GcsFileSystem::GetFileInfo(const std::string& path) { - return Status::NotImplemented("The GCS FileSystem is not fully implemented"); + auto p = GcsPath::FromString(path); + if (!p.ok()) return std::move(p).status(); Review comment: You can simply write: ```c++ ARROW_ASSIGN_OR_RAISE(auto p, GcsPath::FromString(path)); ``` ########## File path: cpp/src/arrow/filesystem/gcsfs_test.cc ########## @@ -59,6 +155,11 @@ TEST(GcsFileSystem, FileSystemCompare) { EXPECT_FALSE(a->Equals(*b)); } +TEST_F(GcsIntegrationTest, MakeBucket) { + auto fs = internal::MakeGcsFileSystemForTest(TestGcsOptions()); + ASSERT_OK(fs->GetFileInfo(kPreexistingBucket)); Review comment: Note we have utilities for testing in `filesystem/test_util.h` that would allow this test to be a bit more interesting, e.g.: ```c++ AssertFileInfo(fs.get(), kPreexistingBucket, FileType::Directory); ``` ########## File path: cpp/src/arrow/filesystem/gcsfs_internal.cc ########## @@ -0,0 +1,68 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +#include "arrow/filesystem/gcsfs_internal.h" + +#include <google/cloud/storage/client.h> + +#include <sstream> + +namespace arrow { +namespace fs { +namespace internal { + +Status ToArrowStatus(const google::cloud::Status& s) { + std::ostringstream os; + os << "google::cloud::Status(" << s << ")"; + switch (s.code()) { + case google::cloud::StatusCode::kOk: + break; + case google::cloud::StatusCode::kCancelled: + return Status::Cancelled(os.str()); + case google::cloud::StatusCode::kUnknown: + return Status::UnknownError(os.str()); + case google::cloud::StatusCode::kInvalidArgument: + return Status::Invalid(os.str()); + case google::cloud::StatusCode::kDeadlineExceeded: + case google::cloud::StatusCode::kNotFound: + // TODO: it is unclear if a better mapping would be possible. Review comment: I would suggest IOError for all external errors (such as `kDeadlineExceeded`, `kPermissionDenied`, `kUnauthenticated`...). ########## File path: cpp/src/arrow/filesystem/gcsfs_test.cc ########## @@ -19,21 +19,75 @@ #include <gmock/gmock-matchers.h> #include <gmock/gmock-more-matchers.h> +#include <google/cloud/credentials.h> +#include <google/cloud/storage/client.h> +#include <google/cloud/storage/options.h> #include <gtest/gtest.h> +#include <boost/process.hpp> #include <string> +#include "arrow/filesystem/gcsfs_internal.h" #include "arrow/testing/gtest_util.h" #include "arrow/testing/util.h" namespace arrow { namespace fs { namespace { +namespace bp = boost::process; +namespace gc = google::cloud; +namespace gcs = google::cloud::storage; + +using ::testing::HasSubstr; using ::testing::IsEmpty; using ::testing::Not; using ::testing::NotNull; +auto const* kPreexistingBucket = "test-bucket-name"; + +class GcsIntegrationTest : public ::testing::Test { + public: + ~GcsIntegrationTest() override { + if (server_process_.valid()) { + // Brutal shutdown + server_process_.terminate(); + server_process_.wait(); + } + } + + protected: + void SetUp() override { + port_ = std::to_string(GetListenPort()); + auto exe_path = bp::search_path("python3"); + ASSERT_THAT(exe_path, Not(IsEmpty())); + + server_process_ = bp::child(boost::this_process::environment(), exe_path, "-m", + "testbench", "--port", port_); + + // Create a bucket in the testbench so additional Review comment: Is this sentence incomplete? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: github-unsubscr...@arrow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org