2
2
3
3
import logging
4
4
import os
5
- import threading
6
5
from datetime import datetime
7
6
from pathlib import Path
8
- from subprocess import PIPE , Popen , run
7
+ from subprocess import run
9
8
10
9
import requests
11
10
from test_base import TestBase
12
11
12
+ GRAFANA_URL = "http://localhost:2019/grafana/"
13
+
13
14
14
15
class LoggingTest (TestBase ):
15
16
def __init__ (self ):
@@ -35,22 +36,6 @@ def start_logging(self):
35
36
self .log .info ("Running install_logging.sh" )
36
37
# Block until complete
37
38
run ([f"{ self .scripts_dir / 'install_logging.sh' } " ])
38
- self .log .info ("Running connect_logging.sh" )
39
- # Stays alive in background
40
- self .connect_logging_process = Popen (
41
- [f"{ self .scripts_dir / 'connect_logging.sh' } " ],
42
- stdout = PIPE ,
43
- stderr = PIPE ,
44
- bufsize = 1 ,
45
- universal_newlines = True ,
46
- )
47
- self .log .info ("connect_logging.sh started..." )
48
- self .connect_logging_thread = threading .Thread (
49
- target = self .output_reader ,
50
- args = (self .connect_logging_process .stdout , self .connect_logging_logger .info ),
51
- )
52
- self .connect_logging_thread .daemon = True
53
- self .connect_logging_thread .start ()
54
39
55
40
def setup_network (self ):
56
41
self .log .info ("Setting up network" )
@@ -64,7 +49,7 @@ def wait_for_endpoint_ready(self):
64
49
65
50
def check_endpoint ():
66
51
try :
67
- response = requests .get ("http://localhost:3000/ login" )
52
+ response = requests .get (f" { GRAFANA_URL } login" )
68
53
return response .status_code == 200
69
54
except requests .RequestException :
70
55
return False
@@ -79,7 +64,7 @@ def make_grafana_api_request(self, ds_uid, start, metric):
79
64
"from" : f"{ start } " ,
80
65
"to" : "now" ,
81
66
}
82
- reply = requests .post ("http://localhost:3000/ api/ds/query" , json = data )
67
+ reply = requests .post (f" { GRAFANA_URL } api/ds/query" , json = data )
83
68
if reply .status_code != 200 :
84
69
self .log .error (f"Grafana API request failed with status code { reply .status_code } " )
85
70
self .log .error (f"Response content: { reply .text } " )
@@ -96,7 +81,7 @@ def test_prometheus_and_grafana(self):
96
81
self .warnet (f"run { miner_file } --allnodes --interval=5 --mature" )
97
82
self .warnet (f"run { tx_flood_file } --interval=1" )
98
83
99
- prometheus_ds = requests .get ("http://localhost:3000/ api/datasources/name/Prometheus" )
84
+ prometheus_ds = requests .get (f" { GRAFANA_URL } api/datasources/name/Prometheus" )
100
85
assert prometheus_ds .status_code == 200
101
86
prometheus_uid = prometheus_ds .json ()["uid" ]
102
87
self .log .info (f"Got Prometheus data source uid from Grafana: { prometheus_uid } " )
0 commit comments