コード例 #1
0
        protected override async Task Test(CancellationToken cancellationToken)
        {
            await this.SeedMetrics(cancellationToken);

            bool hostMetricsFound = await HostMetricUtil.WaitForHostMetrics(this.scraper, cancellationToken);

            this.testReporter.Assert("Host Metrics Found", hostMetricsFound);

            // scrape metrics
            var metrics = await this.scraper.ScrapeEndpointsAsync(cancellationToken);

            var expected = this.GetExpectedMetrics();

            if (OsPlatform.IsWindows())
            {
                // Docker doesn't return this on windows
                expected.Remove("edgeAgent_created_pids_total");
            }

            HashSet <string> unreturnedMetrics = new HashSet <string>(expected.Keys);

            if (expected.Count == 0)
            {
                this.testReporter.Assert("No documented metrics", false, string.Empty);
                return;
            }

            log.LogInformation("Got expected metrics");
            foreach (Metric metric in metrics)
            {
                unreturnedMetrics.Remove(metric.Name);

                string metricId = $"{metric.Name}:{JsonConvert.SerializeObject(metric.Tags)}";
                if (expected.TryGetValue(metric.Name, out string[] expectedTags))
コード例 #2
0
ファイル: ValidateHostRanges.cs プロジェクト: nlcamp/iotedge
        protected override async Task Test(CancellationToken cancellationToken)
        {
            await HostMetricUtil.WaitForHostMetrics(this.scraper, cancellationToken);

            List <Metric> metrics = (await this.scraper.ScrapeEndpointsAsync(cancellationToken)).ToList();

            this.CheckCPU(metrics);
            this.CheckMemory(metrics);
        }