private WlbEnabledFilter Setup(bool WlbEnabledVM, bool WlbEnabledTarget, Mock <Pool> pool, Mock <Pool> targetPool)
        {
            //First connection
            Mock <VM> vm = ObjectFactory.BuiltObject <VM>(ObjectBuilderType.VmWithHomeServerHost, id);

            vm.Setup(v => v.allowed_operations).Returns(new List <vm_operations> {
                vm_operations.migrate_send
            });
            pool.Setup(p => p.wlb_enabled).Returns(WlbEnabledVM);
            pool.Setup(p => p.wlb_url).Returns("wlburl"); //Configured == true

            Mock <Host> master = ObjectFactory.BuiltObject <Host>(ObjectBuilderType.TampaHost, id);

            ObjectManager.MockConnectionFor(id).Setup(c => c.Resolve(It.IsAny <XenRef <Host> >())).Returns(master.Object);

            //Second connection
            Mock <Host> targetHost = ObjectFactory.BuiltObject <Host>(ObjectBuilderType.TampaHost, id2);

            ObjectManager.MockConnectionFor(id2).Setup(c => c.Resolve(It.IsAny <XenRef <Host> >())).Returns(targetHost.Object);
            targetPool.Setup(p => p.wlb_enabled).Returns(WlbEnabledTarget);
            targetPool.Setup(p => p.wlb_url).Returns("wlburl"); //Configured == true

            return(new WlbEnabledFilter(targetHost.Object, new List <VM> {
                vm.Object
            }));
        }
Ejemplo n.º 2
0
        public void StringBasedRepsonsesToRowState(TestCase tc)
        {
            Mock <SummaryTextComponent> baseComponent = new Mock <SummaryTextComponent>();
            StringBuilder sb = new StringBuilder();

            baseComponent.Setup(c => c.BuildSummary()).Returns(sb);

            Mock <Host>           host = ObjectFactory.BuiltObject <Host>(ObjectBuilderType.ClearwaterHost, id);
            Mock <ILicenseStatus> ls   = new Mock <ILicenseStatus>();

            ls.Setup(l => l.CurrentState).Returns(tc.State);
            ls.Setup(l => l.ExpiryDate).Returns(tc.Expiry);
            ls.Setup(l => l.LicenseExpiresIn).Returns(tc.ExpiresIn);

            CheckableDataGridViewRow row = new LicenseDataGridViewRow(host.Object, ls.Object);

            LicenseManagerSummaryLicenseExpiresDecorator decorator = new LicenseManagerSummaryLicenseExpiresDecorator(baseComponent.Object, row);

            decorator.BuildSummary();

            Assert.That(sb.ToString().Contains(Messages.LICENSE_MANAGER_SUMMARY_LICENSE_EXPIRES));
            Assert.That(sb.ToString().Contains(tc.Contains));

            baseComponent.Verify(c => c.BuildSummary(), Times.Once());
        }
        public void TestLicenseStatusForProblem(TestCase tc)
        {
            Mock <Host> host = ObjectFactory.BuiltObject <Host>(tc.HostType, id);

            host.Setup(h => h.IsFreeLicense()).Returns(tc.IsFree);
            host.Setup(h => h.InGrace).Returns(tc.InGrace);
            UpgradingFromTampaAndOlderCheck check = new UpgradingFromTampaAndOlderCheck(host.Object);

            Assert.AreEqual(tc.ExpectProblem, check.RunAllChecks().Count != 0, "Problem found");
        }
Ejemplo n.º 4
0
        public void LicenseExpiresIn(ExipryDateTestCase tc)
        {
            Mock <Host> host = ObjectFactory.BuiltObject <Host>(ObjectBuilderType.ClearwaterHost, id);

            SetupMockHostWithExpiry(host, new DateTime());
            using (OverriddenExpiresIn ls = new OverriddenExpiresIn(host.Object))
            {
                ls.DummyExpiresIn = tc.Expiry;
                ls.CalculateState();
                Assert.That(ls.LicenseExpiresIn, Is.EqualTo(tc.ExpectedExpiry));
            }
        }
