1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
//! Container singletons for mae integration tests.
//!
//! Each sub-module owns one Docker container type and exposes:
//! - A static singleton (started lazily, guarded by `MAE_TESTCONTAINERS=1`).
//! - A per-test **isolation scope** (schema, keyspace, vhost, database) that
//! prevents cross-test interference.
//! - A [`teardown`](MaeContainer::teardown) function that stops the container
//! and clears the singleton so the next test-run starts fresh.
//!
//! All four container types implement [`MaeContainer`]. Call
//! [`teardown_all()`] from your global test teardown hook to stop every
//! container in one shot.
//!
//! # Stability contract for issue #40
//! The trait and module layout are intentionally fixed here. Issue #40 should
//! fill in the `start()` implementations for Redis, Neo4j, and RabbitMQ while
//! keeping the public API below unchanged.
use Future;
use ;
/// Number of concurrent `#[mae_test(docker, teardown = …)]` cases sharing containers.
static DOCKER_TEST_GUARDS: AtomicUsize = new;
/// Mark the start of a docker-gated test that will call [`teardown_all`] on exit.
///
/// Generated by `#[mae_test(docker, teardown = …)]`. Prevents parallel tests from
/// tearing down shared containers while siblings are still running.
/// Common interface shared by every Mae container singleton.
///
/// Implementors are zero-sized unit types (`struct PostgresContainer;` etc.)
/// that act as namespaces — all state lives in module-level statics.
/// Stop **all** Mae container singletons when the last guarded docker test exits.
///
/// Pair with [`docker_test_guard_enter`] (done automatically by
/// `#[mae_test(docker, teardown = …)]`). Parallel tests can share containers
/// safely; the last test to finish stops them.
///
/// For unconditional shutdown (e.g. process exit), use [`teardown_all_force`].
pub async
/// Stop every container singleton immediately, regardless of guard count.
pub async