コード例 #1
0
        public void willSetBIOS()
        {
            string testBiosXML = Properties.Resources.testBIOS;

            using (bladeDirectorDebugServices svc = new bladeDirectorDebugServices(basicBladeTests.WCFPath, basicBladeTests.WebURI))
            {
                machinePools.bladeDirectorURL = svc.servicesURL;
                string hostip = "1.2.3.4";

                // We will be using this blade for our tests.
                bladeSpec spec = svc.svcDebug.createBladeSpec("172.17.129.131", "192.168.129.131", "172.17.2.131", 1234, false, VMDeployStatus.notBeingDeployed, " ... ", "idk", "box", bladeLockType.lockAll, bladeLockType.lockAll);
                svc.svcDebug.initWithBladesFromBladeSpec(new[] { spec }, false, NASFaultInjectionPolicy.retunSuccessful);

                resultAndBladeName res = svc.svcDebug._RequestAnySingleNode(hostip);
                Assert.AreEqual(resultCode.success, res.result.code);

                // Write the new BIOS. This configuration has the 'boot state' of the numlock key set to 'off', so we can
                // read that back after writing to ensure that the BIOS write succeeds.
                var resultAndReadBack = writeBIOSAndReadBack(svc, hostip, res.bladeName, testBiosXML);
                Assert.IsTrue(resultAndReadBack.BIOSConfig.Contains("<Section name=\"NumLock\">Off</Section>"));
                // Now we can modify the BIOS slightly, to set the numlock boot state to 'on', and again write/readback, and see
                // if the change was carried out.
                testBiosXML       = testBiosXML.Replace("<Section name=\"NumLock\">Off</Section>", "<Section name=\"NumLock\">On</Section>");
                resultAndReadBack = writeBIOSAndReadBack(svc, hostip, res.bladeName, testBiosXML);
                Assert.IsTrue(resultAndReadBack.BIOSConfig.Contains("<Section name=\"NumLock\">On</Section>"));

                resultAndWaitToken relRes = svc.svcDebug._ReleaseBladeOrVM(hostip, res.bladeName, false);
                while (relRes.result.code == resultCode.pending)
                {
                    Thread.Sleep(TimeSpan.FromSeconds(3));
                    relRes = svc.svc.getProgress(relRes.waitToken);
                }
                Assert.AreEqual(resultCode.success, relRes.result.code);
            }
        }
コード例 #2
0
        public void willDeallocateBladeDuringBIOSSetting()
        {
            using (bladeDirectorDebugServices svc = new bladeDirectorDebugServices(basicBladeTests.WCFPath))
            {
                string hostIP = "1.1.1.1";
                svc.svcDebug.initWithBladesFromIPList(new[] { "172.17.129.131" }, true, NASFaultInjectionPolicy.retunSuccessful);

                string ourBlade = testUtils.doBladeAllocationForTest(svc, hostIP);

                // Start a slowwww BIOS read
                svc.svcDebug._setBIOSOperationTimeIfMocked(60 * 10);
                resultAndWaitToken readRes = svc.svcDebug._rebootAndStartReadingBIOSConfiguration(hostIP, ourBlade);
                Assert.AreEqual(resultCode.pending, readRes.result.code);

                // Then free the blade. The BIOS operation should be cancelled before it soaks up all the ten minutes of time.
                resultAndWaitToken releaseRes = svc.svcDebug._ReleaseBladeOrVM(hostIP, ourBlade, false);
                testUtils.waitForSuccess(svc, releaseRes, TimeSpan.FromMinutes(1));

                // And it should be no longer getting.
                resultAndWaitToken bladeState = svc.svc.getProgress(readRes.waitToken);
                Assert.AreNotEqual(resultCode.pending, bladeState.result.code);

                // And should not be allocated
                GetBladeStatusResult ownershipRes = svc.svc.GetBladeStatus(ourBlade);
                Assert.AreEqual(GetBladeStatusResult.unused, ownershipRes);
            }
        }
コード例 #3
0
        public void willReallocateBladeAfterLogin()
        {
            using (bladeDirectorDebugServices svc = new bladeDirectorDebugServices(basicBladeTests.WCFPath))
            {
                string hostIP = "1.1.1.1";
                svc.svcDebug.initWithBladesFromIPList(new[] { "172.17.129.131" }, true, NASFaultInjectionPolicy.retunSuccessful);

                string ourBlade = testUtils.doBladeAllocationForTest(svc, hostIP);

                // It should be ours..
                GetBladeStatusResult bladeState = svc.svcDebug._GetBladeStatus(hostIP, ourBlade);
                Assert.AreEqual(bladeState, GetBladeStatusResult.yours);

                // Then free it 'dirtily', by logging in again.
                resultAndWaitToken res = svc.svcDebug._logIn(hostIP);
                while (res.result.code == resultCode.pending)
                {
                    res = svc.svc.getProgress(res.waitToken);
                    Thread.Sleep(TimeSpan.FromSeconds(3));
                }
                Assert.AreEqual(resultCode.success, res.result.code);

                // The blade should now be unused.
                bladeState = svc.svcDebug._GetBladeStatus(hostIP, ourBlade);
                Assert.AreEqual(bladeState, GetBladeStatusResult.unused);

                // And if we allocate again, we should get it OK.
                ourBlade   = testUtils.doBladeAllocationForTest(svc, hostIP);
                bladeState = svc.svcDebug._GetBladeStatus(hostIP, ourBlade);
                Assert.AreEqual(bladeState, GetBladeStatusResult.yours);
            }
        }
