コード例 #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="UIExerciser" /> class.
 /// </summary>
 /// <param name="device">The <see cref="JediDevice" /> object.</param>
 internal UIExerciser(DirtyDeviceManager owner, JediOmniDevice device, JediOmniPreparationManager preparationManager)
 {
     _owner              = owner;
     _device             = device;
     _preparationManager = preparationManager;
     _controlPanel       = device.ControlPanel;
 }
コード例 #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="WebServicesExerciser" /> class.
 /// </summary>
 /// <param name="device">The <see cref="JediDevice" /> object.</param>
 internal WebServicesExerciser(DirtyDeviceManager owner, JediDevice device)
 {
     _owner       = owner;
     _device      = device;
     _webServices = _device.WebServices;
     _snmp        = _device.Snmp;
 }
コード例 #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DigitalSendExerciser" /> class.
 /// </summary>
 /// <param name="device">The <see cref="JediDevice" /> object.</param>
 internal DigitalSendExerciser(DirtyDeviceManager owner, JediOmniDevice deviceDat, JediOmniPreparationManager preparationManager)
 {
     _owner                 = owner;
     _deviceDat             = deviceDat;
     _preparationManager    = preparationManager;
     _webServices           = _deviceDat.WebServices;
     DateTimeStampForNaming = DateTime.Now.ToString($"yyyyMMdd_HHmmss");
 }
コード例 #4
0
        /// <summary>
        /// Gathers the triage data.
        /// </summary>
        /// <param name="reason">The reason.</param>
        private void GatherTriageData(string reason, DirtyDeviceManager pluginActivityManager)
        {
            if (pluginActivityManager?.Device == null)
            {
                var mgrState    = (pluginActivityManager == null) ? "IS" : "IS NOT";
                var deviceState = (pluginActivityManager?.Device == null) ? "IS" : "IS NOT";
                throw new ArgumentException($"Cannot triage null device.  ({nameof(pluginActivityManager)} {mgrState} null.  {nameof(pluginActivityManager)}.Device {deviceState} null.)");
            }

            ITriage triage = TriageFactory.Create(pluginActivityManager.Device, _executionData);

            triage.CollectTriageData(reason);
            triage.Submit();
        }
コード例 #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SnmpExerciser" /> class.
 /// </summary>
 /// <param name="device">The <see cref="JediDevice" /> object.</param>
 internal SnmpExerciser(DirtyDeviceManager owner, JediDevice device)
 {
     _owner  = owner;
     _device = device;
 }
コード例 #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="EwsExerciserViaSeleniumWebDriver" /> class.
 /// </summary>
 /// <param name="device">The <see cref="JediDevice" /> object.</param>
 internal EwsExerciserViaSeleniumWebDriver(DirtyDeviceManager owner, JediDevice device)
 {
     _owner  = owner;
     _device = device;
 }
