Update installer to use local repository

As tests are now part of OCL repository, we prefer to always
run tests from local repository version on the same version
of OCL, so instead of cloning OCL from GitHub we just copy
local repository to DUT.

This also simplifies running remote tests in development
environment without need to push work-in-progress commits
to GitHub or installing OCL manually on DUT.

Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
This commit is contained in:
Robert Baldyga 2019-10-29 18:22:22 +01:00
parent e4a31f51a5
commit 01cd284a48
2 changed files with 26 additions and 45 deletions

View File

@ -9,70 +9,51 @@ import logging
from tests import conftest from tests import conftest
from core.test_run import TestRun from core.test_run import TestRun
LOGGER = logging.getLogger(__name__)
opencas_repo_name = "open-cas-linux"
def install_opencas(): def install_opencas():
LOGGER.info("Cloning Open CAS repository.") TestRun.LOGGER.info("Copying Open CAS repository to DUT")
TestRun.executor.run(f"if [ -d {opencas_repo_name} ]; " TestRun.executor.rsync(
f"then rm -rf {opencas_repo_name}; fi") f"{TestRun.plugins['opencas']['repo_dir']}/",
output = TestRun.executor.run( f"{TestRun.plugins['opencas']['working_dir']}/",
"git clone --recursive https://github.com/Open-CAS/open-cas-linux.git") delete=True)
if output.exit_code != 0:
raise Exception(f"Error while cloning repository: {output.stdout}\n{output.stderr}")
TestRun.LOGGER.info("Building Open CAS")
output = TestRun.executor.run( output = TestRun.executor.run(
f"cd {opencas_repo_name} && " f"cd {TestRun.plugins['opencas']['working_dir']} && "
f"git fetch --all && "
f"git fetch --tags {conftest.get_remote()} +refs/pull/*:refs/remotes/origin/pr/*")
if output.exit_code != 0:
raise Exception(
f"Failed to fetch: "
f"{output.stdout}\n{output.stderr}")
output = TestRun.executor.run(f"cd {opencas_repo_name} && "
f"git checkout {conftest.get_branch()}")
if output.exit_code != 0:
raise Exception(
f"Failed to checkout to {conftest.get_branch()}: {output.stdout}\n{output.stderr}")
LOGGER.info("Open CAS make and make install.")
output = TestRun.executor.run(
f"cd {opencas_repo_name} && "
"git submodule update --init --recursive && "
"./configure && " "./configure && "
"make -j") "make -j")
if output.exit_code != 0: if output.exit_code != 0:
raise Exception( TestRun.exception(
f"Make command executed with nonzero status: {output.stdout}\n{output.stderr}") f"Make command executed with nonzero status: {output.stdout}\n{output.stderr}")
output = TestRun.executor.run(f"cd {opencas_repo_name} && " TestRun.LOGGER.info("Installing Open CAS")
f"make install") output = TestRun.executor.run(
f"cd {TestRun.plugins['opencas']['working_dir']} && "
f"make install")
if output.exit_code != 0: if output.exit_code != 0:
raise Exception( TestRun.exception(
f"Error while installing Open CAS: {output.stdout}\n{output.stderr}") f"Error while installing Open CAS: {output.stdout}\n{output.stderr}")
LOGGER.info("Check if casadm is properly installed.") TestRun.LOGGER.info("Check if casadm is properly installed.")
output = TestRun.executor.run("casadm -V") output = TestRun.executor.run("casadm -V")
if output.exit_code != 0: if output.exit_code != 0:
raise Exception( TestRun.exception(
f"'casadm -V' command returned an error: {output.stdout}\n{output.stderr}") f"'casadm -V' command returned an error: {output.stdout}\n{output.stderr}")
else: else:
LOGGER.info(output.stdout) TestRun.LOGGER.info(output.stdout)
def uninstall_opencas(): def uninstall_opencas():
LOGGER.info("Uninstalling Open CAS.") TestRun.LOGGER.info("Uninstalling Open CAS")
output = TestRun.executor.run("casadm -V") output = TestRun.executor.run("casadm -V")
if output.exit_code != 0: if output.exit_code != 0:
raise Exception("Open CAS is not properly installed.") TestRun.exception("Open CAS is not properly installed")
else: else:
TestRun.executor.run(f"cd {opencas_repo_name} && " TestRun.executor.run(
f"make uninstall") f"cd {TestRun.plugins['opencas']['working_dir']} && "
f"make uninstall")
if output.exit_code != 0: if output.exit_code != 0:
raise Exception( TestRun.exception(
f"There was an error during uninstall process: {output.stdout}\n{output.stderr}") f"There was an error during uninstall process: {output.stdout}\n{output.stderr}")
@ -83,11 +64,11 @@ def reinstall_opencas():
def check_if_installed(): def check_if_installed():
LOGGER.info("Check if Open-CAS-Linux is installed.") TestRun.LOGGER.info("Check if Open-CAS-Linux is installed")
output = TestRun.executor.run("which casadm") output = TestRun.executor.run("which casadm")
if output.exit_code == 0: if output.exit_code == 0:
LOGGER.info("CAS is installed") TestRun.LOGGER.info("CAS is installed")
return True return True
LOGGER.info("CAS not installed") TestRun.LOGGER.info("CAS not installed")
return False return False

@ -1 +1 @@
Subproject commit de0721eb52fbe548a8e7810913151e2e37c66d1c Subproject commit b0081604becc2b9ae23e0de5c29427c59966d68d