Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added tests and .travis-ci.org #3

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -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





11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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:

Expand All @@ -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:
Expand Down
17 changes: 17 additions & 0 deletions test/test-connection.sh
Original file line number Diff line number Diff line change
@@ -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
49 changes: 49 additions & 0 deletions test/test-send-receive-indexes.sh
Original file line number Diff line number Diff line change
@@ -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" }}}
]
}
}
}
'