Create release-7.x branch for Elastic 7.x series

This commit is contained in:
Antoine Cotten
2022-02-28 15:28:06 +01:00
parent 3af413695d
commit 5529d6ea1c
41 changed files with 170 additions and 422 deletions

View File

@@ -0,0 +1,23 @@
#!/usr/bin/expect -f
# List of expected users with dummy password
set user "(elastic|apm_system|kibana_system|logstash_system|beats_system|remote_monitoring_user)"
set password "testpasswd"
# Find elasticsearch container id
set cid [exec docker ps -q -f label=com.docker.compose.service=elasticsearch]
set cmd "docker exec -it $cid bin/elasticsearch-setup-passwords interactive -s -b -u http://localhost:9200"
spawn {*}$cmd
expect {
-re "(E|Ree)nter password for \\\[$user\\\]: " {
send "$password\r"
exp_continue
}
eof
}
lassign [wait] pid spawnid os_error_flag value
exit $value

View File

@@ -27,6 +27,25 @@ grouplog 'Wait for readiness of Kibana'
poll_ready "$cid_kb" 'http://kibana:5601/api/status' --resolve "kibana:5601:${ip_kb}" -u 'kibana_system:testpasswd'
endgroup
log 'Creating Logstash index pattern in Kibana'
source .env
curl -X POST -D- "http://${ip_kb}:5601/api/saved_objects/index-pattern" \
-s -w '\n' \
-H 'Content-Type: application/json' \
-H "kbn-version: ${ELASTIC_VERSION}" \
-u elastic:testpasswd \
-d '{"attributes":{"title":"logstash-*","timeFieldName":"@timestamp"}}'
log 'Searching index pattern via Kibana API'
response="$(curl "http://${ip_kb}:5601/api/saved_objects/_find?type=index-pattern" -s -u elastic:testpasswd)"
echo "$response"
declare -i count
count="$(jq -rn --argjson data "${response}" '$data.total')"
if (( count != 1 )); then
echo "Expected 1 index pattern, got ${count}"
exit 1
fi
log 'Sending message to Logstash TCP input'
declare -i was_retried=0
@@ -47,7 +66,7 @@ if ((was_retried)); then
fi
declare -a refresh_args=( '-X' 'POST' '-s' '-w' '%{http_code}' '-u' 'elastic:testpasswd'
'http://elasticsearch:9200/logs-generic-default/_refresh'
'http://elasticsearch:9200/logstash-*/_refresh'
'--resolve' "elasticsearch:9200:${ip_es}"
)
@@ -87,7 +106,7 @@ EOD
)
declare -a search_args=( '-s' '-u' 'elastic:testpasswd'
'http://elasticsearch:9200/logs-generic-default/_search?pretty'
'http://elasticsearch:9200/logstash-*/_search?pretty'
'--resolve' "elasticsearch:9200:${ip_es}"
'-H' 'Content-Type: application/json'
'-d' "${query}"

View File

@@ -107,72 +107,3 @@ if (( count == 0 )); then
echo 'Expected at least 1 document'
exit 1
fi
log 'Searching a container document generated by Fleet Server'
query=$( (IFS= read -r -d '' data || echo "$data" | jq -c) <<EOD
{
"query": {
"bool": {
"must": [
{
"term": {
"agent.name": "fleet-server"
}
},
{
"term": {
"agent.type": "filebeat"
}
},
{
"term": {
"container.name": "docker-elk-elasticsearch-1"
}
}
]
}
}
}
EOD
)
search_args=( '-s' '-u' 'elastic:testpasswd'
'http://elasticsearch:9200/logs-docker.container_logs-default/_search?size=1&pretty'
'--resolve' "elasticsearch:9200:${ip_es}"
'-H' 'Content-Type: application/json'
'-d' "${query}"
)
response=
count=0
echo "curl arguments: ${search_args[*]}"
was_retried=0
# retry for max 60s (30*2s)
for _ in $(seq 1 30); do
response="$(curl "${search_args[@]}")"
set +u # prevent "unbound variable" if assigned value is not an integer
count="$(jq -rn --argjson data "${response}" '$data.hits.total.value')"
set -u
if (( count > 0 )); then
break
fi
was_retried=1
echo -n 'x' >&2
sleep 2
done
if ((was_retried)); then
# flush stderr, important in non-interactive environments (CI)
echo >&2
fi
echo "$response"
if (( count == 0 )); then
echo 'Expected at least 1 document'
exit 1
fi