Beispiel #1
0
        protected void GenerateAndEnqueueRandomActions(WorkloadList workloadInfo, Guid activityId = default(Guid))
        {
            this.UpdateDice(workloadInfo);
            string workloadName = this.workloadDice.NextRoll().Trim();

            ReleaseAssert.AssertIf(string.IsNullOrEmpty(workloadName), "Workload name cannot be null or empty.");

            bool isRunning = workloadInfo.GetWorkLoadState(workloadName);

            workloadInfo.FlipWorkloadState(workloadName);

            StateTransitionAction workloadScriptAction = null;

            if (isRunning)
            {
                workloadScriptAction = WorkloadStateTransitionAction.CreateStopWorkloadAction(workloadName);

                TestabilityTrace.TraceSource.WriteInfo(this.TraceType, "{0}: Workload {1} has been chosen for Stop-Workload", activityId, workloadName);
            }
            else
            {
                workloadScriptAction = WorkloadStateTransitionAction.CreateStartWorkloadAction(workloadName);

                TestabilityTrace.TraceSource.WriteInfo(this.TraceType, "{0}: Workload {1} has been chosen for Start-Workload", activityId, workloadName);
            }

            this.EnqueueAction(workloadScriptAction);
        }
Beispiel #2
0
        private void UpdateDice(WorkloadList workloadInfo)
        {
            this.workloadDice = new WeightedDice <string>(this.Random);

            if (workloadInfo.Workloads != null)
            {
                foreach (string workload in workloadInfo.Workloads)
                {
                    this.workloadDice.AddNewFace(workload, this.workloadScriptDefaultWeight);
                }
            }
        }
Beispiel #3
0
        private IList <StateTransitionAction> GetPendingActions(WorkloadList workloadInfo, Guid activityId = default(Guid))
        {
            List <StateTransitionAction> pendingActions = new List <StateTransitionAction>();

            const bool isRunning = true;

            foreach (var workloadName in workloadInfo.Workloads)
            {
                if (workloadInfo.GetWorkLoadState(workloadName) == isRunning)
                {
                    pendingActions.Add(WorkloadStateTransitionAction.CreateStopWorkloadAction(workloadName));

                    TestabilityTrace.TraceSource.WriteInfo(this.TraceType, "{0}: Workload {1} has been chosen for Stop-Workload", activityId, workloadName);
                }
            }

            return(pendingActions);
        }