Skip to content

Commit 6c09fad

Browse files
Add grafonnet-lib based tests and formatting script
Merged in #4 Add grafonnet-lib based tests and formatting script, but use jsonnetfmt instead of jsonnet fmt (way described in master C++ jsonnet, go-jsonnet ver.16 and jsonnet docs) and include needed jb vendor libraries. Add simple dashboard test to fixate behavior. Format source code with jsonnetfmt.
1 parent 5865fca commit 6c09fad

File tree

5 files changed

+618
-69
lines changed

5 files changed

+618
-69
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@ node_modules
2121
/tmp/*
2222
!/tmp/.keep
2323
/vendor
24+
*_test_output.json

tarantool/dashboard.libsonnet

Lines changed: 69 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -20,72 +20,72 @@ local datasource = '${DS_INFLUXDB}';
2020
local measurement = '${TARANTOOL_MEASUREMENT}';
2121

2222
dashboard
23-
.addInput(
24-
name='DS_INFLUXDB',
25-
label='InfluxDB bank',
26-
type='datasource',
27-
pluginId='influxdb',
28-
pluginName='InfluxDB',
29-
description='InfluxDB Tarantool metrics bank'
30-
)
31-
.addInput(
32-
name='TARANTOOL_MEASUREMENT',
33-
label='Measurement',
34-
type='constant',
35-
pluginId=null,
36-
pluginName=null,
37-
description='InfluxDB Tarantool metrics measurement'
38-
)
39-
.addRequired(
40-
type='grafana',
41-
id='grafana',
42-
name='Grafana',
43-
version='6.6.0'
44-
)
45-
.addRequired(
46-
type='datasource',
47-
id='influxdb',
48-
name='InfluxDB',
49-
version='1.0.0'
50-
)
51-
.addRequired(
52-
type='panel',
53-
id='graph',
54-
name='Graph',
55-
version=''
56-
)
57-
.addRequired(
58-
type='panel',
59-
id='text',
60-
name='Text',
61-
version=''
62-
)
63-
.addPanel(
64-
grafana.row.new(title='memory'),
65-
{x: 0, y: 0}
66-
)
67-
.addPanel(
68-
slab.monitor_info(),
69-
{w: 24, h: 3, x: 0, y: 0}
70-
)
71-
.addPanel(
72-
slab.quota_used_ratio(
73-
datasource=datasource,
74-
measurement=measurement,
75-
),
76-
{w: 8, h: 8, x: 0, y: 3}
77-
)
78-
.addPanel(
79-
slab.arena_used_ratio(
80-
datasource=datasource,
81-
measurement=measurement,
82-
),
83-
{w: 8, h: 8, x: 8, y: 3},
84-
)
85-
.addPanel(
86-
slab.items_used_ratio(
87-
datasource=datasource,
88-
measurement=measurement,
89-
),
90-
{w: 8, h: 8, x: 16, y: 3},
91-
)
23+
.addInput(
24+
name='DS_INFLUXDB',
25+
label='InfluxDB bank',
26+
type='datasource',
27+
pluginId='influxdb',
28+
pluginName='InfluxDB',
29+
description='InfluxDB Tarantool metrics bank'
30+
)
31+
.addInput(
32+
name='TARANTOOL_MEASUREMENT',
33+
label='Measurement',
34+
type='constant',
35+
pluginId=null,
36+
pluginName=null,
37+
description='InfluxDB Tarantool metrics measurement'
38+
)
39+
.addRequired(
40+
type='grafana',
41+
id='grafana',
42+
name='Grafana',
43+
version='6.6.0'
44+
)
45+
.addRequired(
46+
type='datasource',
47+
id='influxdb',
48+
name='InfluxDB',
49+
version='1.0.0'
50+
)
51+
.addRequired(
52+
type='panel',
53+
id='graph',
54+
name='Graph',
55+
version=''
56+
)
57+
.addRequired(
58+
type='panel',
59+
id='text',
60+
name='Text',
61+
version=''
62+
)
63+
.addPanel(
64+
grafana.row.new(title='memory'),
65+
{ x: 0, y: 0 }
66+
)
67+
.addPanel(
68+
slab.monitor_info(),
69+
{ w: 24, h: 3, x: 0, y: 0 }
70+
)
71+
.addPanel(
72+
slab.quota_used_ratio(
73+
datasource=datasource,
74+
measurement=measurement,
75+
),
76+
{ w: 8, h: 8, x: 0, y: 3 }
77+
)
78+
.addPanel(
79+
slab.arena_used_ratio(
80+
datasource=datasource,
81+
measurement=measurement,
82+
),
83+
{ w: 8, h: 8, x: 8, y: 3 },
84+
)
85+
.addPanel(
86+
slab.items_used_ratio(
87+
datasource=datasource,
88+
measurement=measurement,
89+
),
90+
{ w: 8, h: 8, x: 16, y: 3 },
91+
)

tests.sh

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/bin/bash
2+
3+
jsonnet_fmt='-n 2 --max-blank-lines 2 --sort-imports --string-style s --comment-style s'
4+
x=0
5+
6+
for i in `find ./tarantool ./tests -name '*.jsonnet' -or -name '*.libsonnet'`
7+
do
8+
t="Formatting $i..."
9+
if [[ "$1" == "update" ]]; then
10+
jsonnetfmt -i $jsonnet_fmt $i
11+
fi
12+
if jsonnetfmt --test $jsonnet_fmt $i;
13+
then
14+
echo $t OK
15+
else
16+
echo $t NOK
17+
x=1
18+
fi
19+
done
20+
21+
for i in tests/*/*.jsonnet
22+
do
23+
json=$(dirname $i)/$( basename $i .jsonnet )_test_output.json
24+
json_e=$(dirname $i)/$( basename $i .jsonnet )_compiled.json
25+
t="Compiling $i..."
26+
if jsonnet -J . -J ./vendor $i > $json
27+
then
28+
echo $t OK
29+
else
30+
echo $t NOK
31+
x=1
32+
continue
33+
fi
34+
35+
if [[ "$1" == "update" ]]; then cp $json $json_e; fi
36+
37+
t="Checking $i..."
38+
if diff -urt $json $json_e
39+
then
40+
echo $t OK
41+
else
42+
echo $t NOK
43+
x=1
44+
fi
45+
done
46+
exit $x

tests/InfluxDB/dashboard.jsonnet

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import 'tarantool/dashboard.libsonnet'

0 commit comments

Comments
 (0)