tests: Embed test framework within OCL repository

Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
This commit is contained in:
Robert Baldyga
2022-12-23 12:50:17 +01:00
parent bc0c8c1bf5
commit 849f59855c
91 changed files with 9930 additions and 2 deletions

View File

@@ -0,0 +1,48 @@
#
# Copyright(c) 2020-2021 Intel Corporation
# SPDX-License-Identifier: BSD-3-Clause
#
from datetime import timedelta
from connection.local_executor import LocalExecutor
from connection.ssh_executor import SshExecutor
from core.test_run import TestRun
class PowerControlPlugin:
def __init__(self, params, config):
print("Power Control LibVirt Plugin initialization")
try:
self.ip = config['ip']
self.user = config['user']
except Exception:
raise Exception("Missing fields in config! ('ip' and 'user' required)")
def pre_setup(self):
print("Power Control LibVirt Plugin pre setup")
if self.config['connection_type'] == 'ssh':
self.executor = SshExecutor(
self.ip,
self.user,
self.config.get('port', 22)
)
else:
self.executor = LocalExecutor()
def post_setup(self):
pass
def teardown(self):
pass
def power_cycle(self):
self.executor.run(f"virsh reset {self.config['domain']}")
TestRun.executor.wait_for_connection_loss()
timeout = TestRun.config.get('reboot_timeout')
if timeout:
TestRun.executor.wait_for_connection(timedelta(seconds=int(timeout)))
else:
TestRun.executor.wait_for_connection()
plugin_class = PowerControlPlugin