Skip to content

Commit e437f63

Browse files
committed
Merge #1324: Refactor packages: move integration tests to packages
3f50803 tests: scaffolding for integration tests (Jose Celano) f233dd2 refactor: remove unsued dependencies from the main Cargo.toml (Jose Celano) c34c8bc refactor: [#1316] remove unsued code (Jose Celano) 60c5826 refactor: remove duplicate test (Jose Celano) f783dbd refactor: [#1316] move the rest of the Health Check API integration tests to the server pkg (Jose Celano) 1aef0c1 refactor: [#1316] move HTTP tracker integration tests to pkg (Jose Celano) 92505b9 refactor: [#1316] UDP tracker integration tests to pkg (Jose Celano) 08efc3b refactor: [#1316] move tracker API integration tests to pkg (Jose Celano) a841e03 refactor: [#1316] move health check API integration tests to pkg (Jose Celano) Pull request description: Refactor packages: move integration tests to packages. - [x] Move Health Check API integration tests to the server package (`axum-health-check-api-server`). - [x] Move Tracker API integration tests to the server package (`axum-tracker-api-server`). - [x] Move UDP Tracker integration tests to the server package (`udp-tracker-server`). - [x] Move HTTP Tracker integration tests to the server package (`axum-http-tracker-server`). ACKs for top commit: josecelano: ACK 3f50803 Tree-SHA512: 21e6dc8bca036f2d90062032e7fc6b714069b792eb529ddf6784ff071dbfc41ca21953c6ea44e361bdaf4d19ddb96fc8f6c1c091b796c00eae2104d0504a78ed
2 parents c248caf + 3f50803 commit e437f63

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+430
-324
lines changed

Cargo.lock

+22-19
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

-32
Original file line numberDiff line numberDiff line change
@@ -34,32 +34,18 @@ version = "3.0.0-develop"
3434

3535
[dependencies]
3636
anyhow = "1"
37-
aquatic_udp_protocol = "0"
3837
axum-server = { version = "0", features = ["tls-rustls-no-provider"] }
3938
bittorrent-http-tracker-core = { version = "3.0.0-develop", path = "packages/http-tracker-core" }
40-
bittorrent-primitives = "0.1.0"
41-
bittorrent-tracker-client = { version = "3.0.0-develop", path = "packages/tracker-client" }
4239
bittorrent-tracker-core = { version = "3.0.0-develop", path = "packages/tracker-core" }
4340
bittorrent-udp-tracker-core = { version = "3.0.0-develop", path = "packages/udp-tracker-core" }
4441
chrono = { version = "0", default-features = false, features = ["clock"] }
4542
clap = { version = "4", features = ["derive", "env"] }
46-
crossbeam-skiplist = "0"
47-
dashmap = "6"
48-
figment = "0"
4943
futures = "0"
50-
parking_lot = "0"
51-
percent-encoding = "2"
52-
r2d2 = "0"
53-
r2d2_mysql = "25"
54-
r2d2_sqlite = { version = "0", features = ["bundled"] }
5544
rand = "0"
5645
regex = "1"
5746
reqwest = { version = "0", features = ["json"] }
5847
serde = { version = "1", features = ["derive"] }
59-
serde_bencode = "0"
60-
serde_bytes = "0"
6148
serde_json = { version = "1", features = ["preserve_order"] }
62-
serde_repr = "0"
6349
tokio = { version = "1", features = ["macros", "net", "rt-multi-thread", "signal", "sync"] }
6450
torrust-axum-health-check-api-server = { version = "3.0.0-develop", path = "packages/axum-health-check-api-server" }
6551
torrust-axum-http-tracker-server = { version = "3.0.0-develop", path = "packages/axum-http-tracker-server" }
@@ -69,27 +55,9 @@ torrust-server-lib = { version = "3.0.0-develop", path = "packages/server-lib" }
6955
torrust-tracker-api-core = { version = "3.0.0-develop", path = "packages/tracker-api-core" }
7056
torrust-tracker-clock = { version = "3.0.0-develop", path = "packages/clock" }
7157
torrust-tracker-configuration = { version = "3.0.0-develop", path = "packages/configuration" }
72-
torrust-tracker-primitives = { version = "3.0.0-develop", path = "packages/primitives" }
73-
torrust-tracker-torrent-repository = { version = "3.0.0-develop", path = "packages/torrent-repository" }
7458
torrust-udp-tracker-server = { version = "3.0.0-develop", path = "packages/udp-tracker-server" }
7559
tracing = "0"
7660
tracing-subscriber = { version = "0", features = ["json"] }
77-
url = { version = "2", features = ["serde"] }
78-
uuid = { version = "1", features = ["v4"] }
79-
zerocopy = "0.7"
80-
81-
[package.metadata.cargo-machete]
82-
ignored = [
83-
"crossbeam-skiplist",
84-
"dashmap",
85-
"figment",
86-
"parking_lot",
87-
"r2d2",
88-
"r2d2_mysql",
89-
"r2d2_sqlite",
90-
"serde_bytes",
91-
"torrust-tracker-torrent-repository",
92-
]
9361

9462
[dev-dependencies]
9563
local-ip-address = "0"

packages/axum-health-check-api-server/Cargo.toml

+9
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,16 @@ serde_json = { version = "1", features = ["preserve_order"] }
2323
tokio = { version = "1", features = ["macros", "net", "rt-multi-thread", "signal", "sync"] }
2424
torrust-axum-server = { version = "3.0.0-develop", path = "../axum-server" }
2525
torrust-server-lib = { version = "3.0.0-develop", path = "../server-lib" }
26+
torrust-tracker-configuration = { version = "3.0.0-develop", path = "../configuration" }
2627
tower-http = { version = "0", features = ["compression-full", "cors", "propagate-header", "request-id", "trace"] }
2728
tracing = "0"
2829

2930
[dev-dependencies]
31+
reqwest = { version = "0", features = ["json"] }
32+
torrust-axum-health-check-api-server = { version = "3.0.0-develop", path = "../axum-health-check-api-server" }
33+
torrust-axum-http-tracker-server = { version = "3.0.0-develop", path = "../axum-http-tracker-server" }
34+
torrust-axum-tracker-api-server = { version = "3.0.0-develop", path = "../axum-tracker-api-server" }
35+
torrust-tracker-clock = { version = "3.0.0-develop", path = "../clock" }
36+
torrust-tracker-test-helpers = { version = "3.0.0-develop", path = "../test-helpers" }
37+
torrust-udp-tracker-server = { version = "3.0.0-develop", path = "../udp-tracker-server" }
38+
tracing-subscriber = { version = "0", features = ["json"] }

tests/servers/health_check_api/environment.rs packages/axum-health-check-api-server/src/environment.rs

+20-5
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,14 @@ use std::sync::Arc;
33

44
use tokio::sync::oneshot::{self, Sender};
55
use tokio::task::JoinHandle;
6-
use torrust_axum_health_check_api_server::{server, HEALTH_CHECK_API_LOG_TARGET};
76
use torrust_server_lib::registar::Registar;
8-
use torrust_server_lib::signals::{self, Halted, Started};
7+
use torrust_server_lib::signals::{self, Halted as SignalHalted, Started as SignalStarted};
98
use torrust_tracker_configuration::HealthCheckApi;
109

10+
use crate::{server, HEALTH_CHECK_API_LOG_TARGET};
11+
12+
pub type Started = Environment<Running>;
13+
1114
#[derive(Debug)]
1215
pub enum Error {
1316
#[allow(dead_code)]
@@ -30,6 +33,7 @@ pub struct Environment<S> {
3033
}
3134

3235
impl Environment<Stopped> {
36+
#[must_use]
3337
pub fn new(config: &Arc<HealthCheckApi>, registar: Registar) -> Self {
3438
let bind_to = config.bind_address;
3539

@@ -41,9 +45,13 @@ impl Environment<Stopped> {
4145

4246
/// Start the test environment for the Health Check API.
4347
/// It runs the API server.
48+
///
49+
/// # Panics
50+
///
51+
/// Will panic if it cannot start the service in a spawned task.
4452
pub async fn start(self) -> Environment<Running> {
45-
let (tx_start, rx_start) = oneshot::channel::<Started>();
46-
let (tx_halt, rx_halt) = tokio::sync::oneshot::channel::<Halted>();
53+
let (tx_start, rx_start) = oneshot::channel::<SignalStarted>();
54+
let (tx_halt, rx_halt) = tokio::sync::oneshot::channel::<SignalHalted>();
4755

4856
let register = self.registar.entries();
4957

@@ -81,10 +89,17 @@ impl Environment<Running> {
8189
Environment::<Stopped>::new(config, registar).start().await
8290
}
8391

92+
/// # Errors
93+
///
94+
/// Will return an error if it cannot send the halt signal.
95+
///
96+
/// # Panics
97+
///
98+
/// Will panic if it cannot shutdown the service.
8499
pub async fn stop(self) -> Result<Environment<Stopped>, Error> {
85100
self.state
86101
.halt_task
87-
.send(Halted::Normal)
102+
.send(SignalHalted::Normal)
88103
.map_err(|e| Error::Error(e.to_string()))?;
89104

90105
let bind_to = self.state.task.await.expect("it should shutdown the service");

packages/axum-health-check-api-server/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
pub mod environment;
12
pub mod handlers;
23
pub mod resources;
34
pub mod responses;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//! Integration tests.
2+
//!
3+
//! ```text
4+
//! cargo test --test integration
5+
//! ```
6+
mod server;
7+
8+
use torrust_tracker_clock::clock;
9+
10+
/// This code needs to be copied into each crate.
11+
/// Working version, for production.
12+
#[cfg(not(test))]
13+
#[allow(dead_code)]
14+
pub(crate) type CurrentClock = clock::Working;
15+
16+
/// Stopped version, for testing.
17+
#[cfg(test)]
18+
#[allow(dead_code)]
19+
pub(crate) type CurrentClock = clock::Stopped;

0 commit comments

Comments
 (0)