コード例 #4
0
        public void willReAllocateNode()
        {
            using (bladeDirectorDebugServices uut = new bladeDirectorDebugServices(WCFPath, new[] { "1.1.1.1" }))
            {
                uut.svc.setResourceSharingModel(fairnessChecker.fairnessType.allowAny);

                string hostip = "192.168.1.1";

                Assert.AreEqual(resultCode.success, uut.svcDebug._RequestAnySingleNode(hostip).result.code);

                // First, the node should be ours.
                Assert.AreEqual(GetBladeStatusResult.yours, uut.svcDebug._GetBladeStatus(hostip, "1.1.1.1"));

                // Then, someone else requests it..
                Assert.AreEqual(resultCode.pending, uut.svcDebug._RequestAnySingleNode("192.168.2.2").result.code);

                // and it should be pending.
                Assert.AreEqual(GetBladeStatusResult.releasePending, uut.svcDebug._GetBladeStatus(hostip, "1.1.1.1"));
                Assert.AreEqual(GetBladeStatusResult.releasePending, uut.svcDebug._GetBladeStatus("192.168.2.2", "1.1.1.1"));

                // Then, we release it..
                resultAndWaitToken res = uut.svcDebug._ReleaseBladeOrVM(hostip, "1.1.1.1", false);
                testUtils.waitForSuccess(uut, res, TimeSpan.FromSeconds(5));

                // and it should belong to the second requestor.
                Assert.AreEqual(GetBladeStatusResult.notYours, uut.svcDebug._GetBladeStatus(hostip, "1.1.1.1"));
                Assert.AreEqual(GetBladeStatusResult.yours, uut.svcDebug._GetBladeStatus("192.168.2.2", "1.1.1.1"));
            }
        }
コード例 #5
0
        public void willDeallocateBladeAtLoginDuringVMProvisioning()
        {
            using (bladeDirectorDebugServices svc = new bladeDirectorDebugServices(basicBladeTests.WCFPath))
            {
                string hostIP = "1.1.1.1";
                svc.svcDebug.initWithBladesFromIPList(new[] { "172.17.129.131" }, true, NASFaultInjectionPolicy.retunSuccessful);

                VMHardwareSpec hwspec = new VMHardwareSpec
                {
                    cpuCount = 1,
                    memoryMB = 1024 * 3
                };
                VMSoftwareSpec swspec = new VMSoftwareSpec();

                // Start a slow VM allocation
                svc.svcDebug._setExecutionResultsIfMocked(mockedExecutionResponses.successfulButSlow);
                resultAndWaitToken res = svc.svcDebug._requestAnySingleVM(hostIP, hwspec, swspec);
                Assert.AreEqual(resultCode.pending, res.result.code);

                // Then re-login. The VM operation should be cancelled.
                resultAndWaitToken releaseRes = svc.svcDebug._logIn(hostIP);
                testUtils.waitForSuccess(svc, releaseRes, TimeSpan.FromMinutes(1));

                // And it should be no longer provisioning the VM.
                resultAndWaitToken bladeState = svc.svc.getProgress(res.waitToken);
                Assert.AreNotEqual(resultCode.pending, bladeState.result.code);

                // And should not be allocated.
                GetBladeStatusResult ownershipRes = svc.svc.GetBladeStatus("172.17.129.131");
                Assert.AreEqual(GetBladeStatusResult.unused, ownershipRes);
            }
        }
コード例 #6
0
        public void willReAllocateBladesAfterLogonDuringBIOSOperation()
        {
            using (bladeDirectorDebugServices svc = new bladeDirectorDebugServices(basicBladeTests.WCFPath))
            {
                string hostIP = "1.1.1.1";
                svc.svcDebug.initWithBladesFromIPList(new[] { "172.17.129.131" }, true, NASFaultInjectionPolicy.retunSuccessful);

                testUtils.doLogin(svc, hostIP);
                string bladeIP = testUtils.doBladeAllocationForTest(svc, hostIP);

                // Start a 5-minute long BIOS operation, then cancel it by logging in again.
                svc.svcDebug._setBIOSOperationTimeIfMocked((int)TimeSpan.FromMinutes(5).TotalSeconds);
                resultAndWaitToken res = svc.svcDebug._rebootAndStartDeployingBIOSToBlade(hostIP, bladeIP, ".... some bios file here ... ");
                Assert.AreEqual(resultCode.pending, res.result.code);

                Assert.AreEqual(true, svc.svcDebug._isBladeMine(hostIP, bladeIP, true));

                // Now login again, cancelling the BIOS operation.
                testUtils.doLogin(svc, hostIP);

                // The blade should no longer be ours.
                Assert.AreEqual(false, svc.svcDebug._isBladeMine(hostIP, bladeIP, false));

                // And after an allocation, our blade should be re-used.
                string newbladeIP = testUtils.doBladeAllocationForTest(svc, hostIP);
                Assert.AreEqual(bladeIP, newbladeIP);
            }
        }
