예제 #1
0
        public virtual void TestAsyncReconfigure()
        {
            TestReconfiguration.AsyncReconfigurableDummy dummy = Org.Mockito.Mockito.Spy(new
                                                                                         TestReconfiguration.AsyncReconfigurableDummy(conf1));
            IList <ReconfigurationUtil.PropertyChange> changes = Lists.NewArrayList();

            changes.AddItem(new ReconfigurationUtil.PropertyChange("name1", "new1", "old1"));
            changes.AddItem(new ReconfigurationUtil.PropertyChange("name2", "new2", "old2"));
            changes.AddItem(new ReconfigurationUtil.PropertyChange("name3", "new3", "old3"));
            Org.Mockito.Mockito.DoReturn(changes).When(dummy).GetChangedProperties(Matchers.Any
                                                                                   <Configuration>(), Matchers.Any <Configuration>());
            Org.Mockito.Mockito.DoReturn(true).When(dummy).IsPropertyReconfigurable(Matchers.Eq
                                                                                        ("name1"));
            Org.Mockito.Mockito.DoReturn(false).When(dummy).IsPropertyReconfigurable(Matchers.Eq
                                                                                         ("name2"));
            Org.Mockito.Mockito.DoReturn(true).When(dummy).IsPropertyReconfigurable(Matchers.Eq
                                                                                        ("name3"));
            Org.Mockito.Mockito.DoNothing().When(dummy).ReconfigurePropertyImpl(Matchers.Eq("name1"
                                                                                            ), Matchers.AnyString());
            Org.Mockito.Mockito.DoNothing().When(dummy).ReconfigurePropertyImpl(Matchers.Eq("name2"
                                                                                            ), Matchers.AnyString());
            Org.Mockito.Mockito.DoThrow(new ReconfigurationException("NAME3", "NEW3", "OLD3",
                                                                     new IOException("io exception"))).When(dummy).ReconfigurePropertyImpl(Matchers.Eq
                                                                                                                                               ("name3"), Matchers.AnyString());
            dummy.StartReconfigurationTask();
            WaitAsyncReconfigureTaskFinish(dummy);
            ReconfigurationTaskStatus status = dummy.GetReconfigurationTaskStatus();

            Assert.Equal(3, status.GetStatus().Count);
            foreach (KeyValuePair <ReconfigurationUtil.PropertyChange, Optional <string> > result
                     in status.GetStatus())
            {
                ReconfigurationUtil.PropertyChange change = result.Key;
                if (change.prop.Equals("name1"))
                {
                    NUnit.Framework.Assert.IsFalse(result.Value.IsPresent());
                }
                else
                {
                    if (change.prop.Equals("name2"))
                    {
                        MatcherAssert.AssertThat(result.Value.Get(), CoreMatchers.ContainsString("Property name2 is not reconfigurable"
                                                                                                 ));
                    }
                    else
                    {
                        if (change.prop.Equals("name3"))
                        {
                            MatcherAssert.AssertThat(result.Value.Get(), CoreMatchers.ContainsString("io exception"
                                                                                                     ));
                        }
                        else
                        {
                            NUnit.Framework.Assert.Fail("Unknown property: " + change.prop);
                        }
                    }
                }
            }
        }
예제 #2
0
        private void VerifyStorageType(long blockId, bool expectTransient)
        {
            ReplicaInfo memBlock;

            memBlock = FsDatasetTestUtil.FetchReplicaInfo(fds, bpid, blockId);
            NUnit.Framework.Assert.IsNotNull(memBlock);
            MatcherAssert.AssertThat(memBlock.GetVolume().IsTransientStorage(), IS.Is(expectTransient
                                                                                      ));
        }