From 1645f8bac254141482005a2dfe0186b1cf740447 Mon Sep 17 00:00:00 2001 From: vcerenu Date: Mon, 6 Jun 2022 11:03:34 -0300 Subject: [PATCH] Test CI --- .github/workflows/push.yml | 45 ++++++++++++++++++++++++++++++++------ 1 file changed, 38 insertions(+), 7 deletions(-) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index a64437b8..02255bbb 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -36,7 +36,23 @@ jobs: - name: Check Wazuh indexer start run: | sleep 60 - curl -XGET "https://0.0.0.0:9200/_cluster/health" -u admin:SecretPassword -k -s | grep green + status="`curl -XGET "https://0.0.0.0:9200/_cluster/health" -u admin:SecretPassword -k -s | wc -l`" + status-green="`curl -XGET "https://0.0.0.0:9200/_cluster/health" -u admin:SecretPassword -k -s | grep green | wc -l`" + if [[ $status-green -eq $status ]]; then + curl -XGET "https://0.0.0.0:9200/_cluster/health" -u admin:SecretPassword -k -s + else + curl -XGET "https://0.0.0.0:9200/_cluster/health" -u admin:SecretPassword -k -s + exit 1 + fi + status-index="`curl -XGET "https://0.0.0.0:9200/_cat/indices" -u admin:SecretPassword -k -s | wc -l`" + status-index-green="`curl -XGET "https://0.0.0.0:9200/_cat/indices" -u admin:SecretPassword -k -s | grep -E "green" | wc -l`" + if [[ $status-index-green -eq $status-index ]]; then + curl -XGET "https://0.0.0.0:9200/_cat/indices" -u admin:SecretPassword -k -s + else + curl -XGET "https://0.0.0.0:9200/_cat/indices" -u admin:SecretPassword -k -s + exit 1 + fi + - name: Check Wazuh indexer nodes run: | @@ -51,7 +67,7 @@ jobs: - name: Check documents into wazuh-alerts index run: | docs="`curl -XGET "https://0.0.0.0:9200/wazuh-alerts*/_doc/_search" -u admin:SecretPassword -k -s | jq -r ".hits.total.value"`" - if [[ $docs -gt 0 ]]; then + if [[ $docs -gt 100 ]]; then echo "wazuh-alerts index documents: ${docs}" else echo "wazuh-alerts index documents: ${docs}" @@ -60,9 +76,9 @@ jobs: - name: Check Wazuh templates run: | - qty_templates="`curl -XGET "https://0.0.0.0:9200/_cat/templates" -u admin:SecretPassword -k -s | grep "wazuh" | wc -l`" - templates="`curl -XGET "https://0.0.0.0:9200/_cat/templates" -u admin:SecretPassword -k -s | grep "wazuh"`" - if [[ $qty_templates -gt 0 ]]; then + qty_templates="`curl -XGET "https://0.0.0.0:9200/_cat/templates" -u admin:SecretPassword -k -s | grep -E "wazuh ||wazuh-agent||wazuh-statistics" | wc -l`" + templates="`curl -XGET "https://0.0.0.0:9200/_cat/templates" -u admin:SecretPassword -k -s | grep -E "wazuh ||wazuh-agent||wazuh-statistics"`" + if [[ $qty_templates -eq 3 ]]; then echo "wazuh templates:" echo "${templates}" else @@ -107,7 +123,22 @@ jobs: - name: Check Wazuh indexer start run: | sleep 120 - curl -XGET "https://0.0.0.0:9200/_cluster/health" -u admin:SecretPassword -k + status="`curl -XGET "https://0.0.0.0:9200/_cluster/health" -u admin:SecretPassword -k -s | wc -l`" + status-green="`curl -XGET "https://0.0.0.0:9200/_cluster/health" -u admin:SecretPassword -k -s | grep green | wc -l`" + if [[ $status-green -eq $status ]]; then + curl -XGET "https://0.0.0.0:9200/_cluster/health" -u admin:SecretPassword -k -s + else + curl -XGET "https://0.0.0.0:9200/_cluster/health" -u admin:SecretPassword -k -s + exit 1 + fi + status-index="`curl -XGET "https://0.0.0.0:9200/_cat/indices" -u admin:SecretPassword -k -s | wc -l`" + status-index-green="`curl -XGET "https://0.0.0.0:9200/_cat/indices" -u admin:SecretPassword -k -s | grep -E "green" | wc -l`" + if [[ $status-index-green -eq $status-index ]]; then + curl -XGET "https://0.0.0.0:9200/_cat/indices" -u admin:SecretPassword -k -s + else + curl -XGET "https://0.0.0.0:9200/_cat/indices" -u admin:SecretPassword -k -s + exit 1 + fi - name: Check Wazuh indexer nodes run: | @@ -122,7 +153,7 @@ jobs: - name: Check documents into wazuh-alerts index run: | docs="`curl -XGET "https://0.0.0.0:9200/wazuh-alerts*/_doc/_search" -u admin:SecretPassword -k -s | jq -r ".hits.total.value"`" - if [[ $docs -gt 0 ]]; then + if [[ $docs -gt 200 ]]; then echo "wazuh-alerts index documents: ${docs}" else echo "wazuh-alerts index documents: ${docs}"