public virtual void TestQuotaByStorageTypePersistenceInFsImage()
        {
            string MethodName   = GenericTestUtils.GetMethodName();
            Path   testDir      = new Path(dir, MethodName);
            Path   createdFile1 = new Path(testDir, "created_file1.data");

            dfs.Mkdirs(testDir);
            // set storage policy on testDir to ONESSD
            dfs.SetStoragePolicy(testDir, HdfsConstants.OnessdStoragePolicyName);
            // set quota by storage type on testDir
            long SsdQuota = Blocksize * 4;

            dfs.SetQuotaByStorageType(testDir, StorageType.Ssd, SsdQuota);
            INode testDirNode = fsdir.GetINode4Write(testDir.ToString());

            NUnit.Framework.Assert.IsTrue(testDirNode.IsDirectory());
            NUnit.Framework.Assert.IsTrue(testDirNode.IsQuotaSet());
            // Create file of size 2 * BLOCKSIZE under testDir
            long file1Len = Blocksize * 2;
            int  bufLen   = Blocksize / 16;

            DFSTestUtil.CreateFile(dfs, createdFile1, bufLen, file1Len, Blocksize, Replication
                                   , seed);
            // Verify SSD consumed before namenode restart
            long ssdConsumed = testDirNode.AsDirectory().GetDirectoryWithQuotaFeature().GetSpaceConsumed
                                   ().GetTypeSpaces().Get(StorageType.Ssd);

            NUnit.Framework.Assert.AreEqual(file1Len, ssdConsumed);
            // Restart the namenode with checkpoint to make sure fsImage is correct
            dfs.SetSafeMode(HdfsConstants.SafeModeAction.SafemodeEnter);
            dfs.SaveNamespace();
            dfs.SetSafeMode(HdfsConstants.SafeModeAction.SafemodeLeave);
            cluster.RestartNameNode(true);
            RefreshClusterState();
            INode testDirNodeAfterNNRestart = fsdir.GetINode4Write(testDir.ToString());

            NUnit.Framework.Assert.IsTrue(testDirNode.IsDirectory());
            NUnit.Framework.Assert.IsTrue(testDirNode.IsQuotaSet());
            QuotaCounts qc = testDirNodeAfterNNRestart.GetQuotaCounts();

            NUnit.Framework.Assert.AreEqual(SsdQuota, qc.GetTypeSpace(StorageType.Ssd));
            foreach (StorageType t in StorageType.GetTypesSupportingQuota())
            {
                if (t != StorageType.Ssd)
                {
                    NUnit.Framework.Assert.AreEqual(HdfsConstants.QuotaReset, qc.GetTypeSpace(t));
                }
            }
            long ssdConsumedAfterNNRestart = testDirNodeAfterNNRestart.AsDirectory().GetDirectoryWithQuotaFeature
                                                 ().GetSpaceConsumed().GetTypeSpaces().Get(StorageType.Ssd);

            NUnit.Framework.Assert.AreEqual(file1Len, ssdConsumedAfterNNRestart);
        }