コード例 #1
0
        public JsonResult GetPageResponseTime(int loadTestRunId)
        {
            List <LoadTestOverallGraphModels> Result = new List <LoadTestOverallGraphModels>();

            using (Entity.db_LoadTest2010Entities db = new Entity.db_LoadTest2010Entities())
            {
                var entityLoadTestPerformanceCounters         = db.LoadTestPerformanceCounters.FirstOrDefault(x => x.LoadTestRunId == loadTestRunId && x.CounterId == 74);
                var entityLoadTestPerformanceCounterCategory  = db.LoadTestPerformanceCounterCategories.FirstOrDefault(x => x.LoadTestRunId == loadTestRunId && x.CounterCategoryId == entityLoadTestPerformanceCounters.CounterCategoryId);
                var entityLoadTestPerformanceCounterInstances = db.LoadTestPerformanceCounterInstances.Where(x => x.LoadTestRunId == loadTestRunId && x.LoadTestItemId != null).GroupBy(x => x.LoadTestItemId);

                foreach (var entityLoadTestPerformanceCounterInstance in entityLoadTestPerformanceCounterInstances)
                {
                    var instance = entityLoadTestPerformanceCounterInstance.FirstOrDefault(x => x.InstanceName.Contains('}')).InstanceName;
                    int index    = instance.IndexOf("(");
                    if (index > 0)
                    {
                        instance = instance.Substring(0, index);
                    }
                    var entityLoadTestPageSummaryData = db.LoadTestPageSummaryDatas.FirstOrDefault(x => x.LoadTestRunId == loadTestRunId && x.PageId == entityLoadTestPerformanceCounterInstance.Key);
                    Result.Add(new LoadTestOverallGraphModels(entityLoadTestPerformanceCounters.CounterName, entityLoadTestPerformanceCounterCategory.CategoryName, entityLoadTestPerformanceCounterCategory.MachineName, entityLoadTestPageSummaryData.Minimum, entityLoadTestPageSummaryData.Maximum, entityLoadTestPageSummaryData.Average, instance));
                }

                //var result = str.Substring(str.LastIndexOf('/') + 1);
            }

            return(Json(Result, JsonRequestBehavior.AllowGet));
        }
コード例 #2
0
 public DetailedErrorModels(Entity.LoadTestMessage entityLoadTestMessage, Entity.db_LoadTest2010Entities db)
 {
     LoadTestRunId = entityLoadTestMessage.LoadTestRunId;
     Type          = entityLoadTestMessage.MessageType;
     SubType       = entityLoadTestMessage.SubType;
     Text          = entityLoadTestMessage.MessageText;
     Scenario      = db.LoadTestScenarios.FirstOrDefault(x => x.LoadTestRunId == entityLoadTestMessage.LoadTestRunId).ScenarioName;
     Agent         = db.LoadTestRunAgents.FirstOrDefault(x => x.LoadTestRunId == entityLoadTestMessage.LoadTestRunId).AgentName;
     Request       = entityLoadTestMessage.LoadTestRun.WebLoadTestRequestMaps.FirstOrDefault(x => x.RequestId == entityLoadTestMessage.RequestId).RequestUri;
     Test          = entityLoadTestMessage.LoadTestRun.LoadTestCases.FirstOrDefault(x => x.TestCaseId == entityLoadTestMessage.TestCaseId).TestCaseName;
 }
コード例 #3
0
ファイル: AccountController.cs プロジェクト: babinbabu/Makan
        public string GetUserName()
        {
            int userId = WebSecurity.GetUserId(User.Identity.Name);

            using (Entity.db_LoadTest2010Entities db = new Entity.db_LoadTest2010Entities())
            {
                var entityUserProfile = db.UserProfiles.FirstOrDefault(x => x.UserId == userId);
                return((entityUserProfile.Name.Length > 30) ? entityUserProfile.Name.Substring(0, 30) + "..." : entityUserProfile.Name);
            }
            // retrieve a model, either by instantiating a class, querying a database, etc.
        }
コード例 #4
0
        public JsonResult List()
        {
            List <LoadListModels> Results = new List <LoadListModels>();

            using (Entity.db_LoadTest2010Entities db = new Entity.db_LoadTest2010Entities())
            {
                foreach (var result in db.LoadTestRuns.Select(e => e.LoadTestName).Distinct())
                {
                    Results.Add(new LoadListModels(result));
                }
            }
            return(Json(Results, JsonRequestBehavior.AllowGet));
        }
