Skip to content

Commit

Permalink
ci: use curl 'resolve' flag consistently across branches
Browse files Browse the repository at this point in the history
Reduces differences between the main and tls branches.
  • Loading branch information
antoineco committed Feb 12, 2024
1 parent 3fe48f3 commit e3a9d60
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 28 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/scripts/disable-disk-alloc-decider.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@ cid_es="$(container_id elasticsearch)"
ip_es="$(service_ip elasticsearch)"

grouplog 'Wait for readiness of Elasticsearch'
poll_ready "$cid_es" "http://${ip_es}:9200/" -u 'elastic:testpasswd'
poll_ready "$cid_es" 'http://elasticsearch:9200/' --resolve "elasticsearch:9200:${ip_es}" -u 'elastic:testpasswd'
endgroup

log 'Disabling disk allocation decider'

declare -a put_args=( '-X' 'PUT' '--fail-with-body' '-s' '-u' 'elastic:testpasswd'
'-H' 'Content-Type: application/json'
"http://${ip_es}:9200/_cluster/settings?pretty"
'http://elasticsearch:9200/_cluster/settings?pretty'
'--resolve' "elasticsearch:9200:${ip_es}"
'-d' '{"persistent":{"cluster.routing.allocation.disk.threshold_enabled":false}}'
)
declare response
Expand Down
12 changes: 7 additions & 5 deletions .github/workflows/scripts/run-tests-core.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ ip_ls="$(service_ip logstash)"
ip_kb="$(service_ip kibana)"

grouplog 'Wait for readiness of Elasticsearch'
poll_ready "$cid_es" "http://${ip_es}:9200/" -u 'elastic:testpasswd'
poll_ready "$cid_es" 'http://elasticsearch:9200/' --resolve "elasticsearch:9200:${ip_es}" -u 'elastic:testpasswd'
endgroup

grouplog 'Wait for readiness of Logstash'
poll_ready "$cid_ls" "http://${ip_ls}:9600/_node/pipelines/main?pretty"
poll_ready "$cid_ls" 'http://logstash:9600/_node/pipelines/main?pretty' --resolve "logstash:9600:${ip_ls}"
endgroup

grouplog 'Wait for readiness of Kibana'
poll_ready "$cid_kb" "http://${ip_kb}:5601/api/status" -u 'kibana_system:testpasswd'
poll_ready "$cid_kb" 'http://kibana:5601/api/status' --resolve "kibana:5601:${ip_kb}" -u 'kibana_system:testpasswd'
endgroup

log 'Sending message to Logstash TCP input'
Expand All @@ -50,7 +50,8 @@ fi
# need to be resilient here.
was_retried=0
declare -a refresh_args=( '-X' 'POST' '-s' '-w' '%{http_code}' '-u' 'elastic:testpasswd'
"http://${ip_es}:9200/logs-generic-default/_refresh"
'http://elasticsearch:9200/logs-generic-default/_refresh'
'--resolve' "elasticsearch:9200:${ip_es}"
)

# retry for max 10s (10*1s)
Expand All @@ -75,7 +76,8 @@ log 'Searching message in Elasticsearch'
# we need to be resilient here too.
was_retried=0
declare -a search_args=( '-s' '-u' 'elastic:testpasswd'
"http://${ip_es}:9200/logs-generic-default/_search?q=message:dockerelk&pretty"
'http://elasticsearch:9200/logs-generic-default/_search?q=message:dockerelk&pretty'
'--resolve' "elasticsearch:9200:${ip_es}"
)
declare -i count
declare response
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/scripts/run-tests-enterprise-search.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ ip_es="$(service_ip elasticsearch)"
ip_en="$(service_ip enterprise-search)"

grouplog 'Wait for readiness of Elasticsearch'
poll_ready "$cid_es" "http://${ip_es}:9200/" -u 'elastic:testpasswd'
poll_ready "$cid_es" 'http://elasticsearch:9200/' --resolve "elasticsearch:9200:${ip_es}" -u 'elastic:testpasswd'
endgroup

grouplog 'Wait for readiness of Enterprise Search'
poll_ready "$cid_en" "http://${ip_en}:3002/api/ent/v1/internal/health" -u 'elastic:testpasswd'
poll_ready "$cid_en" 'http://enterprise-search:3002/api/ent/v1/internal/health' --resolve "enterprise-search:3002:${ip_en}" -u 'elastic:testpasswd'
endgroup

