private void PrintGetPsuFwStatus(ref UpdatePsu psu, bool verifyAfter5Min, bool primaryImage, string currentApi, string fwFilePath, ref bool allPassed) { // Get Psu Firmware Status psu.psuFwStatus = this.TestChannelContext.GetPSUFirmwareStatus(psu.index); CmTestLog.Info(string.Format( "{0}: GetPsuFWStatus for Psu {1} - fwRevision: {2} completionCode: {3} fwUpdateStatus: {4} fwUpdateStage: {5}", currentApi, psu.index, psu.psuFwStatus.fwRevision, psu.psuFwStatus.completionCode, psu.psuFwStatus.fwUpdateStatus, psu.psuFwStatus.fwUpdateStage)); if (verifyAfter5Min) { // Verify Psu Update is progressing as expected if (((psu.psuFwStatus.completionCode != CompletionCode.Success) && (psu.psuFwStatus.completionCode != CompletionCode.PSUFirmwareUpdateInProgress)) || ((psu.psuFwStatus.fwUpdateStatus != "InProgress") && (psu.psuFwStatus.fwUpdateStatus != "Success"))) { CmTestLog.Failure(string.Format("{0}: Psu {1} failed update after 5 minutes\nfw: {2}", currentApi, psu.index, fwFilePath)); psu.passed = false; allPassed = false; } } else { // Verify Psu Fw Update Complete if (psu.psuFwStatus.completionCode != CompletionCode.Success || ((psu.psuFwStatus.fwUpdateStatus != "Success") && (psu.psuFwStatus.fwUpdateStage != "Completed"))) { CmTestLog.Failure(string.Format("{0}: Psu {1} failed update after 12 minutes\nfw: {2}", currentApi, psu.index, fwFilePath)); psu.passed = false; allPassed = false; } else { if (primaryImage) psu.primaryUpdateSuccessCount++; else psu.secondaryUpdateSuccessCount++; } } }
private TestResponse PsuDoesNotOutputPowerForUpdatePsuFirmware() { TestCase testCase = new TestCase("PsuDoesNotOutputPowerForUpdatePsuFirmware", 22840); CmTestLog.Info(string.Format( "\n !!!!!!Verifying {0} Causes Psu To Not Output Power During Fw Update. WorkItemId: {1}!!!!!!", this.currentApi, testCase.WorkItemId)); TestResponse response = new TestResponse(); // Get random Psu int[] psuIds = null; if (!ReturnSingleOrMultipleRandomPsus(1, ref psuIds, ref response)) return response; UpdatePsu psu = new UpdatePsu(psuIds[0], this.priLesFwFilePath, primaryImage); // Run test case using WcsCmAdmin this.TestChannelContext = this.ListTestChannelContexts[(int)WCSSecurityRole.WcsCmAdmin]; psu.psuFwStatus = this.TestChannelContext.GetPSUFirmwareStatus(psu.index); LogMessage.Message = string.Format( "{0}: GetPsuFirmwareStatus for PSU {1} before update - fwRevision: {2} completionCode: {3} fwUpdateStatus: {4} fwUpdateStage: {5}", this.currentApi, psu.index, psu.psuFwStatus.fwRevision, psu.psuFwStatus.completionCode, psu.psuFwStatus.fwUpdateStatus, psu.psuFwStatus.fwUpdateStage); // Verify PSU is available for update if (psu.psuFwStatus.completionCode != CompletionCode.Success || psu.psuFwStatus.fwUpdateStatus == "InProgress") { LogMessage.Log(LogMessage.MessageType.Failure, ref response); return response; } else LogMessage.Log(LogMessage.MessageType.Success, ref response); // Update PSU psu.psuFwUpdateResponse = this.TestChannelContext.UpdatePSUFirmware(psu.index, psu.psuFwFilePath, psu.primaryImage); LogMessage.Message = string.Format( "{0}: Psu {1} returned completion code {2} and status description {3}", this.currentApi, psu.index, psu.psuFwUpdateResponse.completionCode, psu.psuFwUpdateResponse.statusDescription); if (psu.psuFwUpdateResponse.completionCode != CompletionCode.Success) { LogMessage.Log(LogMessage.MessageType.Failure, ref response); return response; } else LogMessage.Log(LogMessage.MessageType.Success, ref response); // Sleep for 1 minute LogMessage.Message = "Thread sleeping for 1 minutes..."; LogMessage.Log(LogMessage.MessageType.Info, ref response); Thread.Sleep(TimeSpan.FromMinutes(1)); // Check Psu Power Output is 0 using GetChassisHealth ChassisHealthResponse getChassisHealthResponse = new ChassisHealthResponse(); getChassisHealthResponse = this.TestChannelContext.GetChassisHealth(false, true, false, false); PsuInfo psuHealth = getChassisHealthResponse.psuInfoCollection .FirstOrDefault(x => x.id == psu.index); LogMessage.Message = string.Format( "{0}: GetChassisHealth for Psu {1} - completionCode {2} and powerOut {3}", this.currentApi, psuHealth.id, getChassisHealthResponse.completionCode, psuHealth.powerOut); if (getChassisHealthResponse.completionCode == CompletionCode.Success && psuHealth.powerOut == 0) LogMessage.Log(LogMessage.MessageType.Success, ref response); else LogMessage.Log(LogMessage.MessageType.Failure, ref response); testCase.LogPassOrFail(ref response, this.currentApi); return response; }
private TestResponse InvalidPsuFwFileUpdateFailForUpdatePsuFirmware() { // Change test case Id and fwFilePath if testing Les or Non-Les Psus int testCaseId = -1; string fwFilePath; if (lesPsusInChassis == "1") // currently testing LES PSU { testCaseId = 22896; fwFilePath = this.secLesFwFilePath; } else { testCaseId = 22909; fwFilePath = this.secNonLesFwFilePath; } TestCase testCase = new TestCase("InvalidPsuFwFileUpdateFailForUpdatePsuFirmware", testCaseId); CmTestLog.Info(string.Format( "\n !!!!!!Verifying {0} Fails Update for Invalid Psu Fw File. WorkItemId: {1}!!!!!!", this.currentApi, testCase.WorkItemId)); TestResponse response = new TestResponse(); // Get random valid Psu Id int[] psuIds = null; if (!ReturnSingleOrMultipleRandomPsus(1, ref psuIds, ref response)) return response; UpdatePsu psu = new UpdatePsu(psuIds[0], fwFilePath, primaryImage); // Run test case using WcsCmAdmin this.TestChannelContext = this.ListTestChannelContexts[(int)WCSSecurityRole.WcsCmAdmin]; psu.psuFwStatus = this.TestChannelContext.GetPSUFirmwareStatus(psu.index); LogMessage.Message = string.Format( "{0}: GetPsuFirmwareStatus for PSU {1} before update - fwRevision: {2} completionCode: {3} fwUpdateStatus: {4} fwUpdateStage: {5}", this.currentApi, psu.index, psu.psuFwStatus.fwRevision, psu.psuFwStatus.completionCode, psu.psuFwStatus.fwUpdateStatus, psu.psuFwStatus.fwUpdateStage); // Verify PSU is available for update if (psu.psuFwStatus.completionCode != CompletionCode.Success || psu.psuFwStatus.fwUpdateStatus == "InProgress") { LogMessage.Log(LogMessage.MessageType.Failure, ref response); return response; } else LogMessage.Log(LogMessage.MessageType.Success, ref response); // Update Psu with secondary fw image and true value for primaryImage psu.psuFwUpdateResponse = this.TestChannelContext.UpdatePSUFirmware(psu.index, psu.psuFwFilePath, primaryImage); LogMessage.Message = string.Format( "{0}: Psu {1} returned completion code {2} and status description {3}", this.currentApi, psu.index, psu.psuFwUpdateResponse.completionCode, psu.psuFwUpdateResponse.statusDescription); if (psu.psuFwUpdateResponse.completionCode != CompletionCode.Success) { LogMessage.Log(LogMessage.MessageType.Failure, ref response); return response; } else LogMessage.Log(LogMessage.MessageType.Success, ref response); // Sleep for 5 minutes LogMessage.Message = "Thread sleeping for 5 minutes..."; LogMessage.Log(LogMessage.MessageType.Info, ref response); Thread.Sleep(TimeSpan.FromMinutes(5)); // Verify Psu Fw Update has failed psu.psuFwStatus = this.TestChannelContext.GetPSUFirmwareStatus(psu.index); LogMessage.Message = string.Format( "{0}: GetPsuFirmwareStatus for PSU {1} - fwRevision: {2} completionCode: {3} fwUpdateStatus: {4} fwUpdateStage: {5}", this.currentApi, psu.index, psu.psuFwStatus.fwRevision, psu.psuFwStatus.completionCode, psu.psuFwStatus.fwUpdateStatus, psu.psuFwStatus.fwUpdateStage); if (psu.psuFwStatus.completionCode == CompletionCode.Success && psu.psuFwStatus.fwUpdateStatus == "Failed" && psu.psuFwStatus.fwUpdateStage == "SendModelId") LogMessage.Log(LogMessage.MessageType.Success, ref response); else { LogMessage.Log(LogMessage.MessageType.Failure, ref response); return response; } // Update Psu with invalid psu image and true value for primaryImage string invalidFwFilePath = ConfigurationManager.AppSettings["InvalidPsuFwFilePath"].ToString(); psu.psuFwUpdateResponse = this.TestChannelContext.UpdatePSUFirmware(psu.index, invalidFwFilePath, primaryImage); LogMessage.Message = string.Format( "{0}: Psu {1} returned completion code {2} and status description {3}", this.currentApi, psu.index, psu.psuFwUpdateResponse.completionCode, psu.psuFwUpdateResponse.statusDescription); if (psu.psuFwUpdateResponse.completionCode != CompletionCode.Success) { LogMessage.Log(LogMessage.MessageType.Failure, ref response); return response; } else LogMessage.Log(LogMessage.MessageType.Success, ref response); // Sleep for 5 minutes LogMessage.Message = "Thread sleeping for 5 minutes..."; LogMessage.Log(LogMessage.MessageType.Info, ref response); Thread.Sleep(TimeSpan.FromMinutes(5)); // Verify Psu Fw Update has failed psu.psuFwStatus = this.TestChannelContext.GetPSUFirmwareStatus(psu.index); LogMessage.Message = string.Format( "{0}: GetPsuFirmwareStatus for PSU {1} - fwRevision: {2} completionCode: {3} fwUpdateStatus: {4} fwUpdateStage: {5}", this.currentApi, psu.index, psu.psuFwStatus.fwRevision, psu.psuFwStatus.completionCode, psu.psuFwStatus.fwUpdateStatus, psu.psuFwStatus.fwUpdateStage); if (psu.psuFwStatus.completionCode == CompletionCode.Success && psu.psuFwStatus.fwUpdateStatus == "Failed" && psu.psuFwStatus.fwUpdateStage == "ExtractModelId") LogMessage.Log(LogMessage.MessageType.Success, ref response); else { LogMessage.Log(LogMessage.MessageType.Failure, ref response); return response; } testCase.LogPassOrFail(ref response, this.currentApi); return response; }
private TestResponse OnlyAdminCanExecuteUpdatePsuFirmware() { TestCase testCase = new TestCase("OnlyAdminCanExecuteUpdatePsuFirmware", 22713); CmTestLog.Info(string.Format( "\n !!!!!!Verifying {0} Can Only Be Executed By WcsCmAdmin Users. WorkItemId: {1}!!!!!!", this.currentApi, testCase.WorkItemId)); TestResponse response = new TestResponse(); // Get random Psu int[] psuIds = null; if (!ReturnSingleOrMultipleRandomPsus(1, ref psuIds, ref response)) return response; UpdatePsu psu = new UpdatePsu(psuIds[0]); // Loop through different user types foreach (WCSSecurityRole roleId in Enum.GetValues(typeof(WCSSecurityRole))) { this.TestChannelContext = this.ListTestChannelContexts[(int)roleId]; try { string fwFilePath = lesPsusInChassis == "1" ? priLesFwFilePath : priNonLesFwFilePath; psu.psuFwUpdateResponse = this.TestChannelContext.UpdatePSUFirmware(psu.index, fwFilePath, primaryImage); LogMessage.Message = string.Format( "{0}: Command returns completion code {1} for user {2} for psu Id {3}", currentApi, psu.psuFwUpdateResponse.completionCode, Enum.GetName(typeof(WCSSecurityRole), roleId), psu.index); if (psu.psuFwUpdateResponse.completionCode == CompletionCode.Success && roleId == WCSSecurityRole.WcsCmAdmin) LogMessage.Log(LogMessage.MessageType.Success, ref response); else LogMessage.Log(LogMessage.MessageType.Failure, ref response); } catch (Exception ex) { // Check error is due to permission HTTP 400 unauthorize if (ex.Message.Contains("400")) { // Check if 400 error due to WcsAdmin (fail) LogMessage.Message = string.Format("{0}: Command returned Bad Request for user {1} for psuId {2}", currentApi, Enum.GetName(typeof(WCSSecurityRole), roleId), psu.index); if (roleId != WCSSecurityRole.WcsCmAdmin) LogMessage.Log(LogMessage.MessageType.Success, ref response); else LogMessage.Log(LogMessage.MessageType.Failure, ref response); } else { ChassisManagerTestHelper.IsTrue(false, "Exception: " + ex.Message); response.Result = false; response.ResultDescription.Append(ex.Message); } } } testCase.LogPassOrFail(ref response, currentApi); return response; }
private TestResponse ForceEmersonPsuFwUpdateAfterCmServiceRestartForUpdatePsuFirmware() { // Change test case Id and fwFilePath if testing Les or Non-Les Psus int testCaseId = -1; string fwFilePath; if (lesPsusInChassis == "1") // currently testing LES PSU { testCaseId = 22934; fwFilePath = this.priLesFwFilePath; } else { testCaseId = 22935; fwFilePath = this.priNonLesFwFilePath; } TestCase testCase = new TestCase("ForceEmersonPsuFwUpdateAfterCmServiceRestartForUpdatePsuFirmware", testCaseId); CmTestLog.Info(string.Format( "\n !!!!!!Verifying {0} Requires ForceEmersonPsu App Config Key for Psu Fw Update After CM Service Restart. WorkItemId: {1}!!!!!!", this.currentApi, testCase.WorkItemId)); TestResponse response = new TestResponse(); // Get random valid Psu Id int[] psuIds = null; if (!ReturnSingleOrMultipleRandomPsus(1, ref psuIds, ref response)) return response; UpdatePsu psu = new UpdatePsu(psuIds[0], fwFilePath, primaryImage); // Initialize FRU Writes Remaining Dictionary KeyValue Pair Dictionary<string, string> forceEmersonPsuKeyValue = new Dictionary<string, string> { {"ForceEmersonPsu", "0"} }; // configure app.config and restart CM ConfigureAppConfig(forceEmersonPsuKeyValue, false); RestartCmService(this.currentApi); // Run test case using WcsCmAdmin this.TestChannelContext = this.ListTestChannelContexts[(int)WCSSecurityRole.WcsCmAdmin]; psu.psuFwStatus = this.TestChannelContext.GetPSUFirmwareStatus(psu.index); LogMessage.Message = string.Format( "{0}: GetPsuFirmwareStatus for PSU {1} before update - fwRevision: {2} completionCode: {3} fwUpdateStatus: {4} fwUpdateStage: {5}", this.currentApi, psu.index, psu.psuFwStatus.fwRevision, psu.psuFwStatus.completionCode, psu.psuFwStatus.fwUpdateStatus, psu.psuFwStatus.fwUpdateStage); // Verify PSU is available for update if (psu.psuFwStatus.completionCode != CompletionCode.Success || psu.psuFwStatus.fwUpdateStatus == "InProgress") { LogMessage.Log(LogMessage.MessageType.Failure, ref response); return response; } else LogMessage.Log(LogMessage.MessageType.Success, ref response); // Update PSU psu.psuFwUpdateResponse = this.TestChannelContext.UpdatePSUFirmware(psu.index, psu.psuFwFilePath, psu.primaryImage); LogMessage.Message = string.Format( "{0}: Psu {1} returned completion code {2} and status description {3}", this.currentApi, psu.index, psu.psuFwUpdateResponse.completionCode, psu.psuFwUpdateResponse.statusDescription); if (psu.psuFwUpdateResponse.completionCode != CompletionCode.Success) { LogMessage.Log(LogMessage.MessageType.Failure, ref response); return response; } else LogMessage.Log(LogMessage.MessageType.Success, ref response); // Sleep for 5 minutes LogMessage.Message = "Thread sleeping for 5 minutes..."; LogMessage.Log(LogMessage.MessageType.Info, ref response); Thread.Sleep(TimeSpan.FromMinutes(5)); // Restart CM Service LogMessage.Message = "Restarting CM Service"; LogMessage.Log(LogMessage.MessageType.Info, ref response); RestartCmService(this.currentApi); // Verify Psu Fw Update has failed psu.psuFwUpdateResponse = this.TestChannelContext.UpdatePSUFirmware(psu.index, psu.psuFwFilePath, psu.primaryImage); LogMessage.Message = string.Format( "{0}: Psu {1} returned completion code {2} and status description {3}", this.currentApi, psu.index, psu.psuFwUpdateResponse.completionCode, psu.psuFwUpdateResponse.statusDescription); if (psu.psuFwUpdateResponse.completionCode == CompletionCode.Failure && psu.psuFwUpdateResponse.statusDescription == "UpdatePSUFirmware() only supported on Emerson PSU.") LogMessage.Log(LogMessage.MessageType.Success, ref response); else { LogMessage.Log(LogMessage.MessageType.Failure, ref response); return response; } // Configure ForceEmersonPsu App Config Key forceEmersonPsuKeyValue["ForceEmersonPsu"] = "1"; ConfigureAppConfig(forceEmersonPsuKeyValue, false); RestartCmService(this.currentApi); // Verify ForceEmersonPsu allows for successful Psu Fw Update List<UpdatePsu> psuList = new List<UpdatePsu>(); psuList.Add(psu); VerifyPsuFwUpdate(ref psuList, ref response); // Code Clean-Up: restore App.Config in CM ConfigureAppConfig(null, true); testCase.LogPassOrFail(ref response, this.currentApi); return response; }
private TestResponse AllGroupsCanExecuteGetPsuFirmwareStatus() { TestCase testCase = new TestCase("AllGroupsCanExecuteGetPsuFirmwareStatus", 22696); CmTestLog.Info(string.Format("\n !!!!!!Verifying {0} Can Be Executed By All Users. WorkItemId: {1}.!!!!!!", this.currentApi, testCase.WorkItemId)); TestResponse response = new TestResponse(); // Get random Psu int[] psuIds = null; if (!ReturnSingleOrMultipleRandomPsus(1, ref psuIds, ref response)) return response; UpdatePsu psu = new UpdatePsu(psuIds[0]); // Loop through different user types foreach (WCSSecurityRole roleId in Enum.GetValues(typeof(WCSSecurityRole))) { // Use different user context this.TestChannelContext = this.ListTestChannelContexts[(int)roleId]; // Get Pass Through Mode and verify psu.psuFwStatus = this.TestChannelContext.GetPSUFirmwareStatus(psu.index); LogMessage.Message = string.Format( "{0}: Command returned completion code {1} for user {2} and psu Id {3}", this.currentApi, psu.psuFwStatus.completionCode, Enum.GetName(typeof(WCSSecurityRole), roleId), psu.index); if (psu.psuFwStatus.completionCode != CompletionCode.Success) LogMessage.Log(LogMessage.MessageType.Failure, ref response); else LogMessage.Log(LogMessage.MessageType.Success, ref response); // Verify Correct psuId returned by GetPsuFirmwareStatus LogMessage.Message = string.Format( "{0}: Command returned psu Id {0} for expected psu Id {1}", this.currentApi, psu.psuFwStatus.id, psu.index); if (psu.psuFwStatus.id != psu.index) LogMessage.Log(LogMessage.MessageType.Failure, ref response); else LogMessage.Log(LogMessage.MessageType.Success, ref response); } testCase.LogPassOrFail(ref response, this.currentApi); return response; }
public bool UpdatePsuFirmwareStressTest() { CmTestLog.Start(); bool allPassed = true; string currentApi = "UpdatePsuFirmware"; int numberOfCycles = Int32.Parse(ConfigurationManager.AppSettings["PsuStressCycleCount"].ToString()); try { this.TestChannelContext = this.ListTestChannelContexts[(int)WCSSecurityRole.WcsCmAdmin]; // Get 4 random psu locations int[] psuIds = null; TestResponse response = new TestResponse(); if (!ReturnSingleOrMultipleRandomPsus(4, ref psuIds, ref response)) return false; UpdatePsu psu1 = new UpdatePsu(psuIds[0]); UpdatePsu psu2 = new UpdatePsu(psuIds[1]); UpdatePsu psu3 = new UpdatePsu(psuIds[2]); UpdatePsu psu4 = new UpdatePsu(psuIds[3]); bool primaryOrSecondaryImage; string fwFilePath = string.Empty; string[] fwFilePaths = new string[2]; if (lesPsusInChassis == "1") { fwFilePaths[0] = priLesFwFilePath; fwFilePaths[1] = secLesFwFilePath; } else { fwFilePaths[0] = priNonLesFwFilePath; fwFilePaths[1] = secNonLesFwFilePath; } for (int cycleCount = 0; cycleCount < numberOfCycles; cycleCount++) { fwFilePath = fwFilePaths[cycleCount % 2]; primaryOrSecondaryImage = fwFilePath == fwFilePaths[0] ? primaryImage : secondaryImage; psu1.passed = true; psu2.passed = true; psu3.passed = true; psu4.passed = true; // Sleep for 30 seconds before starting each test cycle CmTestLog.Info(string.Format("\n{0}: Sleeping for 30 seconds before starting test cycle {1} ...", currentApi, cycleCount)); Thread.Sleep(TimeSpan.FromSeconds(30)); CmTestLog.Info(string.Format("{0}: Update Psu FW Test {1} for Psu {2}, Psu {3}, Psu {4}, Psu {5} for fwFilePath {6}", currentApi, cycleCount, psu1.index, psu2.index, psu3.index, psu4.index, fwFilePath)); // Update Psu psu1.psuFwUpdateResponse = this.TestChannelContext.UpdatePSUFirmware(psu1.index, fwFilePath, primaryOrSecondaryImage); Thread.Sleep(TimeSpan.FromSeconds(30)); // Update second Psu psu2.psuFwUpdateResponse = this.TestChannelContext.UpdatePSUFirmware(psu2.index, fwFilePath, primaryOrSecondaryImage); Thread.Sleep(TimeSpan.FromSeconds(30)); // Update thrid Psu psu3.psuFwUpdateResponse = this.TestChannelContext.UpdatePSUFirmware(psu3.index, fwFilePath, primaryOrSecondaryImage); Thread.Sleep(TimeSpan.FromSeconds(30)); // Update fourth Psu psu4.psuFwUpdateResponse = this.TestChannelContext.UpdatePSUFirmware(psu4.index, fwFilePath, primaryOrSecondaryImage); // Verify response if (psu1.psuFwUpdateResponse.completionCode != CompletionCode.Success && psu2.psuFwUpdateResponse.completionCode != CompletionCode.Success && psu3.psuFwUpdateResponse.completionCode != CompletionCode.Success && psu4.psuFwUpdateResponse.completionCode != CompletionCode.Success) { CmTestLog.Failure(string.Format( "{0}: Command returned Completion Code {1} for Psu {2}, Completion Code {3} for Psu {4}, Completion Code {5} for Psu {6}, Completion Code {7} for Psu {8}", currentApi, psu1.psuFwUpdateResponse.completionCode, psu1.index, psu2.psuFwUpdateResponse.completionCode, psu2.index, psu3.psuFwUpdateResponse.completionCode, psu3.index, psu4.psuFwUpdateResponse.completionCode, psu4.index)); allPassed = false; continue; } // Sleep 5 minutes CmTestLog.Info("Thread sleeping for 5 minutes.."); Thread.Sleep(TimeSpan.FromMinutes(5)); // GetPsuFwStatus and verify test is progressing correctly PrintGetPsuFwStatus(ref psu1, true, primaryOrSecondaryImage, currentApi, fwFilePath, ref allPassed); PrintGetPsuFwStatus(ref psu2, true, primaryOrSecondaryImage, currentApi, fwFilePath, ref allPassed); PrintGetPsuFwStatus(ref psu3, true, primaryOrSecondaryImage, currentApi, fwFilePath, ref allPassed); PrintGetPsuFwStatus(ref psu4, true, primaryOrSecondaryImage, currentApi, fwFilePath, ref allPassed); if (!(psu1.passed || psu1.passed || psu3.passed || psu4.passed)) { CmTestLog.Info("\n"); continue; } // Sleep 7 minutes CmTestLog.Info("Thread sleeping for 7 minutes.."); Thread.Sleep(TimeSpan.FromMinutes(7)); // GetPsuFwStatus and verify test completed successfully PrintGetPsuFwStatus(ref psu1, false, primaryOrSecondaryImage, currentApi, fwFilePath, ref allPassed); PrintGetPsuFwStatus(ref psu2, false, primaryOrSecondaryImage, currentApi, fwFilePath, ref allPassed); PrintGetPsuFwStatus(ref psu3, false, primaryOrSecondaryImage, currentApi, fwFilePath, ref allPassed); PrintGetPsuFwStatus(ref psu4, false, primaryOrSecondaryImage, currentApi, fwFilePath, ref allPassed); CmTestLog.Info("\n"); } if (psu1.primaryUpdateSuccessCount != 0 || psu2.primaryUpdateSuccessCount != 0 || psu3.primaryUpdateSuccessCount != 0 || psu4.primaryUpdateSuccessCount != 0) { CmTestLog.Info(string.Format("{0}: {1} Updates successful for Primary Les Fw Update for Psu {2}\nfw: {3}", currentApi, psu1.primaryUpdateSuccessCount, psu1.index, fwFilePaths[0])); CmTestLog.Info(string.Format("{0}: {1} Updates successful for Primary Les Fw Update for Psu {2}\nfw: {3}", currentApi, psu2.primaryUpdateSuccessCount, psu2.index, fwFilePaths[0])); CmTestLog.Info(string.Format("{0}: {1} Updates successful for Primary Les Fw Update for Psu {2}\nfw: {3}", currentApi, psu3.primaryUpdateSuccessCount, psu3.index, fwFilePaths[0])); CmTestLog.Info(string.Format("{0}: {1} Updates successful for Primary Les Fw Update for Psu {2}\nfw: {3}", currentApi, psu4.primaryUpdateSuccessCount, psu4.index, fwFilePaths[0])); } if (psu1.secondaryUpdateSuccessCount != 0 || psu2.secondaryUpdateSuccessCount != 0 || psu3.secondaryUpdateSuccessCount != 0 || psu4.secondaryUpdateSuccessCount != 0) { CmTestLog.Info(string.Format("{0}: {1} Updates successful for Secondary Les Fw Update for Psu {2}\nfw: {3}", currentApi, psu1.secondaryUpdateSuccessCount, psu1.index, fwFilePaths[1])); CmTestLog.Info(string.Format("{0}: {1} Updates successful for Secondary Les Fw Update for Psu {2}\nfw: {3}", currentApi, psu2.secondaryUpdateSuccessCount, psu2.index, fwFilePaths[1])); CmTestLog.Info(string.Format("{0}: {1} Updates successful for Secondary Les Fw Update for Psu {2}\nfw: {3}", currentApi, psu3.secondaryUpdateSuccessCount, psu3.index, fwFilePaths[1])); CmTestLog.Info(string.Format("{0}: {1} Updates successful for Secondary Les Fw Update for Psu {2}\nfw: {3}", currentApi, psu4.secondaryUpdateSuccessCount, psu4.index, fwFilePaths[1])); } StartStopCmService("stop"); } catch (Exception ex) { ChassisManagerTestHelper.IsTrue(false, string.Format("Exception: {0}", ex.Message)); allPassed = false; } CmTestLog.End(allPassed); return allPassed; }
private TestResponse SuccessfulSecFwUpdateForUpdatePsuFirmware() { // Change test case Id and fwFilePath if testing Les or Non-Les Psus int testCaseId = -1; string fwFilePath; if (lesPsusInChassis == "1") // currently testing LES PSU { testCaseId = 22745; fwFilePath = this.secLesFwFilePath; } else { testCaseId = 22746; fwFilePath = this.secNonLesFwFilePath; } TestCase testCase = new TestCase("SuccessfulSecFwUpdateForUpdatePsuFirmware", testCaseId); CmTestLog.Info(string.Format( "\n !!!!!!Verifying {0} Returns Successful Secondary Psu Fw Image Update for Psu. WorkItemId: {1}!!!!!!", this.currentApi, testCase.WorkItemId)); TestResponse response = new TestResponse(); // Get random valid Psu Id int[] psuIds = null; if (!ReturnSingleOrMultipleRandomPsus(1, ref psuIds, ref response)) return response; UpdatePsu psu = new UpdatePsu(psuIds[0], fwFilePath, secondaryImage); // Initialize List to contain UpdatePsu elements List<UpdatePsu> psuList = new List<UpdatePsu>(); psuList.Add(psu); // Verify Secondary Psu Fw Update VerifyPsuFwUpdate(ref psuList, ref response); testCase.LogPassOrFail(ref response, currentApi); return response; }
private TestResponse SuccessfulPriOrSecNotBothFwUpdateForUpdatePsuFirmware() { // Change test case Id and fwFilePath if testing Les or Non-Les Psus int testCaseId = -1; string fwFilePath; if (lesPsusInChassis == "1") // currently testing LES PSU { testCaseId = 22848; fwFilePath = this.priLesFwFilePath; } else { testCaseId = 22864; fwFilePath = this.priNonLesFwFilePath; } TestCase testCase = new TestCase("SuccessfulMultiplePriSecFwUpdatesForUpdatePsuFirmware", testCaseId); CmTestLog.Info(string.Format( "\n !!!!!!Verifying {0} Only Allows Successful Primary Or Secondary Psu Fw Image To Be Updated, Not Both. WorkItemId: {1}!!!!!!", this.currentApi, testCase.WorkItemId)); TestResponse response = new TestResponse(); // Get random valid Psu Id int[] psuIds = null; if (!ReturnSingleOrMultipleRandomPsus(1, ref psuIds, ref response)) return response; UpdatePsu psu = new UpdatePsu(psuIds[0], fwFilePath, primaryImage); // Run test case using WcsCmAdmin this.TestChannelContext = this.ListTestChannelContexts[(int)WCSSecurityRole.WcsCmAdmin]; psu.psuFwStatus = this.TestChannelContext.GetPSUFirmwareStatus(psu.index); LogMessage.Message = string.Format( "{0}: GetPsuFirmwareStatus for PSU {1} before update - fwRevision: {2} completionCode: {3} fwUpdateStatus: {4} fwUpdateStage: {5}", this.currentApi, psu.index, psu.psuFwStatus.fwRevision, psu.psuFwStatus.completionCode, psu.psuFwStatus.fwUpdateStatus, psu.psuFwStatus.fwUpdateStage); // Verify PSU is available for update if (psu.psuFwStatus.completionCode != CompletionCode.Success || psu.psuFwStatus.fwUpdateStatus == "InProgress") { LogMessage.Log(LogMessage.MessageType.Failure, ref response); return response; } else LogMessage.Log(LogMessage.MessageType.Success, ref response); // Update PSU psu.psuFwUpdateResponse = this.TestChannelContext.UpdatePSUFirmware(psu.index, psu.psuFwFilePath, psu.primaryImage); LogMessage.Message = string.Format( "{0}: Psu {1} returned completion code {2} and status description {3}", this.currentApi, psu.index, psu.psuFwUpdateResponse.completionCode, psu.psuFwUpdateResponse.statusDescription); if (psu.psuFwUpdateResponse.completionCode != CompletionCode.Success) { LogMessage.Log(LogMessage.MessageType.Failure, ref response); return response; } else LogMessage.Log(LogMessage.MessageType.Success, ref response); // Sleep for 5 minutes LogMessage.Message = "Thread sleeping for 5 minutes..."; LogMessage.Log(LogMessage.MessageType.Info, ref response); Thread.Sleep(TimeSpan.FromMinutes(5)); // Verify PSU is still updating psu.psuFwStatus = this.TestChannelContext.GetPSUFirmwareStatus(psu.index); LogMessage.Message = string.Format( "{0}: GetPsuFirmwareStatus for PSU {1} after 5 minutes - fwRevision: {2} completionCode: {3} fwUpdateStatus: {4} fwUpdateStage: {5}", this.currentApi, psu.index, psu.psuFwStatus.fwRevision, psu.psuFwStatus.completionCode, psu.psuFwStatus.fwUpdateStatus, psu.psuFwStatus.fwUpdateStage); // Verify PSU is still updating if (psu.psuFwStatus.completionCode != CompletionCode.Success || psu.psuFwStatus.fwUpdateStatus != "InProgress") { LogMessage.Log(LogMessage.MessageType.Failure, ref response); return response; } else LogMessage.Log(LogMessage.MessageType.Success, ref response); // Attempt to update PSU with secondary image and verify Failure if (lesPsusInChassis == "1") psu.psuFwFilePath = this.secLesFwFilePath; else psu.psuFwFilePath = this.secNonLesFwFilePath; psu.psuFwUpdateResponse = this.TestChannelContext.UpdatePSUFirmware(psu.index, psu.psuFwFilePath, secondaryImage); LogMessage.Message = string.Format( "{0}: Psu {1} returned completion code {2} and status description {3}", this.currentApi, psu.index, psu.psuFwUpdateResponse.completionCode, psu.psuFwUpdateResponse.statusDescription); if (psu.psuFwUpdateResponse.completionCode != CompletionCode.Failure) { LogMessage.Log(LogMessage.MessageType.Failure, ref response); return response; } else LogMessage.Log(LogMessage.MessageType.Success, ref response); // Sleep for 7 more minutes LogMessage.Message = "Thread sleeping for 7 minutes..."; LogMessage.Log(LogMessage.MessageType.Info, ref response); Thread.Sleep(TimeSpan.FromMinutes(7)); // Verify successful Primary PSU Fw Update psu.psuFwStatus = this.TestChannelContext.GetPSUFirmwareStatus(psu.index); LogMessage.Message = string.Format( "{0}: GetPsuFWStatus for Psu {1} - fwRevision: {2} completionCode: {3} fwUpdateStatus: {4} fwUpdateStage: {5}", currentApi, psu.index, psu.psuFwStatus.fwRevision, psu.psuFwStatus.completionCode, psu.psuFwStatus.fwUpdateStatus, psu.psuFwStatus.fwUpdateStage); if (psu.psuFwStatus.completionCode != CompletionCode.Success || ((psu.psuFwStatus.fwUpdateStatus != "Success") && (psu.psuFwStatus.fwUpdateStage != "Completed"))) LogMessage.Log(LogMessage.MessageType.Failure, ref response); else LogMessage.Log(LogMessage.MessageType.Success, ref response); // Verify Successful Secondary PSU Fw Update if Primary was successful List<UpdatePsu> psuList = new List<UpdatePsu>(); psuList.Add(psu); if (response.Result) VerifyPsuFwUpdate(ref psuList, ref response); testCase.LogPassOrFail(ref response, this.currentApi); return response; }