Ejemplo n.º 5
0
        public void TestMinimumHostLicenseValue()
        {
            Mock <Host> saHost = ObjectFactory.BuiltObject <Host>(ObjectBuilderType.ClearwaterHost, id);

            SetupMockHostWithExpiry(saHost, new DateTime(2015, 10, 25));

            using (LicenseStatus ls = new LicenseStatus(saHost.Object))
            {
                Assert.True(ls.ExpiryDate.HasValue, "Expiry date doesn't have a value");
                Assert.That(ls.ExpiryDate.Value.ToShortDateString(),
                            Is.EqualTo(new DateTime(2015, 10, 25).ToShortDateString()), "Expiry dates");
            }
        }
Ejemplo n.º 6
0
        public void MinimumPoolLicenseValueOnSlave()
        {
            Mock <Pool>         pool   = ObjectFactory.BuiltObject <Pool>(ObjectBuilderType.PoolOfTwoClearwaterHosts, id);
            List <Mock <Host> > hosts  = ObjectManager.GeneratedXenObjectsMocks <Host>(id);
            Mock <Host>         master = hosts.FirstOrDefault(h => h.Object.opaque_ref.Contains("master"));

            SetupMockHostWithExpiry(master, new DateTime(2013, 4, 1));
            Mock <Host> slave = hosts.FirstOrDefault(h => h.Object.opaque_ref.Contains("slave"));

            SetupMockHostWithExpiry(slave, new DateTime(2012, 1, 12));

            using (LicenseStatus ls = new LicenseStatus(pool.Object))
            {
                Assert.True(ls.ExpiryDate.HasValue, "Expiry date doesn't have a value");
                Assert.That(ls.ExpiryDate.Value.ToShortDateString(), Is.EqualTo(new DateTime(2012, 1, 12).ToShortDateString()), "Expiry dates");
            }
        }
        public bool VerifyLunPerVdiBehaviour(bool IsLunPerVdi)
        {
            Mock <VM> vm = ObjectFactory.BuiltObject <VM>(ObjectBuilderType.VmWithHomeServerHost, id);
            Mock <SR> sr = ObjectManager.NewXenObject <SR>(id);

            vm.Setup(v => v.SRs).Returns(new List <SR> {
                sr.Object
            });
            vm.Setup(v => v.allowed_operations).Returns(new List <vm_operations> {
                vm_operations.migrate_send
            });
            sr.Setup(s => s.HBALunPerVDI).Returns(IsLunPerVdi);

            IMainWindow mw = new MockMainWindow();

            var cmd = new CrossPoolMigrateCommand(mw, new List <SelectedItem> {
                new SelectedItem(vm.Object)
            }, null);

            return(cmd.CanExecute());
        }
Ejemplo n.º 8
0
        private List <CheckableDataGridViewRow> CreateList(params TestCase[] testCases)
        {
            List <CheckableDataGridViewRow> rows = new List <CheckableDataGridViewRow>();

            foreach (TestCase tc in testCases)
            {
                Mock <Host>           mh     = ObjectFactory.BuiltObject <Host>(tc.MockType, id);
                Mock <ILicenseStatus> status = new Mock <ILicenseStatus>();
                status.Setup(s => s.LicenseEdition).Returns(tc.License);

                if (tc.License != Host.Edition.Free)
                {
                    mh.Setup(h => h.license_server).Returns(new Dictionary <string, string>
                    {
                        { "address", "address" }, { "port", "port" }
                    });
                }
                rows.Add(new LicenseDataGridViewRow(mh.Object, status.Object));
            }

            return(rows);
        }
        public bool IntrapoolWlbEnabledBehaviour(bool WlbEnabled)
        {
            Mock <VM>   vm         = ObjectFactory.BuiltObject <VM>(ObjectBuilderType.VmWithHomeServerHost, id);
            Mock <Host> targetHost = ObjectFactory.BuiltObject <Host>(ObjectBuilderType.TampaHost, id);

            ObjectManager.MockConnectionFor(id).Setup(c => c.Resolve(It.IsAny <XenRef <Host> >())).Returns(targetHost.Object);
            vm.Setup(v => v.allowed_operations).Returns(new List <vm_operations> {
                vm_operations.migrate_send
            });
            Mock <Pool> pool = ObjectManager.NewXenObject <Pool>(id);

            pool.Setup(p => p.wlb_enabled).Returns(WlbEnabled);
            pool.Setup(p => p.wlb_url).Returns("wlburl"); //Configured == true

            IMainWindow mw  = new MockMainWindow();
            var         cmd = new CrossPoolMigrateCommand(mw, new List <SelectedItem> {
                new SelectedItem(vm.Object)
            }, null);
            bool canExecute = cmd.CanExecute();

            pool.Verify(p => p.wlb_enabled, Times.AtLeastOnce());
            return(canExecute);
        }