コード例 #5
0
        public static List <DetailedErrorModels> GetDetailedErrorMessage(int LoadTestRunId, string SubType)
        {
            List <DetailedErrorModels> Result = new List <DetailedErrorModels>();

            using (Entity.db_LoadTest2010Entities db = new Entity.db_LoadTest2010Entities())
            {
                var entityLoadTestMessages = db.LoadTestMessages.Where(x => x.LoadTestRunId == LoadTestRunId && x.SubType == SubType).OrderBy(x => x.MessageType).ToList();
                foreach (var entityLoadTestMessage in entityLoadTestMessages)
                {
                    Result.Add(new DetailedErrorModels(entityLoadTestMessage, db));
                }
            }
            return(Result);
        }
コード例 #6
0
 public JsonResult GetLoadTestBasedOnId(int LoadTestRunId)
 {
     using (Entity.db_LoadTest2010Entities db = new Entity.db_LoadTest2010Entities())
     {
         var entityLoadTestRuns = db.LoadTestRuns.FirstOrDefault(e => e.LoadTestRunId == LoadTestRunId);
         if (entityLoadTestRuns != null)
         {
             return(Json(new LoadTestResultModels(entityLoadTestRuns, db, true), JsonRequestBehavior.AllowGet));
         }
         else
         {
             return(Json(false));
         }
     }
 }
コード例 #7
0
        public JsonResult GetControllerandAgents(int loadTestRunId)
        {
            List <LoadTestOverallGraphModels> Result = new List <LoadTestOverallGraphModels>();

            using (Entity.db_LoadTest2010Entities db = new Entity.db_LoadTest2010Entities())
            {
                var entityLoadTestPerformanceCounterSamples = db.LoadTestPerformanceCounterSamples.Where(x => x.LoadTestRunId == loadTestRunId && (x.InstanceId == 0 || x.InstanceId == 48)).GroupBy(x => x.InstanceId);
                foreach (var entityLoadTestPerformanceCounterSample in entityLoadTestPerformanceCounterSamples)
                {
                    var entityLoadTestPerformanceCounter         = db.LoadTestPerformanceCounters.FirstOrDefault(x => x.LoadTestRunId == loadTestRunId && x.CounterId == entityLoadTestPerformanceCounterSample.Key);
                    var entityLoadTestPerformanceCounterCategory = db.LoadTestPerformanceCounterCategories.FirstOrDefault(x => x.LoadTestRunId == loadTestRunId && x.CounterCategoryId == entityLoadTestPerformanceCounter.CounterCategoryId);
                    Result.Add(new LoadTestOverallGraphModels(entityLoadTestPerformanceCounter.CounterName, entityLoadTestPerformanceCounterCategory.CategoryName, entityLoadTestPerformanceCounterCategory.MachineName, entityLoadTestPerformanceCounterSample.Min(x => x.ComputedValue).Value, entityLoadTestPerformanceCounterSample.Max(x => x.ComputedValue).Value, entityLoadTestPerformanceCounterSample.Average(x => x.ComputedValue).Value));
                }
            }

            return(Json(Result, JsonRequestBehavior.AllowGet));
        }
コード例 #8
0
        public JsonResult GetLoadTestPageGraphValues(int LoadTestRunId)
        {
            List <LoadTestPageGraphModels> Result = new List <LoadTestPageGraphModels>();

            using (Entity.db_LoadTest2010Entities db = new Entity.db_LoadTest2010Entities())
            {
                var LoadTestRunStartTime      = db.LoadTestRuns.FirstOrDefault(x => x.LoadTestRunId == LoadTestRunId).StartTime;
                var entityLoadTestPageDetails = db.LoadTestPageDetails.Where(x => x.LoadTestRunId == LoadTestRunId && x.Outcome == 0).GroupBy(x => x.PageId);
                foreach (var entityLoadTestPageDetail in entityLoadTestPageDetails)
                {
                    KeyValuePair <int, List <Entity.LoadTestPageDetail> > collection = new KeyValuePair <int, List <Entity.LoadTestPageDetail> >(entityLoadTestPageDetail.Key, entityLoadTestPageDetail.ToList());
                    var entityLoadTestPerformanceCounterInstances = db.LoadTestPerformanceCounterInstances.Where(x => x.LoadTestItemId == entityLoadTestPageDetail.Key && x.LoadTestRunId == LoadTestRunId);
                    Result.Add(new LoadTestPageGraphModels(collection, LoadTestRunStartTime, entityLoadTestPerformanceCounterInstances.FirstOrDefault(x => x.InstanceName.Contains("}")).InstanceName));
                }
            }
            return(Json(Result, JsonRequestBehavior.AllowGet));
        }
