示例#1
0
        public virtual void SetupMocks()
        {
            mockNN1 = SetupNNMock(0);
            mockNN2 = SetupNNMock(1);
            // Set up a mock DN with the bare-bones configuration
            // objects, etc.
            mockDn = Org.Mockito.Mockito.Mock <DataNode>();
            Org.Mockito.Mockito.DoReturn(true).When(mockDn).ShouldRun();
            Configuration conf      = new Configuration();
            FilePath      dnDataDir = new FilePath(new FilePath(TestBuildData, "dfs"), "data");

            conf.Set(DFSConfigKeys.DfsDatanodeDataDirKey, dnDataDir.ToURI().ToString());
            Org.Mockito.Mockito.DoReturn(conf).When(mockDn).GetConf();
            Org.Mockito.Mockito.DoReturn(new DNConf(conf)).When(mockDn).GetDnConf();
            Org.Mockito.Mockito.DoReturn(DataNodeMetrics.Create(conf, "fake dn")).When(mockDn
                                                                                       ).GetMetrics();
            // Set up a simulated dataset with our fake BP
            mockFSDataset = Org.Mockito.Mockito.Spy(new SimulatedFSDataset(null, conf));
            mockFSDataset.AddBlockPool(FakeBpid, conf);
            // Wire the dataset to the DN.
            Org.Mockito.Mockito.DoReturn(mockFSDataset).When(mockDn).GetFSDataset();
        }
示例#2
0
        public virtual void TestBPInitErrorHandling()
        {
            DataNode mockDn = Org.Mockito.Mockito.Mock <DataNode>();

            Org.Mockito.Mockito.DoReturn(true).When(mockDn).ShouldRun();
            Configuration conf      = new Configuration();
            FilePath      dnDataDir = new FilePath(new FilePath(TestBuildData, "testBPInitErrorHandling"
                                                                ), "data");

            conf.Set(DFSConfigKeys.DfsDatanodeDataDirKey, dnDataDir.ToURI().ToString());
            Org.Mockito.Mockito.DoReturn(conf).When(mockDn).GetConf();
            Org.Mockito.Mockito.DoReturn(new DNConf(conf)).When(mockDn).GetDnConf();
            Org.Mockito.Mockito.DoReturn(DataNodeMetrics.Create(conf, "fake dn")).When(mockDn
                                                                                       ).GetMetrics();
            AtomicInteger count = new AtomicInteger();

            Org.Mockito.Mockito.DoAnswer(new _Answer_328(this, count, mockDn)).When(mockDn).InitBlockPool
                (Org.Mockito.Mockito.Any <BPOfferService>());
            // The initBlockPool is called again. Now mock init is done.
            BPOfferService         bpos   = SetupBPOSForNNs(mockDn, mockNN1, mockNN2);
            IList <BPServiceActor> actors = bpos.GetBPServiceActors();

            NUnit.Framework.Assert.AreEqual(2, actors.Count);
            bpos.Start();
            try
            {
                WaitForInitialization(bpos);
                // even if one of the actor initialization fails, the other one will be
                // finish block report.
                WaitForBlockReport(mockNN1, mockNN2);
            }
            finally
            {
                bpos.Stop();
            }
        }