1
1
#!/usr/bin/env python3
2
2
3
- import logging
4
3
import os
5
- import threading
6
4
from datetime import datetime
7
5
from pathlib import Path
8
- from subprocess import PIPE , Popen
9
6
10
7
import requests
11
8
from test_base import TestBase
@@ -18,39 +15,15 @@ def __init__(self):
18
15
super ().__init__ ()
19
16
self .network_dir = Path (os .path .dirname (__file__ )) / "data" / "logging"
20
17
self .scripts_dir = Path (os .path .dirname (__file__ )) / ".." / "resources" / "scripts"
21
- self .connect_logging_process = None
22
- self .connect_logging_thread = None
23
- self .connect_logging_logger = logging .getLogger ("cnct_log" )
24
18
25
19
def run_test (self ):
26
20
try :
27
21
self .setup_network ()
28
- self .start_logging ()
22
+ self .wait_for_endpoint_ready ()
29
23
self .test_prometheus_and_grafana ()
30
24
finally :
31
- if self .connect_logging_process is not None :
32
- self .log .info ("Terminating background connect_logging.sh process..." )
33
- self .connect_logging_process .terminate ()
34
25
self .cleanup ()
35
26
36
- def start_logging (self ):
37
- # Stays alive in background
38
- self .connect_logging_process = Popen (
39
- [f"{ self .scripts_dir / 'connect_logging.sh' } " ],
40
- stdout = PIPE ,
41
- stderr = PIPE ,
42
- bufsize = 1 ,
43
- universal_newlines = True ,
44
- )
45
- self .log .info ("connect_logging.sh started..." )
46
- self .connect_logging_thread = threading .Thread (
47
- target = self .output_reader ,
48
- args = (self .connect_logging_process .stdout , self .connect_logging_logger .info ),
49
- )
50
- self .connect_logging_thread .daemon = True
51
- self .connect_logging_thread .start ()
52
- self .wait_for_endpoint_ready ()
53
-
54
27
def setup_network (self ):
55
28
self .log .info ("Setting up network" )
56
29
self .log .info (self .warnet (f"deploy { self .network_dir } " ))
@@ -118,6 +91,10 @@ def get_five_values_for_metric(metric):
118
91
self .wait_for_predicate (lambda : get_five_values_for_metric ("blocks" ))
119
92
self .wait_for_predicate (lambda : get_five_values_for_metric ("txrate" ))
120
93
94
+ # Verify default dashboard exists
95
+ dbs = requests .get (f"{ GRAFANA_URL } api/search" ).json ()
96
+ assert dbs [0 ]["title" ] == "Default Warnet Dashboard"
97
+
121
98
122
99
if __name__ == "__main__" :
123
100
test = LoggingTest ()
0 commit comments