Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #923 from mackerelio/improve-test
Improve test
- Loading branch information
Showing
17 changed files
with
338 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
memcached.cmd.cmd_get >=0 | ||
memcached.cmd.cmd_set >=0 | ||
memcached.cmd.cmd_flush >=0 | ||
memcached.cmd.cmd_touch >=0 | ||
memcached.hitmiss.get_hits >=0 | ||
memcached.hitmiss.get_misses >=0 | ||
memcached.hitmiss.delete_hits >=0 | ||
memcached.hitmiss.delete_misses >=0 | ||
memcached.hitmiss.incr_hits >=0 | ||
memcached.hitmiss.incr_misses >=0 | ||
memcached.hitmiss.cas_hits >=0 | ||
memcached.hitmiss.cas_misses >=0 | ||
memcached.hitmiss.touch_hits >=0 | ||
memcached.hitmiss.touch_misses >=0 | ||
memcached.rusage.rusage_user >=0 | ||
memcached.rusage.rusage_system >=0 | ||
memcached.cachesize.limit_maxbytes >=0 | ||
memcached.cachesize.bytes >=0 | ||
memcached.connections.curr_connections >=0 | ||
memcached.evictions.evictions >=0 | ||
memcached.evictions.reclaimed >=0 | ||
memcached.unfetched.expired_unfetched >=0 | ||
memcached.unfetched.evicted_unfetched >=0 | ||
memcached.bytes.bytes_read >=0 | ||
memcached.bytes.bytes_written >=0 | ||
memcached.items.curr_items >=0 | ||
memcached.items.new_items >=0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/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")" || exit | ||
PATH=$(pwd):$PATH | ||
plugin=$(basename "$(pwd)") | ||
if ! which "$plugin" >/dev/null | ||
then | ||
echo "$prog: $plugin is not installed" >&2 | ||
exit 2 | ||
fi | ||
|
||
image=memcached:1.6 | ||
port=21211 | ||
|
||
docker run --name "test-$plugin" -p $port:11211 -d $image | ||
trap 'docker stop test-$plugin; docker rm test-$plugin; exit 1' 1 2 3 15 | ||
sleep 10 | ||
|
||
# to store previous value to calculate a diff of metrics | ||
$plugin -port $port >/dev/null 2>&1 | ||
sleep 1 | ||
|
||
$plugin -port $port | graphite-metric-test -f rule.txt | ||
status=$? | ||
|
||
docker stop "test-$plugin" | ||
docker rm "test-$plugin" | ||
exit $status |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
nginx.connections.connections >=0 | ||
nginx.requests.accepts >=0 | ||
nginx.requests.handled >=0 | ||
nginx.requests.requests >=0 | ||
nginx.queue.reading >=0 | ||
nginx.queue.writing >=0 | ||
nginx.queue.waiting >=0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/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")" || exit | ||
PATH=$(pwd):$PATH | ||
plugin=$(basename "$(pwd)") | ||
if ! which "$plugin" >/dev/null | ||
then | ||
echo "$prog: $plugin is not installed" >&2 | ||
exit 2 | ||
fi | ||
|
||
image=nginx:1.23 | ||
port=20080 | ||
|
||
docker run --name "test-$plugin" -p $port:80 -v $(pwd)/testdata/nginx.conf:/etc/nginx/nginx.conf:ro -d $image | ||
trap 'docker stop test-$plugin; docker rm test-$plugin; exit 1' 1 2 3 15 | ||
sleep 10 | ||
|
||
# to store previous value to calculate a diff of metrics | ||
$plugin -port $port >/dev/null 2>&1 | ||
sleep 1 | ||
|
||
$plugin -port $port | graphite-metric-test -f rule.txt | ||
status=$? | ||
|
||
docker stop "test-$plugin" | ||
docker rm "test-$plugin" | ||
exit $status |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
|
||
user nginx; | ||
worker_processes auto; | ||
|
||
error_log /var/log/nginx/error.log notice; | ||
pid /var/run/nginx.pid; | ||
|
||
|
||
events { | ||
worker_connections 1024; | ||
} | ||
|
||
|
||
http { | ||
include /etc/nginx/mime.types; | ||
default_type application/octet-stream; | ||
|
||
log_format main '$remote_addr - $remote_user [$time_local] "$request" ' | ||
'$status $body_bytes_sent "$http_referer" ' | ||
'"$http_user_agent" "$http_x_forwarded_for"'; | ||
|
||
access_log /var/log/nginx/access.log main; | ||
|
||
sendfile on; | ||
#tcp_nopush on; | ||
|
||
keepalive_timeout 65; | ||
|
||
#gzip on; | ||
|
||
server { | ||
listen 80; | ||
server_name localhost; | ||
|
||
location / { | ||
root /usr/share/nginx/html; | ||
index index.html index.htm; | ||
} | ||
|
||
location = /nginx_status { | ||
stub_status; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
plack.workers.busy_workers >=0 | ||
plack.workers.idle_workers >=0 | ||
plack.req.requests >=0 | ||
plack.bytes.bytes_sent >=0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/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")" || exit | ||
PATH=$(pwd):$PATH | ||
plugin=$(basename "$(pwd)") | ||
if ! which "$plugin" >/dev/null | ||
then | ||
echo "$prog: $plugin is not installed" >&2 | ||
exit 2 | ||
fi | ||
|
||
image=local/test-$plugin | ||
port=5000 | ||
|
||
docker build -t $image testdata/ | ||
|
||
docker run --name "test-$plugin" -p $port:5000 -d $image | ||
trap 'docker stop test-$plugin; docker rm test-$plugin; exit 1' 1 2 3 15 | ||
sleep 10 | ||
|
||
# to store previous value to calculate a diff of metrics | ||
$plugin -port $port >/dev/null 2>&1 | ||
sleep 1 | ||
|
||
$plugin -port $port | graphite-metric-test -f rule.txt | ||
status=$? | ||
|
||
docker stop "test-$plugin" | ||
docker rm "test-$plugin" | ||
exit $status |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
FROM perl:5.36 | ||
|
||
COPY . /usr/src/myapp | ||
WORKDIR /usr/src/myapp | ||
|
||
RUN cpm install -v | ||
|
||
EXPOSE 5000 | ||
|
||
ENV PERL5LIB /usr/src/myapp/local/lib/perl5 | ||
ENV PATH $PATH:/usr/src/myapp/local/bin/ | ||
|
||
CMD [ "plackup", "app.psgi" ] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/usr/bin/env perl | ||
|
||
use strict; | ||
use warnings; | ||
use utf8; | ||
|
||
use Plack::Builder; | ||
|
||
builder { | ||
enable "Plack::Middleware::ServerStatus::Lite", | ||
path => '/server-status', | ||
allow => [ '0.0.0.0/0' ], | ||
counter_file => '/tmp/counter_file', | ||
scoreboard => '/var/run/server'; | ||
|
||
sub { | ||
[200, ["Content-Type" => "text/plain"], "ok"]; | ||
} | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
requires "Plack", ">= 1.0048"; | ||
requires "Plack::Middleware::ServerStatus::Lite", "0.36"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
snmp.hrSystemNumUsers >=0 | ||
snmp.hrSystemProcesses >=0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#!/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")" || exit | ||
PATH=$(pwd):$PATH | ||
plugin=$(basename "$(pwd)") | ||
if ! which "$plugin" >/dev/null | ||
then | ||
echo "$prog: $plugin is not installed" >&2 | ||
exit 2 | ||
fi | ||
|
||
image=local/test-$plugin | ||
# mackerel-plugin-snmp is disallowed --port option. | ||
port=161 | ||
|
||
docker build -t $image testdata/ | ||
|
||
docker run --name "test-$plugin" -v $(pwd)/testdata/snmpd.conf:/etc/snmp/snmpd.conf:ro -p $port:161/udp -d $image | ||
trap 'docker stop test-$plugin; docker rm test-$plugin; exit 1' 1 2 3 15 | ||
sleep 10 | ||
|
||
$plugin '.1.3.6.1.2.1.25.1.5.0:hrSystemNumUsers:0:0' '.1.3.6.1.2.1.25.1.6.0:hrSystemProcesses:0:0' | graphite-metric-test -f rule.txt | ||
status=$? | ||
|
||
docker stop "test-$plugin" | ||
docker rm "test-$plugin" | ||
exit $status |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
FROM alpine:3.16 | ||
|
||
RUN apk add --update net-snmp net-snmp-tools | ||
|
||
EXPOSE 161 | ||
|
||
CMD ["snmpd", "-V", "-f", "-c", "/etc/snmp/snmpd.conf"] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
view systemonly included .1.3.6.1.2.1.1 | ||
view systemonly included .1.3.6.1.2.1.25.1 | ||
|
||
rocommunity public default -V systemonly |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
squid.cache_storage_usage.swap_used_ratio >=0 | ||
squid.cache_storage_usage.memory_used_ratio >=0 | ||
squid.file_descriptor_usage.total_fd >=0 | ||
squid.file_descriptor_usage.max_fd >=0 | ||
squid.file_descriptor_usage.current_fd >=0 | ||
squid.file_descriptor_usage.avail_fd >=0 | ||
squid.file_descriptor_usage.reserved_fd >=0 | ||
squid.file_descriptor_usage.open_files >=0 | ||
squid.file_descriptor_usage.queued_files >=0 | ||
squid.memory_account_for.memory_poll_alloc >=0 | ||
squid.memory_account_for.memory_poll_free >=0 | ||
squid.requests.requests >=0 | ||
squid.cache_hit_ratio.5min.request_ratio >=0 | ||
squid.cpu_usage_ratio.5min.cpu_usage >=0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/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")" || exit | ||
PATH=$(pwd):$PATH | ||
plugin=$(basename "$(pwd)") | ||
if ! which "$plugin" >/dev/null | ||
then | ||
echo "$prog: $plugin is not installed" >&2 | ||
exit 2 | ||
fi | ||
|
||
image=ubuntu/squid:5.2-22.04_beta | ||
port=13128 | ||
|
||
docker run --name "test-$plugin" -p $port:3128 -v $(pwd)/testdata/squid.conf:/etc/squid/squid.conf:ro -d $image | ||
trap 'docker stop test-$plugin; docker rm test-$plugin; exit 1' 1 2 3 15 | ||
sleep 10 | ||
|
||
# to store previous value to calculate a diff of metrics | ||
$plugin -port $port >/dev/null 2>&1 | ||
sleep 1 | ||
|
||
$plugin -port $port | graphite-metric-test -f rule.txt | ||
status=$? | ||
|
||
docker stop "test-$plugin" | ||
docker rm "test-$plugin" | ||
exit $status |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
acl localnet src 0.0.0.1-0.255.255.255 # RFC 1122 "this" network (LAN) | ||
acl localnet src 10.0.0.0/8 # RFC 1918 local private network (LAN) | ||
acl localnet src 100.64.0.0/10 # RFC 6598 shared address space (CGN) | ||
acl localnet src 169.254.0.0/16 # RFC 3927 link-local (directly plugged) machines | ||
acl localnet src 172.16.0.0/12 # RFC 1918 local private network (LAN) | ||
acl localnet src 192.168.0.0/16 # RFC 1918 local private network (LAN) | ||
acl localnet src fc00::/7 # RFC 4193 local private network range | ||
acl localnet src fe80::/10 # RFC 4291 link-local (directly plugged) machines | ||
|
||
http_access allow localnet manager | ||
http_access deny manager | ||
|
||
http_access allow localnet | ||
http_access deny all | ||
|
||
http_port 3128 |