You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/console/ci/e2e/logs_parser.rs
+51-22Lines changed: 51 additions & 22 deletions
Original file line number
Diff line number
Diff line change
@@ -1,9 +1,9 @@
1
1
//! Utilities to parse Torrust Tracker logs.
2
2
use serde::{Deserialize,Serialize};
3
3
4
-
constUDP_TRACKER_PATTERN:&str = "INFO UDP TRACKER: Starting on: udp://";
5
-
constHTTP_TRACKER_PATTERN:&str = "INFO HTTP TRACKER: Starting on: ";
6
-
constHEALTH_CHECK_PATTERN:&str = "INFO HEALTH CHECK API: Starting on: ";
4
+
constUDP_TRACKER_PATTERN:&str = "UDP TRACKER: Started on: udp://";
5
+
constHTTP_TRACKER_PATTERN:&str = "HTTP TRACKER: Started on: ";
6
+
constHEALTH_CHECK_PATTERN:&str = "HEALTH CHECK API: Started on: ";
7
7
8
8
#[derive(Serialize,Deserialize,Debug,Default)]
9
9
pubstructRunningServices{
@@ -19,16 +19,17 @@ impl RunningServices {
19
19
///
20
20
/// ```text
21
21
/// Loading configuration from default configuration file: `./share/default/config/tracker.development.sqlite3.toml` ...
22
-
/// 2024-06-10T14:26:10.040894Z INFO torrust_tracker::bootstrap::logging: logging initialized.
23
-
/// 2024-06-10T14:26:10.041363Z INFO UDP TRACKER: Starting on: udp://0.0.0.0:6969
24
-
/// 2024-06-10T14:26:10.041386Z INFO torrust_tracker::bootstrap::jobs: TLS not enabled
25
-
/// 2024-06-10T14:26:10.041420Z INFO HTTP TRACKER: Starting on: http://0.0.0.0:7070
26
-
/// 2024-06-10T14:26:10.041516Z INFO HTTP TRACKER: Started on: http://0.0.0.0:7070
27
-
/// 2024-06-10T14:26:10.041521Z INFO torrust_tracker::bootstrap::jobs: TLS not enabled
28
-
/// 2024-06-10T14:26:10.041611Z INFO API: Starting on http://127.0.0.1:1212
29
-
/// 2024-06-10T14:26:10.041614Z INFO API: Started on http://127.0.0.1:1212
30
-
/// 2024-06-10T14:26:10.041623Z INFO HEALTH CHECK API: Starting on: http://127.0.0.1:1313
31
-
/// 2024-06-10T14:26:10.041657Z INFO HEALTH CHECK API: Started on: http://127.0.0.1:1313
22
+
/// 2024-06-10T14:59:57.973525Z INFO torrust_tracker::bootstrap::logging: logging initialized.
23
+
/// 2024-06-10T14:59:57.974306Z INFO UDP TRACKER: Starting on: udp://0.0.0.0:6969
24
+
/// 2024-06-10T14:59:57.974316Z INFO UDP TRACKER: Started on: udp://0.0.0.0:6969
25
+
/// 2024-06-10T14:59:57.974332Z INFO torrust_tracker::bootstrap::jobs: TLS not enabled
26
+
/// 2024-06-10T14:59:57.974366Z INFO HTTP TRACKER: Starting on: http://0.0.0.0:7070
27
+
/// 2024-06-10T14:59:57.974513Z INFO HTTP TRACKER: Started on: http://0.0.0.0:7070
28
+
/// 2024-06-10T14:59:57.974521Z INFO torrust_tracker::bootstrap::jobs: TLS not enabled
29
+
/// 2024-06-10T14:59:57.974615Z INFO API: Starting on http://127.0.0.1:1212
30
+
/// 2024-06-10T14:59:57.974618Z INFO API: Started on http://127.0.0.1:1212
31
+
/// 2024-06-10T14:59:57.974643Z INFO HEALTH CHECK API: Starting on: http://127.0.0.1:1313
32
+
/// 2024-06-10T14:59:57.974760Z INFO HEALTH CHECK API: Started on: http://127.0.0.1:1313
32
33
/// ```
33
34
///
34
35
/// It would extract these services:
@@ -46,6 +47,9 @@ impl RunningServices {
46
47
/// ]
47
48
/// }
48
49
/// ```
50
+
///
51
+
/// NOTICE: Using colors in the console output could affect this method
52
+
/// due to the hidden control chars.
49
53
#[must_use]
50
54
pubfnparse_from_logs(logs:&str) -> Self{
51
55
letmut udp_trackers:Vec<String> = Vec::new();
@@ -85,20 +89,45 @@ mod tests {
85
89
86
90
#[test]
87
91
fnit_should_parse_from_logs_with_valid_logs(){
88
-
let logs = "\
89
-
INFO UDP TRACKER: Starting on: udp://0.0.0.0:8080\n\
90
-
INFO HTTP TRACKER: Starting on: 0.0.0.0:9090\n\
91
-
INFO HEALTH CHECK API: Starting on: 0.0.0.0:10010";
92
-
let running_services = RunningServices::parse_from_logs(logs);
92
+
let log = r#"
93
+
Loading configuration from environment variable db_path = "/var/lib/torrust/tracker/database/sqlite3.db"
Loading configuration from file: `/etc/torrust/tracker/tracker.toml` ...
108
+
2024-06-10T15:09:54.411031Z INFO torrust_tracker::bootstrap::logging: logging initialized.
109
+
2024-06-10T15:09:54.415084Z INFO UDP TRACKER: Starting on: udp://0.0.0.0:6969
110
+
2024-06-10T15:09:54.415091Z INFO UDP TRACKER: Started on: udp://0.0.0.0:6969
111
+
2024-06-10T15:09:54.415104Z INFO torrust_tracker::bootstrap::jobs: TLS not enabled
112
+
2024-06-10T15:09:54.415130Z INFO HTTP TRACKER: Starting on: http://0.0.0.0:7070
113
+
2024-06-10T15:09:54.415266Z INFO HTTP TRACKER: Started on: http://0.0.0.0:7070
114
+
2024-06-10T15:09:54.415275Z INFO torrust_tracker::bootstrap::jobs: TLS not enabled
115
+
2024-06-10T15:09:54.415403Z INFO API: Starting on http://127.0.0.1:1212
116
+
2024-06-10T15:09:54.415411Z INFO API: Started on http://127.0.0.1:1212
117
+
2024-06-10T15:09:54.415430Z INFO HEALTH CHECK API: Starting on: http://127.0.0.1:1313
118
+
2024-06-10T15:09:54.415472Z INFO HEALTH CHECK API: Started on: http://127.0.0.1:1313
119
+
"#;
120
+
121
+
let running_services = RunningServices::parse_from_logs(log);
0 commit comments