about summary refs log tree commit diff
path: root/nixos/tests/opensearch.nix
blob: c0caf950cb9c9db308bbc69c78b3aeaef5861eda (plain) (blame)
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
let
  opensearchTest =
    import ./make-test-python.nix (
      { pkgs, lib, extraSettings ? {} }: {
        name = "opensearch";
        meta.maintainers = with pkgs.lib.maintainers; [ shyim ];

        nodes.machine = lib.mkMerge [
          {
            virtualisation.memorySize = 2048;
            services.opensearch.enable = true;
          }
          extraSettings
        ];

        testScript = ''
          machine.start()
          machine.wait_for_unit("opensearch.service")
          machine.wait_for_open_port(9200)

          machine.succeed(
              "curl --fail localhost:9200"
          )
        '';
      });
in
{
  opensearch = opensearchTest {};
  opensearchCustomPathAndUser = opensearchTest {
    extraSettings = {
      services.opensearch.dataDir = "/var/opensearch_test";
      services.opensearch.user = "open_search";
      services.opensearch.group = "open_search";
      system.activationScripts.createDirectory = {
        text = ''
          mkdir -p "/var/opensearch_test"
          chown open_search:open_search /var/opensearch_test
          chmod 0700 /var/opensearch_test
        '';
        deps = [ "users" "groups" ];
      };
      users = {
        groups.open_search = {};
        users.open_search = {
          description = "OpenSearch daemon user";
          group = "open_search";
          isSystemUser = true;
        };
      };
    };
  };
}