Skip to content

Instantly share code, notes, and snippets.

@till
Created November 10, 2019 12:35
Show Gist options
  • Save till/8db35d9f522af20ddbfa752471861230 to your computer and use it in GitHub Desktop.
Save till/8db35d9f522af20ddbfa752471861230 to your computer and use it in GitHub Desktop.
Debuggable TestInfra
import os
import testinfra.utils.ansible_runner
testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
os.environ['MOLECULE_INVENTORY_FILE']
).get_hosts('all')
def get_docker_services(host):
return host.check_output("docker service ls")
def test_service_is_installed_and_global(host, capsys):
services = get_docker_services(host)
with capsys.disabled():
print(services)
assert services.find("service-name")
assert services.find("global")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment