protected static AsyncResult <ActiveDirectoryConnectivityOutcome> SingleCommandTransaction(ActiveDirectoryConnectivityBase.ActiveDirectoryConnectivityTask command, AsyncResult <ActiveDirectoryConnectivityOutcome> result)
        {
            ExDateTime now = ExDateTime.Now;
            ActiveDirectoryConnectivityOutcome item = command();

            result.Outcomes.Add(item);
            result.Complete();
            return(result);
        }
示例#2
0
        private ActiveDirectoryConnectivityOutcome IsNetlogonRunning()
        {
            ActiveDirectoryConnectivityOutcome activeDirectoryConnectivityOutcome = base.CreateOutcome(TestActiveDirectoryConnectivityTask.ScenarioId.IsNetlogonRunning, Strings.IsNetlogonRunningScenario, Strings.IsNetlogonRunningScenario, base.Context.CurrentDomainController);

            if (!base.CanContinue)
            {
                base.WriteVerbose(Strings.CannotContinue(Strings.IsNetlogonRunningScenario));
                activeDirectoryConnectivityOutcome.Update(CasTransactionResultEnum.Skipped);
                return(activeDirectoryConnectivityOutcome);
            }
            return(this.IsServiceRunning("Netlogon", activeDirectoryConnectivityOutcome, TestActiveDirectoryConnectivityTask.ScenarioId.NetLogonNotRunning));
        }
示例#3
0
        private ActiveDirectoryConnectivityOutcome RunSearchOperationWithTimeCheck(Func <int> operation)
        {
            ActiveDirectoryConnectivityOutcome activeDirectoryConnectivityOutcome = base.CreateOutcome(TestActiveDirectoryConnectivityTask.ScenarioId.Search, Strings.ActiveDirectorySearchScenario, Strings.ActiveDirectorySearchScenario, base.Context.CurrentDomainController);

            if (!base.CanContinue)
            {
                base.WriteVerbose(Strings.CannotContinue(Strings.ActiveDirectorySearchScenario));
                activeDirectoryConnectivityOutcome.Update(CasTransactionResultEnum.Skipped);
                return(activeDirectoryConnectivityOutcome);
            }
            try
            {
                operation();
                activeDirectoryConnectivityOutcome.UpdateTarget(base.Context.CurrentDomainController);
                TimeSpan timeSpan = ExDateTime.Now - activeDirectoryConnectivityOutcome.StartTime;
                if (timeSpan.TotalMilliseconds > (double)base.Context.Instance.SearchLatencyThresholdInMilliseconds)
                {
                    activeDirectoryConnectivityOutcome.Update(CasTransactionResultEnum.Success, string.Format("Over Threshold. Threshold :{0} Actual {1}", base.Context.Instance.SearchLatencyThresholdInMilliseconds, timeSpan.TotalMilliseconds));
                    base.Context.Instance.WriteVerbose(string.Format("Over Threshold. Threshold :{0} Actual {1}", base.Context.Instance.SearchLatencyThresholdInMilliseconds, timeSpan.TotalMilliseconds));
                    base.AddMonitoringEvent(TestActiveDirectoryConnectivityTask.ScenarioId.SearchOverLatency, EventTypeEnumeration.Error, base.GenerateErrorMessage(TestActiveDirectoryConnectivityTask.ScenarioId.SearchLatency, 0, string.Format("Over Threshold. Threshold :{0} Actual {1}", base.Context.Instance.SearchLatencyThresholdInMilliseconds, timeSpan.TotalMilliseconds), null));
                }
                else
                {
                    base.AddMonitoringEvent(TestActiveDirectoryConnectivityTask.ScenarioId.SearchLatency, EventTypeEnumeration.Success, base.GenerateErrorMessage(TestActiveDirectoryConnectivityTask.ScenarioId.SearchLatency, 0, string.Empty, null));
                    activeDirectoryConnectivityOutcome.Update(CasTransactionResultEnum.Success);
                }
            }
            catch (Exception ex)
            {
                ActiveDirectorySearchError errorCode;
                if (ex is ADTransientException)
                {
                    errorCode = ActiveDirectorySearchError.ADTransientException;
                }
                else
                {
                    errorCode = ActiveDirectorySearchError.OtherException;
                }
                TimeSpan timeSpan = ExDateTime.Now - activeDirectoryConnectivityOutcome.StartTime;
                activeDirectoryConnectivityOutcome.Update(CasTransactionResultEnum.Failure);
                base.AddMonitoringEvent(TestActiveDirectoryConnectivityTask.ScenarioId.SearchFailed, EventTypeEnumeration.Error, base.GenerateErrorMessage(TestActiveDirectoryConnectivityTask.ScenarioId.Search, (int)errorCode, ex.ToString(), null));
            }
            return(activeDirectoryConnectivityOutcome);
        }
