Ejemplo n.º 1
0
        /// <summary>Checks that the edits file has all opCodes</summary>
        /// <param name="filename">edits file</param>
        /// <returns>true is edits (filename) has all opCodes</returns>
        /// <exception cref="System.IO.IOException"/>
        private bool HasAllOpCodes(string inFilename)
        {
            string                 outFilename = inFilename + ".stats";
            FileOutputStream       fout        = new FileOutputStream(outFilename);
            StatisticsEditsVisitor visitor     = new StatisticsEditsVisitor(fout);

            Org.Apache.Hadoop.Hdfs.Tools.OfflineEditsViewer.OfflineEditsViewer oev = new Org.Apache.Hadoop.Hdfs.Tools.OfflineEditsViewer.OfflineEditsViewer
                                                                                         ();
            if (oev.Go(inFilename, outFilename, "stats", new OfflineEditsViewer.Flags(), visitor
                       ) != 0)
            {
                return(false);
            }
            Log.Info("Statistics for " + inFilename + "\n" + visitor.GetStatisticsString());
            bool hasAllOpCodes = true;

            foreach (FSEditLogOpCodes opCode in FSEditLogOpCodes.Values())
            {
                // don't need to test obsolete opCodes
                if (skippedOps.Contains(opCode))
                {
                    continue;
                }
                long count = visitor.GetStatistics()[opCode];
                if ((count == null) || (count == 0))
                {
                    hasAllOpCodes = false;
                    Log.Info("Opcode " + opCode + " not tested in " + inFilename);
                }
            }
            return(hasAllOpCodes);
        }
Ejemplo n.º 2
0
 public override void AssertWhat(Filter filter, int numInsertions, int hashId, ImmutableSet
                                 <int> falsePositives)
 {
     // add all even keys
     for (int i = 0; i < numInsertions; i += 2)
     {
         filter.Add(new Key(Runtime.GetBytesForString(Extensions.ToString(
                                                          i))));
     }
     // check on present even key
     for (int i_1 = 0; i_1 < numInsertions; i_1 += 2)
     {
         Assert.True(" filter might contains " + i_1, filter.MembershipTest
                         (new Key(Runtime.GetBytesForString(Extensions.ToString(i_1)))));
     }
     // check on absent odd in event
     for (int i_2 = 1; i_2 < numInsertions; i_2 += 2)
     {
         if (!falsePositives.Contains(i_2))
         {
             NUnit.Framework.Assert.IsFalse(" filter should not contain " + i_2, filter.MembershipTest
                                                (new Key(Runtime.GetBytesForString(Extensions.ToString(i_2)))));
         }
     }
 }