|
@@ -17,40 +17,14 @@
|
|
|
*/
|
|
|
package org.apache.hadoop.hdfs;
|
|
|
|
|
|
-import java.io.ByteArrayOutputStream;
|
|
|
-import java.io.File;
|
|
|
-import java.io.IOException;
|
|
|
-import java.io.InputStream;
|
|
|
-import java.io.OutputStream;
|
|
|
-import java.io.PrintStream;
|
|
|
-import java.io.RandomAccessFile;
|
|
|
-import java.io.StringReader;
|
|
|
-import java.net.HttpURLConnection;
|
|
|
-import java.net.InetSocketAddress;
|
|
|
-import java.net.URI;
|
|
|
-import java.net.URL;
|
|
|
-import java.security.PrivilegedExceptionAction;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Arrays;
|
|
|
-import java.util.Collection;
|
|
|
-import java.util.EnumSet;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
-import java.util.concurrent.Callable;
|
|
|
-import java.util.concurrent.CountDownLatch;
|
|
|
-import java.util.concurrent.ExecutionException;
|
|
|
-import java.util.concurrent.ExecutorService;
|
|
|
-import java.util.concurrent.Executors;
|
|
|
-import java.util.concurrent.Future;
|
|
|
-
|
|
|
-import org.apache.hadoop.test.GenericTestUtils;
|
|
|
-
|
|
|
import org.apache.hadoop.conf.Configuration;
|
|
|
import org.apache.hadoop.crypto.CipherSuite;
|
|
|
import org.apache.hadoop.crypto.CryptoInputStream;
|
|
|
import org.apache.hadoop.crypto.CryptoProtocolVersion;
|
|
|
import org.apache.hadoop.crypto.key.JavaKeyStoreProvider;
|
|
|
import org.apache.hadoop.crypto.key.KeyProvider;
|
|
|
+import org.apache.hadoop.crypto.key.KeyProviderCryptoExtension.CryptoExtension;
|
|
|
+import org.apache.hadoop.crypto.key.KeyProviderDelegationTokenExtension.DelegationTokenExtension;
|
|
|
import org.apache.hadoop.crypto.key.KeyProviderFactory;
|
|
|
import org.apache.hadoop.fs.CommonConfigurationKeysPublic;
|
|
|
import org.apache.hadoop.fs.FSDataInputStream;
|
|
@@ -74,9 +48,9 @@ import org.apache.hadoop.hdfs.client.CreateEncryptionZoneFlag;
|
|
|
import org.apache.hadoop.hdfs.client.HdfsAdmin;
|
|
|
import org.apache.hadoop.hdfs.protocol.ClientProtocol;
|
|
|
import org.apache.hadoop.hdfs.protocol.EncryptionZone;
|
|
|
+import org.apache.hadoop.hdfs.protocol.HdfsConstants.SafeModeAction;
|
|
|
import org.apache.hadoop.hdfs.protocol.HdfsFileStatus;
|
|
|
import org.apache.hadoop.hdfs.protocol.LocatedBlocks;
|
|
|
-import org.apache.hadoop.hdfs.protocol.HdfsConstants.SafeModeAction;
|
|
|
import org.apache.hadoop.hdfs.protocol.SnapshotDiffReport.DiffReportEntry;
|
|
|
import org.apache.hadoop.hdfs.protocol.SnapshotDiffReport.DiffType;
|
|
|
import org.apache.hadoop.hdfs.server.common.HdfsServerConstants;
|
|
@@ -91,19 +65,18 @@ import org.apache.hadoop.hdfs.web.WebHdfsConstants;
|
|
|
import org.apache.hadoop.hdfs.web.WebHdfsFileSystem;
|
|
|
import org.apache.hadoop.hdfs.web.WebHdfsTestUtil;
|
|
|
import org.apache.hadoop.io.IOUtils;
|
|
|
+import org.apache.hadoop.io.Text;
|
|
|
import org.apache.hadoop.ipc.RemoteException;
|
|
|
import org.apache.hadoop.security.AccessControlException;
|
|
|
import org.apache.hadoop.security.Credentials;
|
|
|
import org.apache.hadoop.security.UserGroupInformation;
|
|
|
import org.apache.hadoop.security.authorize.AuthorizationException;
|
|
|
-import org.apache.hadoop.security.token.Token;
|
|
|
import org.apache.hadoop.security.token.DelegationTokenIssuer;
|
|
|
+import org.apache.hadoop.security.token.Token;
|
|
|
+import org.apache.hadoop.test.GenericTestUtils;
|
|
|
import org.apache.hadoop.util.DataChecksum;
|
|
|
import org.apache.hadoop.util.Lists;
|
|
|
import org.apache.hadoop.util.ToolRunner;
|
|
|
-import org.apache.hadoop.crypto.key.KeyProviderDelegationTokenExtension.DelegationTokenExtension;
|
|
|
-import org.apache.hadoop.crypto.key.KeyProviderCryptoExtension.CryptoExtension;
|
|
|
-import org.apache.hadoop.io.Text;
|
|
|
import org.junit.Rule;
|
|
|
import org.junit.jupiter.api.AfterEach;
|
|
|
import org.junit.jupiter.api.Assertions;
|
|
@@ -111,14 +84,41 @@ import org.junit.jupiter.api.BeforeEach;
|
|
|
import org.junit.jupiter.api.Test;
|
|
|
import org.junit.rules.Timeout;
|
|
|
import org.mockito.Mockito;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
+import org.slf4j.event.Level;
|
|
|
+import org.xml.sax.InputSource;
|
|
|
+import org.xml.sax.helpers.DefaultHandler;
|
|
|
+
|
|
|
+import javax.xml.parsers.SAXParser;
|
|
|
+import javax.xml.parsers.SAXParserFactory;
|
|
|
+import java.io.ByteArrayOutputStream;
|
|
|
+import java.io.File;
|
|
|
+import java.io.IOException;
|
|
|
+import java.io.InputStream;
|
|
|
+import java.io.OutputStream;
|
|
|
+import java.io.PrintStream;
|
|
|
+import java.io.RandomAccessFile;
|
|
|
+import java.io.StringReader;
|
|
|
+import java.net.HttpURLConnection;
|
|
|
+import java.net.InetSocketAddress;
|
|
|
+import java.net.URI;
|
|
|
+import java.net.URL;
|
|
|
+import java.security.PrivilegedExceptionAction;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Arrays;
|
|
|
+import java.util.Collection;
|
|
|
+import java.util.EnumSet;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.concurrent.Callable;
|
|
|
+import java.util.concurrent.CountDownLatch;
|
|
|
+import java.util.concurrent.ExecutionException;
|
|
|
+import java.util.concurrent.ExecutorService;
|
|
|
+import java.util.concurrent.Executors;
|
|
|
+import java.util.concurrent.Future;
|
|
|
|
|
|
import static org.apache.hadoop.fs.CommonConfigurationKeys.DFS_CLIENT_IGNORE_NAMENODE_DEFAULT_KMS_URI;
|
|
|
-import static org.mockito.ArgumentMatchers.any;
|
|
|
-import static org.mockito.ArgumentMatchers.anyBoolean;
|
|
|
-import static org.mockito.ArgumentMatchers.anyLong;
|
|
|
-import static org.mockito.ArgumentMatchers.anyShort;
|
|
|
-import static org.mockito.Mockito.withSettings;
|
|
|
-import static org.mockito.Mockito.anyString;
|
|
|
import static org.apache.hadoop.fs.CommonConfigurationKeysPublic.FS_TRASH_INTERVAL_DEFAULT;
|
|
|
import static org.apache.hadoop.fs.CommonConfigurationKeysPublic.FS_TRASH_INTERVAL_KEY;
|
|
|
import static org.apache.hadoop.fs.CommonConfigurationKeysPublic.IO_FILE_BUFFER_SIZE_DEFAULT;
|
|
@@ -137,16 +137,19 @@ import static org.apache.hadoop.hdfs.client.HdfsClientConfigKeys.DFS_CLIENT_WRIT
|
|
|
import static org.apache.hadoop.test.GenericTestUtils.assertExceptionContains;
|
|
|
import static org.apache.hadoop.test.MetricsAsserts.assertGauge;
|
|
|
import static org.apache.hadoop.test.MetricsAsserts.getMetrics;
|
|
|
-import static org.junit.jupiter.api.Assertions.*;
|
|
|
-
|
|
|
-import org.slf4j.Logger;
|
|
|
-import org.slf4j.LoggerFactory;
|
|
|
-import org.slf4j.event.Level;
|
|
|
-import org.xml.sax.InputSource;
|
|
|
-import org.xml.sax.helpers.DefaultHandler;
|
|
|
-
|
|
|
-import javax.xml.parsers.SAXParser;
|
|
|
-import javax.xml.parsers.SAXParserFactory;
|
|
|
+import static org.junit.jupiter.api.Assertions.assertEquals;
|
|
|
+import static org.junit.jupiter.api.Assertions.assertFalse;
|
|
|
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
|
|
|
+import static org.junit.jupiter.api.Assertions.assertNotNull;
|
|
|
+import static org.junit.jupiter.api.Assertions.assertNull;
|
|
|
+import static org.junit.jupiter.api.Assertions.assertTrue;
|
|
|
+import static org.junit.jupiter.api.Assertions.fail;
|
|
|
+import static org.mockito.ArgumentMatchers.any;
|
|
|
+import static org.mockito.ArgumentMatchers.anyBoolean;
|
|
|
+import static org.mockito.ArgumentMatchers.anyLong;
|
|
|
+import static org.mockito.ArgumentMatchers.anyShort;
|
|
|
+import static org.mockito.Mockito.anyString;
|
|
|
+import static org.mockito.Mockito.withSettings;
|
|
|
|
|
|
public class TestEncryptionZones {
|
|
|
static final Logger LOG = LoggerFactory.getLogger(TestEncryptionZones.class);
|
|
@@ -649,8 +652,9 @@ public class TestEncryptionZones {
|
|
|
EncryptionZone ezForZone2 = dfsAdmin.getEncryptionZoneForPath(zone2FQP);
|
|
|
Path ezTrashForZone2 = new Path(ezForZone2.getPath(),
|
|
|
FileSystem.TRASH_PREFIX);
|
|
|
- assertTrue("provisionEZTrash with fully qualified path should create " +
|
|
|
- "trash directory ", fsWrapper.exists(ezTrashForZone2));
|
|
|
+ assertTrue(fsWrapper.exists(ezTrashForZone2),
|
|
|
+ "provisionEZTrash with fully qualified path should create "
|
|
|
+ + "trash directory ");
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -815,16 +819,16 @@ public class TestEncryptionZones {
|
|
|
|
|
|
// Verify that we can rename dir and files within an encryption zone.
|
|
|
assertTrue(fs.rename(pathFooBaz, pathFooBar));
|
|
|
- assertTrue("Rename of dir and file within ez failed",
|
|
|
- !wrapper.exists(pathFooBaz) && wrapper.exists(pathFooBar));
|
|
|
+ assertTrue(!wrapper.exists(pathFooBaz) && wrapper.exists(pathFooBar),
|
|
|
+ "Rename of dir and file within ez failed");
|
|
|
assertEquals(
|
|
|
contents, DFSTestUtil.readFile(fs, pathFooBarFile), "Renamed file contents not the same");
|
|
|
|
|
|
// Verify that we can rename an EZ root
|
|
|
final Path newFoo = new Path(testRoot, "newfoo");
|
|
|
assertTrue(fs.rename(pathFoo, newFoo), "Rename of EZ root");
|
|
|
- assertTrue("Rename of EZ root failed",
|
|
|
- !wrapper.exists(pathFoo) && wrapper.exists(newFoo));
|
|
|
+ assertTrue(!wrapper.exists(pathFoo) && wrapper.exists(newFoo),
|
|
|
+ "Rename of EZ root failed");
|
|
|
|
|
|
// Verify that we can't rename an EZ root onto itself
|
|
|
try {
|