-
Notifications
You must be signed in to change notification settings - Fork 123
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support running sti tests via 'tmt'. Add an template for easily create the test plan. Example of the workflow $ fedpkg clone python3 $ cd python3 $ tmt init --template sti $ tmt run -a provision -h virtual.testcloud Signed-off-by: Miroslav Vadkerti <mvadkert@redhat.com>
- Loading branch information
Showing
8 changed files
with
131 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import os | ||
|
||
from tmt.utils import GeneralError | ||
from tmt.steps.execute.base import ExecutorBase | ||
|
||
|
||
DEFAULT_PLAYBOOK = 'tests/tests.yml' | ||
ANSIBLE_INVENTORY = """ | ||
[localhost] | ||
sut ansible_host={hostname} ansible_user=root ansible_remote_tmp={remote_tmp} | ||
""" | ||
|
||
|
||
class ExecutorSTI(ExecutorBase): | ||
""" Run tests using how: sti """ | ||
type = 'sti' | ||
|
||
def _playbook(self, data): | ||
if 'playbook' in data and data['playbook']: | ||
playbook = data['playbook'] | ||
else: | ||
playbook = DEFAULT_PLAYBOOK | ||
|
||
if not os.path.exists(playbook): | ||
raise GeneralError(f"Playbook '{playbook}' not found.") | ||
|
||
return playbook | ||
|
||
def _inventory(self, guest, workdir): | ||
""" Provides Ansible inventory compared to STI """ | ||
hostname = guest.guest or guest.container | ||
|
||
inventory_file = os.path.join(workdir, f'inventory-{hostname}') | ||
# Note that we have to force remote_tmp because in rootless container | ||
# it would default to '/root/.ansible/tmp' which is | ||
# not accessible by ordinary users | ||
inventory_content = ANSIBLE_INVENTORY.format( | ||
hostname=hostname, | ||
remote_tmp=os.path.expanduser('~/.ansible/tmp') | ||
) | ||
|
||
with open(inventory_file, 'w') as inventory: | ||
inventory.write(inventory_content) | ||
|
||
return inventory_file | ||
|
||
def go(self, guests, data, workdir): | ||
""" Run tests """ | ||
super(ExecutorSTI, self).go(workdir) | ||
|
||
for guest in guests: | ||
guest.ansible( | ||
self._playbook(data), | ||
inventory=self._inventory(guest, workdir) | ||
) | ||
|
||
def results(self): | ||
""" Returns results from executed tests """ | ||
super(ExecutorSTI, self).results() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters