forked from apache/hbase
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HBASE-20859 Backup and incremental load could fail in secure clusters.
Signed-off-by: tedyu <[email protected]>
- Loading branch information
1 parent
0d33caa
commit 6ee0fed
Showing
5 changed files
with
140 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
hbase-backup/src/test/java/org/apache/hadoop/hbase/backup/TestBackupUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/** | ||
* 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. | ||
*/ | ||
package org.apache.hadoop.hbase.backup; | ||
|
||
import java.io.IOException; | ||
import java.security.PrivilegedAction; | ||
|
||
import org.apache.hadoop.conf.Configuration; | ||
import org.apache.hadoop.fs.FileSystem; | ||
import org.apache.hadoop.fs.Path; | ||
import org.apache.hadoop.hbase.HBaseClassTestRule; | ||
import org.apache.hadoop.hbase.HBaseTestingUtility; | ||
import org.apache.hadoop.hbase.backup.util.BackupUtils; | ||
import org.apache.hadoop.hbase.testclassification.SmallTests; | ||
import org.apache.hadoop.security.UserGroupInformation; | ||
import org.junit.Assert; | ||
import org.junit.ClassRule; | ||
import org.junit.Test; | ||
import org.junit.experimental.categories.Category; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
@Category(SmallTests.class) | ||
public class TestBackupUtils { | ||
@ClassRule | ||
public static final HBaseClassTestRule CLASS_RULE = | ||
HBaseClassTestRule.forClass(TestBackupUtils.class); | ||
private static final Logger LOG = LoggerFactory.getLogger(TestBackupUtils.class); | ||
|
||
protected static HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility(); | ||
protected static Configuration conf = TEST_UTIL.getConfiguration(); | ||
|
||
@Test | ||
public void TestGetBulkOutputDir() { | ||
// Create a user who is not the current user | ||
String fooUserName = "foo1234"; | ||
String fooGroupName = "group1"; | ||
UserGroupInformation | ||
ugi = UserGroupInformation.createUserForTesting(fooUserName, new String[]{fooGroupName}); | ||
// Get user's home directory | ||
Path fooHomeDirectory = ugi.doAs(new PrivilegedAction<Path>() { | ||
@Override public Path run() { | ||
try (FileSystem fs = FileSystem.get(conf)) { | ||
return fs.getHomeDirectory(); | ||
} catch (IOException ioe) { | ||
LOG.error("Failed to get foo's home directory", ioe); | ||
} | ||
return null; | ||
} | ||
}); | ||
|
||
Path bulkOutputDir = ugi.doAs(new PrivilegedAction<Path>() { | ||
@Override public Path run() { | ||
try { | ||
return BackupUtils.getBulkOutputDir("test", conf, false); | ||
} catch (IOException ioe) { | ||
LOG.error("Failed to get bulk output dir path", ioe); | ||
} | ||
return null; | ||
} | ||
}); | ||
// Make sure the directory is in foo1234's home directory | ||
Assert.assertTrue(bulkOutputDir.toString().startsWith(fooHomeDirectory.toString())); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters