ansible-role-elasticsearch/molecule/default/tests/test_default.py

32 lines
990 B
Python

import os
import testinfra.utils.ansible_runner
def test_packages(host):
package = host.package('elasticsearch')
assert package.is_installed
def test_config_file(host):
config = host.file('/etc/elasticsearch/elasticsearch.yml')
assert config.user == 'root'
assert config.group == 'elasticsearch'
assert config.mode == 0o640
assert config.contains('path.data: /var/lib/elasticsearch')
def test_service(host):
service = host.service('elasticsearch')
assert service.is_running
assert service.is_enabled
def test_socket(host):
for port in [9200, 9300]:
socket = host.socket('tcp://127.0.0.1:%d' % (port))
assert socket.is_listening
def test_java_memory(host):
process = host.process.get(user='elasticsearch', comm='java')
assert '-Xms512m' in process.args
assert '-Xmx512m' in process.args
def test_elasticsearch_template(host):
result = host.check_output('curl -v http://127.0.0.1:9200/_template/test')
assert '"number_of_replicas":"1"' in result