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

49 lines
1.2 KiB
Python
Raw Normal View History

2021-08-18 12:38:32 +00:00
import testinfra.utils.ansible_runner
2023-09-07 08:36:42 +00:00
CURL = ('curl --header "Authorization: Token SuP3rS3cr3t"'
' http://localhost:8086/api/v2')
2021-08-18 12:38:32 +00:00
def test_packages(host):
2023-09-07 08:36:42 +00:00
package = host.package('influxdb2')
assert package.is_installed
2021-08-18 12:38:32 +00:00
def test_service(host):
2023-09-07 08:36:42 +00:00
service = host.service('influxdb')
assert service.is_running
assert service.is_enabled
2021-08-18 12:38:32 +00:00
def test_sockets(host):
2023-09-07 08:36:42 +00:00
socket = host.socket('tcp://0.0.0.0:8086')
assert socket.is_listening
2021-08-18 12:38:32 +00:00
def test_users(host):
2023-09-07 08:36:42 +00:00
cmd = host.run('{}/users -X GET'.format(CURL))
assert cmd.succeeded
assert '"name": "admin"' in cmd.stdout
assert '"name": "telegraf"' in cmd.stdout
def test_org(host):
cmd = host.run('{}/orgs -X GET'.format(CURL))
assert cmd.succeeded
assert '"name": "neworg"' in cmd.stdout
assert '"name": "init_org"' not in cmd.stdout
def test_bucket(host):
cmd = host.run('{}/buckets -X GET'.format(CURL))
assert cmd.succeeded
assert '"name": "mybucket"' in cmd.stdout
assert '"everySeconds": 3600' in cmd.stdout
assert '"name": "test"' not in cmd.stdout
def test_auth(host):
cmd = host.run('{}/authorizations -X GET'.format(CURL))
assert cmd.succeeded
assert '"description": "write telegraf"' in cmd.stdout