| OLD | NEW |
| (Empty) |
| 1 <!-- | |
| 2 Copyright 2014 The Chromium Authors. All rights reserved. | |
| 3 Use of this source code is governed by a BSD-style license that can be | |
| 4 found in the LICENSE file. | |
| 5 --> | |
| 6 | |
| 7 <link rel="import" href="../../lib/log.html"> | |
| 8 <link rel="import" href="../../lib/network-simulator.html"> | |
| 9 <link rel="import" href="../cqstats-graph-data.html"> | |
| 10 | |
| 11 <script> | |
| 12 (function() { | |
| 13 | |
| 14 var assert = chai.assert; | |
| 15 | |
| 16 var testCQStats = { | |
| 17 results: [{ | |
| 18 key: '2002', | |
| 19 begin: 1500, | |
| 20 end: 1500 + 500 * 60, | |
| 21 interval_minutes: 500, | |
| 22 stats: [{ | |
| 23 name: 'test-stat-a', | |
| 24 max: 600, | |
| 25 percentile_99: 540, | |
| 26 percentile_90: 480, | |
| 27 percentile_50: 420, | |
| 28 min: 360, | |
| 29 mean: 420, | |
| 30 }, { | |
| 31 name: 'test-stat-b', | |
| 32 max: 6000, | |
| 33 percentile_99: 5400, | |
| 34 percentile_90: 4800, | |
| 35 percentile_50: 4200, | |
| 36 min: 3600, | |
| 37 mean: 4200, | |
| 38 }], | |
| 39 }, { | |
| 40 key: '1001', | |
| 41 begin: 1000, | |
| 42 end: 1000 + 500 * 60, | |
| 43 interval_minutes: 500, | |
| 44 stats: [{ | |
| 45 name: 'test-stat-a', | |
| 46 max: 6000, | |
| 47 percentile_99: 5400, | |
| 48 percentile_90: 4800, | |
| 49 percentile_50: 4200, | |
| 50 min: 3600, | |
| 51 mean: 4200, | |
| 52 }, { | |
| 53 name: 'test-stat-b', | |
| 54 max: 600, | |
| 55 percentile_99: 540, | |
| 56 percentile_90: 480, | |
| 57 percentile_50: 420, | |
| 58 min: 360, | |
| 59 mean: 420, | |
| 60 }], | |
| 61 }], | |
| 62 }; | |
| 63 | |
| 64 describe('CQStatsGraphData.createBatch', function() { | |
| 65 it('should create CQStatsGraphData objects that get data', function(done) { | |
| 66 var simulator = new NetworkSimulator(assert); | |
| 67 simulator.json = function(options) { | |
| 68 if (options.url === 'https://chromium-cq-status.appspot.com/stats/query?pr
oject=testProject&interval_minutes=500&names=test-stat-a%2Ctest-stat-b&count=100
0') { | |
| 69 return Promise.resolve(testCQStats); | |
| 70 } | |
| 71 console.log('Unexpected url: ' + options.url); | |
| 72 } | |
| 73 | |
| 74 var dataList; | |
| 75 simulator.runTest(function() { | |
| 76 dataList = CQStatsGraphData.createBatch( | |
| 77 'testProject', 500, ['test-stat-a', 'test-stat-b'], 1000); | |
| 78 }).then(function() { | |
| 79 assert.equal(dataList.length, 2); | |
| 80 assert.equal(dataList[0]._name, 'test-stat-a'); | |
| 81 assert.equal(dataList[1]._name, 'test-stat-b'); | |
| 82 return Promise.all([ | |
| 83 dataList[0].get().then(function(data) { | |
| 84 assert.deepEqual(data, { | |
| 85 cols: ['timestamp', 'max', 'p90', 'p50', 'min', 'mean'], | |
| 86 rows: [ | |
| 87 [new Date((1000 + 500 * 60) * 1000), 100, 80, 70, 60, 70], | |
| 88 [new Date((1500 + 500 * 60) * 1000), 10, 8, 7, 6, 7], | |
| 89 ], | |
| 90 }); | |
| 91 }), | |
| 92 dataList[1].get().then(function(data) { | |
| 93 assert.deepEqual(data, { | |
| 94 cols: ['timestamp', 'max', 'p90', 'p50', 'min', 'mean'], | |
| 95 rows: [ | |
| 96 [new Date((1000 + 500 * 60) * 1000), 10, 8, 7, 6, 7], | |
| 97 [new Date((1500 + 500 * 60) * 1000), 100, 80, 70, 60, 70], | |
| 98 ], | |
| 99 }); | |
| 100 }), | |
| 101 ]); | |
| 102 }).then(function() { | |
| 103 done(); | |
| 104 }).catch(log); | |
| 105 }); | |
| 106 }); | |
| 107 | |
| 108 })(); | |
| 109 </script> | |
| 110 | |
| OLD | NEW |