コード例 #9
0
        public JsonResult GetResultCompare(List <int> LoadTestRunIds)
        {
            List <LoadTestResultModels> Results = new List <LoadTestResultModels>();

            using (Entity.db_LoadTest2010Entities db = new Entity.db_LoadTest2010Entities())
            {
                var entityLoadTestRuns = db.LoadTestRuns.Where(e => LoadTestRunIds.Contains(e.LoadTestRunId));
                if (entityLoadTestRuns.Count() > 0)
                {
                    foreach (var entityLoadTestRun in entityLoadTestRuns)
                    {
                        Results.Add(new LoadTestResultModels(entityLoadTestRun, db, true));
                    }
                }
            }

            return(Json(Results, JsonRequestBehavior.AllowGet));
        }
コード例 #10
0
        public static List <LoadTestResultList> GetLoadTestBasedOnName(string loadTestName, int take, int skip, out long Total)
        {
            List <LoadTestResultList> Results = new List <LoadTestResultList>();

            using (Entity.db_LoadTest2010Entities db = new Entity.db_LoadTest2010Entities())
            {
                var entityLoadTestRuns = db.LoadTestRuns.Where(e => e.LoadTestName == loadTestName);
                Total = entityLoadTestRuns.Count();
                entityLoadTestRuns = entityLoadTestRuns.OrderByDescending(x => x.EndTime);
                entityLoadTestRuns = entityLoadTestRuns.Skip(skip).Take(take);

                foreach (var loadTest in entityLoadTestRuns)
                {
                    Results.Add(new LoadTestResultList(loadTest));
                }

                return(Results);
            }
        }
コード例 #11
0
        public static string ForgotPassword(string userName)
        {
            if (string.IsNullOrEmpty(userName))
            {
                return("Invalid User Name");
            }
            using (Entity.db_LoadTest2010Entities db = new Entity.db_LoadTest2010Entities())
            {
                var entityUser = db.UserProfiles.FirstOrDefault(e => e.UserName == userName);
                if (entityUser == null)
                {
                    return("You are not registred with us");
                }

                string token = WebSecurity.GeneratePasswordResetToken(entityUser.UserName);

                SendPasswordResetMail(entityUser.UserName, token);
            }
            return("Successfully sent the password reset mail");
        }
コード例 #12
0
        public JsonResult GetKeyIndicators(int loadTestRunId)
        {
            List <LoadTestOverallGraphModels> Result = new List <LoadTestOverallGraphModels>();

            using (Entity.db_LoadTest2010Entities db = new Entity.db_LoadTest2010Entities())
            {
                var entityLoadTestPerformanceCounterInstances = db.LoadTestPerformanceCounterInstances
                                                                .Where(x => x.LoadTestRunId == loadTestRunId &&
                                                                       (x.CounterId == 49 || x.CounterId == 77 ||
                                                                        x.CounterId == 74 || x.CounterId == 72 ||
                                                                        x.CounterId == 91)).GroupBy(x => x.CounterId);
                foreach (var entityLoadTestPerformanceCounterInstance in entityLoadTestPerformanceCounterInstances)
                {
                    var entityLoadTestPerformanceCounter         = db.LoadTestPerformanceCounters.FirstOrDefault(x => x.LoadTestRunId == loadTestRunId && x.CounterId == entityLoadTestPerformanceCounterInstance.Key);
                    var entityLoadTestPerformanceCounterCategory = db.LoadTestPerformanceCounterCategories.FirstOrDefault(x => x.LoadTestRunId == loadTestRunId && x.CounterCategoryId == entityLoadTestPerformanceCounter.CounterCategoryId);
                    Result.Add(new LoadTestOverallGraphModels(entityLoadTestPerformanceCounter.CounterName, entityLoadTestPerformanceCounterCategory.CategoryName, entityLoadTestPerformanceCounterCategory.MachineName, entityLoadTestPerformanceCounterInstance.Min(x => x.CumulativeValue).Value, entityLoadTestPerformanceCounterInstance.Max(x => x.CumulativeValue).Value, entityLoadTestPerformanceCounterInstance.Average(x => x.CumulativeValue).Value, entityLoadTestPerformanceCounterInstance.FirstOrDefault().InstanceName));
                }
            }
            return(Json(Result, JsonRequestBehavior.AllowGet));
        }
