Questions tagged [testinfra]

testinfra is an extension to py.test framework to create infrastructure level testing. It provides means of connection to server and corresponding fixtures for server testing.

16 questions
7
votes
2 answers

Using Ansible variables in testinfra

Using TestInfra with Ansible backend for testing purposes. Everything goes fine except using Ansible itself while running tests test.py import pytest def test_zabbix_agent_package(host): package = host.package("zabbix-agent") assert…
FRC
  • 475
  • 1
  • 8
  • 16
5
votes
0 answers

Accessing Ansible variables in molecule test, TestInfra

I picked up molecule while researching around inspec and how to use it in ansible. I found molecule very cool and adopted it. I wanted to use it in 2 ways. 1- When developing a role or playbook 2- After a particular playbook have been run on…
black sensei
  • 6,528
  • 22
  • 109
  • 188
2
votes
0 answers

Relative import in the directory with dash in the name

I'm trying to build a test system with pytest/testinfra, and I use Python's relative imports to move settings from tests into a separate file (settings.py or __init__.py). All tests look similar: from . import * def test_port(host): assert…
George Shuklin
  • 6,952
  • 10
  • 39
  • 80
2
votes
0 answers

How to make pytest to pass test if any parametrized test passed?

We have a cluster where only a single server (master) can return a meaningful result. The master is selected automatically and at test time I don't know who is master and who is not. In our tests we are using testinfra which gives us a fixture…
George Shuklin
  • 6,952
  • 10
  • 39
  • 80
2
votes
0 answers

pytest - Ignore test, not just skip

I am using testinfra to test if some services is running/enabled on different nodes. Testinfra can use ansible for getting the nodes to test and it will also make ansible groups available. Testinfra uses pytest. I only want to test for services on…
xeor
  • 5,301
  • 5
  • 36
  • 59
1
vote
1 answer

How to use Module from pytest testinfra to validate running docker container

All, i have been struggling with trying to use the modules example from https://testinfra.readthedocs.io/en/latest/examples.html#parametrize-your-tests. Test Docker images Scenario: I have an image that is spun up through my CICD pipeline, and I…
1
vote
0 answers

load base class for tests from conftest in pytest

We have a lot of repeated tests for many applications (testinfra). I want to create BaseClass to be inherited by app-specific test classes to reduce boilerplate of repeated tests (is this service running? is this port listen?). We have tests in a…
George Shuklin
  • 6,952
  • 10
  • 39
  • 80
1
vote
0 answers

Trigger Prow job reading parameters from the comment with some parameters

Git hub link to issue that i have raised: https://github.com/kubernetes/test-infra/issues/25654 We have api tests that are triggered once user comments /test smoke on a PR request,but we want to make this job parametrized which will help run these…
1
vote
0 answers

How to switch to a different Testinfra host mid-test?

I am trying to, within the same test, execute the code first on the machine A (aka The Host), make an assertion, then execute code on the machine B (aka The SNIC), make an assertion there, and then execute code on the machine A again. Here is my…
Andy Mac
  • 157
  • 2
  • 12
1
vote
1 answer

Using an array of testinfra_hosts, can you control the parametrized values used for each host in a test?

I'm trying to write a test suite for verifying the state of some servers using testinfra. It's my first time working with python/testinfra/pytest. As a brief pseudocodey example test_files.py testinfra_hosts=[server1,server2,server3] with…
1
vote
2 answers

Using fixtures at collect time in pytest

I use testinfra with ansible transport. It provides host fixture which has ansible, so I can do host.ansible.get_variables(). Now I need to create a parametrization of test based on value from this inventory. Inventory: foo: hosts: foo1: …
George Shuklin
  • 6,952
  • 10
  • 39
  • 80
0
votes
0 answers

get variable available fto function and pytest function

i'm working on a script test with testinfra plugin to check and validate any servers deployment. testinfra plugin has a fixture "host" which is used to connect to the server. we can use it with the argument "pytest --hosts=". The idea here i need to…
NicoW
  • 61
  • 5
0
votes
0 answers

Execute testinfra ssh using ssh identity file directly

Basically, I am trying to run some tests on a remote host using pytest. Based on https://testinfra.readthedocs.io/en/latest/backends.html is it possible to do so. I have tried commands like: $ py.test --ssh-config=/path/to/ssh_config…
user14073111
  • 647
  • 5
  • 14
0
votes
1 answer

How to fix text via the module testinfra?

wrote a dockerfile. in it, I run the test using module testinfra. image module, which is used in the dockerile FROM alpine:3.11 there is such an error Step 24/27 : RUN py.test /etc/nginx/test/test.py ---> Running in…
Iceforest
  • 309
  • 1
  • 11
0
votes
1 answer

testinfra - ansible variables not interpreted correctly

With testinfra, I'm using get_variables() method from testinfra.modules.ansible.Ansible but it seems that testinfra cannot evaluate my Ansible variable. Let's describe my poc. ~/tmp/ansible-testinfra ├── inventories │   ├── group_vars │   │   └──…
super-sk
  • 65
  • 2
  • 6
1
2