コード例 #7
0
        public void willCancelBIOSWrite(TimeSpan delay)
        {
            using (bladeDirectorDebugServices svc = new bladeDirectorDebugServices(basicBladeTests.WCFPath, basicBladeTests.WebURI))
            {
                machinePools.bladeDirectorURL = svc.servicesURL;

                string    hostIP = "1.1.1.1";
                bladeSpec spec   = svc.svcDebug.createBladeSpec("172.17.129.131", "192.168.129.131", "172.17.2.131", 1234, false, VMDeployStatus.notBeingDeployed, " ... ", "idk", "box", bladeLockType.lockAll, bladeLockType.lockAll);
                svc.svcDebug.initWithBladesFromBladeSpec(new[] { spec }, false, NASFaultInjectionPolicy.retunSuccessful);

                resultAndBladeName res = svc.svcDebug._RequestAnySingleNode(hostIP);
                Assert.AreEqual(resultCode.success, res.result.code);
                string ourBlade = ((resultAndBladeName)testUtils.waitForSuccess(svc, res, TimeSpan.FromSeconds(30))).bladeName;

                // Start a BIOS read
                resultAndWaitToken readRes = svc.svcDebug._rebootAndStartReadingBIOSConfiguration(hostIP, ourBlade);
                Assert.AreEqual(resultCode.pending, readRes.result.code);

                // Wait a while to see if we get somewhere where it is impossible to free without a hueg delay
                Thread.Sleep(delay);

                // Then free the blade. The BIOS operation should be cancelled before it soaks up all the ten minutes of time.
                resultAndWaitToken releaseRes = svc.svcDebug._ReleaseBladeOrVM(hostIP, ourBlade, false);
                testUtils.waitForSuccess(svc, releaseRes, TimeSpan.FromMinutes(1));

                // And it should be no longer getting.
                resultAndWaitToken bladeState = svc.svc.getProgress(readRes.waitToken);
                Assert.AreNotEqual(resultCode.pending, bladeState.result.code);

                // It no longer be allocated to us, since we released it earlier.
                GetBladeStatusResult ownershipRes = svc.svc.GetBladeStatus(ourBlade);
                Assert.AreEqual(GetBladeStatusResult.unused, ownershipRes);
            }
        }
コード例 #8
0
        public void willEnforceSharing()
        {
            using (bladeDirectorDebugServices uut = new bladeDirectorDebugServices(WCFPath, new[] { "1.1.1.1", "1.1.1.2" }))
            {
                uut.svc.setResourceSharingModel(fairnessChecker.fairnessType.fair);

                string hostipA = "192.168.1.1";
                string hostipB = "192.168.1.2";

                // Host A will allocate all blades. Then, host B will request one.
                // Host A should be asked to release one of its nodes, and then that should be allocated to B.
                Assert.AreEqual(resultCode.success, uut.svcDebug._RequestAnySingleNode(hostipA).result.code);
                Assert.AreEqual(resultCode.success, uut.svcDebug._RequestAnySingleNode(hostipA).result.code);

                // A owns both
                Assert.AreEqual(GetBladeStatusResult.yours, uut.svcDebug._GetBladeStatus(hostipA, "1.1.1.1"));
                Assert.AreEqual(GetBladeStatusResult.yours, uut.svcDebug._GetBladeStatus(hostipA, "1.1.1.2"));

                // B requests one
                Assert.AreEqual(resultCode.pending, uut.svcDebug._RequestAnySingleNode(hostipB).result.code);

                // A should be asked to release a blade.
                Assert.IsTrue(
                    uut.svcDebug._GetBladeStatus(hostipA, "1.1.1.1") == GetBladeStatusResult.releasePending ||
                    uut.svcDebug._GetBladeStatus(hostipA, "1.1.1.2") == GetBladeStatusResult.releasePending
                    );

                // host A does as instructed, and releases its blade
                if (uut.svcDebug._GetBladeStatus(hostipA, "1.1.1.1") == GetBladeStatusResult.releasePending)
                {
                    resultAndWaitToken res = uut.svcDebug._ReleaseBladeOrVM(hostipA, "1.1.1.1", false);
                    testUtils.waitForSuccess(uut, res, TimeSpan.FromSeconds(5));
                }
                else if (uut.svcDebug._GetBladeStatus(hostipA, "1.1.1.2") == GetBladeStatusResult.releasePending)
                {
                    resultAndWaitToken res = uut.svcDebug._ReleaseBladeOrVM(hostipA, "1.1.1.2", false);
                    testUtils.waitForSuccess(uut, res, TimeSpan.FromSeconds(5));
                }
                else
                {
                    throw new ArgumentException();
                }

                // and now, each should have one blade.
                Assert.IsTrue(
                    (
                        uut.svcDebug._GetBladeStatus(hostipA, "1.1.1.1") == GetBladeStatusResult.yours &&
                        uut.svcDebug._GetBladeStatus(hostipB, "1.1.1.2") == GetBladeStatusResult.yours
                    )
                    ||
                    (
                        uut.svcDebug._GetBladeStatus(hostipA, "1.1.1.2") == GetBladeStatusResult.yours &&
                        uut.svcDebug._GetBladeStatus(hostipB, "1.1.1.1") == GetBladeStatusResult.yours
                    )
                    );
            }
        }