コード例 #13
0
        public LoadTestResultModels(Entity.LoadTestRun entityLoadTestRun, Entity.db_LoadTest2010Entities db, bool compare = false)
        {
            RunId           = entityLoadTestRun.RunId;
            LoadTestRunId   = entityLoadTestRun.LoadTestRunId;
            LoadTestName    = entityLoadTestRun.LoadTestName;
            Description     = entityLoadTestRun.Description;
            StartTime       = entityLoadTestRun.StartTime.Value.AddHours(Constants.Malaysia_Time_Zone);
            EndTime         = entityLoadTestRun.EndTime.Value.AddHours(Constants.Malaysia_Time_Zone);
            RunDuration     = entityLoadTestRun.RunDuration;
            WarmupTime      = entityLoadTestRun.WarmupTime;
            RunSettingUsed  = entityLoadTestRun.RunSettingUsed;
            IsLocalRun      = entityLoadTestRun.IsLocalRun;
            Outcome         = entityLoadTestRun.Outcome;
            NumberOfAgents  = entityLoadTestRun.LoadTestRunAgents.Select(e => e.AgentId).Distinct().Count();
            SlowestTestName = db.LoadTestCases.FirstOrDefault(x => x.LoadTestRunId == entityLoadTestRun.LoadTestRunId).TestCaseName;
            SlowestTestTime = db.LoadTestTestSummaryDatas.Where(x => x.LoadTestRunId == entityLoadTestRun.LoadTestRunId).OrderByDescending(e => e.Percentile95).Take(5).Sum(p => p.Percentile95);
            MaxUserLoad     = db.LoadTestTestDetails.Where(x => x.LoadTestRunId == entityLoadTestRun.LoadTestRunId).Select(e => e.UserId).Distinct().Count();

            var entityLoadTestTestSummaryDatas = db.LoadTestTestSummaryDatas.Where(x => x.LoadTestRunId == entityLoadTestRun.LoadTestRunId).ToList();

            if (entityLoadTestTestSummaryDatas.Count > 0)
            {
                TestsPerSec = (float)entityLoadTestTestSummaryDatas.Sum(x => x.TestsRun) / entityLoadTestRun.RunDuration;
            }

            TestsFailed = entityLoadTestRun.LoadTestTestLogs.Count();
            AvgTestTime = db.LoadTestTestSummaryDatas.Where(x => x.LoadTestRunId == entityLoadTestRun.LoadTestRunId).Sum(x => x.Average);
            PagesPerSec = (double)entityLoadTestRun.LoadTestPageSummaryDatas.Sum(x => x.PageCount) / entityLoadTestRun.RunDuration;
            AvgPageTime = (double)entityLoadTestRun.LoadTestPageSummaryDatas.Sum(x => x.Average) / entityLoadTestRun.LoadTestPageSummaryDatas.Count();
            var entityLoadTestTransactionSummaryData = db.LoadTestTransactionSummaryDatas.FirstOrDefault(x => x.LoadTestRunId == entityLoadTestRun.LoadTestRunId);

            if (entityLoadTestTransactionSummaryData != null)
            {
                TransactionsPerSec = (double)entityLoadTestTransactionSummaryData.TransactionCount / entityLoadTestRun.RunDuration;
                AvgTransactionTime = entityLoadTestTransactionSummaryData.Average;
            }

            RequestsFailed  = entityLoadTestRun.LoadTestMessages.Select(x => x.RequestId).Distinct().Count();
            AvgResponseTime = db.LoadTestPageDetails.Where(x => x.LoadTestRunId == entityLoadTestRun.LoadTestRunId).Average(x => x.ResponseTime);
            //TotalTests = db.LoadTestTestSummaryDatas.Where(x => x.LoadTestRunId == entityLoadTestRun.LoadTestRunId).Sum(x => x.TestsRun);
            if (compare)
            {
                LoadTestErrors = new List <LoadTestErrors>();
                if (entityLoadTestRun.LoadTestMessages != null)
                {
                    foreach (var LoadTestError in entityLoadTestRun.LoadTestMessages.GroupBy(p => p.SubType).Select(g => new { SubType = g.Key, Count = g.Count(), MessageText = g.FirstOrDefault().MessageText, ErrorType = g.FirstOrDefault().MessageType, LoadTestRunId = g.FirstOrDefault().LoadTestRunId }))
                    {
                        LoadTestErrors.Add(new LoadTestErrors
                        {
                            ErrorSubtype     = LoadTestError.SubType,
                            ErrorCount       = LoadTestError.Count,
                            ErrorLastMessage = LoadTestError.MessageText,
                            ErrorType        = LoadTestError.ErrorType,
                            LoadTestRunId    = LoadTestError.LoadTestRunId,
                        });
                    }
                }
                PageResults = new List <PageResultsModels>();
                if (entityLoadTestRun.LoadTestPageSummaryDatas != null)
                {
                    foreach (var LoadTestPageSummaryData in entityLoadTestRun.LoadTestPageSummaryDatas.OrderByDescending(x => x.Average))
                    {
                        PageResults.Add(new PageResultsModels(LoadTestPageSummaryData, db));
                    }
                }
                SlowestPages = new List <SlowestPagesModel>();
                if (entityLoadTestRun.LoadTestPageSummaryDatas != null)
                {
                    foreach (var LoadTestPageSummaryData in entityLoadTestRun.LoadTestPageSummaryDatas.OrderByDescending(x => x.Percentile95).Take(5))
                    {
                        SlowestPages.Add(new SlowestPagesModel(LoadTestPageSummaryData, db));
                    }
                }
                TestResults = new List <TestResultsModels>();

                if (entityLoadTestTestSummaryDatas != null)
                {
                    foreach (var entityLoadTestTestSummaryData in entityLoadTestTestSummaryDatas)
                    {
                        TestResults.Add(new TestResultsModels(entityLoadTestTestSummaryData, db));
                    }
                }
            }
        }