log 'Ensuring that App Search API keys were created in Elasticsearch'
response="$(curl "http://${ip_es}:9200/.ent-search-actastic-app_search_api_tokens_v3/_search?q=*:*&pretty" -s -u elastic:testpasswd)"
response="$(curl 'http://elasticsearch:9200/.ent-search-actastic-app_search_api_tokens_v3/_search?q=*:*&pretty' -s --resolve "elasticsearch:9200:${ip_es}" -u elastic:testpasswd)"
echo "$response"
declare -i count
count="$(jq -rn --argjson data "${response}" '$data.hits.total.value')"
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/scripts/run-tests-filebeat.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@ source "${BASH_SOURCE[0]%/*}"/lib/testing.sh


cid_es="$(container_id elasticsearch)"
cid_mb="$(container_id filebeat)"
cid_fb="$(container_id filebeat)"

ip_es="$(service_ip elasticsearch)"
ip_mb="$(service_ip filebeat)"
ip_fb="$(service_ip filebeat)"

grouplog 'Wait for readiness of Elasticsearch'
poll_ready "$cid_es" "http://${ip_es}:9200/" -u 'elastic:testpasswd'
poll_ready "$cid_es" 'http://elasticsearch:9200/' --resolve "elasticsearch:9200:${ip_es}" -u 'elastic:testpasswd'
endgroup

grouplog 'Wait for readiness of Filebeat'
poll_ready "$cid_mb" "http://${ip_mb}:5066/?pretty"
poll_ready "$cid_fb" 'http://filebeat:5066/?pretty' --resolve "filebeat:5066:${ip_fb}"
endgroup

# We expect to find log entries for the 'elasticsearch' Compose service using
Expand All @@ -37,7 +37,7 @@ declare -i was_retried=0

# retry for max 60s (30*2s)
for _ in $(seq 1 30); do
response="$(curl "http://${ip_es}:9200/filebeat-*/_search?q=agent.type:%22filebeat%22%20AND%20input.type:%22container%22%20AND%20container.name:%22docker-elk-elasticsearch-1%22&pretty" -s -u elastic:testpasswd)"
response="$(curl 'http://elasticsearch:9200/filebeat-*/_search?q=agent.type:%22filebeat%22%20AND%20input.type:%22container%22%20AND%20container.name:%22docker-elk-elasticsearch-1%22&pretty' -s --resolve "elasticsearch:9200:${ip_es}" -u elastic:testpasswd)"

set +u # prevent "unbound variable" if assigned value is not an integer
count="$(jq -rn --argjson data "${response}" '$data.hits.total.value')"
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/scripts/run-tests-fleet.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ ip_fl="$(service_ip fleet-server)"
ip_apm="$(service_ip apm-server)"

grouplog 'Wait for readiness of Elasticsearch'
poll_ready "$cid_es" "http://${ip_es}:9200/" -u 'elastic:testpasswd'
poll_ready "$cid_es" 'http://elasticsearch:9200/' --resolve "elasticsearch:9200:${ip_es}" -u 'elastic:testpasswd'
endgroup

grouplog 'Wait for readiness of Fleet Server'
poll_ready "$cid_fl" "http://${ip_fl}:8220/api/status"
poll_ready "$cid_fl" 'http://fleet-server:8220/api/status' --resolve "fleet-server:8220:${ip_fl}"
endgroup

grouplog 'Wait for readiness of APM Server'
poll_ready "$cid_apm" "http://${ip_apm}:8200/"
poll_ready "$cid_apm" 'http://apm-server:8200/' --resolve "apm-server:8200:${ip_apm}"
endgroup

# We expect to find metrics entries using the following query:
Expand All @@ -44,7 +44,7 @@ declare -i was_retried=0

# retry for max 60s (30*2s)
for _ in $(seq 1 30); do
response="$(curl "http://${ip_es}:9200/metrics-system.cpu-default/_search?q=agent.name:%22fleet-server%22%20AND%20agent.type:%22metricbeat%22%20AND%20event.module:%22system%22%20AND%20event.dataset:%22system.cpu%22%20AND%20metricset.name:%22cpu%22&pretty" -s -u elastic:testpasswd)"
response="$(curl 'http://elasticsearch:9200/metrics-system.cpu-default/_search?q=agent.name:%22fleet-server%22%20AND%20agent.type:%22metricbeat%22%20AND%20event.module:%22system%22%20AND%20event.dataset:%22system.cpu%22%20AND%20metricset.name:%22cpu%22&pretty' -s --resolve "elasticsearch:9200:${ip_es}" -u elastic:testpasswd)"

set +u # prevent "unbound variable" if assigned value is not an integer
count="$(jq -rn --argjson data "${response}" '$data.hits.total.value')"
Expand Down Expand Up @@ -87,7 +87,7 @@ was_retried=0

