sudo: required
language: bash
services: docker

before_install:
- sudo sysctl -w vm.max_map_count=262144
# Docker for elk:
- docker build -t elk_image .

- docker images
- docker run -p 5601:5601 -p 9200:9200 -p 5044:5044 -p 6379:6379 -d --name elk_container elk_image
- travis_wait 30

- docker exec -it elk_container echo hello world
- docker exec -it elk_container /opt/logstash/bin/logstash --version
- docker exec -it elk_container setfacl -m u:logstash:r /var/log/{syslog,auth.log}
- docker exec -it elk_container  service logstash restart
- docker exec -it elk_container /opt/logstash/bin/logstash --config.test_and_exit -f /etc/logstash/conf.d/indexing.conf/ 
- docker exec -it elk_container redis-server --version 
#- docker exec -it elk_container /opt/logstash/bin/logstash -f /etc/logstash/conf.d/indexing.conf/  

# Docker for shipper:
#- docker build -t shipper_image shipper/.
#- docker run -p  6379:6379 -d --name shipper_container shipper_image
#- docker exec -it shipper_container service logstash restart

- docker ps -a
# HardWare Usage:
- echo HardWare Usage
- cat /proc/cpuinfo | grep 'model name' | uniq
- cat /proc/cpuinfo | grep processor
- sudo lshw -c memory
- sudo df -h
# Network Information
- echo Network Information
- current_ip="$(curl --silent --show-error --fail ipecho.net/plain)"
- echo "Public IP :$current_ip"
- ifconfig 
script:
# Elastic Search TEST
- echo Elastic Search TEST
- wget -q --waitretry=1 --retry-connrefused -T 10 -O - http://127.0.0.1:9200
- curl  http://127.0.0.1:9200
- curl  http://127.0.0.1:6379
- curl  curl -XGET 'localhost:9200/?pretty'
# Checking the cluster health
- echo Checking the cluster health
- curl 'localhost:9200/_cat/health?v'
- curl 'localhost:9200/_cat/nodes?v'
- curl 'localhost:9200/_cat/indices?v'


# Creating an Index
- echo Creating an Index
- curl -XPUT 'localhost:9200/customer?pretty'
- curl 'localhost:9200/_cat/indices?v'

- curl -XPUT  'localhost:9200/customer/external/1?pretty'  -d '{"name":"ramin rostami"}'
- curl -XGET 'localhost:9200/customer/external/1?pretty'
- curl -XDELETE 'localhost:9200/customer?pretty'
- curl 'localhost:9200/_cat/indices?v'
- curl -XPOST 'localhost:9200/customer/external?pretty' -d '{"name":"ramin rostami"}'
- curl -XPOST 'localhost:9200/customer/external?pretty' -d '{"name":"masood rostami"}'
- curl 'localhost:9200/_cat/indices?v'
- curl -XGET 'localhost:9200/_search?pretty'
- curl -XPOST http://localhost:9200/customer/external/_search?pretty -d '{"query":{"match_all":{}}}'