コード例 #14
0
        public SlowestPagesModel(Entity.LoadTestPageSummaryData entityLoadTestPageSummaryData, Entity.db_LoadTest2010Entities db)
        {
            var entityWebLoadTestRequestMap = db.WebLoadTestRequestMaps.FirstOrDefault(x => x.RequestId == entityLoadTestPageSummaryData.PageId);

            if (entityWebLoadTestRequestMap != null)
            {
                URL = entityWebLoadTestRequestMap.RequestUri;
            }
            PageTime = entityLoadTestPageSummaryData.Percentile95;
        }
コード例 #15
0
        public TestResultsModels(Entity.LoadTestTestSummaryData entityLoadTestTestSummaryData, Entity.db_LoadTest2010Entities db)
        {
            Name       = db.LoadTestCases.FirstOrDefault(x => x.TestCaseId == entityLoadTestTestSummaryData.TestCaseId && x.LoadTestRunId == entityLoadTestTestSummaryData.LoadTestRunId).TestCaseName;
            Scenario   = db.LoadTestScenarios.FirstOrDefault(x => x.LoadTestRunId == entityLoadTestTestSummaryData.LoadTestRunId).ScenarioName;
            TotalTests = entityLoadTestTestSummaryData.TestsRun;
            int failedTests = db.LoadTestTestLogs.Where(x => x.LoadTestRunId == entityLoadTestTestSummaryData.LoadTestRunId && x.TestCaseId == entityLoadTestTestSummaryData.TestCaseId).Count();

            FailedTests = string.Format("{0} ({1})", failedTests, Math.Round((float)failedTests * 100 / TotalTests, 2));
            AvgTestTime = entityLoadTestTestSummaryData.Average;
        }
コード例 #16
0
        public PageResultsModels(Entity.LoadTestPageSummaryData entityLoadTestPageSummaryData, Entity.db_LoadTest2010Entities db)
        {
            var entityWebLoadTestRequestMap = db.WebLoadTestRequestMaps.FirstOrDefault(x => x.RequestId == entityLoadTestPageSummaryData.PageId);

            if (entityWebLoadTestRequestMap != null)
            {
                URL = entityWebLoadTestRequestMap.RequestUri;
            }
            PageCount   = entityLoadTestPageSummaryData.PageCount;
            AvgPageTime = entityLoadTestPageSummaryData.Average;
            Scenario    = db.LoadTestScenarios.FirstOrDefault(x => x.LoadTestRunId == entityLoadTestPageSummaryData.LoadTestRunId).ScenarioName;
            TestName    = db.LoadTestCases.FirstOrDefault(x => x.LoadTestRunId == entityLoadTestPageSummaryData.LoadTestRunId).TestCaseName;
            var  entityLoadTestPerformanceCounterInstances = db.LoadTestPerformanceCounterInstances.Where(x => x.LoadTestRunId == entityLoadTestPageSummaryData.LoadTestRunId && x.LoadTestItemId == entityLoadTestPageSummaryData.PageId);
            bool overallThresholdRuleResultStatus          = true;

            if (entityLoadTestPerformanceCounterInstances.Any(x => x.OverallThresholdRuleResult == 2) && overallThresholdRuleResultStatus)
            {
                ThresholdRuleResult = OverallThresholdRuleResult.critical.ToString();
                overallThresholdRuleResultStatus = false;
            }
            else if (entityLoadTestPerformanceCounterInstances.Any(x => x.OverallThresholdRuleResult == 1) && overallThresholdRuleResultStatus)
            {
                ThresholdRuleResult = OverallThresholdRuleResult.warnings.ToString();
                overallThresholdRuleResultStatus = false;
            }
            else
            {
                ThresholdRuleResult = OverallThresholdRuleResult.ok.ToString();
            }
        }