aboutsummaryrefslogtreecommitdiffstats
path: root/doc/template/index-stability-tmpl.html
blob: 073ff266053d796a269f2f035d203323a51fa04f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
<!DOCTYPE html>
<html>
<meta charset="UTF-8">

<head>
    <title>Xtesting ONAP Results</title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.2.13/semantic.min.css">
    <style>
        canvas{
            margin-bottom: 30px;
        }
     </style>
</head>

<body>
    <div class='ui inverted vertical masthead center aligned segment'>

        <div class="ui text container">
            <h1 class="ui inverted header">
                Stability testing results evolution
            </h1>
        </div>

    </div>

    <div class='ui vertical stripe segment'>
        <div class='ui   grid container'>
            <div class="row">
                <div class="column">
                    <h1 class="ui header">
                        <i class="warehouse icon"></i>

                    </h1>
                    <div class="sub header">

                        <!-- <div class="ui olive statistic">

                            <div class="value">20%</div>
                            <div class="label">last check</div>
                        </div> -->
                        <!-- <div class="ui olive statistic">
                            <div class="value">
                                <i class="{{ trend }}"></i>
                            </div>
                            <div class="label">trend</div>
                        </div> -->
                        <div class="ui tiny grey statistic">
                            <div class="value">{{ lab_version }}</div>
                            <div class="label">ONAP Version</div>
                        </div>
                        <div class="ui tiny grey statistic">
                            <div class="value">{{ lab_owner }}</div>
                            <div class="label">Lab owner</div>
                        </div>
                    </div>

                </div>
            </div>

                <div class="ui vertical segment">
                    <div class="ui middle aligned stackable grid container">
                        <div class="row">
                            <div class="eight wide column">
                                <h3 class="ui header center aligned">Infra test results</h3>
                                <div class=" column" style="  height:300px">
                                    <canvas id="canvas_infra"></canvas>
                                </div>
                            </div>
                            <div class="eight wide column">
                                <h3 class="ui header center aligned">Healthcheck test results</h3>
                                <div class=" column" style=" height:300px">
                                    <canvas id="canvas_healthcheck"></canvas>
                                </div>
                            </div>
                            <div class="eight wide column">
                                <h3 class="ui header center aligned">Smoke test results</h3>
                                <div class=" column" style=" height:300px">
                                    <canvas id="canvas_smoke"></canvas>
                                </div>
                            </div>
                            <div class="eight wide column">
                                <h3 class="ui header center aligned">Security test results</h3>
                                <div class=" column" style=" height:300px">
                                    <canvas id="canvas_security"></canvas>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>


    <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/3.3.2/chart.min.js"></script>
    <script>

        let DATA = {{ data |safe }}
        let TEST_NAMES= ["infrastructure-healthcheck", "healthcheck","smoke-usecases", "security"]

        function get_dates(data) {
            let dates = []
            for (const date of data){
                dates.push(date["date"])
            }
            // data.forEach(element => {
            //     dates.push(element.date)
            // });
            return dates
        }

        function get_tests_results(data,test_name){
            let results = []
        
            for (const item of data){
                console.log(item[test_name])
                results.push(item[test_name])
                
            }
           
            return results
        }

        function trendlineEq(X, Y) {
            // X : all x coordinates
            // Y: all y coordinate
            var x_sum = 0
            var y_sum = 0

            var N = 0;
            var A = 0;
            var B = 0;
            var C = 0;
            var D = 0;
            var E = 0;
            var F = 0;
            var m = 0;
            var b = 0;

            if (X.length == Y.length) {

                var N = X.length
                console.log("N : " + N)

            } else {

                return console.log(" X and Y must be of the same size")
            }

            for (let i = 0; i <= N - 1; i++) {

                A = A + (X[i] * Y[i])



                x_sum = x_sum + X[i]
                y_sum = y_sum + Y[i]

                C = C + Math.pow(X[i], 2)

            }
            A = N * A;
            console.log("A : " + A)

            B = x_sum * y_sum
            console.log("B : " + B)

            C = N * C
            console.log("C : " + C)

            D = Math.pow(x_sum, 2)
            console.log("D : " + D)

            m = (A - B) / (C - D)
            console.log("m : " + m)

            E = y_sum
            console.log("E : " + E)

            F = m * x_sum
            console.log("F : " + F)

            b = (E - F) / N
            console.log("b : " + b)

            return [m, b]
        }

        function get_trend_line_data(X, params) {
            let trend_line_data = []
            for (let i = 0; i <= X.length - 1; i++) {
                let y_param = (params[0] * X[i]) + params[1]
                let coordinates = {
                    x: X[i],
                    y: y_param
                }
                trend_line_data.push(coordinates)
            }
            return trend_line_data
        }

        var x_coord = 0
        var X_COORDS = []

        DATA.forEach(element => {
            X_COORDS.push(x_coord);
            x_coord++

        });

        function generate_target_array(data, target) {
            let target_array = []
            for (const item of data){
                target_array.push(target)
            }
            // data.forEach(element => {
            //     target_array.push(target)
            // });
            return target_array
        }

        const results_infra = get_tests_results(DATA,TEST_NAMES[0])
        const results_healthcheck = get_tests_results(DATA,TEST_NAMES[1])
        const results_smoke = get_tests_results(DATA,TEST_NAMES[2])
        const results_security = get_tests_results(DATA,TEST_NAMES[3])

        const target_infra = generate_target_array(DATA, 75)
        const target_healthcheck = generate_target_array(DATA, 100)
        const target_smoke = generate_target_array(DATA, 100)
        const target_security = generate_target_array(DATA, 100)

        const params_infra = trendlineEq(X_COORDS, results_infra)
        const params_healthcheck = trendlineEq(X_COORDS, results_healthcheck)
        const params_smoke = trendlineEq(X_COORDS, results_smoke)
        const params_security = trendlineEq(X_COORDS, results_security)

        const trend_line_infra = get_trend_line_data(X_COORDS, params_infra)
        const trend_line_healthcheck = get_trend_line_data(X_COORDS, params_healthcheck)
        const trend_line_smoke = get_trend_line_data(X_COORDS, params_smoke)
        const trend_line_security = get_trend_line_data(X_COORDS, params_security)

        const labels = get_dates(DATA)

        const data_infra = {
            labels: labels,
            datasets: [{
                label: 'Infra results',
                borderColor: 'rgb(255, 99, 132)',
                data: results_infra
            }, {
                type: 'line',
                label: 'Target',
                borderColor: 'rgb(99, 255, 132)',
                data: target_infra,
            }, {
                type: 'line',
                label: 'trend',
                borderColor: 'rgb(66, 191, 245)',
                data: trend_line_infra,
            }
            ]

        };

        const data_healthcheck = {
            labels: labels,
            datasets: [{
                label: 'healthcheck results',
                borderColor: 'rgb(255, 99, 132)',
                data: results_healthcheck
            }, {
                type: 'line',
                label: 'Target',
                borderColor: 'rgb(99, 255, 132)',
                data: target_healthcheck,
            },{
                type: 'line',
                label: 'trend',
                borderColor: 'rgb(66, 191, 245)',
                data: trend_line_healthcheck,
            }
        ]
        };

        const data_smoke = {
            labels: labels,
            datasets: [{
                label: 'smoke results',
                borderColor: 'rgb(255, 99, 132)',
                data: results_smoke
            }, {
                type: 'line',
                label: 'Target',
                borderColor: 'rgb(99, 255, 132)',
                data: target_smoke,
            },{
                type: 'line',
                label: 'trend',
                borderColor: 'rgb(66, 191, 245)',
                data: trend_line_smoke,
            }
        ]
        };

        const data_security = {
            labels: labels,
            datasets: [{
                label: 'security results',
                borderColor: 'rgb(255, 99, 132)',
                data: results_security
            }, {
                type: 'line',
                label: 'Target',
                borderColor: 'rgb(99, 255, 132)',
                data: target_security,
            },{
                type: 'line',
                label: 'trend',
                borderColor: 'rgb(66, 191, 245)',
                data: trend_line_security,
            }
        ]
        };

        var options = {
            responsive: true,
            maintainAspectRatio: false,
            scales: {
                y: {
                    title: {
                        display: true,
                        text: 'Value'
                    },
                    min: 0,
                    max: 100,
                    ticks: {
                        stepSize: 10
                    }
                }
            }
        }

        const config_infra = {
            type: 'line',
            data: data_infra,
            options: options,
        };
        const config_healthcheck = {
            type: 'line',
            data: data_healthcheck,
            options: options
        };
        const config_smoke = {
            type: 'line',
            data: data_smoke,
            options: options
        };
        const config_security = {
            type: 'line',
            data: data_security,
            options: options
        };

        //charts rendering


        var chart_infra = new Chart(
            document.getElementById('canvas_infra'),
            config_infra
        );


        var chart_healthcheck = new Chart(
            document.getElementById('canvas_healthcheck'),
            config_healthcheck
        );

        var chart_smoke = new Chart(
            document.getElementById('canvas_smoke'),
            config_smoke
        );

        var chart_security = new Chart(
            document.getElementById('canvas_security'),
            config_security
        );

</script>
</body>

</html>