示例#4
0
 private void RunTasksWithTimeout(ExDateTime expireTime, IEnumerable <AsyncResult <ActiveDirectoryConnectivityOutcome> > task)
 {
     this.TotalLatency = TimeSpan.Zero;
     using (IEnumerator <AsyncResult <ActiveDirectoryConnectivityOutcome> > enumerator = task.GetEnumerator())
     {
         for (;;)
         {
             AsyncResult <ActiveDirectoryConnectivityOutcome> asyncResult = null;
             TimeSpan timeSpan = expireTime - ExDateTime.Now;
             try
             {
                 if (enumerator.MoveNext())
                 {
                     if (timeSpan.Ticks >= 0L)
                     {
                         asyncResult = enumerator.Current;
                         if (timeSpan.Ticks >= 0L && !asyncResult.IsCompleted)
                         {
                             ActiveDirectoryConnectivityOutcome activeDirectoryConnectivityOutcome = asyncResult.Outcomes[asyncResult.Outcomes.Count - 1];
                             if (activeDirectoryConnectivityOutcome.Timeout != null && timeSpan > activeDirectoryConnectivityOutcome.Timeout.Value)
                             {
                                 timeSpan = activeDirectoryConnectivityOutcome.Timeout.Value;
                             }
                             asyncResult.AsyncWaitHandle.WaitOne(timeSpan, true);
                         }
                         continue;
                     }
                     string message = string.Format("Task failed on timeout. Overtime = {0}.", ExDateTime.Now - expireTime);
                     this.WriteError(new TaskException(Strings.ErrorRecordReport(message, 1)), ErrorCategory.OperationTimeout, this, false);
                 }
             }
             finally
             {
                 if (asyncResult != null)
                 {
                     this.ReportTestStepResult(asyncResult, timeSpan);
                 }
             }
             break;
         }
     }
 }
示例#5
0
        private ActiveDirectoryConnectivityOutcome MachinePing()
        {
            ActiveDirectoryConnectivityOutcome activeDirectoryConnectivityOutcome = base.CreateOutcome(TestActiveDirectoryConnectivityTask.ScenarioId.MachinePing, Strings.MachinePingScenario, Strings.MachinePingScenario, base.Context.CurrentDomainController);

            if (!base.CanContinue)
            {
                base.WriteVerbose(Strings.CannotContinue(Strings.MachinePingScenario));
                activeDirectoryConnectivityOutcome.Update(CasTransactionResultEnum.Skipped);
                return(activeDirectoryConnectivityOutcome);
            }
            try
            {
                Dns.GetHostEntry(base.Context.CurrentDomainController);
                activeDirectoryConnectivityOutcome.Update(CasTransactionResultEnum.Success);
            }
            catch (SocketException ex)
            {
                base.Context.Instance.SkipRemainingTests = true;
                activeDirectoryConnectivityOutcome.Update(CasTransactionResultEnum.Failure);
                base.AddMonitoringEvent(TestActiveDirectoryConnectivityTask.ScenarioId.MachinePingFailed, EventTypeEnumeration.Error, base.GenerateErrorMessage(TestActiveDirectoryConnectivityTask.ScenarioId.MachinePing, 0, ex.Message, null));
            }
            return(activeDirectoryConnectivityOutcome);
        }
示例#6
0
 private ActiveDirectoryConnectivityOutcome IsServiceRunning(string serviceName, ActiveDirectoryConnectivityOutcome outcome, TestActiveDirectoryConnectivityTask.ScenarioId failureId)
 {
     try
     {
         using (ServiceController serviceController = new ServiceController(serviceName, base.Context.CurrentDomainController))
         {
             if (serviceController.Status != ServiceControllerStatus.Running)
             {
                 outcome.Update(CasTransactionResultEnum.Failure, TimeSpan.Zero, Strings.ServiceNotRunning(serviceName));
                 base.AddMonitoringEvent(failureId, EventTypeEnumeration.Error, base.GenerateErrorMessage(outcome.Id, 0, Strings.ServiceNotRunning(serviceName), null));
                 return(outcome);
             }
         }
     }
     catch (InvalidOperationException ex)
     {
         outcome.Update(CasTransactionResultEnum.Failure, TimeSpan.Zero, ex.ToString());
         base.AddMonitoringEvent(failureId, EventTypeEnumeration.Error, base.GenerateErrorMessage(outcome.Id, 0, ex.ToString(), null));
         return(outcome);
     }
     outcome.Update(CasTransactionResultEnum.Success);
     return(outcome);
 }