コード例 #9
0
        public void setBIOSConfig(string newBiosXML)
        {
            hypSpec_iLo spec = getConnectionSpec();

            using (BladeDirectorServices director = new BladeDirectorServices(machinePools.bladeDirectorURL))
            {
                resultAndWaitToken res = director.svc.rebootAndStartDeployingBIOSToBlade(spec.kernelDebugIPOrHostname, newBiosXML);
                director.waitForSuccess(res, TimeSpan.FromMinutes(3));
            }
        }
コード例 #10
0
        public void canAllocateBlade()
        {
            using (bladeDirectorDebugServices uut = new bladeDirectorDebugServices(WCFPath, new[] { "1.1.1.1", "2.2.2.2", "3.3.3.3" }))
            {
                resultAndWaitToken requestStatus = uut.svcDebug._RequestAnySingleNode("192.168.1.1");
                Assert.AreEqual(resultCode.success, requestStatus.result.code);

                string[] allocated = uut.svc.getBladesByAllocatedServer("192.168.1.1");
                Assert.IsTrue(allocated.Contains("1.1.1.1"), "String '" + allocated + "' does not contain IP we allocated");
            }
        }
コード例 #11
0
        public static string doBladeAllocationForTest(bladeDirectorDebugServices uut, string hostIP)
        {
            uut.svcDebug._setExecutionResultsIfMocked(mockedExecutionResponses.successful);

            resultAndWaitToken allocRes = uut.svcDebug._RequestAnySingleNode(hostIP);

            Assert.AreEqual(resultCode.success, allocRes.result.code);


            return(((resultAndBladeName)allocRes).bladeName);
        }
コード例 #12
0
        public static void doLogin(bladeDirectorDebugServices uut, string hostIP,
                                   TimeSpan permissibleDelay = default(TimeSpan))
        {
            if (permissibleDelay == default(TimeSpan))
            {
                permissibleDelay = TimeSpan.FromSeconds(30);
            }

            resultAndWaitToken res = uut.svcDebug._logIn(hostIP);

            res = waitForSuccess(uut, res, permissibleDelay);
        }
コード例 #13
0
        public hypervisorCollection <hypSpec_iLo> requestAsManyHypervisorsAsPossible(string snapshotName)
        {
            initialiseIfNeeded();
            using (BladeDirectorServices director = new BladeDirectorServices(machinePools.bladeDirectorURL))
            {
                int nodeCount = director.svc.getAllBladeIP().Length;

                hypervisorCollection <hypSpec_iLo> toRet = new hypervisorCollection <hypSpec_iLo>();
                DateTime deadline = DateTime.Now + TimeSpan.FromMinutes(60);
                try
                {
                    for (int i = 0; i < nodeCount; i++)
                    {
                        resultAndBladeName res      = director.svc.RequestAnySingleNode();
                        resultAndBladeName progress = director.waitForSuccess(res, deadline - DateTime.Now);

                        bladeSpec          bladeConfig = director.svc.getBladeByIP_withoutLocking(progress.bladeName);
                        resultAndWaitToken snapRes     = director.svc.selectSnapshotForBladeOrVM(progress.bladeName, snapshotName);
                        director.waitForSuccess(snapRes, TimeSpan.FromMinutes(3));

                        snapshotDetails snapshot = director.svc.getCurrentSnapshotDetails(progress.bladeName);
                        userDesc        cred     = bladeConfig.credentials.First();
                        NASParams       nas      = director.svc.getNASParams();
                        hypSpec_iLo     spec     = new hypSpec_iLo(
                            bladeConfig.bladeIP, cred.username, cred.password,
                            bladeConfig.iLOIP, bladeConfig.iLoUsername, bladeConfig.iLoPassword,
                            nas.IP, nas.username, nas.password,
                            snapshot.friendlyName, snapshot.path,
                            bladeConfig.kernelDebugPort, bladeConfig.kernelDebugKey
                            );

                        ipUtils.ensurePortIsFree(bladeConfig.kernelDebugPort);

                        bladeDirectedHypervisor_iLo newHyp = new bladeDirectedHypervisor_iLo(spec);
                        newHyp.setDisposalCallback(onDestruction);

                        if (!toRet.TryAdd(bladeConfig.bladeIP, newHyp))
                        {
                            throw new Exception();
                        }
                    }
                    return(toRet);
                }
                catch (Exception)
                {
                    toRet.Dispose();
                    throw;
                }
            }
        }
