Skip to content

Commit 9868435

Browse files
committed
Tests: Run Grafana on non-standard port 33333
1 parent 518c1e5 commit 9868435

File tree

4 files changed

+19
-18
lines changed

4 files changed

+19
-18
lines changed

CHANGES.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ in progress
1010
- Tests: Add fixture ``create_dashboard`` to create dashboards at runtime
1111
- Tests: Disable caching in test mode
1212
- Tests: Make test suite clean up its provisioned assets from Grafana
13+
- Tests: Run Grafana on non-standard port 33333
1314

1415

1516
2022-02-03 0.13.1

doc/backlog.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ grafana-wtf backlog
77
Prio 1
88
******
99
- [o] With Grafana >8.3, resolve datasource name and add to ``{'type': 'influxdb', 'uid': 'PDF2762CDFF14A314'}``
10-
- [o] Move test harness Grafana to a different port than 3000
1110

1211

1312
*********
@@ -64,3 +63,4 @@ Done
6463
- [x] Add test fixture for adding dashboards at runtime from branch ``amo/test-dashboard-runtime``
6564
- [x] Improve test suite wrt. test case isolation vs. Grafana resources
6665
- [x] Add test fixture which completely resets everything in Grafana before running the test harness.
66+
- [x] Move test harness Grafana to a different port than 3000

tests/docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ services:
55
container_name: grafana-wtf-test
66
image: grafana/grafana:${GRAFANA_VERSION}
77
ports:
8-
- "3000:3000"
8+
- "33333:3000"
99
environment:
1010
GF_LOG_LEVEL: info
1111
#GF_LOG_LEVEL: debug

tests/test_commands.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def set_command(command, more_options="", cache=False):
1616
cache_option = ""
1717
if cache is False:
1818
cache_option = "--cache-ttl=0"
19-
command = f'grafana-wtf --grafana-url="http://localhost:3000" {cache_option} {more_options} {command}'
19+
command = f'grafana-wtf --grafana-url="http://localhost:33333" {cache_option} {more_options} {command}'
2020
sys.argv = shlex.split(command)
2121

2222

@@ -42,7 +42,7 @@ def test_find_textual_empty(docker_grafana, capsys):
4242
captured = capsys.readouterr()
4343

4444
# Verify output.
45-
assert 'Searching for expression "foobar" at Grafana instance http://localhost:3000' in captured.out
45+
assert 'Searching for expression "foobar" at Grafana instance http://localhost:33333' in captured.out
4646
assert "Data Sources: 0 hits" in captured.out
4747
assert "Dashboards: 0 hits" in captured.out
4848

@@ -73,13 +73,13 @@ def test_find_textual_dashboard_success(ldi_resources, capsys):
7373
captured = capsys.readouterr()
7474

7575
# Verify output.
76-
assert 'Searching for expression "ldi_readings" at Grafana instance http://localhost:3000' in captured.out
76+
assert 'Searching for expression "ldi_readings" at Grafana instance http://localhost:33333' in captured.out
7777
assert "Dashboards: 2 hits" in captured.out
7878
assert "luftdaten-info-generic-trend" in captured.out
7979
assert "Title luftdaten.info generic trend" in captured.out
8080
assert "Folder Testdrive" in captured.out
8181
assert "UID ioUrPwQiz" in captured.out
82-
assert "URL http://localhost:3000/d/ioUrPwQiz/luftdaten-info-generic-trend" in captured.out
82+
assert "URL http://localhost:33333/d/ioUrPwQiz/luftdaten-info-generic-trend" in captured.out
8383
assert "dashboard.panels.[1].targets.[0].measurement: ldi_readings" in captured.out
8484
assert "dashboard.panels.[7].panels.[0].targets.[0].measurement: ldi_readings" in captured.out
8585

@@ -92,7 +92,7 @@ def test_find_textual_datasource_success(ldi_resources, capsys):
9292
captured = capsys.readouterr()
9393

9494
# Verify output.
95-
assert 'Searching for expression "ldi_v2" at Grafana instance http://localhost:3000' in captured.out
95+
assert 'Searching for expression "ldi_v2" at Grafana instance http://localhost:33333' in captured.out
9696

9797
assert "Data Sources: 1 hits" in captured.out
9898
assert "name: ldi_v2" in captured.out
@@ -112,13 +112,13 @@ def test_find_tabular_dashboard_success(ldi_resources, capsys):
112112
captured = capsys.readouterr()
113113

114114
# Verify output.
115-
assert 'Searching for expression "ldi_readings" at Grafana instance http://localhost:3000' in captured.out
115+
assert 'Searching for expression "ldi_readings" at Grafana instance http://localhost:33333' in captured.out
116116

