]> git.proxmox.com Git - ceph.git/blob - ceph/src/arrow/r/tests/testthat/test-s3.R
import quincy 17.2.0
[ceph.git] / ceph / src / arrow / r / tests / testthat / test-s3.R
1 # Licensed to the Apache Software Foundation (ASF) under one
2 # or more contributor license agreements. See the NOTICE file
3 # distributed with this work for additional information
4 # regarding copyright ownership. The ASF licenses this file
5 # to you under the Apache License, Version 2.0 (the
6 # "License"); you may not use this file except in compliance
7 # with the License. You may obtain a copy of the License at
8 #
9 # http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing,
12 # software distributed under the License is distributed on an
13 # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 # KIND, either express or implied. See the License for the
15 # specific language governing permissions and limitations
16 # under the License.
17
18
19 run_these <- tryCatch(
20 expr = {
21 if (arrow_with_s3() &&
22 identical(tolower(Sys.getenv("ARROW_R_DEV")), "true") &&
23 !identical(Sys.getenv("AWS_ACCESS_KEY_ID"), "") &&
24 !identical(Sys.getenv("AWS_SECRET_ACCESS_KEY"), "")) {
25 # See if we have access to the test bucket
26 bucket <- s3_bucket("ursa-labs-r-test")
27 bucket$GetFileInfo("")
28 TRUE
29 } else {
30 FALSE
31 }
32 },
33 error = function(e) FALSE
34 )
35
36 bucket_uri <- function(..., bucket = "s3://ursa-labs-r-test/%s?region=us-west-2") {
37 segments <- paste(..., sep = "/")
38 sprintf(bucket, segments)
39 }
40
41 if (run_these) {
42 now <- as.numeric(Sys.time())
43 on.exit(bucket$DeleteDir(now))
44
45 test_that("read/write Feather on S3", {
46 write_feather(example_data, bucket_uri(now, "test.feather"))
47 expect_identical(read_feather(bucket_uri(now, "test.feather")), example_data)
48 })
49
50 test_that("read/write Parquet on S3", {
51 skip_if_not_available("parquet")
52 write_parquet(example_data, bucket_uri(now, "test.parquet"))
53 expect_identical(read_parquet(bucket_uri(now, "test.parquet")), example_data)
54 })
55 }