From d247758e0d1f8c33df6955f15553da5511742305 Mon Sep 17 00:00:00 2001 From: Ana Gelez Date: Mon, 4 Mar 2024 13:59:28 +0100 Subject: [PATCH] opensearch-mono: fix tests and check that OSD runs Also be smarter when waiting for the OpenSearch server when running the securityadmin.sh script. --- opensearch-mono/composition.nix | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/opensearch-mono/composition.nix b/opensearch-mono/composition.nix index 8ae19b8..3a8ead9 100644 --- a/opensearch-mono/composition.nix +++ b/opensearch-mono/composition.nix @@ -63,7 +63,9 @@ in "wait-and-run-securityadmin" '' # wait for opensearch to start - sleep 100 + while ! ${pkgs.nettools}/bin/netstat -tlnp | grep ':9200' ; do + sleep 1 + done ${pkgs.coreutils}/bin/env JAVA_HOME="${pkgs.jre_headless}" \ /var/lib/opensearch/plugins/opensearch-security/tools/securityadmin.sh \ @@ -133,7 +135,7 @@ in user = "admin"; password = "admin"; }; - tls.verify_certificate = false; + tls.verify_certificate = false; }; }; }; @@ -162,7 +164,7 @@ in opensearch.wait_for_open_port(9200) opensearch.succeed( - "curl --fail localhost:9200" + "curl -k -u admin:admin --fail https://localhost:9200" ) opensearch.wait_for_unit("vector.service") @@ -172,7 +174,12 @@ in # The outer curl call just queries the content of the index and checks that it is in the expected # format with JQ opensearch.succeed( - "curl --fail http://localhost:9200/$(curl --fail http://localhost:9200/_stats | jq -r '.indices | keys[]' | grep vector | tail -n 1)/_search | jq '.hits.hits[0]._source'" + "curl -k -u admin:admin --fail https://localhost:9200/$(curl -k -u admin:admin --fail https://localhost:9200/_stats | jq -r '.indices | keys[]' | grep vector | tail -n 1)/_search | jq '.hits.hits[0]._source'" + ) + + opensearch.wait_for_unit("opensearch-dashboards.service") + opensearch.succeed( + "curl --fail http://localhost:5601/" ) ''; }