コード例 #14
0
        public void canAllocateANumberOfVMMocked()
        {
            string hostIP = "1.1.1.1";

            using (bladeDirectorDebugServices svc = new bladeDirectorDebugServices(basicBladeTests.WCFPath, new[] { "1.1.1.1", "2.2.2.2", "3.3.3.3" }))
            {
                vmHWAndSWSpec[] toAlloc = new vmHWAndSWSpec[8];
                for (int i = 0; i < toAlloc.Length; i++)
                {
                    toAlloc[i] = new vmHWAndSWSpec(
                        new VMHardwareSpec()
                    {
                        memoryMB = 4096, cpuCount = 1
                    },
                        new VMSoftwareSpec());
                }

                resultAndBladeName[] allocRes = doVMAllocationsForTest(svc, hostIP, toAlloc);
                Assert.AreEqual(toAlloc.Length, allocRes.Length);

                // Group blades by their parent blade's IP
                IGrouping <string, resultAndBladeName>[] bladesByParent = allocRes.GroupBy(x => svc.svc.getVMByIP_withoutLocking(x.bladeName).parentBladeIP).ToArray();

                // We should have two VM servers in use.
                Assert.AreEqual(2, bladesByParent.Length);

                // 7 should be on the first blade, and 1 on the second.
                Assert.AreEqual(7, bladesByParent[0].Count());
                Assert.AreEqual("172.17.129.130", bladesByParent[0].Key);
                Assert.AreEqual(1, bladesByParent[1].Count());
                Assert.AreEqual("172.17.129.131", bladesByParent[1].Key);

                // And release them, checking hardware status after each blade is empty.
                foreach (IGrouping <string, resultAndBladeName> bladeAndParent in bladesByParent)
                {
                    //string parentBladeName = uut.db.getConfigurationOfBladeByID((int)bladeAndParent.Key, bladeLockType.lockNone).spec.bladeIP;

                    foreach (resultAndBladeName res in bladeAndParent)
                    {
                        // The VM server should still be allocated before release..
                        Assert.AreEqual(svc.svcDebug._GetBladeStatus(hostIP, bladeAndParent.Key), GetBladeStatusResult.notYours);
                        resultAndWaitToken releaseWait = svc.svcDebug._ReleaseBladeOrVM(hostIP, res.bladeName, false);
                        testUtils.waitForSuccess(svc, releaseWait, TimeSpan.FromSeconds(30));
                    }

                    // This VM server should now be unused.
                    Assert.AreEqual(svc.svcDebug._GetBladeStatus(hostIP, bladeAndParent.Key), GetBladeStatusResult.unused);
                }
            }
        }
コード例 #15
0
        private static resultAndBIOSConfig writeBIOSAndReadBack(bladeDirectorDebugServices svc, string hostIP, string bladeIP, string testBiosXML)
        {
            resultAndWaitToken result = svc.svcDebug._rebootAndStartDeployingBIOSToBlade(hostIP, bladeIP, testBiosXML);

            testUtils.waitForSuccess(svc, result, TimeSpan.FromMinutes(5));

            // Now check it wrote OK by reading it back and comparing the numlock key state.
            Assert.AreEqual(resultCode.pending, svc.svcDebug._rebootAndStartReadingBIOSConfiguration(hostIP, bladeIP).result.code);
            result = testUtils.waitForSuccess(svc, result, TimeSpan.FromMinutes(5));

            // We should definitely have written the config, so we don't permit the 'no need' code here.
            Assert.AreEqual(resultCode.success, result.result.code);

            return((resultAndBIOSConfig)result);
        }
コード例 #16
0
        public static string doVMAllocationForTest(bladeDirectorDebugServices uut, string hostIP)
        {
            uut.svcDebug._setExecutionResultsIfMocked(mockedExecutionResponses.successful);

            VMHardwareSpec hwspec = new VMHardwareSpec
            {
                cpuCount = 1,
                memoryMB = 1024 * 3
            };
            VMSoftwareSpec swspec = new VMSoftwareSpec();

            resultAndWaitToken res = uut.svcDebug._requestAnySingleVM(hostIP, hwspec, swspec);

            res = waitForSuccess(uut, res, TimeSpan.FromSeconds(30));
            return(((resultAndBladeName)res).bladeName);
        }
コード例 #17
0
        public void willTimeoutOnNoKeepalives()
        {
            using (bladeDirectorDebugServices uut = new bladeDirectorDebugServices(WCFPath, new[] { "1.1.1.1" }))
            {
                uut.svcDebug.setKeepAliveTimeout(10);

                string hostip = "192.168.1.1";

                resultAndWaitToken resp        = uut.svcDebug._RequestAnySingleNode(hostip);
                resultAndBladeName resWithName = (resultAndBladeName)resp;
                Assert.AreEqual(resultCode.success, resp.result.code);
                Assert.AreEqual("1.1.1.1", resWithName.bladeName);
                Assert.AreEqual(GetBladeStatusResult.yours, uut.svcDebug._GetBladeStatus(hostip, resWithName.bladeName));
                Thread.Sleep(TimeSpan.FromSeconds(11));
                Assert.AreEqual(GetBladeStatusResult.unused, uut.svcDebug._GetBladeStatus(hostip, resWithName.bladeName));
            }
        }
