diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..07eb408 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,18 @@ +sudo: required + +services: + - docker + +install: + - docker build . -t openwrt-elastic:6.1.1 + +script: + - docker run -d -p 9200:9200 --restart=unless-stopped --name elasticsearch -e "xpack.security.enabled=false" openwrt-elastic:6.1.1 + - sleep 15 + - sh test/test-connection.sh + - sh test/test-send-receive-indexes.sh + + + + + diff --git a/README.md b/README.md index d321fcd..92a7666 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,14 @@ Elastic 6.1.1 as a Docker container. For development use only. +**Note that this repository is not yet linked to our Dockerhub account.** This means you'll have to build the image yourself first with: + +``` +docker build . -t mcreations/openwrt-elastic +``` + +from this repository's top directory. + + ## Quickstart Without arguments, the container starts the Elastic server: @@ -8,7 +17,7 @@ docker run -d --name elastic mcreations/openwrt-elastic ``` ## Configuration Details -the volume as /data cab be passed from outside of Docker container with -v switch. +the volume as /data can be passed from outside of Docker container with -v switch. The ports can be opened with -p switch. This is a sample command line with custom parameters: diff --git a/test/test-connection.sh b/test/test-connection.sh new file mode 100644 index 0000000..4f9bbc7 --- /dev/null +++ b/test/test-connection.sh @@ -0,0 +1,17 @@ +#!/bin/sh + +# Sometimes health tests should be repeated (especially if this is ran right after the containers come up). + +echo "first health test:" +curl http://127.0.0.1:9200/_cat/health + +sleep 4 +echo "second health test:" +curl http://127.0.0.1:9200/_cat/health + +sleep 3 +echo "third health test:" +curl http://127.0.0.1:9200/_cat/health + +echo "Indices:" +curl http://localhost:9200/_cat/indices diff --git a/test/test-send-receive-indexes.sh b/test/test-send-receive-indexes.sh new file mode 100644 index 0000000..ef241a7 --- /dev/null +++ b/test/test-send-receive-indexes.sh @@ -0,0 +1,49 @@ +#!/bin/sh + +# create a new index while posting a message to it: + +curl -XPUT 'localhost:9200/foo/tweet/1?pretty' -H 'Content-Type: application/json' -d' +{ + "user" : "kimchy", + "post_date" : "2009-11-15T14:12:12", + "message" : "trying out Elasticsearch" +} +' + +# query for this index: + +curl -XGET 'localhost:9200/twitter/tweet/1?pretty' + + +# post a second message to the index: + + +curl -XPUT 'localhost:9200/foo/tweet/2?pretty' -H 'Content-Type: application/json' -d' +{ + "title" : "Search", + "publish_date" : "2017-11-15", + "content" : "trying out Elasticsearch", + "status" : "published" +} +' + +# send a query on this index to get only the second message: + +echo "Query test:" + +curl -XGET 'localhost:9200/_search?pretty' -H 'Content-Type: application/json' -d' +{ + "query": { + "bool": { + "must": [ + { "match": { "title": "Search" }}, + { "match": { "content": "Elasticsearch" }} + ], + "filter": [ + { "term": { "status": "published" }}, + { "range": { "publish_date": { "gte": "2015-01-01" }}} + ] + } + } +} +'