Impala
Impalaistheopensource,nativeanalyticdatabaseforApacheHadoop.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
S3PlannerTest.java
Go to the documentation of this file.
1 // Copyright (c) 2015 Cloudera, Inc. All rights reserved.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 package com.cloudera.impala.planner;
16 
17 import static org.junit.Assume.assumeTrue;
18 
19 import java.net.URI;
20 
21 import org.apache.commons.lang.StringUtils;
22 import org.apache.hadoop.conf.Configuration;
23 import org.apache.hadoop.fs.Path;
24 import org.junit.Assert;
25 import org.junit.Before;
26 import org.junit.Test;
27 
29 
30 // S3 specific planner tests go here, and will run against tables in S3. These tests
31 // are run only when test.fs.s3a.name is set in the configuration.
32 public class S3PlannerTest extends PlannerTestBase {
33  // Set to the s3a bucket URI when running on S3. e.g. s3a://bucket/
34  private static final String TEST_FS_S3A_NAME = "test.fs.s3a.name";
35 
36  // The path that will replace the value of TEST_FS_S3A_NAME in file paths.
37  private static final Path S3A_CANONICAL_BUCKET = new Path("s3a://bucket");
38 
39  // The Hadoop configuration.
40  private final Configuration CONF = new Configuration();
41 
42  // The value of the TEST_FS_S3A_NAME property.
43  private Path fsName;
44 
50  @Before
51  public void setUpTest() {
52  String fsNameStr = CONF.getTrimmed(TEST_FS_S3A_NAME);
53  // Skip if the config property was not set. i.e. not running against S3.
54  assumeTrue(!StringUtils.isEmpty(fsNameStr));
55  fsName = new Path(fsNameStr);
56  }
57 
63  @Override
64  protected Path cleanseFilePath(Path path) {
65  path = super.cleanseFilePath(path);
66  URI fsURI = fsName.toUri();
67  URI pathURI = path.toUri();
68  Assert.assertTrue("error: " + path + " is not on filesystem " + fsName,
69  fsURI.getScheme().equals(pathURI.getScheme()) &&
70  fsURI.getAuthority().equals(pathURI.getAuthority()));
71  return Path.mergePaths(S3A_CANONICAL_BUCKET, path);
72  }
73 
77  @Test
78  public void testS3ScanRanges() {
79  runPlannerTestFile("s3");
80  }
81 
82 }
string path("/usr/lib/sasl2:/usr/lib64/sasl2:/usr/local/lib/sasl2:/usr/lib/x86_64-linux-gnu/sasl2")
void runPlannerTestFile(String testFile, TQueryOptions options)
uint64_t Test(T *ht, const ProbeTuple *input, uint64_t num_tuples)