コード例 #18
0
        public void willEnforceSharingWithVMs()
        {
            using (bladeDirectorDebugServices uut = new bladeDirectorDebugServices(WCFPath, new[] { "1.1.1.1", "1.1.1.2" }))
            {
                string hostipA = "192.168.1.1";
                string hostipB = "192.168.1.2";

                // Host A requests all the VMs
                vmHWAndSWSpec toAlloc = new vmHWAndSWSpec(
                    new VMHardwareSpec()
                {
                    memoryMB = 4, cpuCount = 1
                },
                    new VMSoftwareSpec());

                resultAndBladeName[] intialReqs = uut.svcDebug._requestAsManyVMAsPossible(hostipA, toAlloc.hw, toAlloc.sw);
                for (int index = 0; index < intialReqs.Length; index++)
                {
                    intialReqs[index] = (resultAndBladeName)testUtils.waitForSuccess(uut, intialReqs[index], TimeSpan.FromMinutes(1));
                }

                // Now B requests a VM
                resultAndBladeName reqFromB = uut.svcDebug._requestAnySingleVM(hostipB, toAlloc.hw, toAlloc.sw);
                Assert.AreEqual(resultCode.pending, reqFromB.result.code);

                // A should be asked to release a single VM, and does as it is told
                int releaseRequestCount = 0;
                foreach (resultAndBladeName req in intialReqs)
                {
                    Debug.WriteLine(uut.svcDebug._GetVMStatus(hostipA, req.bladeName));
                    if (uut.svcDebug._GetVMStatus(hostipA, req.bladeName) == GetBladeStatusResult.releasePending)
                    {
                        resultAndWaitToken relWait = uut.svcDebug._ReleaseBladeOrVM(hostipA, req.bladeName, false);
                        testUtils.waitForSuccess(uut, relWait, TimeSpan.FromSeconds(30));

                        releaseRequestCount++;
                    }
                }
                Assert.AreEqual(1, releaseRequestCount);

                // Now, host B should have one VM.
                resultAndWaitToken newVM = testUtils.waitForSuccess(uut, reqFromB, TimeSpan.FromSeconds(30));
                Assert.AreEqual(resultCode.success, newVM.result.code);
            }
        }
コード例 #19
0
        public void willDeallocateBladeAfterVMDestruction()
        {
            using (bladeDirectorDebugServices svc = new bladeDirectorDebugServices(basicBladeTests.WCFPath, "2.2.2.2", true))
            {
                string hostIP = "1.1.1.1";

                string ourVM = testUtils.doVMAllocationForTest(svc, hostIP);

                // Our blade should become a VM server
                GetBladeStatusResult bladeState = svc.svcDebug._GetBladeStatus(hostIP, "2.2.2.2");
                Assert.AreEqual(GetBladeStatusResult.notYours, bladeState);

                // Then free the VM.
                resultAndWaitToken releaseRes = svc.svcDebug._ReleaseBladeOrVM(hostIP, ourVM, false);
                testUtils.waitForSuccess(svc, releaseRes, TimeSpan.FromSeconds(10));

                // The blade itself should become unused.
                bladeState = svc.svcDebug._GetBladeStatus(hostIP, "2.2.2.2");
                Assert.AreEqual(GetBladeStatusResult.unused, bladeState);
            }
        }
コード例 #20
0
        public void willDeallocateBlade()
        {
            using (bladeDirectorDebugServices svc = new bladeDirectorDebugServices(basicBladeTests.WCFPath))
            {
                string hostIP = "1.1.1.1";
                svc.svcDebug.initWithBladesFromIPList(new[] { "172.17.129.131" }, true, NASFaultInjectionPolicy.retunSuccessful);

                string ourBlade = testUtils.doBladeAllocationForTest(svc, hostIP);

                // It should be ours..
                GetBladeStatusResult bladeState = svc.svcDebug._GetBladeStatus(hostIP, ourBlade);
                Assert.AreEqual(bladeState, GetBladeStatusResult.yours);

                // Then free it
                resultAndWaitToken releaseRes = svc.svcDebug._ReleaseBladeOrVM(hostIP, ourBlade, false);
                testUtils.waitForSuccess(svc, releaseRes, TimeSpan.FromSeconds(10));

                // And it should be unused.
                bladeState = svc.svcDebug._GetBladeStatus(hostIP, ourBlade);
                Assert.AreEqual(bladeState, GetBladeStatusResult.unused);
            }
        }
コード例 #21
0
        private void initialiseIfNeeded()
        {
            if (!doesCallStackHasTrait("requiresBladeDirector"))
            {
                Assert.Fail("This test uses the blade director; please decorate it with [TestCategory(\"requiresBladeDirector\")] for easier maintenence");
            }

            if (keepaliveThread == null)
            {
                lock (keepaliveThreadLock)
                {
                    if (keepaliveThread == null)
                    {
                        using (BladeDirectorServices director = new BladeDirectorServices(machinePools.bladeDirectorURL))
                        {
                            resultAndWaitToken waitToken = director.svc.logIn();
                            // If there's a login already going for this machine, we will just use that one.
                            if (waitToken.result.code == resultCode.alreadyInProgress)
                            {
                                waitToken.result.code = resultCode.pending;
                            }
                            director.waitForSuccess(waitToken, TimeSpan.FromMinutes(10));
                        }
                        keepaliveThread      = new Thread(keepaliveThreadMain);
                        keepaliveThread.Name = "Blade director keepalive thread";
                        keepaliveThread.Start();
                    }
                }
            }

            if (!isConnected)
            {
                lock (_connectionLock)
                {
                    isConnected = true;
                }
            }
        }
