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

45 lines
1.2 KiB
Python
Raw Normal View History

2020-04-11 13:16:20 +00:00
import testinfra.utils.ansible_runner
def test_packages(host):
2021-08-24 06:30:10 +00:00
for package_name in ['cron', 'gitlab-ce']:
package = host.package(package_name)
assert package.is_installed
2020-04-11 13:16:20 +00:00
2021-08-24 05:59:04 +00:00
def test_git_directory(host):
path = host.file('/opt/data/git')
assert path.exists
assert path.is_directory
2020-04-11 13:16:20 +00:00
def test_config_file(host):
config = host.file('/etc/gitlab/gitlab.rb')
assert config.exists
assert config.is_file
assert config.user == 'root'
assert config.group == 'root'
assert config.mode == 0o600
assert config.contains("external_url 'http://gitlab.example.com'")
assert config.contains("grafana\\['enable'\\] = false")
assert config.contains('label: Main AD')
2020-04-11 13:16:20 +00:00
def test_service(host):
service = host.service('gitlab-runsvdir')
assert service.is_running
assert service.is_enabled
def test_socket(host):
socket = host.socket('tcp://0.0.0.0:80')
assert socket.is_listening
def test_grafana_down(host):
try:
host.process.get(user='gitlab-prometheus', comm='grafana-server')
assert False
except:
assert True
2021-08-24 06:30:10 +00:00
def test_cron_file(host):
config = host.file('/var/spool/cron/crontabs/root')
assert config.exists
assert config.is_file
assert config.contains('30 2 \\* \\* \\* gitlab-backup create')