forked from torrust/torrust-tracker
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: [torrust#634] E2E test runner: parse log to get running services
- Loading branch information
1 parent
6398dc1
commit 815f2ca
Showing
4 changed files
with
162 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
use serde::{Deserialize, Serialize}; | ||
|
||
#[derive(Serialize, Deserialize, Debug, Default)] | ||
pub struct RunningServices { | ||
pub udp_trackers: Vec<String>, | ||
pub http_trackers: Vec<String>, | ||
pub health_checks: Vec<String>, | ||
} | ||
|
||
impl RunningServices { | ||
pub fn extract_from_logs(&mut self, logs: &str) { | ||
// todo: extract duplicate code | ||
for line in logs.lines() { | ||
let heal_check_pattern = "[Health Check API][INFO] Starting on: "; | ||
let udp_tracker_pattern = "[UDP Tracker][INFO] Starting on: udp://"; | ||
let http_tracker_pattern = "[HTTP Tracker][INFO] Starting on: "; | ||
|
||
if let Some(start) = line.find(heal_check_pattern) { | ||
let address = &line[start + heal_check_pattern.len()..].trim(); | ||
self.health_checks.push(Self::replace_wildcard_ip_with_localhost(address)); | ||
} else if let Some(start) = line.find(udp_tracker_pattern) { | ||
let address = &line[start + udp_tracker_pattern.len()..].trim(); | ||
self.udp_trackers.push(Self::replace_wildcard_ip_with_localhost(address)); | ||
} else if let Some(start) = line.find(http_tracker_pattern) { | ||
let address = &line[start + http_tracker_pattern.len()..].trim(); | ||
self.http_trackers.push(Self::replace_wildcard_ip_with_localhost(address)); | ||
} | ||
} | ||
} | ||
|
||
fn replace_wildcard_ip_with_localhost(address: &str) -> String { | ||
address.replace("0.0.0.0", "127.0.0.1") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
pub mod docker; | ||
pub mod logs; | ||
pub mod runner; | ||
pub mod temp_dir; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters