mirror of
https://codeberg.org/scip/esctl.git
synced 2026-08-24 15:24:17 +02:00
add more tests
This commit is contained in:
5
Makefile
5
Makefile
@@ -62,9 +62,8 @@ install: buildlocal
|
|||||||
clean:
|
clean:
|
||||||
rm -rf $(tool) coverage.out testdata t/out pkg/es/openspec.go
|
rm -rf $(tool) coverage.out testdata t/out pkg/es/openspec.go
|
||||||
|
|
||||||
test: clean
|
test: clean buildlocal
|
||||||
mkdir -p t/out
|
make -C t test
|
||||||
go test ./... $(ARGS)
|
|
||||||
|
|
||||||
testlint: test lint
|
testlint: test lint
|
||||||
|
|
||||||
|
|||||||
15
t/.env
15
t/.env
@@ -1,19 +1,6 @@
|
|||||||
# Password for the 'elastic' user (at least 6 characters)
|
ES_PASS=tuscador1
|
||||||
ELASTIC_PASSWORD=tuscador1
|
|
||||||
|
|
||||||
# Version of Elastic products
|
|
||||||
STACK_VERSION=9.4.2
|
STACK_VERSION=9.4.2
|
||||||
|
|
||||||
# Set the cluster name
|
|
||||||
CLUSTER_NAME=domdoc
|
CLUSTER_NAME=domdoc
|
||||||
|
|
||||||
# Set to 'basic' or 'trial' to automatically start the 30-day trial
|
|
||||||
LICENSE=basic
|
LICENSE=basic
|
||||||
#LICENSE=trial
|
|
||||||
|
|
||||||
# Port to expose Elasticsearch HTTP API to the host
|
|
||||||
ES_PORT=9200
|
ES_PORT=9200
|
||||||
#ES_PORT=127.0.0.1:9200
|
|
||||||
|
|
||||||
# Increase or decrease based on the available host memory (in bytes)
|
|
||||||
MEM_LIMIT=1073741824
|
MEM_LIMIT=1073741824
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ clean-docker: down delete
|
|||||||
|
|
||||||
|
|
||||||
# mosscap esctl stuff
|
# mosscap esctl stuff
|
||||||
test: up waitup cluster docs search
|
test: up waitup cluster docs wait search
|
||||||
|
|
||||||
cluster:
|
cluster:
|
||||||
@echo "setting up elastisearch cluster"
|
@echo "setting up elastisearch cluster"
|
||||||
@@ -31,9 +31,12 @@ docs:
|
|||||||
@echo "put some docs"
|
@echo "put some docs"
|
||||||
mosscap msc-actions.yaml msc-docs.yaml -n -c 1000 -p 100
|
mosscap msc-actions.yaml msc-docs.yaml -n -c 1000 -p 100
|
||||||
|
|
||||||
|
wait:
|
||||||
|
sleep 10
|
||||||
|
|
||||||
search:
|
search:
|
||||||
@echo "make some searches"
|
@echo "make some searches"
|
||||||
mosscap msc-actions.yaml msc-search.yaml -n
|
mosscap msc-actions.yaml msc-search.yaml -n -t 60
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
@echo "cleaning up cluster"
|
@echo "cleaning up cluster"
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ The following is required:
|
|||||||
|
|
||||||
- linux, any distro will do
|
- linux, any distro will do
|
||||||
- docker in a decent version
|
- docker in a decent version
|
||||||
- [mosscap](https://codeberg.org/scip/mosscap)
|
- [mosscap](https://codeberg.org/scip/mosscap) version `0.0.17` or higher.
|
||||||
|
|
||||||
# Docker
|
# Docker
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,5 @@ clusters:
|
|||||||
docker/domdoc:
|
docker/domdoc:
|
||||||
uri: https://elastic:9200
|
uri: https://elastic:9200
|
||||||
user: elastic
|
user: elastic
|
||||||
pass: tuscador1
|
|
||||||
token: ""
|
token: ""
|
||||||
default: false
|
default: false
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ services:
|
|||||||
user: "0"
|
user: "0"
|
||||||
command: >
|
command: >
|
||||||
bash -c '
|
bash -c '
|
||||||
if [ x${ELASTIC_PASSWORD} == x ]; then
|
if [ x${ES_PASS} == x ]; then
|
||||||
echo "Set the ELASTIC_PASSWORD environment variable in the .env file";
|
echo "Set the ES_PASS environment variable in the .env file";
|
||||||
exit 1;
|
exit 1;
|
||||||
fi;
|
fi;
|
||||||
if [ ! -f config/certs/ca.zip ]; then
|
if [ ! -f config/certs/ca.zip ]; then
|
||||||
@@ -70,7 +70,7 @@ services:
|
|||||||
- cluster.name=${CLUSTER_NAME}
|
- cluster.name=${CLUSTER_NAME}
|
||||||
- cluster.initial_master_nodes=es01
|
- cluster.initial_master_nodes=es01
|
||||||
- discovery.seed_hosts=es02
|
- discovery.seed_hosts=es02
|
||||||
- ELASTIC_PASSWORD=${ELASTIC_PASSWORD}
|
- ELASTIC_PASSWORD=${ES_PASS}
|
||||||
- bootstrap.memory_lock=true
|
- bootstrap.memory_lock=true
|
||||||
- xpack.security.enabled=true
|
- xpack.security.enabled=true
|
||||||
- xpack.security.http.ssl.enabled=true
|
- xpack.security.http.ssl.enabled=true
|
||||||
@@ -117,7 +117,7 @@ services:
|
|||||||
- cluster.name=${CLUSTER_NAME}
|
- cluster.name=${CLUSTER_NAME}
|
||||||
- cluster.initial_master_nodes=es01,es02
|
- cluster.initial_master_nodes=es01,es02
|
||||||
- discovery.seed_hosts=es01
|
- discovery.seed_hosts=es01
|
||||||
- ELASTIC_PASSWORD=${ELASTIC_PASSWORD}
|
- ELASTIC_PASSWORD=${ES_PASS}
|
||||||
- bootstrap.memory_lock=true
|
- bootstrap.memory_lock=true
|
||||||
- xpack.security.enabled=true
|
- xpack.security.enabled=true
|
||||||
- xpack.security.http.ssl.enabled=true
|
- xpack.security.http.ssl.enabled=true
|
||||||
@@ -163,7 +163,7 @@ services:
|
|||||||
- cluster.name=${CLUSTER_NAME}
|
- cluster.name=${CLUSTER_NAME}
|
||||||
- cluster.initial_master_nodes=es01,es03
|
- cluster.initial_master_nodes=es01,es03
|
||||||
- discovery.seed_hosts=es01
|
- discovery.seed_hosts=es01
|
||||||
- ELASTIC_PASSWORD=${ELASTIC_PASSWORD}
|
- ELASTIC_PASSWORD=${ES_PASS}
|
||||||
- bootstrap.memory_lock=true
|
- bootstrap.memory_lock=true
|
||||||
- xpack.security.enabled=true
|
- xpack.security.enabled=true
|
||||||
- xpack.security.http.ssl.enabled=true
|
- xpack.security.http.ssl.enabled=true
|
||||||
|
|||||||
@@ -26,13 +26,25 @@ actions:
|
|||||||
cluster_status: |
|
cluster_status: |
|
||||||
[[.esctl]] cluster status | grep green
|
[[.esctl]] cluster status | grep green
|
||||||
|
|
||||||
|
create_ilm: |
|
||||||
|
[[.esctl]] ilm create --hot-rollover-max-age 7d \
|
||||||
|
--hot-rollover-max-primary-shard-size 25g \
|
||||||
|
--warm-min-age 0 \
|
||||||
|
--delete-min-age 14d [[.policy]]
|
||||||
|
|
||||||
|
describe_ilm: |
|
||||||
|
[[.esctl]] ilm show [[.policy]] -t | grep -E "rollover when storage > 25g"
|
||||||
|
|
||||||
create_index_template: |
|
create_index_template: |
|
||||||
[[.esctl]] index template create [[.index]] -i [[.index]] \
|
[[.esctl]] index template create [[.index]] -i [[.index]] \
|
||||||
-s number_of_shards:3 \
|
-s number_of_shards:3 \
|
||||||
-s index.sort.field:@timestamp \
|
-s index.sort.field:@timestamp \
|
||||||
-r 1m \
|
-r 1m --ilm-policy [[.policy]] \
|
||||||
user:keyword message:text @timestamp:date
|
user:keyword message:text @timestamp:date
|
||||||
|
|
||||||
|
describe_index_template: |
|
||||||
|
[[.esctl]] index template show [[.index]] | grep -E "index.sort.field.*@timestamp"
|
||||||
|
|
||||||
create_index: |
|
create_index: |
|
||||||
[[.esctl]] index create -s 2 -r 2 [[.index]]
|
[[.esctl]] index create -s 2 -r 2 [[.index]]
|
||||||
|
|
||||||
@@ -57,7 +69,7 @@ actions:
|
|||||||
doc_add: |
|
doc_add: |
|
||||||
[[.esctl]] doc add -i [[.index]] '{"user": "[[.user]]", "message":"[[.message]]", "@timestamp":"[[.ts]]"}'
|
[[.esctl]] doc add -i [[.index]] '{"user": "[[.user]]", "message":"[[.message]]", "@timestamp":"[[.ts]]"}'
|
||||||
|
|
||||||
search: |
|
search_any: |
|
||||||
[[.esctl]] search -i [[.index]] -l 1 | jq .source.message
|
[[.esctl]] search -i [[.index]] -l 1 | jq .source.message
|
||||||
|
|
||||||
search_date: |
|
search_date: |
|
||||||
@@ -66,3 +78,19 @@ actions:
|
|||||||
search_count: |
|
search_count: |
|
||||||
[[.esctl]] search -i [[.index]] -l 5000 | wc -l | grep 1000
|
[[.esctl]] search -i [[.index]] -l 5000 | wc -l | grep 1000
|
||||||
|
|
||||||
|
search_content: |
|
||||||
|
[[.esctl]] search -i [[.index]] [[.content_pattern]] -l 1 | jq .source.message
|
||||||
|
|
||||||
|
search_content_and: |
|
||||||
|
[[.esctl]] search -i [[.index]] [[.content_and_pattern]] -l 1 | jq .source.message
|
||||||
|
|
||||||
|
nodes: |
|
||||||
|
[[.esctl]] node ls | grep es01
|
||||||
|
|
||||||
|
describe_node: |
|
||||||
|
[[.esctl]] node show [[.node]] | grep "Node version"
|
||||||
|
|
||||||
|
license: |
|
||||||
|
[[.esctl]] license show | grep -E "Expires.*never"
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -7,17 +7,31 @@ items:
|
|||||||
|
|
||||||
vars:
|
vars:
|
||||||
index: test
|
index: test
|
||||||
|
node: es01
|
||||||
|
policy: testpolicy
|
||||||
|
|
||||||
tasks:
|
tasks:
|
||||||
- name: ls
|
- name: ls
|
||||||
action: cluster_ls
|
action: cluster_ls
|
||||||
|
|
||||||
|
- name: license
|
||||||
|
action: license
|
||||||
|
|
||||||
- name: status
|
- name: status
|
||||||
action: cluster_status
|
action: cluster_status
|
||||||
|
|
||||||
|
- name: ilm
|
||||||
|
action: create_ilm
|
||||||
|
|
||||||
|
- name: check_ilm
|
||||||
|
action: describe_ilm
|
||||||
|
|
||||||
- name: template
|
- name: template
|
||||||
action: create_index_template
|
action: create_index_template
|
||||||
|
|
||||||
|
- name: check_template
|
||||||
|
action: describe_index_template
|
||||||
|
|
||||||
- name: index
|
- name: index
|
||||||
action: create_index
|
action: create_index
|
||||||
|
|
||||||
@@ -26,3 +40,9 @@ tasks:
|
|||||||
|
|
||||||
- name: describe
|
- name: describe
|
||||||
action: describe_index
|
action: describe_index
|
||||||
|
|
||||||
|
- name: nodes
|
||||||
|
action: nodes
|
||||||
|
|
||||||
|
- name: check_node
|
||||||
|
action: describe_node
|
||||||
|
|||||||
@@ -14,5 +14,8 @@ tasks:
|
|||||||
|
|
||||||
generate:
|
generate:
|
||||||
user: $name
|
user: $name
|
||||||
message: "$rand $rand $rand"
|
# will become something like:
|
||||||
|
# "content34 iBAXQ2Va Ko5gMwwu FEH2O99B"
|
||||||
|
# so we can search for "content3*" and get multiple matches
|
||||||
|
message: "content$int8 $rand make$int8 $rand"
|
||||||
|
|
||||||
|
|||||||
@@ -5,22 +5,27 @@ items:
|
|||||||
|
|
||||||
vars:
|
vars:
|
||||||
index: test
|
index: test
|
||||||
time: 5s
|
time: 10s
|
||||||
|
content_pattern: "content3*"
|
||||||
|
content_and_pattern: "content3* make"
|
||||||
|
|
||||||
tasks:
|
tasks:
|
||||||
- name: today
|
- name: today
|
||||||
action: date
|
action: date
|
||||||
|
|
||||||
- name: search
|
- name: search_any
|
||||||
action: search
|
action: search_any
|
||||||
|
|
||||||
- name: date
|
- name: date
|
||||||
action: search_date
|
action: search_date
|
||||||
args:
|
args:
|
||||||
today: today.result
|
today: today.result
|
||||||
|
|
||||||
- name: wait
|
|
||||||
action: wait
|
|
||||||
|
|
||||||
- name: count
|
- name: count
|
||||||
action: search_count
|
action: search_count
|
||||||
|
|
||||||
|
- name: content
|
||||||
|
action: search_content
|
||||||
|
|
||||||
|
- name: content_and
|
||||||
|
action: search_content_and
|
||||||
|
|||||||
Reference in New Issue
Block a user