117117
reference_table = """
118-
| Type | Name | Title | Folder | UID | Created | Updated | Created by | Datasources | URL |
119-
|:-----------|:---------------------------------|:---------------------------------|:----------|:----------|:---------------------|:---------------------|:-------------|:--------------------------------------------------------------------------------------|:-------------------------------------------------------------------|
120-
| Dashboards | luftdaten-info-generic-trend-v27 | luftdaten.info generic trend v27 | Testdrive | ioUrPwQiz | xxxx-xx-xxTxx:xx:xxZ | xxxx-xx-xxTxx:xx:xxZ | admin | -- Grafana --,ldi_v2,weatherbase | http://localhost:3000/d/ioUrPwQiz/luftdaten-info-generic-trend-v27 |
121-
| Dashboards | luftdaten-info-generic-trend-v33 | luftdaten.info generic trend v33 | Testdrive | jpVsQxRja | xxxx-xx-xxTxx:xx:xxZ | xxxx-xx-xxTxx:xx:xxZ | admin | -- Grafana --,{'type': 'influxdb', 'uid': 'PDF2762CDFF14A314'},{'uid': 'weatherbase'} | http://localhost:3000/d/jpVsQxRja/luftdaten-info-generic-trend-v33 |
118+
| Type | Name | Title | Folder | UID | Created | Updated | Created by | Datasources | URL |
119+
|:-----------|:---------------------------------|:---------------------------------|:----------|:----------|:---------------------|:---------------------|:-------------|:--------------------------------------------------------------------------------------|:--------------------------------------------------------------------|
120+
| Dashboards | luftdaten-info-generic-trend-v27 | luftdaten.info generic trend v27 | Testdrive | ioUrPwQiz | xxxx-xx-xxTxx:xx:xxZ | xxxx-xx-xxTxx:xx:xxZ | admin | -- Grafana --,ldi_v2,weatherbase | http://localhost:33333/d/ioUrPwQiz/luftdaten-info-generic-trend-v27 |
121+
| Dashboards | luftdaten-info-generic-trend-v33 | luftdaten.info generic trend v33 | Testdrive | jpVsQxRja | xxxx-xx-xxTxx:xx:xxZ | xxxx-xx-xxTxx:xx:xxZ | admin | -- Grafana --,{'type': 'influxdb', 'uid': 'PDF2762CDFF14A314'},{'uid': 'weatherbase'} | http://localhost:33333/d/jpVsQxRja/luftdaten-info-generic-trend-v33 |
122122
""".strip()
123123

124124
output_table = captured.out[captured.out.find("| Type") :]
@@ -140,7 +140,7 @@ def test_replace_dashboard_success(ldi_resources, capsys):
140140
set_command("find ldi_v3")
141141
grafana_wtf.commands.run()
142142
captured = capsys.readouterr()
143-
assert 'Searching for expression "ldi_v3" at Grafana instance http://localhost:3000' in captured.out
143+
assert 'Searching for expression "ldi_v3" at Grafana instance http://localhost:33333' in captured.out
144144

145145
# TODO: Expand renaming to data sources.
146146
assert "Data Sources: 0 hits" in captured.out
@@ -167,7 +167,7 @@ def test_log_empty(ldi_resources, capsys, caplog):
167167
captured = capsys.readouterr()
168168

169169
# Verify output.
170-
assert 'Aggregating edit history for Grafana dashboard "foobar" at http://localhost:3000' in caplog.text
170+
assert 'Aggregating edit history for Grafana dashboard "foobar" at http://localhost:33333' in caplog.text
171171
assert "[]" in captured.out
172172

173173

@@ -180,7 +180,7 @@ def test_log_json_success(ldi_resources, capsys, caplog):
180180
captured = capsys.readouterr()
181181

182182
# Verify output.
183-
assert 'Aggregating edit history for Grafana dashboard "ioUrPwQiz" at http://localhost:3000' in caplog.text
183+
assert 'Aggregating edit history for Grafana dashboard "ioUrPwQiz" at http://localhost:33333' in caplog.text
184184

185185
reference = {
186186
# "datetime": "2021-09-29T17:32:23Z",
@@ -189,7 +189,7 @@ def test_log_json_success(ldi_resources, capsys, caplog):
189189
"folder": "Testdrive",
190190
"title": "luftdaten.info generic trend v27",
191191
"version": 1,
192-
"url": "http://localhost:3000/d/ioUrPwQiz/luftdaten-info-generic-trend-v27",
192+
"url": "http://localhost:33333/d/ioUrPwQiz/luftdaten-info-generic-trend-v27",
193193
}
194194

195195
history = json.loads(captured.out)
@@ -208,10 +208,10 @@ def test_log_tabular_success(ldi_resources, capsys, caplog):
208208
captured = capsys.readouterr()
209209

210210
# Verify output.
211-
assert 'Aggregating edit history for Grafana dashboard "ioUrPwQiz" at http://localhost:3000' in caplog.text
211+
assert 'Aggregating edit history for Grafana dashboard "ioUrPwQiz" at http://localhost:33333' in caplog.text
212212

213213
reference = """
214-
| Notes: n/a<br/>[Testdrive » luftdaten.info generic trend v27](http://localhost:3000/d/ioUrPwQiz/luftdaten-info-generic-trend-v27) | User: admin<br/>Date: xxxx-xx-xxTxx:xx:xxZ |
214+
| Notes: n/a<br/>[Testdrive » luftdaten.info generic trend v27](http://localhost:33333/d/ioUrPwQiz/luftdaten-info-generic-trend-v27) | User: admin<br/>Date: xxxx-xx-xxTxx:xx:xxZ |
215215
""".strip()
216216

217217
first_item_raw = str.splitlines(captured.out)[-1]

0 commit comments

Comments
 (0)