Ejemplo n.º 10
0
        public void TestExpiredClearwater()
        {
            Mock <SummaryTextComponent> baseComponent = new Mock <SummaryTextComponent>();
            StringBuilder sb = new StringBuilder();

            baseComponent.Setup(c => c.BuildSummary()).Returns(sb);

            Mock <Host> host = ObjectFactory.BuiltObject <Host>(ObjectBuilderType.ClearwaterHost, id);

            ObjectManager.MockConnectionFor(id).Setup(c => c.IsConnected).Returns(true);
            Mock <ILicenseStatus> ls = new Mock <ILicenseStatus>();

            ls.Setup(l => l.CurrentState).Returns(LicenseStatus.HostState.Expired);

            CheckableDataGridViewRow row = new LicenseDataGridViewRow(host.Object, ls.Object);

            LicenseManagerSummaryLicenseExpiresDecorator decorator = new LicenseManagerSummaryLicenseExpiresDecorator(baseComponent.Object, row);

            decorator.BuildSummary();

            Assert.That(sb.Length, Is.EqualTo(0));
            baseComponent.Verify(c => c.BuildSummary(), Times.Once());
        }
        public bool CrossPoolWlbEnabledBehaviour(bool WlbEnabledVM, bool WlbEnabledTarget)
        {
            //First connection
            Mock <VM>   vm     = ObjectFactory.BuiltObject <VM>(ObjectBuilderType.VmWithHomeServerHost, id);
            Mock <Host> master = ObjectFactory.BuiltObject <Host>(ObjectBuilderType.TampaHost, id);

            ObjectManager.MockConnectionFor(id).Setup(c => c.Resolve(It.IsAny <XenRef <Host> >())).Returns(master.Object);
            vm.Setup(v => v.allowed_operations).Returns(new List <vm_operations> {
                vm_operations.migrate_send
            });
            Mock <Pool> pool = ObjectManager.NewXenObject <Pool>(id);

            pool.Setup(p => p.wlb_enabled).Returns(WlbEnabledVM);
            pool.Setup(p => p.wlb_url).Returns("wlburl"); //Configured == true

            //Second connection
            Mock <Host> targetHost = ObjectFactory.BuiltObject <Host>(ObjectBuilderType.TampaHost, id2);
            Mock <Pool> targetPool = ObjectManager.NewXenObject <Pool>(id2);

            ObjectManager.MockConnectionFor(id2).Setup(c => c.Resolve(It.IsAny <XenRef <Host> >())).Returns(targetHost.Object);
            targetPool.Setup(p => p.wlb_enabled).Returns(WlbEnabledTarget);
            targetPool.Setup(p => p.wlb_url).Returns("wlburl"); //Configured == true

            //Command
            IMainWindow mw  = new MockMainWindow();
            var         cmd = new CrossPoolMigrateCommand(mw, new List <SelectedItem> {
                new SelectedItem(vm.Object)
            }, null);
            bool canExecute = cmd.CanExecute();

            //As the command is launching the wizard it should only need to
            //check the VMs are on Wlb as the target can be changed in the wizard anyhow
            pool.Verify(p => p.wlb_enabled, Times.AtLeastOnce());
            targetPool.Verify(tp => tp.wlb_enabled, Times.Never());
            return(canExecute);
        }