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);
        }
        // Creates service fault actions
        private List <StateTransitionAction> GenerateServiceFaultActions(Guid activityId = default(Guid))
        {
            List <StateTransitionAction> serviceFaultActions = new List <StateTransitionAction>();

            StateTransitionAction replicaAction = null;

            for (int trial = 0; trial < this.maxTrialPerActionGeneration && replicaAction == null; trial++)
            {
                // Choose category
                ServiceFaultCategory faultCategory = (ServiceFaultCategory)this.serviceFaultCategoryChooser.NextRoll();

                switch (faultCategory)
                {
                case ServiceFaultCategory.RemoveReplica:
                {
                    replicaAction = this.GenerateOneRemoveReplicaAction(activityId);
                }

                break;

                case ServiceFaultCategory.RestartReplica:
                {
                    replicaAction = this.GenerateOneRestartReplicaAction(activityId);
                }

                break;

                case ServiceFaultCategory.RestartCodePackage:
                {
                    replicaAction = this.GenerateOneRestartCodePackageAction(activityId);
                }

                break;

                case ServiceFaultCategory.MovePrimary:
                {
                    replicaAction = this.GenerateOneMovePrimaryAction(activityId);
                }

                break;

                case ServiceFaultCategory.MoveSecondary:
                {
                    replicaAction = this.GenerateOneMoveSecondaryAction(activityId);
                }

                break;

                default:
                    throw new ArgumentException("Unknown category:" + faultCategory);
                }
            }

            if (replicaAction != null)
            {
                serviceFaultActions.Add(replicaAction);
            }

            return(serviceFaultActions);
        }
 // Enqueue one action if it is not null.
 protected void EnqueueAction(StateTransitionAction action)
 {
     if (action != null)
     {
         this.actionsQueue.Add(action);
     }
 }
Beispiel #4
0
        /// Create and append commands for the given action.
        public FabricTestAction GetCommandForActions(StateTransitionAction ragAction)
        {
            if (ragAction == null)
            {
                return(null);
            }

            switch (ragAction.ActionType)
            {
            case StateTransitionActionType.NodeUp:
            {
                return(this.GetStartNodeAction(ragAction as NodeStateTransitionAction));
            }

            case StateTransitionActionType.NodeDown:
            {
                return(this.GetStopNodeAction(ragAction as NodeStateTransitionAction));
            }

            case StateTransitionActionType.NodeRestart:
            {
                return(this.GetRestartNodeAction(ragAction as NodeStateTransitionAction));
            }

            case StateTransitionActionType.RemoveReplica:
            {
                return(this.GetRemoveReplicaAction(ragAction as ReplicaStateTransitionAction));
            }

            case StateTransitionActionType.RestartReplica:
            {
                return(this.GetRestartReplicaAction(ragAction as ReplicaStateTransitionAction));
            }

            case StateTransitionActionType.MovePrimary:
            {
                return(this.GetMovePrimaryReplicaAction(ragAction as MovePrimaryReplicaStateTransitionAction));
            }

            case StateTransitionActionType.MoveSecondary:
            {
                return(this.GetMoveSecondaryReplicaAction(ragAction as MoveSecondaryReplicaStateTransitionAction));
            }

            case StateTransitionActionType.CodePackageRestart:
            {
                return(this.GetRestartCodePackageAction(ragAction as RestartCodePackageStateTransitionAction));
            }

            default:
            {
                throw new InvalidOperationException("Action type not yet supported.");
            }
            }
        }