コード例 #22
0
        public void willReUseOldVMsAfterLogonDuringBIOSOperation()
        {
            using (bladeDirectorDebugServices svc = new bladeDirectorDebugServices(basicBladeTests.WCFPath))
            {
                string hostIP = "1.1.1.1";
                svc.svcDebug.initWithBladesFromIPList(new[] { "172.17.129.131" }, true, NASFaultInjectionPolicy.retunSuccessful);

                // Start a 5-minute long BIOS operation, then cancel it by logging in again.
                svc.svcDebug._setBIOSOperationTimeIfMocked((int)TimeSpan.FromMinutes(5).TotalSeconds);

                testUtils.doLogin(svc, hostIP);

                // Start to allocate a VM
                VMHardwareSpec hwspec = new VMHardwareSpec {
                    cpuCount = 1, memoryMB = 1024 * 3
                };
                VMSoftwareSpec swspec = new VMSoftwareSpec();

                resultAndWaitToken res = svc.svcDebug._requestAnySingleVM(hostIP, hwspec, swspec);
                Assert.AreEqual(resultCode.pending, res.result.code);

                // The blade director should have assumed ownership of the blade itself, in order to deploy the VM
                Assert.AreEqual(true, svc.svcDebug._isBladeMine("vmserver", "172.17.129.131", true));

                // Now login again, cancelling the BIOS operation.
                testUtils.doLogin(svc, hostIP);

                // The blade should no longer be used by the blade director, nor by us
                Assert.AreEqual(false, svc.svcDebug._isBladeMine("vmserver", "172.17.129.131", false));
                Assert.AreEqual(false, svc.svcDebug._isBladeMine(hostIP, "172.17.129.131", false));

                // And after an allocation, our blade should be re-used successfully.
                svc.svcDebug._setBIOSOperationTimeIfMocked((int)2);
                testUtils.doVMAllocationForTest(svc, hostIP);
            }
        }
コード例 #23
0
        public bladeDirectedHypervisor_iLo createSingleHypervisor(string snapshotName)
        {
            initialiseIfNeeded();

            // We request a blade from the blade director, and use them for all our tests, blocking if none are available.
            using (BladeDirectorServices director = new BladeDirectorServices(machinePools.bladeDirectorURL))
            {
                // Request a node. If all queues are full, then wait and retry until we get one.
                resultAndBladeName allocatedBladeResult;
                while (true)
                {
                    allocatedBladeResult = director.svc.RequestAnySingleNode();
                    if (allocatedBladeResult.result.code == resultCode.success ||
                        allocatedBladeResult.result.code == resultCode.pending)
                    {
                        break;
                    }
                    if (allocatedBladeResult.result.code == resultCode.bladeQueueFull)
                    {
                        Debug.WriteLine("All blades are fully queued, waiting until one is spare");
                        Thread.Sleep(TimeSpan.FromSeconds(5));
                        continue;
                    }
                    throw new Exception("Blade director returned unexpected return status '" + allocatedBladeResult.result + "'");
                }

                // Now, wait until our blade is available.
                try
                {
                    bool isMine = director.svc.isBladeMine(allocatedBladeResult.bladeName);
                    while (!isMine)
                    {
                        Debug.WriteLine("Blade " + allocatedBladeResult.bladeName + " not released yet, awaiting release..");
                        Thread.Sleep(TimeSpan.FromSeconds(5));
                        isMine = director.svc.isBladeMine(allocatedBladeResult.bladeName);
                    }

                    // Great, now we have ownership of the blade, so we can use it safely.
                    //bladeSpec bladeConfig = director.svc.getConfigurationOfBlade(allocatedBladeResult.bladeName);
                    resultAndWaitToken res = director.svc.selectSnapshotForBladeOrVM(allocatedBladeResult.bladeName, snapshotName);
                    director.waitForSuccess(res, TimeSpan.FromMinutes(5));

                    bladeSpec       bladeConfig = director.svc.getBladeByIP_withoutLocking(allocatedBladeResult.bladeName);
                    snapshotDetails currentShot = director.svc.getCurrentSnapshotDetails(allocatedBladeResult.bladeName);
                    userDesc        cred        = bladeConfig.credentials.First();
                    NASParams       nas         = director.svc.getNASParams();

                    hypSpec_iLo spec = new hypSpec_iLo(
                        bladeConfig.bladeIP, cred.username, cred.password,
                        bladeConfig.iLOIP, bladeConfig.iLoUsername, bladeConfig.iLoPassword,
                        nas.IP, nas.username, nas.password,
                        currentShot.friendlyName, currentShot.path,
                        bladeConfig.kernelDebugPort, bladeConfig.kernelDebugKey
                        );

                    ipUtils.ensurePortIsFree(bladeConfig.kernelDebugPort);

                    bladeDirectedHypervisor_iLo toRet = new bladeDirectedHypervisor_iLo(spec);
                    toRet.setDisposalCallback(onDestruction);
                    return(toRet);
                }
                catch (Exception)
                {
                    director.svc.ReleaseBladeOrVM(allocatedBladeResult.bladeName);
                    throw;
                }
            }
        }
