summaryrefslogtreecommitdiffstats
path: root/nixos/tests/garage/basic.nix
blob: 67b52c9a8c4ae74fb01b09d40035c3a8b38d3560 (plain)
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
{
  lib,
  mkNode,
  package,
  testScriptSetup,
  ...
}:
{
  name = "garage-${package.version}-basic";

  nodes = {
    single_node = mkNode {
      extraSettings =
        if (lib.versionAtLeast package.version "2") then
          {
            replication_factor = 1;
            consistency_mode = "consistent";
          }
        else
          {
            replication_mode = "none";
          };
    };
  };

  testScript = # python
    ''
      ${testScriptSetup}

      with subtest("Garage works as a single-node S3 storage"):
        single_node.wait_for_unit("garage.service")
        single_node.wait_for_open_port(3900)
        # Now Garage is initialized.
        single_node_id = get_node_id(single_node)
        apply_garage_layout(single_node, [f'-z qemutest -c 1G "{single_node_id}"'])
        # Now Garage is operational.
        test_bucket_writes(single_node)
        test_bucket_over_http(single_node)
    '';
}