/// <summary> /// Returns Chassis Health including Fan Speed and Health, PSU Health, Battery Health and Blade Type and Health /// </summary> /// <returns></returns> public Contracts.ChassisHealthResponse GetChassisHealth(bool bladeHealth = false, bool psuHealth = false, bool fanHealth = false, bool batteryHealth = false) { Tracer.WriteInfo("Received GetChassisHealth bladeHealth = {0}, psuHealth = {1}, fanHealth = {2})", bladeHealth, psuHealth, fanHealth); Tracer.WriteInfo(" batteryHealth = {0}", batteryHealth); Tracer.WriteUserLog("Received GetChassisHealth bladeHealth = {0}, psuHealth = {1}, fanHealth = {2})", bladeHealth, psuHealth, fanHealth); Tracer.WriteUserLog(" batteryHealth = {0}", batteryHealth); // If all options are not given by user, then default to providing all information if (!bladeHealth && !psuHealth && !fanHealth && !batteryHealth) { bladeHealth = psuHealth = fanHealth = batteryHealth = true; } ChassisHealthResponse response = new ChassisHealthResponse(); response.completionCode = Contracts.CompletionCode.Unknown; response.statusDescription = String.Empty; if (bladeHealth) { response.bladeShellCollection = new List<BladeShellResponse>(); // Populate Blade Shell information (Type, Internal State) for (byte i = 1; i <= ConfigLoaded.Population; i++) { BladeShellResponse br = new BladeShellResponse(); br.completionCode = Contracts.CompletionCode.Success; br.bladeNumber = i; br.bladeState = FunctionValidityChecker.CheckBladeStateValidity(i).PowerStatus.ToString(); br.bladeType = ChassisState.GetBladeTypeName(ChassisState.GetBladeType(i)); response.bladeShellCollection.Add(br); } response.completionCode = Contracts.CompletionCode.Success; // Always success if bladeinfo requested, since reading static variable Tracer.WriteInfo("Populated Blade Shell information, state and type for blades"); } // Get Psu health information if (psuHealth) { response.psuInfoCollection = GetPsuInfo(); // if the master object is not successful, check child objects if (response.completionCode != Contracts.CompletionCode.Success) { // if it received any positive results, return success. foreach (PsuInfo psu in response.psuInfoCollection) { // if any children are successful, set master to success. if (psu.completionCode == Contracts.CompletionCode.Success) { response.completionCode = Contracts.CompletionCode.Success; break; // once a match has been found escape foreach } } } if (ConfigLoaded.NumPsus == 0) { response.completionCode = Contracts.CompletionCode.Success; response.statusDescription += "\nPower Supply monitoring not supported in sku configuration."; } } // Get battery health information if (batteryHealth) { // Get the battery info response.batteryInfoCollection = GetBatteryInfo(); // if the master object is not successful, check child objects if (response.completionCode != Contracts.CompletionCode.Success) { // if battery status received any positive results, return success. foreach (BatteryInfo battery in response.batteryInfoCollection) { // if any children are successful, set master to success. if (battery.completionCode == Contracts.CompletionCode.Success) { response.completionCode = Contracts.CompletionCode.Success; break; // once a match has been found escape foreach } } } if (ConfigLoaded.NumBatteries == 0) { response.completionCode = Contracts.CompletionCode.Success; response.statusDescription += "\nBattery monitoring not supported in sku configuration."; } } // Get Fan Health Information if (fanHealth) { response.fanInfoCollection = GetFanInfo(); // if the master object is not successful, check child objects if (response.completionCode != Contracts.CompletionCode.Success) { // if it received any positive results, return success. foreach (FanInfo fan in response.fanInfoCollection) { // if any children are successful, set master to success. if (fan.completionCode == Contracts.CompletionCode.Success || fan.completionCode == Contracts.CompletionCode.FanlessChassis) { response.completionCode = Contracts.CompletionCode.Success; break; // once a match has been found escape foreach } } } if (ConfigLoaded.NumFans == 0) { response.completionCode = Contracts.CompletionCode.Success; response.statusDescription += "\nFan monitoring not supported in sku configuration."; } } return response; }
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 bool VerifyOnlyChassisBatteriesHealth(bool allPassed, ChassisHealthResponse chassisHealth) { try { allPassed &= ChassisManagerTestHelper.IsTrue(chassisHealth != null, "Received chasssis health "); if (CmConstants.NumBatteries == 0) { if (chassisHealth.completionCode != CompletionCode.Unknown) { CmTestLog.Failure(string.Format("With no batteries the completion code is expected to be Unknow when it is {0}", chassisHealth.completionCode)); return false; } } else { if (chassisHealth.completionCode != CompletionCode.Success) { CmTestLog.Failure(string.Format("Chassis health is expected to return success but completion code returned is {0}", chassisHealth.completionCode)); return false; } } CmTestLog.Success("Successfully get chassis health"); allPassed = VerifyBatteriesHealth(allPassed, chassisHealth); allPassed &= ChassisManagerTestHelper.IsTrue(chassisHealth.bladeShellCollection.Count == 0, "BladeShell information is empty"); allPassed &= ChassisManagerTestHelper.IsTrue(chassisHealth.psuInfoCollection.Count == 0, "PSU information is empty"); allPassed &= ChassisManagerTestHelper.IsTrue(chassisHealth.fanInfoCollection.Count == 0, "Fan information is empty"); } catch (Exception ex) { ChassisManagerTestHelper.IsTrue(false, ex.Message); allPassed = false; } return allPassed; }
/// <summary> /// Test Command: GetChassisHealth: Get Only bladeHealth information (bladehealth=true). Test Verifies: /// Command returns completion code Success; /// Command returns full blade shell collection and verifies population,bladeType and bladeState /// Command returns Empty for Fan, PSU and Battery information. /// </summary> /// <param name="allPassed"></param> /// <param name="chassisHealth"></param> /// <returns>True if all check-points pass; false, otherwise.</returns> private bool VerifyOnlyChassisBladeHealth(bool allPassed, ChassisHealthResponse chassisHealth) { try { allPassed &= ChassisManagerTestHelper.IsTrue(chassisHealth != null, "Received chasssis health "); if (chassisHealth.completionCode != CompletionCode.Success) { CmTestLog.Failure("Failed to get chassis health"); return false; } CmTestLog.Success("Successfully get chassis health"); allPassed = this.VerifyChassisBladeHealth(allPassed, chassisHealth); allPassed &= ChassisManagerTestHelper.IsTrue(chassisHealth.fanInfoCollection.Count == 0, "Fan information is empty"); allPassed &= ChassisManagerTestHelper.IsTrue(chassisHealth.psuInfoCollection.Count == 0, "PSU information is empty"); allPassed &= ChassisManagerTestHelper.IsTrue(chassisHealth.batteryInfoCollection.Count == 0, "Battery information is empty"); } catch (Exception ex) { ChassisManagerTestHelper.IsTrue(false, ex.Message); allPassed = false; } return allPassed; }
private bool VerifyChassisBladeHealth(bool allPassed, ChassisHealthResponse chassisHealth) { CmTestLog.Info("Verifying blade shell health state"); allPassed &= ChassisManagerTestHelper.AreEqual(CmConstants.Population, chassisHealth.bladeShellCollection.Count, "Verified the number of blades in the chassis"); foreach (var shell in chassisHealth.bladeShellCollection) { allPassed &= ChassisManagerTestHelper.AreEqual(CompletionCode.Success, shell.completionCode, string.Format("Blade# {0} returns success", shell.bladeNumber)); // [TFS WorkItem: 3375] GetChassishealth: Command shows blade failures when they exist if (this.EmptyLocations != null && this.EmptyLocations.Contains(shell.bladeNumber)) { allPassed &= ChassisManagerTestHelper.AreEqual(CmConstants.HealthyBladeState, shell.bladeState, string.Format("{0} Blade# {1} is not healthy", shell.bladeState, shell.bladeNumber)); allPassed &= ChassisManagerTestHelper.AreEqual(CmConstants.UnKnownBladeType, shell.bladeType, string.Format("{0} Blade# {1} is Unknown", shell.bladeType, shell.bladeNumber)); } else if (this.JbodLocations != null && this.JbodLocations.Contains(shell.bladeNumber)) { allPassed &= ChassisManagerTestHelper.AreEqual(CmConstants.HealthyBladeState, shell.bladeState, string.Format("{0} Blade# {1} is in good healthy", shell.bladeState, shell.bladeNumber)); allPassed &= ChassisManagerTestHelper.AreEqual(CmConstants.JbodBladeType, shell.bladeType, string.Format("{0} Blade# {1} is JBOD", shell.bladeType, shell.bladeNumber)); } else { allPassed &= ChassisManagerTestHelper.AreEqual(CmConstants.HealthyBladeState, shell.bladeState, string.Format("{0} Blade# {1} is in good healthy", shell.bladeState, shell.bladeNumber)); allPassed &= ChassisManagerTestHelper.AreEqual(CmConstants.ServerBladeType, shell.bladeType, string.Format("{0} Blade# {1} is Server ", shell.bladeType, shell.bladeNumber)); } } return allPassed; }
private bool VerifyChassisHealth(bool allPassed, ChassisHealthResponse chassisHealth) { allPassed &= ChassisManagerTestHelper.IsTrue(chassisHealth != null, "Received chasssis health "); if (chassisHealth.completionCode != CompletionCode.Success) { CmTestLog.Failure("Failed to get chassis health"); return false; } CmTestLog.Success("Successfully get chassis health"); allPassed = this.VerifyChassisBladeHealth(allPassed, chassisHealth); allPassed = VerifyFanHealth(allPassed, chassisHealth); allPassed = VerifyPsuHealth(allPassed, chassisHealth); return allPassed; }
private static bool VerifyPsuHealth(bool allPassed, ChassisHealthResponse chassisHealth) { CmTestLog.Info("Verifying PSU health state"); allPassed &= ChassisManagerTestHelper.AreEqual(CmConstants.NumPsus, chassisHealth.psuInfoCollection.Count, "Verified the number of PSUs is correct"); foreach (var psu in chassisHealth.psuInfoCollection) { if (ConfigurationManager.AppSettings["TimeoutPSU"] != psu.id.ToString()) { allPassed &= ChassisManagerTestHelper.AreEqual(CompletionCode.Success, psu.completionCode, string.Format("PSU# {0} returns {1}", psu.id, psu.completionCode)); allPassed &= ChassisManagerTestHelper.AreEqual(PowerState.ON, psu.state, string.Format("PSU# {0} power state is {1}", psu.id, psu.state)); } else { allPassed &= ChassisManagerTestHelper.AreEqual(CompletionCode.Timeout, psu.completionCode, string.Format("PSU# {0} returns Completion code {1} instead of the expected Timeout", psu.id, psu.completionCode)); } } return allPassed; }
private bool VerifyBatteriesHealth(bool allPassed, ChassisHealthResponse chassisHealth) { int MaxNumberOfBatteries = 6; CmTestLog.Info("Verifying Battery health state"); allPassed &= ChassisManagerTestHelper.AreEqual(MaxNumberOfBatteries, chassisHealth.batteryInfoCollection.Count, "Verified the number of Batteris is correct"); if (CmConstants.NumBatteries == 0) { foreach (var battery in chassisHealth.batteryInfoCollection) { allPassed &= ChassisManagerTestHelper.AreEqual(CompletionCode.Unknown, battery.completionCode, string.Format("Battery# {0} returned Completeion code {1}", battery.id, battery.completionCode)); allPassed &= ChassisManagerTestHelper.AreEqual(0, battery.batteryPowerOutput, string.Format("Battery# {0} returned BatteryPowerOut {1}", battery.id, battery.batteryPowerOutput)); allPassed &= ChassisManagerTestHelper.AreEqual(0, battery.batteryChargeLevel, string.Format("Battery# {0} returned BatteryChargeLevel {1}", battery.id, battery.batteryChargeLevel)); allPassed &= ChassisManagerTestHelper.AreEqual(0, battery.faultDetected, string.Format("Battery# {0} returned FaultDetected {1}", battery.id, battery.faultDetected)); } } else { foreach (var battery in chassisHealth.batteryInfoCollection) { if (ConfigurationManager.AppSettings["FailedBattery"] != battery.id.ToString()) { allPassed &= ChassisManagerTestHelper.AreEqual(CompletionCode.Success, battery.completionCode, string.Format("Battery# {0} returned Completeion code {1}", battery.id, battery.completionCode)); allPassed &= ChassisManagerTestHelper.AreNotEqual(0, battery.batteryPowerOutput, string.Format("Battery# {0} returned BatteryPowerOut {1}", battery.id, battery.batteryPowerOutput)); allPassed &= ChassisManagerTestHelper.AreNotEqual(0, battery.batteryChargeLevel, string.Format("Battery# {0} returned BatteryChargeLevel {1}", battery.id, battery.batteryChargeLevel)); allPassed &= ChassisManagerTestHelper.AreNotEqual(0, battery.faultDetected, string.Format("Battery# {0} returned FaultDetected {1}", battery.id, battery.faultDetected)); } else { allPassed &= ChassisManagerTestHelper.AreEqual(CompletionCode.Failure, battery.completionCode, string.Format("Battery# {0} returned Completeion code {1} instead of the expected Failure state", battery.id, battery.completionCode)); } } } return allPassed; }
private static bool VerifyFanHealth(bool allPassed, ChassisHealthResponse chassisHealth) { CmTestLog.Info("Verifying Fan health state"); allPassed &= ChassisManagerTestHelper.AreEqual(CmConstants.NumFans, chassisHealth.fanInfoCollection.Count, "Verified the number of fans"); foreach (var fan in chassisHealth.fanInfoCollection) { if (ConfigurationManager.AppSettings["FailedFan"] != fan.fanId.ToString()) { allPassed &= ChassisManagerTestHelper.AreEqual(CompletionCode.Success, fan.completionCode, string.Format("Fan# {0} returns {1}", fan.fanId, fan.completionCode)); allPassed &= ChassisManagerTestHelper.IsTrue(fan.isFanHealthy, string.Format("Fan# {0} healthy state is {1}", fan.fanId, fan.isFanHealthy)); } else { allPassed &= ChassisManagerTestHelper.AreEqual(false, fan.isFanHealthy, string.Format("Fan# {0} health status is {1} instead of the expected false", fan.fanId, fan.isFanHealthy)); allPassed &= ChassisManagerTestHelper.AreEqual(0, fan.fanSpeed, string.Format("Fan# {0} speed is reported as {1} instead of the expected 0", fan.fanId, fan.fanSpeed)); } } return allPassed; }
private static bool VerifyBatteryHealth(bool allPassed, ChassisHealthResponse chassisHealth) { CmTestLog.Info("Verifying Battery health state"); allPassed &= ChassisManagerTestHelper.AreEqual(CmConstants.NumBatteries, chassisHealth.psuInfoCollection.Count, "Verified the number of Batteris is correct"); foreach (var battery in chassisHealth.psuInfoCollection) { allPassed &= ChassisManagerTestHelper.AreEqual(CompletionCode.Success, battery.completionCode, string.Format("Battery# {0} returns {1}", battery.id, battery.completionCode)); allPassed &= ChassisManagerTestHelper.AreEqual(PowerState.ON, battery.state, string.Format("Battery# {0} power state is {1}", battery.id, battery.state)); } return allPassed; }
private static bool VerifyPsuHealth(bool allPassed, ChassisHealthResponse chassisHealth) { CmTestLog.Info("Verifying PSU health state"); allPassed &= ChassisManagerTestHelper.AreEqual(CmConstants.NumPsus, chassisHealth.psuInfoCollection.Count, "Verified the number of PSUs is correct"); foreach (var psu in chassisHealth.psuInfoCollection) { allPassed &= ChassisManagerTestHelper.AreEqual(CompletionCode.Success, psu.completionCode, string.Format("PSU #{0} returns success", psu.id)); allPassed &= ChassisManagerTestHelper.AreEqual(PowerState.ON, psu.state, string.Format("PSU #{0} is ON", psu.id)); } return allPassed; }
private static bool VerifyFanHealth(bool allPassed, ChassisHealthResponse chassisHealth) { CmTestLog.Info("Verifying Fan health state"); allPassed &= ChassisManagerTestHelper.AreEqual(CmConstants.NumFans, chassisHealth.fanInfoCollection.Count, "Verified the number of fans"); foreach (var fan in chassisHealth.fanInfoCollection) { allPassed &= ChassisManagerTestHelper.AreEqual(CompletionCode.Success, fan.completionCode, string.Format("Fan #{0} returns success", fan.fanId)); allPassed &= ChassisManagerTestHelper.IsTrue(fan.isFanHealthy, string.Format("Fan #{0} is in good health", fan.fanId)); } return allPassed; }
/// <summary> /// Returns Chassis Health including Fan Speed and Health, PSU Health and Blade Type and Health /// </summary> /// <returns></returns> public Contracts.ChassisHealthResponse GetChassisHealth(bool bladeHealth = false, bool psuHealth = false, bool fanHealth = false) { Tracer.WriteInfo("Received GetChassisHealth({0},{1},{2})", bladeHealth, psuHealth, fanHealth); Tracer.WriteUserLog("Invoked GetChassisHealth({0},{1},{2})", bladeHealth, psuHealth, fanHealth); // If all options are not given by user, then default to providing all information if (!bladeHealth && !psuHealth && !fanHealth) { bladeHealth = psuHealth = fanHealth = true; } ChassisHealthResponse response = new ChassisHealthResponse(); response.completionCode = Contracts.CompletionCode.Unknown; response.statusDescription = String.Empty; if (bladeHealth) { response.bladeShellCollection = new List<BladeShellResponse>(); // Populate Blade Shell information (Type, Internal State) for (byte i = 1; i <= ConfigLoaded.Population; i++) { BladeShellResponse br = new BladeShellResponse(); br.completionCode = Contracts.CompletionCode.Success; br.bladeNumber = i; br.bladeState = ChassisState.GetStateName(i); br.bladeType = ChassisState.GetBladeTypeName(ChassisState.GetBladeType(i)); response.bladeShellCollection.Add(br); } response.completionCode = Contracts.CompletionCode.Success; // Always success if bladeinfo requested, since reading static variable Tracer.WriteInfo("Populated Blade Shell information, state and type for blades"); } // Get Psu health information if (psuHealth) { response.psuInfoCollection = GetPsuInfo(); // if the master object is not successful, check child objects if(response.completionCode != Contracts.CompletionCode.Success) { // if it received any positive results, return success. foreach (PsuInfo psu in response.psuInfoCollection) { // if any children are successful, set master to success. if (psu.completionCode == Contracts.CompletionCode.Success) { response.completionCode = Contracts.CompletionCode.Success; break; // once a match has been found escape foreach } } } } // Get Fan Health Information if (fanHealth) { response.fanInfoCollection = GetFanInfo(); // if the master object is not successful, check child objects if (response.completionCode != Contracts.CompletionCode.Success) { // if it received any positive results, return success. foreach (FanInfo fan in response.fanInfoCollection) { // if any children are successful, set master to success. if (fan.completionCode == Contracts.CompletionCode.Success || fan.completionCode == Contracts.CompletionCode.FanlessChassis ) { response.completionCode = Contracts.CompletionCode.Success; break; // once a match has been found escape foreach } } } } return response; }