From 93d219c2b60a956a35953ce73abbef140d9a8efa Mon Sep 17 00:00:00 2001 From: yseto Date: Wed, 9 Nov 2022 19:03:32 +0900 Subject: [PATCH] added test for elasticsearch --- mackerel-plugin-elasticsearch/rule.txt | 36 ++++++++++++++++++++++++ mackerel-plugin-elasticsearch/test.sh | 39 ++++++++++++++++++++++++++ 2 files changed, 75 insertions(+) create mode 100644 mackerel-plugin-elasticsearch/rule.txt create mode 100755 mackerel-plugin-elasticsearch/test.sh diff --git a/mackerel-plugin-elasticsearch/rule.txt b/mackerel-plugin-elasticsearch/rule.txt new file mode 100644 index 000000000..fa7cf891a --- /dev/null +++ b/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 diff --git a/mackerel-plugin-elasticsearch/test.sh b/mackerel-plugin-elasticsearch/test.sh new file mode 100755 index 000000000..38a8c559a --- /dev/null +++ b/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 40 + +# 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