Skip to content

Commit

Permalink
added test for elasticsearch
Browse files Browse the repository at this point in the history
  • Loading branch information
yseto committed Nov 9, 2022
1 parent b58e6bd commit 7ed7450
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 0 deletions.
36 changes: 36 additions & 0 deletions mackerel-plugin-elasticsearch/rule.txt
@@ -0,0 +1,36 @@
elasticsearch.indices.memory_size.fielddata_size >=0
elasticsearch.indices.memory_size.segments_size >=0
elasticsearch.indices.memory_size.segments_index_writer_size >=0
elasticsearch.indices.memory_size.segments_version_map_size >=0
elasticsearch.indices.memory_size.segments_fixed_bit_set_size >=0
elasticsearch.jvm.heap.heap_used >=0
elasticsearch.jvm.heap.heap_max >=0
elasticsearch.thread_pool.threads.threads_generic >=0
elasticsearch.thread_pool.threads.threads_get >=0
elasticsearch.thread_pool.threads.threads_snapshot >=0
elasticsearch.thread_pool.threads.threads_warmer >=0
elasticsearch.thread_pool.threads.threads_flush >=0
elasticsearch.thread_pool.threads.threads_search >=0
elasticsearch.thread_pool.threads.threads_refresh >=0
elasticsearch.thread_pool.threads.threads_management >=0
elasticsearch.thread_pool.threads.threads_fetch_shard_started >=0
elasticsearch.thread_pool.threads.threads_fetch_shard_store >=0
elasticsearch.process.open_file_descriptors >=0
elasticsearch.indices.docs.docs_count >=0
elasticsearch.indices.docs.docs_deleted >=0
elasticsearch.http.http_opened >=0
elasticsearch.indices.total_indexing_index >=0
elasticsearch.indices.total_indexing_delete >=0
elasticsearch.indices.total_get >=0
elasticsearch.indices.total_search_query >=0
elasticsearch.indices.total_search_fetch >=0
elasticsearch.indices.total_merges >=0
elasticsearch.indices.total_refresh >=0
elasticsearch.indices.total_flush >=0
elasticsearch.indices.total_warmer >=0
elasticsearch.transport.count.count_rx >=0
elasticsearch.transport.count.count_tx >=0
elasticsearch.indices.evictions.evictions_fielddata >=0
elasticsearch.script.compilations >=0
elasticsearch.script.cache_evictions >=0
elasticsearch.script.compilation_limit_triggered >=0
39 changes: 39 additions & 0 deletions mackerel-plugin-elasticsearch/test.sh
@@ -0,0 +1,39 @@
#!/bin/sh

prog=$(basename $0)
if ! [ -S /var/run/docker.sock ]
then
echo "$prog: there are no running docker" >&2
exit 2
fi

cd $(dirname $0)
PATH=$(pwd):$PATH
plugin=$(basename $(pwd))
if ! which $plugin >/dev/null
then
echo "$prog: $plugin is not installed" >&2
exit 2
fi

password=passpass
port=9200
docker run -d \
--name test-$plugin \
-p $port:$port \
-e "ELASTIC_PASSWORD=$password" \
-e "discovery.type=single-node" \
-e "ingest.geoip.downloader.enabled=false" \
elasticsearch:8.5.0
trap 'docker stop test-$plugin; docker rm test-$plugin; exit' EXIT
sleep 60

# to store previous value to calculate a diff of metrics
$plugin -scheme https -port $port -user=elastic -password $password -insecure -suppress-missing-error >/dev/null 2>&1
sleep 1
$plugin -scheme https -port $port -user=elastic -password $password -insecure -suppress-missing-error | graphite-metric-test -f rule.txt
status=$?

docker stop "test-$plugin"
docker rm "test-$plugin"
exit $status

0 comments on commit 7ed7450

Please sign in to comment.