2025-06-17 10:00:51 -04:00
|
|
|
{
|
|
|
|
lib,
|
|
|
|
mkNode,
|
|
|
|
package,
|
|
|
|
testScriptSetup,
|
|
|
|
...
|
|
|
|
}:
|
|
|
|
let
|
|
|
|
extraSettings =
|
|
|
|
if (lib.versionAtLeast package.version "2") then
|
|
|
|
{
|
|
|
|
replication_factor = 3;
|
|
|
|
consistency_mode = "consistent";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
replication_mode = "3";
|
|
|
|
};
|
|
|
|
in
|
2025-06-17 11:44:24 -04:00
|
|
|
{
|
|
|
|
name = "garage-3node-replication";
|
|
|
|
|
|
|
|
nodes = {
|
|
|
|
node1 = mkNode {
|
2025-06-17 10:00:51 -04:00
|
|
|
inherit extraSettings;
|
2025-06-17 11:44:24 -04:00
|
|
|
publicV6Address = "fc00:1::1";
|
2022-09-07 22:04:27 +02:00
|
|
|
};
|
2025-06-17 11:44:24 -04:00
|
|
|
node2 = mkNode {
|
2025-06-17 10:00:51 -04:00
|
|
|
inherit extraSettings;
|
2025-06-17 11:44:24 -04:00
|
|
|
publicV6Address = "fc00:1::2";
|
|
|
|
};
|
|
|
|
node3 = mkNode {
|
2025-06-17 10:00:51 -04:00
|
|
|
inherit extraSettings;
|
2025-06-17 11:44:24 -04:00
|
|
|
publicV6Address = "fc00:1::3";
|
|
|
|
};
|
|
|
|
node4 = mkNode {
|
2025-06-17 10:00:51 -04:00
|
|
|
inherit extraSettings;
|
2025-06-17 11:44:24 -04:00
|
|
|
publicV6Address = "fc00:1::4";
|
2024-12-10 20:26:33 +01:00
|
|
|
};
|
2025-06-17 11:44:24 -04:00
|
|
|
};
|
2024-12-10 20:26:33 +01:00
|
|
|
|
2025-06-17 11:44:24 -04:00
|
|
|
testScript = # python
|
|
|
|
''
|
2025-06-17 10:00:51 -04:00
|
|
|
${testScriptSetup}
|
2024-12-10 20:26:33 +01:00
|
|
|
|
2022-09-07 22:04:27 +02:00
|
|
|
with subtest("Garage works as a multi-node S3 storage"):
|
|
|
|
nodes = ('node1', 'node2', 'node3', 'node4')
|
|
|
|
rev_machines = {m.name: m for m in machines}
|
|
|
|
def get_machine(key): return rev_machines[key]
|
|
|
|
for key in nodes:
|
|
|
|
node = get_machine(key)
|
|
|
|
node.wait_for_unit("garage.service")
|
|
|
|
node.wait_for_open_port(3900)
|
2024-12-10 20:26:33 +01:00
|
|
|
|
2022-09-07 22:04:27 +02:00
|
|
|
# Garage is initialized on all nodes.
|
|
|
|
node_ids = {key: get_node_fqn(get_machine(key)) for key in nodes}
|
2024-12-10 20:26:33 +01:00
|
|
|
|
2022-09-07 22:04:27 +02:00
|
|
|
for key in nodes:
|
|
|
|
for other_key in nodes:
|
|
|
|
if other_key != key:
|
|
|
|
other_id = node_ids[other_key]
|
|
|
|
get_machine(key).succeed(f"garage node connect {other_id.node_id}@{other_id.host}")
|
2024-12-10 20:26:33 +01:00
|
|
|
|
2022-09-07 22:04:27 +02:00
|
|
|
# Provide multiple zones for the nodes.
|
|
|
|
zones = ["nixcon", "nixcon", "paris_meetup", "fosdem"]
|
|
|
|
apply_garage_layout(node1,
|
|
|
|
[
|
2025-06-17 11:44:24 -04:00
|
|
|
f'{ndata.node_id} -z {zones[index]} -c 1G'
|
2022-09-07 22:04:27 +02:00
|
|
|
for index, ndata in enumerate(node_ids.values())
|
|
|
|
])
|
|
|
|
# Now Garage is operational.
|
|
|
|
test_bucket_writes(node1)
|
|
|
|
for node in nodes:
|
|
|
|
test_bucket_over_http(get_machine(node))
|
|
|
|
'';
|
2025-06-17 11:44:24 -04:00
|
|
|
}
|