# retry for max 60s (30*2s)
for _ in $(seq 1 30); do
response="$(curl "http://${ip_es}:9200/logs-docker.container_logs-default/_search?q=agent.name:%22fleet-server%22%20AND%20agent.type:%22filebeat%22%20AND%20container.name:%22docker-elk-elasticsearch-1%22&pretty" -s -u elastic:testpasswd)"
response="$(curl 'http://elasticsearch:9200/logs-docker.container_logs-default/_search?q=agent.name:%22fleet-server%22%20AND%20agent.type:%22filebeat%22%20AND%20container.name:%22docker-elk-elasticsearch-1%22&pretty' -s --resolve "elasticsearch:9200:${ip_es}" -u elastic:testpasswd)"

set +u # prevent "unbound variable" if assigned value is not an integer
count="$(jq -rn --argjson data "${response}" '$data.hits.total.value')"
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/scripts/run-tests-heartbeat.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@ source "${BASH_SOURCE[0]%/*}"/lib/testing.sh


cid_es="$(container_id elasticsearch)"
cid_mb="$(container_id heartbeat)"
cid_hb="$(container_id heartbeat)"

ip_es="$(service_ip elasticsearch)"
ip_mb="$(service_ip heartbeat)"
ip_hb="$(service_ip heartbeat)"

grouplog 'Wait for readiness of Elasticsearch'
poll_ready "$cid_es" "http://${ip_es}:9200/" -u 'elastic:testpasswd'
poll_ready "$cid_es" 'http://elasticsearch:9200/' --resolve "elasticsearch:9200:${ip_es}" -u 'elastic:testpasswd'
endgroup

grouplog 'Wait for readiness of Heartbeat'
poll_ready "$cid_mb" "http://${ip_mb}:5066/?pretty"
poll_ready "$cid_hb" 'http://heartbeat:5066/?pretty' --resolve "heartbeat:5066:${ip_hb}"
endgroup

# We expect to find heartbeat entries for the 'elasticsearch' HTTP service
Expand All @@ -37,7 +37,7 @@ declare -i was_retried=0

# retry for max 60s (30*2s)
for _ in $(seq 1 30); do
response="$(curl "http://${ip_es}:9200/heartbeat-*/_search?q=agent.type:%22heartbeat%22%20AND%20monitor.type:%22http%22%20AND%20url.domain:%22elasticsearch%22&pretty" -s -u elastic:testpasswd)"
response="$(curl 'http://elasticsearch:9200/heartbeat-*/_search?q=agent.type:%22heartbeat%22%20AND%20monitor.type:%22http%22%20AND%20url.domain:%22elasticsearch%22&pretty' -s --resolve "elasticsearch:9200:${ip_es}" -u elastic:testpasswd)"

set +u # prevent "unbound variable" if assigned value is not an integer
count="$(jq -rn --argjson data "${response}" '$data.hits.total.value')"
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/scripts/run-tests-metricbeat.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ ip_es="$(service_ip elasticsearch)"
ip_mb="$(service_ip metricbeat)"

grouplog 'Wait for readiness of Elasticsearch'
poll_ready "$cid_es" "http://${ip_es}:9200/" -u 'elastic:testpasswd'
poll_ready "$cid_es" 'http://elasticsearch:9200/' --resolve "elasticsearch:9200:${ip_es}" -u 'elastic:testpasswd'
endgroup

grouplog 'Wait for readiness of Metricbeat'
poll_ready "$cid_mb" "http://${ip_mb}:5066/?pretty"
poll_ready "$cid_mb" 'http://metricbeat:5066/?pretty' --resolve "metricbeat:5066:${ip_mb}"
endgroup

# We expect to find monitoring entries for the 'elasticsearch' Compose service
Expand All @@ -38,7 +38,7 @@ declare -i was_retried=0

# retry for max 60s (30*2s)
for _ in $(seq 1 30); do
response="$(curl "http://${ip_es}:9200/metricbeat-*/_search?q=agent.type:%22metricbeat%22%20AND%20event.module:%22docker%22%20AND%20event.dataset:%22docker.container%22%20AND%20container.name:%22docker-elk-elasticsearch-1%22&pretty" -s -u elastic:testpasswd)"
response="$(curl 'http://elasticsearch:9200/metricbeat-*/_search?q=agent.type:%22metricbeat%22%20AND%20event.module:%22docker%22%20AND%20event.dataset:%22docker.container%22%20AND%20container.name:%22docker-elk-elasticsearch-1%22&pretty' -s --resolve "elasticsearch:9200:${ip_es}" -u elastic:testpasswd)"

set +u # prevent "unbound variable" if assigned value is not an integer
count="$(jq -rn --argjson data "${response}" '$data.hits.total.value')"
Expand Down

0 comments on commit e3a9d60

Please sign in to comment.