コード例 #7
0
        /// <summary>
        /// Executes this plugin's workflow using the specified <see cref="T:HP.ScalableTest.Framework.Plugin.PluginExecutionData" />.
        /// </summary>
        /// <param name="executionData">The execution data.</param>
        /// <returns>A <see cref="T:HP.ScalableTest.Framework.Plugin.PluginExecutionResult" /> indicating the outcome of the execution.</returns>
        public PluginExecutionResult Execute(PluginExecutionData executionData)
        {
            // reset current user as it may have changed since control load.
            _executionData = executionData;
            _currentUser   = _executionData.Credential;
            _activityData  = _executionData.GetMetadata <DirtyDeviceActivityData>(new[] { new DirtyDeviceDataConverter1_1() });

            UpdateExecutionStatus(this, "Starting activity...");

            _currentDevice  = _executionData.Assets.GetRandom <Framework.Assets.IDeviceInfo>();
            _workflowLogger = new DeviceWorkflowLogger(_executionData);

            InitializeControlWithActivityData();

            try
            {
                // Wrap in using to release any connections to the device.  This is critical for Omni operations.
                using (DirtyDeviceManager pluginActivityManager = new DirtyDeviceManager(_currentDevice, _currentUser, _activityData, executionData.Environment))
                {
                    pluginActivityManager.UpdateStatus += (s, e) => UpdateExecutionStatus(s, e);

                    if (_currentDevice == null)
                    {
                        return(new PluginExecutionResult(PluginResult.Error, $"{typeof(IDeviceInfo).Name} retrieved is null.  If this is a count-based run, your reservation in asset inventory may have expired.", "DeviceInfo Asset error"));
                    }
                    else if (_currentDevice.AssetId == null)
                    {
                        return(new PluginExecutionResult(PluginResult.Error, $"{typeof(IDeviceInfo).Name}.AssetId property is null.", "DeviceInfo Asset error"));
                    }
                    else if (_currentDevice.AssetType == null)
                    {
                        return(new PluginExecutionResult(PluginResult.Error, $"{typeof(IDeviceInfo).Name}.AssetType property is null.", "DeviceInfo Asset error"));
                    }
                    else if (pluginActivityManager.Device == null)
                    {
                        return(new PluginExecutionResult(PluginResult.Error, $"{nameof(pluginActivityManager)}.Device property is null.", $"Could not create IDevice (AssetId: {_currentDevice.AssetId})"));
                    }

                    PluginExecutionResult pluginExecutionResult = new PluginExecutionResult(PluginResult.Error, new Exception($"The {typeof(PluginExecutionResult)} was never set by the activity."));
                    try
                    {
                        UpdateExecutionStatus(this, $"Waiting for access to {_currentDevice.AssetId} ({_currentDevice.Address})");
                        var token = new AssetLockToken(_currentDevice, _activityData.LockTimeouts.AcquireTimeout, _activityData.LockTimeouts.HoldTimeout);
                        _workflowLogger.RecordEvent(DeviceWorkflowMarker.DeviceLockBegin);
                        ExecutionServices.CriticalSection.Run(token, () =>
                        {
                            var retryManager      = new PluginRetryManager(executionData, (e) => UpdateExecutionStatus(this, e));
                            pluginExecutionResult = retryManager.Run(() =>
                            {
                                ExecutionServices.DataLogger.Submit(new ActivityExecutionAssetUsageLog(_executionData, _currentDevice.AssetId));

                                try
                                {
                                    pluginActivityManager.ExecuteDirty();
                                    return(new PluginExecutionResult(PluginResult.Passed));
                                }
                                catch (DeviceCommunicationException ex)
                                {
                                    GatherTriageData(ex.ToString(), pluginActivityManager);
                                    return(new PluginExecutionResult(PluginResult.Failed, ex, "Device communication error."));
                                }
                                catch (DeviceInvalidOperationException ex)
                                {
                                    GatherTriageData(ex.ToString(), pluginActivityManager);
                                    return(new PluginExecutionResult(PluginResult.Failed, ex, "Device automation error."));
                                }
                                catch (DeviceWorkflowException ex)
                                {
                                    GatherTriageData(ex.ToString(), pluginActivityManager);
                                    return(new PluginExecutionResult(PluginResult.Failed, ex, "Device workflow error."));
                                }
                                catch (Exception ex)
                                {
                                    GatherTriageData(ex.ToString(), pluginActivityManager);
                                    return(new PluginExecutionResult(PluginResult.Error, new Exception($"The plugin activity threw an unexpected exception: {ex.ToString()}", ex)));
                                }
                            });
                        });
                        _workflowLogger.RecordEvent(DeviceWorkflowMarker.DeviceLockEnd);
                    }
                    catch (AcquireLockTimeoutException ex)
                    {
                        GatherTriageData(ex.ToString(), pluginActivityManager);
                        return(new PluginExecutionResult(PluginResult.Skipped, string.Format("Could not obtain lock on device {0}.", (_currentDevice != null ? _currentDevice.AssetId : "null")), "Device unavailable."));
                    }
                    catch (HoldLockTimeoutException ex)
                    {
                        GatherTriageData(ex.ToString(), pluginActivityManager);
                        return(new PluginExecutionResult(PluginResult.Error, $"Automation did not complete within {_activityData.LockTimeouts.HoldTimeout}.", "Automation timeout exceeded."));
                    }
                    catch (Exception ex)
                    {
                        GatherTriageData(ex.ToString(), pluginActivityManager);
                        return(new PluginExecutionResult(PluginResult.Error, new Exception($"The {typeof(PluginRetryManager).Name} threw an unexpected exception.", ex)));
                    }

                    return(pluginExecutionResult);
                }
            }
            catch (Exception x)
            {
                return(new PluginExecutionResult(PluginResult.Error, x, "Plugin error during activity setup."));
            }
            finally
            {
                UpdateExecutionStatus(this, $"Finished activity.");
            }
        }