diff options
author | talyz <kim.lindberger@gmail.com> | 2023-02-15 16:11:39 +0100 |
---|---|---|
committer | Soner Sayakci <s.sayakci@shopware.com> | 2023-02-15 16:38:24 +0000 |
commit | 9e9007e45fec743f41f47aa92c47ba36bc8e76b5 (patch) | |
tree | d78a41633952edb0298c5d1979e094a2efed4e7f /nixos/tests | |
parent | 8b84a720e87fe30f992fcee9ba9ae4b5f5588b91 (diff) |
nixos/opensearch: Use DynamicUser and StateDirectory by default
...but still allow for setting `dataDir` to a custom path. This gets rid of the use of the deprecated option PermissionsStartOnly. Also, add the ability to customize user and group, since that could be useful with a custom `dataDir`.
Diffstat (limited to 'nixos/tests')
-rw-r--r-- | nixos/tests/all-tests.nix | 2 | ||||
-rw-r--r-- | nixos/tests/opensearch.nix | 65 |
2 files changed, 50 insertions, 17 deletions
diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index 4e8334622f834..86dd096afc0b0 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -490,7 +490,7 @@ in { ombi = handleTest ./ombi.nix {}; openarena = handleTest ./openarena.nix {}; openldap = handleTest ./openldap.nix {}; - opensearch = handleTest ./opensearch.nix {}; + opensearch = discoverTests (import ./opensearch.nix); openresty-lua = handleTest ./openresty-lua.nix {}; opensmtpd = handleTest ./opensmtpd.nix {}; opensmtpd-rspamd = handleTest ./opensmtpd-rspamd.nix {}; diff --git a/nixos/tests/opensearch.nix b/nixos/tests/opensearch.nix index db63c2e053f5d..c0caf950cb9c9 100644 --- a/nixos/tests/opensearch.nix +++ b/nixos/tests/opensearch.nix @@ -1,19 +1,52 @@ -import ./make-test-python.nix ({ pkgs, ... }: { - name = "opensearch"; - meta.maintainers = with pkgs.lib.maintainers; [ shyim ]; +let + opensearchTest = + import ./make-test-python.nix ( + { pkgs, lib, extraSettings ? {} }: { + name = "opensearch"; + meta.maintainers = with pkgs.lib.maintainers; [ shyim ]; - nodes.machine = { - virtualisation.memorySize = 2048; - services.opensearch.enable = true; - }; + 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) + testScript = '' + machine.start() + machine.wait_for_unit("opensearch.service") + machine.wait_for_open_port(9200) - machine.succeed( - "curl --fail localhost: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; + }; + }; + }; + }; +} |