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); } }
public void willReAllocateNodeAfterTimeout() { using (bladeDirectorDebugServices uut = new bladeDirectorDebugServices(WCFPath, new[] { "1.1.1.1" })) { uut.svc.setResourceSharingModel(fairnessChecker.fairnessType.allowAny); uut.svcDebug.setKeepAliveTimeout(10); Assert.AreEqual(resultCode.success, uut.svcDebug._RequestAnySingleNode("192.168.1.1").result.code); Assert.AreEqual(resultCode.pending, uut.svcDebug._RequestAnySingleNode("192.168.2.2").result.code); // 1.1 has it, 2.2 is queued Assert.IsTrue(uut.svcDebug._isBladeMine("192.168.1.1", "1.1.1.1", false)); Assert.IsFalse(uut.svcDebug._isBladeMine("192.168.2.2", "1.1.1.1", false)); // Now let 1.1 timeout for (int i = 0; i < 11; i++) { uut.svcDebug._keepAlive("192.168.2.2"); Thread.Sleep(TimeSpan.FromSeconds(1)); } // and it should belong to the second requestor. Assert.IsFalse(uut.svcDebug._isBladeMine("192.168.1.1", "1.1.1.1", false)); Assert.IsTrue(uut.svcDebug._isBladeMine("192.168.2.2", "1.1.1.1", false)); } }
public void canAllocateAllVMsMocked() { 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" })) { svc.svcDebug._setExecutionResultsIfMocked(mockedExecutionResponses.successful); vmHWAndSWSpec toAlloc = new vmHWAndSWSpec( new VMHardwareSpec() { memoryMB = 4, cpuCount = 1 }, new VMSoftwareSpec()); resultAndBladeName[] res = svc.svcDebug._requestAsManyVMAsPossible(hostIP, toAlloc.hw, toAlloc.sw); foreach (resultAndBladeName resultAndBladeName in res) { testUtils.waitForSuccess(svc, resultAndBladeName, TimeSpan.FromMinutes(1)); } // Now see what we got. Assert.AreEqual(3 * 12, res.Length); } }
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); } }
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); } }
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); } }
public static resultAndBladeName[] doVMAllocationsForTest(bladeDirectorDebugServices uut, string hostIP, vmHWAndSWSpec[] specs, NASFaultInjectionPolicy NASFaultInjection = NASFaultInjectionPolicy.retunSuccessful) { uut.svcDebug.initWithBladesFromIPList(new[] { "172.17.129.131", "172.17.129.130" }, true, NASFaultInjection); uut.svcDebug._setExecutionResultsIfMocked(mockedExecutionResponses.successful); return(doAllocation(uut, hostIP, specs)); }
public void canGetBladeSpec() { using (bladeDirectorDebugServices svc = new bladeDirectorDebugServices(WCFPath)) { bladeSpec spec1Expected = svc.svcDebug.createBladeSpec("blade1ip", "blade1iscsiIP", "blade1ILOIP", 111, false, VMDeployStatus.notBeingDeployed, null, "idk", "box1", bladeLockType.lockAll, bladeLockType.lockAll); bladeSpec spec2Expected = svc.svcDebug.createBladeSpec("blade2ip", "blade2iscsiIP", "blade2ILOIP", 222, false, VMDeployStatus.notBeingDeployed, null, "idk", "box2", bladeLockType.lockAll, bladeLockType.lockAll); bladeSpec[] expected = new[] { spec1Expected, spec2Expected }; svc.svcDebug.initWithBladesFromBladeSpec(expected, false, NASFaultInjectionPolicy.retunSuccessful); bladeSpec spec1Actual = svc.svc.getBladeByIP_withoutLocking("blade1ip"); bladeSpec spec2Actual = svc.svc.getBladeByIP_withoutLocking("blade2ip"); bladeSpec[] actual = new[] { spec1Actual, spec2Actual }; for (int i = 0; i < 2; i++) { Assert.AreEqual(expected[i].bladeIP, actual[i].bladeIP); Assert.AreEqual(expected[i].ESXiPassword, actual[i].ESXiPassword); Assert.AreEqual(expected[i].ESXiUsername, actual[i].ESXiUsername); Assert.AreEqual(expected[i].currentlyBeingAVMServer, actual[i].currentlyBeingAVMServer); Assert.AreEqual(expected[i].currentlyHavingBIOSDeployed, actual[i].currentlyHavingBIOSDeployed); Assert.AreEqual(expected[i].iLOIP, actual[i].iLOIP); Assert.AreEqual(expected[i].kernelDebugPort, actual[i].kernelDebugPort); Assert.AreEqual(expected[i].iLoPassword, actual[i].iLoPassword); Assert.AreEqual(expected[i].iLoUsername, actual[i].iLoUsername); Assert.AreEqual(expected[i].iscsiIP, actual[i].iscsiIP); Assert.AreEqual(expected[i].lastDeployedBIOS, actual[i].lastDeployedBIOS); Assert.AreEqual(expected[i].ESXiPassword, actual[i].ESXiPassword); Assert.AreEqual(expected[i].ESXiUsername, actual[i].ESXiUsername); // thats enough for now } } }
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")); } }
public void willDeallocateOldVMsOnLogon() { using (bladeDirectorDebugServices svc = new bladeDirectorDebugServices(basicBladeTests.WCFPath, "172.17.129.131", true)) { string hostIP = "1.1.1.1"; testUtils.doLogin(svc, hostIP); // Allocate all the blades, then login again. The allocated blades should no longer be allocated. string ourVM = testUtils.doVMAllocationForTest(svc, hostIP); // Find the parent blade of the VM we got, and make sure it is now in use (by the blade director) vmSpec VMSpec = svc.svc.getVMByIP_withoutLocking(ourVM); bladeSpec bladeSpec = svc.svc.getBladeByIP_withoutLocking(VMSpec.parentBladeIP); GetBladeStatusResult bladeState = svc.svcDebug._GetBladeStatus(hostIP, bladeSpec.bladeIP); string bladeIP = bladeSpec.bladeIP; Assert.AreEqual(bladeState, GetBladeStatusResult.notYours); // Do a new login, which should cause our blades to be deallocated. testUtils.doLogin(svc, hostIP); // The VM should now not exist. Assert.AreEqual(null, svc.svc.getVMByIP_withoutLocking(ourVM)); // Find the parent blade of the VM we got, and make sure it is now unused. GetBladeStatusResult bladeState2 = svc.svcDebug._GetBladeStatus(hostIP, bladeIP); Assert.AreEqual(bladeState2, GetBladeStatusResult.unused); } }
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); } }
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); } }
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); }
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 ) ); } }
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"); } }
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); }
public void canInitWithBladesAndGetListBack() { using (bladeDirectorDebugServices svc = new bladeDirectorDebugServices(WCFPath, new[] { "1.1.1.1", "2.2.2.2", "3.3.3.3" })) { string[] foundIPs = svc.svc.getAllBladeIP(); Assert.AreEqual(3, foundIPs.Length); Assert.IsTrue(foundIPs.Contains("1.1.1.1")); Assert.IsTrue(foundIPs.Contains("2.2.2.2")); Assert.IsTrue(foundIPs.Contains("3.3.3.3")); } }
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); }
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); } } }
public void reportsVMCreationFailureNeatly() { string hostIP = "1.1.1.1"; using (bladeDirectorDebugServices uut = new bladeDirectorDebugServices(basicBladeTests.WCFPath, new[] { "1.1.1.1", "2.2.2.2", "3.3.3.3" })) { VMHardwareSpec hwSpec = new VMHardwareSpec() { memoryMB = 2344, cpuCount = 2 }; VMSoftwareSpec swSpec = new VMSoftwareSpec(); uut.svcDebug.initWithBladesFromIPList(new[] { "172.17.129.131", "172.17.129.130" }, true, NASFaultInjectionPolicy.failSnapshotDeletionOnFirstSnapshot); uut.svcDebug._setExecutionResultsIfMocked(mockedExecutionResponses.successful); resultAndBladeName allocRes; allocRes = uut.svcDebug._requestAnySingleVM(hostIP, hwSpec, swSpec); Assert.AreEqual(resultCode.pending, allocRes.result.code); waitToken waitTok = allocRes.waitToken; while (true) { Thread.Sleep(TimeSpan.FromSeconds(1)); resultAndBladeName progress = (resultAndBladeName)uut.svc.getProgress(waitTok); waitTok = progress.waitToken; if (progress.result.code == resultCode.pending) { continue; } Assert.AreEqual(resultCode.genericFail, progress.result.code); Assert.AreEqual("172.17.158.1", progress.bladeName); break; } // OK, our allocation failed. Try allocating a second VM - this one should succeed. allocRes = uut.svcDebug._requestAnySingleVM(hostIP, hwSpec, swSpec); Assert.AreEqual(resultCode.pending, allocRes.result.code); allocRes = (resultAndBladeName)testUtils.waitForSuccess(uut, allocRes, TimeSpan.FromMinutes(11)); Assert.AreNotEqual("172.17.158.1", allocRes.bladeName); Assert.AreNotEqual("172.17.158.1", allocRes.bladeName); vmSpec VMConfig = uut.svc.getVMByIP_withoutLocking(allocRes.bladeName); Assert.AreNotEqual("00:50:56:00:30:01", VMConfig.eth0MAC); Assert.AreNotEqual("00:50:56:01:30:01", VMConfig.eth1MAC); } }
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); }
public void willReUseOldVMsAfterLogon() { using (bladeDirectorDebugServices svc = new bladeDirectorDebugServices(basicBladeTests.WCFPath, "172.17.129.131", true)) { string hostIP = "1.1.1.1"; testUtils.doLogin(svc, hostIP); string firstVM = testUtils.doVMAllocationForTest(svc, hostIP); testUtils.doLogin(svc, hostIP); string secondVM = testUtils.doVMAllocationForTest(svc, hostIP); Assert.AreEqual(firstVM, secondVM); } }
public void willDeallocateOldBladesOnLogon() { using (bladeDirectorDebugServices svc = new bladeDirectorDebugServices(basicBladeTests.WCFPath)) { string hostIP = "1.1.1.1"; svc.svcDebug.initWithBladesFromIPList(new[] { "172.17.129.131" }, true, NASFaultInjectionPolicy.retunSuccessful); // Allocate a blade, then login again. The allocated blade should no longer be allocated. string ourBlade = testUtils.doBladeAllocationForTest(svc, hostIP); testUtils.doLogin(svc, hostIP); GetBladeStatusResult bladeState = svc.svcDebug._GetBladeStatus(hostIP, ourBlade); Assert.AreEqual(bladeState, GetBladeStatusResult.unused); } }
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); }
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)); } }
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); } }
public void willNotTimeoutWhenWeSendKeepalives() { using (bladeDirectorDebugServices uut = new bladeDirectorDebugServices(WCFPath, new[] { "1.1.1.1" })) { uut.svcDebug.setKeepAliveTimeout(10); string hostip = "192.168.1.1"; Assert.AreEqual(resultCode.success, uut.svcDebug._RequestAnySingleNode(hostip).result.code); Assert.AreEqual(GetBladeStatusResult.yours, uut.svcDebug._GetBladeStatus(hostip, "1.1.1.1")); for (int i = 0; i < 11; i++) { uut.svcDebug._keepAlive("192.168.1.1"); Thread.Sleep(TimeSpan.FromSeconds(1)); } Assert.AreEqual(GetBladeStatusResult.yours, uut.svcDebug._GetBladeStatus(hostip, "1.1.1.1")); } }
private static resultAndBladeName[] doAllocation(bladeDirectorDebugServices uut, string hostIP, vmHWAndSWSpec[] specs) { resultAndBladeName[] allocRes = new resultAndBladeName[specs.Length]; for (int i = 0; i < specs.Length; i++) { allocRes[i] = uut.svcDebug._requestAnySingleVM(hostIP, specs[i].hw, specs[i].sw); Assert.AreEqual(resultCode.pending, allocRes[i].result.code); } // Wait until all the allocation operations are complete for (int i = 0; i < specs.Length; i++) { allocRes[i] = (resultAndBladeName)testUtils.waitForSuccess(uut, allocRes[i], TimeSpan.FromMinutes(15)); } return(allocRes); }
public void canGenerateIPXEScriptForUnknownBlade() { Uri webURL = new Uri("http://localhost/" + Guid.NewGuid()); using (bladeDirectorDebugServices uut = new bladeDirectorDebugServices(WCFPath, new[] { "1.1.1.1" }, false, webURL)) { WebRequest request = WebRequest.Create(webURL + "/generateIPXEScript"); using (WebResponse response = request.GetResponse()) { using (Stream respStream = response.GetResponseStream()) { using (StreamReader respStreamReader = new StreamReader(respStream)) { string responseText = respStreamReader.ReadToEnd(); Assert.AreEqual("No blade at this IP address", responseText); } } } } }
public static resultAndBladeName startAsyncVMAllocationForTest(bladeDirectorDebugServices uut, string hostIP) { uut.svcDebug._setExecutionResultsIfMocked(mockedExecutionResponses.successful); VMHardwareSpec hwspec = new VMHardwareSpec { cpuCount = 1, memoryMB = 1024 * 3 }; VMSoftwareSpec swspec = new VMSoftwareSpec(); resultAndBladeName allocRes = uut.svcDebug._requestAnySingleVM(hostIP, hwspec, swspec); if (allocRes.result.code != resultCode.pending && allocRes.result.code != resultCode.success) { Assert.Fail("unexpected status: " + allocRes.result.code.ToString()); } return(allocRes); }