Skip to content

Commit 080525d

Browse files
Merge pull request #3823 from manticoresoftware/test/integrations-grafana
Added Grafana integration test
2 parents 0bc5a96 + 1c3d5d3 commit 080525d

File tree

2 files changed

+239
-0
lines changed

2 files changed

+239
-0
lines changed

.github/workflows/nightly_integration.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,3 +143,18 @@ jobs:
143143
comment_mode: failures
144144
run_args: --privileged
145145
ui_host: "https://clt.manticoresearch.com"
146+
147+
test_grafana:
148+
name: Test Grafana integration
149+
runs-on: ubuntu-22.04
150+
timeout-minutes: 60
151+
steps:
152+
- name: Checkout repository
153+
uses: actions/checkout@v3
154+
- uses: manticoresoftware/[email protected]
155+
with:
156+
test_prefix: test/clt-tests/integrations/test-integrations-grafana
157+
image: manticoresearch/dind:v1
158+
comment_mode: failures
159+
run_args: --privileged
160+
ui_host: "https://clt.manticoresearch.com"
Lines changed: 224 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,224 @@
1+
––– block: ../base/dind/init –––
2+
––– comment –––
3+
Create Docker network
4+
––– input –––
5+
docker network create manticore-grafana-net > /dev/null 2>&1; echo $?
6+
––– output –––
7+
0
8+
––– comment –––
9+
Start Manticore container
10+
––– input –––
11+
docker run -it --network=manticore-grafana-net --platform linux/amd64 \
12+
-p 9306:9306 -p 9308:9308 \
13+
--name manticore -d \
14+
ghcr.io/manticoresoftware/manticoresearch:test-kit-fix-grafana-builder-query-buddy bash > /dev/null 2>&1; echo $?
15+
––– output –––
16+
0
17+
––– input –––
18+
docker exec manticore sed -i 's/127.0.0.1/0.0.0.0/g' /etc/manticoresearch/manticore.conf
19+
––– output –––
20+
––– input –––
21+
docker exec manticore cat /etc/manticoresearch/manticore.conf
22+
––– output –––
23+
searchd {
24+
listen = 0.0.0.0:9312
25+
listen = 0.0.0.0:9306:mysql
26+
listen = 0.0.0.0:9308:http
27+
log = /var/log/manticore/searchd.log
28+
query_log = /var/log/manticore/query.log
29+
pid_file = /run/manticore/searchd.pid
30+
data_dir = /var/lib/manticore
31+
}
32+
––– input –––
33+
docker exec manticore bash -c "mkdir -p /var/log/manticore && stdbuf -oL searchd --logdebugvv > /dev/null 2>&1 &"
34+
––– output –––
35+
––– input –––
36+
docker exec manticore bash -c "timeout 10 bash -c 'until [ -f /var/log/manticore/searchd.log ] && grep -q \"accepting connections\" /var/log/manticore/searchd.log; do sleep 0.5; done' && echo 'Accepting connections!'"
37+
––– output –––
38+
Accepting connections!
39+
––– input –––
40+
docker exec manticore mysql -h0 -P9306 -e "SELECT 1\G"
41+
––– output –––
42+
*************************** 1. row ***************************
43+
1: 1
44+
––– comment –––
45+
Start Grafana container
46+
––– input –––
47+
docker run -d --name grafana --network manticore-grafana-net -p 3000:3000 -e GF_SECURITY_ADMIN_PASSWORD=admin grafana/grafana:12.2 > /dev/null 2>&1; echo $?
48+
––– output –––
49+
0
50+
––– comment –––
51+
Wait for Grafana to be ready
52+
––– input –––
53+
timeout 30 bash -c 'until docker logs grafana 2>&1 | grep -q "HTTP Server Listen"; do sleep 1; done' && echo 'Grafana is ready!'
54+
––– output –––
55+
Grafana is ready!
56+
––– comment –––
57+
Verify Grafana is accessible
58+
––– input –––
59+
docker exec grafana wget -qO- http://localhost:3000/api/health
60+
––– output –––
61+
{
62+
"database": "ok",
63+
"version": "#!/[0-9]+\.[0-9]+\.[0-9]+/!#",
64+
"commit": "#!/[a-z0-9]+/!#"
65+
}
66+
––– comment –––
67+
Create Manticore data source in Grafana
68+
––– input –––
69+
docker exec grafana curl -s -X POST "http://localhost:3000/api/datasources" -u "admin:admin" -H "Content-Type: application/json" -d '{"name":"Manticore","type":"mysql","url":"manticore:9306","access":"proxy"}'
70+
––– output –––
71+
{"datasource":{"id":%{NUMBER},"uid":#!/"[a-zA-Z0-9]+"/!#,"orgId":1,"name":"Manticore","type":"mysql","typeLogoUrl":#!/"[^"]*"/!#,"access":"proxy","url":"manticore:9306","user":"","database":"","basicAuth":false,"basicAuthUser":"","withCredentials":false,"isDefault":#!/(true|false)/!#,"jsonData":{},"secureJsonFields":{},"version":1,"readOnly":false,"apiVersion":#!/"[^"]*"/!#},"id":%{NUMBER},"message":"Datasource added","name":"Manticore"}
72+
––– comment –––
73+
Verify data source was created
74+
––– input –––
75+
docker exec grafana curl -s -X GET "http://localhost:3000/api/datasources/name/Manticore" -u "admin:admin"
76+
––– output –––
77+
{"id":%{NUMBER},"uid":#!/"[a-zA-Z0-9]+"/!#,"orgId":1,"name":"Manticore","type":"mysql","typeLogoUrl":#!/"[^"]*"/!#,"access":"proxy","url":"manticore:9306","user":"","database":"","basicAuth":false,"basicAuthUser":"","withCredentials":false,"isDefault":#!/(true|false)/!#,"jsonData":{},"secureJsonFields":{},"version":1,"readOnly":false,"apiVersion":#!/"[^"]*"/!#}
78+
––– comment –––
79+
Create test tables
80+
––– input –––
81+
docker exec manticore mysql -h0 -P9306 -e "CREATE TABLE products (title text, price float, created bigint)"
82+
––– output –––
83+
––– input –––
84+
docker exec manticore mysql -h0 -P9306 -e "CREATE TABLE users (name text, email text, registered bigint)"
85+
––– output –––
86+
––– input –––
87+
docker exec manticore mysql -h0 -P9306 -e "CREATE TABLE orders (order_id bigint, amount float, status string)"
88+
––– output –––
89+
––– comment –––
90+
Insert test data
91+
––– input –––
92+
docker exec manticore mysql -h0 -P9306 -e "INSERT INTO products (title, price, created) VALUES ('Laptop', 999.99, 1697200000), ('Mouse', 29.99, 1697210000), ('Keyboard', 79.99, 1697220000)"
93+
––– output –––
94+
––– input –––
95+
docker exec manticore mysql -h0 -P9306 -e "INSERT INTO users (name, email, registered) VALUES ('John Doe', '[email protected]', 1697200000), ('Jane Smith', '[email protected]', 1697210000)"
96+
––– output –––
97+
––– input –––
98+
docker exec manticore mysql -h0 -P9306 -e "INSERT INTO orders (order_id, amount, status) VALUES (1, 500.0, 'completed'), (2, 750.5, 'completed'), (3, 320.0, 'pending')"
99+
––– output –––
100+
––– comment –––
101+
Verify all tables are listed
102+
––– input –––
103+
docker exec manticore mysql -h0 -P9306 -e "SHOW TABLES"
104+
––– output –––
105+
+----------+------+
106+
| Table | Type |
107+
+----------+------+
108+
| orders | rt |
109+
| products | rt |
110+
| users | rt |
111+
+----------+------+
112+
––– comment –––
113+
Critical test: information_schema.tables must return all tables with correct table_schema and table_type
114+
––– input –––
115+
docker exec manticore mysql -h0 -P9306 -e "SELECT * FROM information_schema.tables"
116+
––– output –––
117+
+------------+------------+--------------+
118+
| table_type | table_name | table_schema |
119+
+------------+------------+--------------+
120+
| BASE TABLE | orders | Manticore |
121+
| BASE TABLE | products | Manticore |
122+
| BASE TABLE | users | Manticore |
123+
+------------+------------+--------------+
124+
––– comment –––
125+
Test table discovery query used by Grafana Query Builder
126+
––– input –––
127+
docker exec manticore mysql -h0 -P9306 -e "SELECT table_name FROM information_schema.tables WHERE table_schema = 'Manticore'"
128+
––– output –––
129+
+------------+
130+
| TABLE_NAME |
131+
+------------+
132+
| orders |
133+
| products |
134+
| users |
135+
+------------+
136+
––– comment –––
137+
Test DISTINCT TABLE_SCHEMA query
138+
––– input –––
139+
docker exec manticore mysql -h0 -P9306 -e "SELECT DISTINCT TABLE_SCHEMA FROM information_schema.TABLES WHERE TABLE_TYPE != 'SYSTEM VIEW'"
140+
––– output –––
141+
+-----------------------+
142+
| DISTINCT TABLE_SCHEMA |
143+
+-----------------------+
144+
| Manticore |
145+
+-----------------------+
146+
––– comment –––
147+
Test SHOW FULL TABLES
148+
––– input –––
149+
docker exec manticore mysql -h0 -P9306 -e "SHOW FULL TABLES"
150+
––– output –––
151+
+---------------------+------------+
152+
| Tables_in_Manticore | Table_type |
153+
+---------------------+------------+
154+
| orders | BASE TABLE |
155+
| products | BASE TABLE |
156+
| users | BASE TABLE |
157+
+---------------------+------------+
158+
––– comment –––
159+
Execute SELECT query via Grafana API
160+
––– input –––
161+
docker exec grafana curl -s -X POST "http://localhost:3000/api/ds/query" -u "admin:admin" -H "Content-Type: application/json" -d '{"queries":[{"datasourceId":1,"rawSql":"SELECT title, price FROM products","format":"table"}]}'
162+
––– output –––
163+
{"results":{"A":{"status":%{NUMBER},"frames":[{"schema":{"refId":"A","meta":{"typeVersion":[0,0],"executedQueryString":"SELECT title, price FROM products"},"fields":[{"name":"title","type":"string","typeInfo":{"frame":"string","nullable":true}},{"name":"price","type":"number","typeInfo":{"frame":"float64","nullable":true}}]},"data":{"values":[["Laptop","Mouse","Keyboard"],[#!/[0-9]+.[0-9]+/!#,#!/[0-9]+.[0-9]+/!#,#!/[0-9]+.[0-9]+/!#]]}}]}}}
164+
––– comment –––
165+
Test COUNT aggregation via Grafana API
166+
––– input –––
167+
docker exec grafana curl -s -X POST "http://localhost:3000/api/ds/query" -u "admin:admin" -H "Content-Type: application/json" -d '{"queries":[{"datasourceId":1,"rawSql":"SELECT COUNT(*) as total FROM products","format":"table"}]}'
168+
––– output –––
169+
{"results":{"A":{"status":%{NUMBER},"frames":[{"schema":{"refId":"A","meta":{"typeVersion":[0,0],"executedQueryString":"SELECT COUNT(*) as total FROM products"},"fields":[{"name":"total","type":"number","typeInfo":{"frame":"int64","nullable":true}}]},"data":{"values":[[3]]}}]}}}
170+
––– comment –––
171+
Test GROUP BY via Grafana API
172+
––– input –––
173+
docker exec grafana curl -s -X POST "http://localhost:3000/api/ds/query" -u "admin:admin" -H "Content-Type: application/json" -d '{"queries":[{"datasourceId":1,"rawSql":"SELECT status, COUNT(*) as count FROM orders GROUP BY status","format":"table"}]}'
174+
––– output –––
175+
{"results":{"A":{"status":%{NUMBER},"frames":[{"schema":{"refId":"A","meta":{"typeVersion":[0,0],"executedQueryString":"SELECT status, COUNT(*) as count FROM orders GROUP BY status"},"fields":[{"name":"status","type":"string","typeInfo":{"frame":"string","nullable":true}},{"name":"count","type":"number","typeInfo":{"frame":"int64","nullable":true}}]},"data":{"values":[["completed","pending"],[2,1]]}}]}}}
176+
––– comment –––
177+
Test AVG aggregation
178+
––– input –––
179+
docker exec manticore mysql -h0 -P9306 -e "SELECT AVG(price) as avg_price FROM products"
180+
––– output –––
181+
+--------------+
182+
| avg_price |
183+
+--------------+
184+
| #!/[0-9]+.[0-9]+/!# |
185+
+--------------+
186+
––– comment –––
187+
Test MAX and MIN
188+
––– input –––
189+
docker exec manticore mysql -h0 -P9306 -e "SELECT MAX(price) as max_price, MIN(price) as min_price FROM products"
190+
––– output –––
191+
+------------+-----------+
192+
| max_price | min_price |
193+
+------------+-----------+
194+
| #!/[0-9]+.[0-9]+/!# | #!/[0-9]+.[0-9]+/!# |
195+
+------------+-----------+
196+
––– comment –––
197+
Test ORDER BY
198+
––– input –––
199+
docker exec manticore mysql -h0 -P9306 -e "SELECT title, price FROM products ORDER BY price DESC"
200+
––– output –––
201+
+----------+------------+
202+
| title | price |
203+
+----------+------------+
204+
| Laptop | #!/[0-9]+.[0-9]+/!# |
205+
| Keyboard | #!/[0-9]+.[0-9]+/!# |
206+
| Mouse | #!/[0-9]+.[0-9]+/!# |
207+
+----------+------------+
208+
––– comment –––
209+
Test WHERE clause
210+
––– input –––
211+
docker exec manticore mysql -h0 -P9306 -e "SELECT title FROM products WHERE price > 50"
212+
––– output –––
213+
+----------+
214+
| title |
215+
+----------+
216+
| Laptop |
217+
| Keyboard |
218+
+----------+
219+
––– comment –––
220+
Delete data source cleanup
221+
––– input –––
222+
docker exec grafana curl -s -X DELETE "http://localhost:3000/api/datasources/name/Manticore" -u "admin:admin"
223+
––– output –––
224+
{"id":%{NUMBER},"message":"Data source deleted"}

0 commit comments

Comments
 (0)