Esempio n. 1
0
        public void CollectBuildData(DateTime minFinishTime, DateTime maxFinishTime, int BUILD_PER_REQUEST)
        {
            var vso     = this.config[SolutionConfigName.VSO_NAME].ToString();
            var project = this.config[SolutionConfigName.VSO_PROJECT_NAME].ToString();
            var token   = this.config[SolutionConfigName.PERSONAL_ACCESS_TOKEN].ToString();
            var query   = OfficialBuildUtil.GetQueryStringWithPaging(
                vso,
                project,
                this.config[SolutionConfigName.OFFICIAL_BUILD_ID].ToString(),
                minFinishTime.ToString(),
                maxFinishTime.ToString(),
                BUILD_PER_REQUEST,
                "Completed"
                );

            var buildFromVSO = OfficialBuildUtil.GetOfficialBuildDBModel(vso, project, query, token);
            var metricList   = new List <Metric>();

            foreach (var build in buildFromVSO)
            {
                var detail = new Dictionary <string, object>();
                detail["VSO"]          = build.VSO;
                detail["Project"]      = build.Project;
                detail["BuildId"]      = build.BuildId;
                detail["Result"]       = build.Result ? 1 : 0;
                detail["SourceBranch"] = build.SourceBranch;
                detail["CreationDate"] = build.CreationDate;
                metricList.Add(new Metric("OfficialBuild", MetricType.OfficialBuild, detail));
            }

            writer.Write(metricList);
        }
        public override void CollectMetric()
        {
            var end   = DateTime.Now.AddDays(1);
            var begin = end.AddDays(-5);

            var vso     = this.config[SolutionConfigName.VSO_NAME].ToString();
            var project = this.config[SolutionConfigName.VSO_PROJECT_NAME].ToString();
            var token   = this.config[SolutionConfigName.PERSONAL_ACCESS_TOKEN].ToString();
            var builIds = this.config[SolutionConfigName.OFFICIAL_BUILD_ID].ToString();

            var builds     = OfficialBuildUtil.GetOfficialBuildDBModel(vso, project, builIds, begin, end, token);
            var metricList = new List <Metric>();

            foreach (var build in builds)
            {
                var coverage = TestCoverageUtil.GetTestCoverageForBuild(this.config[SolutionConfigName.VSO_NAME].ToString(), this.config[SolutionConfigName.VSO_PROJECT_NAME].ToString(), build.BuildId, token);
                foreach (var item in coverage)
                {
                    var detail = new Dictionary <string, object>();
                    detail["VSO"]             = item.VSO;
                    detail["Project"]         = item.Project;
                    detail["BuildId"]         = build.BuildId;
                    detail["ModuleName"]      = item.ModuleName;
                    detail["LinesCovered"]    = item.LinesCovered;
                    detail["LinesNotCovered"] = item.LinesNotCovered;
                    var metric = new Metric("TestCoverage", MetricType.TestCoverage, detail);
                    metricList.Add(metric);
                }
            }
            writer.Write(metricList);
        }
        public void OfficialBuild_GetOfficialBuildModel_Test()
        {
            var query = @"https://dltc.visualstudio.com/DefaultCollection/Deep Learning/_apis/build/builds?api-version=2.0&minFinishTime=2015-08-15T00:00:00Z&maxFinishTime=2018-08-20T00:00:00Z&definitions=18";
            var token = this.config[SolutionConfigName.PERSONAL_ACCESS_TOKEN].ToString();

            var buildModelList = OfficialBuildUtil.GetOfficialBuildDBModel("dltc", "Deep Learning", query, token);

            Assert.IsTrue(buildModelList.Count > 0);
        }