コード例 #24
0
        public void willProvisionBlade()
        {
            using (bladeDirectorDebugServices svc = new bladeDirectorDebugServices(basicBladeTests.WCFPath, basicBladeTests.WebURI))
            {
                machinePools.bladeDirectorURL = svc.servicesURL;

                string hostip = "1.2.3.4";
                //string debuggerHost = testUtils.getBestRouteTo(IPAddress.Parse("172.17.129.131")).ToString();

                // We will be using this blade for our tests.
                bladeSpec spec = svc.svcDebug.createBladeSpecForXDLNode(31, "xdl.hacks.the.planet", bladeLockType.lockAll, bladeLockType.lockAll);
                spec.friendlyName = "newBlade";
                svc.svcDebug.initWithBladesFromBladeSpec(new[] { spec }, false, NASFaultInjectionPolicy.retunSuccessful);

                resultAndBladeName res = svc.svcDebug._RequestAnySingleNode(hostip);
                testUtils.waitForSuccess(svc, res, TimeSpan.FromMinutes(15));

                string             bladeName = res.bladeName;
                resultAndWaitToken res2      = svc.svcDebug._selectSnapshotForBladeOrVM(hostip, bladeName, "discord");
                testUtils.waitForSuccess(svc, res2, TimeSpan.FromMinutes(30));

                // Okay, we have our blade allocated now.
                bladeSpec       createdBlade = svc.svc.getBladeByIP_withoutLocking(bladeName);
                snapshotDetails snap         = svc.svc.getCurrentSnapshotDetails(bladeName);
                NASParams       nas          = svc.svc.getNASParams();
                using (hypervisor foo = utils.createHypForBlade(createdBlade, snap, nas))
                {
                    foo.powerOn(new cancellableDateTime(TimeSpan.FromMinutes(5)));

                    // Check that debugging has been provisioned correctly
                    executionResult bcdEditRes = foo.startExecutable("bcdedit", "/dbgsettings");
                    try
                    {
                        Assert.AreEqual(0, bcdEditRes.resultCode);
                        Assert.IsTrue(Regex.IsMatch(bcdEditRes.stdout, "key\\s*xdl.hacks.the.planet"), "bcdedit did not match regex for debug key");
                        Assert.IsTrue(Regex.IsMatch(bcdEditRes.stdout, "debugtype\\s*NET"), "bcdedit did not match regex for debug type");
                        Assert.IsTrue(Regex.IsMatch(bcdEditRes.stdout, "hostip\\s*1.2.3.4"), "bcdedit did not match regex for debug host");
                        Assert.IsTrue(Regex.IsMatch(bcdEditRes.stdout, "port\\s*53101"), "bcdedit did not match regex for debug port");
                    }
                    catch (AssertFailedException)
                    {
                        Debug.WriteLine("return code " + bcdEditRes.resultCode);
                        Debug.WriteLine("stdout " + bcdEditRes.stdout);
                        Debug.WriteLine("stderr " + bcdEditRes.stderr);
                    }

                    executionResult getNameRes = foo.startExecutable("echo %COMPUTERNAME%", "");
                    try
                    {
                        Assert.AreEqual(0, getNameRes.resultCode);
                        Assert.AreSame(getNameRes.stdout.ToLower(), "newBlade".Trim().ToLower(), "machine name was incorrect");
                    }
                    catch (AssertFailedException)
                    {
                        Debug.WriteLine("return code " + bcdEditRes.resultCode);
                        Debug.WriteLine("stdout " + bcdEditRes.stdout);
                        Debug.WriteLine("stderr " + bcdEditRes.stderr);
                    }
                }
            }
        }
コード例 #25
0
        public static resultAndWaitToken waitForSuccess(bladeDirectorDebugServices uut, resultAndWaitToken res,
                                                        TimeSpan timeout)
        {
            DateTime deadline = DateTime.Now + timeout;

            while (res.result.code != resultCode.success)
            {
                switch (res.result.code)
                {
                case resultCode.success:
                case resultCode.noNeedLah:
                    break;

                case resultCode.pending:
                    if (DateTime.Now > deadline)
                    {
                        throw new TimeoutException();
                    }
                    res = uut.svc.getProgress(res.waitToken);
                    break;

                default:
                    Assert.Fail("Unexpected status during .getProgress: " + res.result.code + " / " +
                                res.result.errMsg);
                    break;
                }
                Thread.Sleep(TimeSpan.FromSeconds(1));
            }
            return(res);
        }