Skip to content

Commit

Permalink
Change test fsp for another repo and better teardown
Browse files Browse the repository at this point in the history
We changed the test for fsp to use repo on repo.vates.tech and
to have a better teardown when the test failed. We con't want that the
repo file stayed on the test server.

Signed-off-by: Gael Duperrey <[email protected]>
  • Loading branch information
gduperrey committed Aug 24, 2023
1 parent 2fa3e69 commit a38133d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
6 changes: 4 additions & 2 deletions lib/host.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,15 @@ def create_file(self, filename, text):
file.flush()
self.scp(file.name, filename)

def add_xcpng_repo(self, name):
def add_xcpng_repo(self, name, base_repo='xcp-ng'):
assert base_repo in ['xcp-ng', 'vates']
base_repo_url = 'http://mirrors.xcp-ng.org/' if base_repo == 'xcp-ng' else 'https://repo.vates.tech/xcp-ng/'
major = self.xcp_version.major
version = self.xcp_version_short
self.create_file(f"/etc/yum.repos.d/xcp-ng-{name}.repo", (
f"[xcp-ng-{name}]\n"
f"name=XCP-ng {name} Repository\n"
f"baseurl=http://mirrors.xcp-ng.org/{major}/{version}/{name}/x86_64/ http://updates.xcp-ng.org/{major}/{version}/{name}/x86_64/\n" # noqa
f"baseurl={base_repo_url}/{major}/{version}/{name}/x86_64/\n"
"enabled=1\n"
"gpgcheck=1\n"
"repo_gpgcheck=1\n"
Expand Down
22 changes: 14 additions & 8 deletions tests/storage/fsp/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,26 @@

DIRECTORIES_PATH = 'directories'

def install_fsp(host):
host.add_xcpng_repo(FSP_REPO_NAME)
@pytest.fixture(scope='package')
def host_with_saved_yum_state(host):
host.yum_save_state()
host.yum_install(FSP_PACKAGES)

def uninstall_fsp(host):
yield host
host.yum_restore_saved_state()

@pytest.fixture(scope='package')
def host_with_runx_repo(host_with_saved_yum_state):
host = host_with_saved_yum_state
host.add_xcpng_repo(FSP_REPO_NAME, 'vates')
yield host
# teardown
host.remove_xcpng_repo(FSP_REPO_NAME)

@pytest.fixture(scope='package')
def host_with_fsp(host):
install_fsp(host)
def host_with_fsp(host_with_runx_repo):
host = host_with_runx_repo
host.yum_install(FSP_PACKAGES)
yield host
uninstall_fsp(host)
# teardown: nothing to do, the teardown of host_with_saved_yum_state will revert the package installation

@pytest.fixture(scope='package')
def fsp_config(host_with_fsp):
Expand Down

0 comments on commit a38133d

Please sign in to comment.