Skip to content
Snippets Groups Projects
Commit 5f0e57c1 authored by Adrian Ciu's avatar Adrian Ciu
Browse files

VT-101: fixed warnings from tests

parent dae40b4d
No related branches found
No related tags found
1 merge request!9VT-101: implemented spack find operation
Pipeline #60805 passed with stages
in 37 minutes and 19 seconds
...@@ -9,8 +9,8 @@ from dedal.utils.utils import file_exists_and_not_empty, count_files_in_folder ...@@ -9,8 +9,8 @@ from dedal.utils.utils import file_exists_and_not_empty, count_files_in_folder
from dedal.utils.variables import test_spack_env_git, ebrains_spack_builds_git from dedal.utils.variables import test_spack_env_git, ebrains_spack_builds_git
def test_spack_from_cache_setup(tmp_path): def setup(path):
install_dir = tmp_path install_dir = path
env = SpackDescriptor('test-spack-env', install_dir, test_spack_env_git) env = SpackDescriptor('test-spack-env', install_dir, test_spack_env_git)
repo = SpackDescriptor('ebrains-spack-builds', install_dir, ebrains_spack_builds_git) repo = SpackDescriptor('ebrains-spack-builds', install_dir, ebrains_spack_builds_git)
concretization_dir = install_dir / 'concretize' concretization_dir = install_dir / 'concretize'
...@@ -19,6 +19,11 @@ def test_spack_from_cache_setup(tmp_path): ...@@ -19,6 +19,11 @@ def test_spack_from_cache_setup(tmp_path):
buildcache_dir=buildcache_dir) buildcache_dir=buildcache_dir)
spack_config.add_repo(repo) spack_config.add_repo(repo)
spack_operation = SpackOperationCreator.get_spack_operator(spack_config, use_cache=True) spack_operation = SpackOperationCreator.get_spack_operator(spack_config, use_cache=True)
return spack_operation, concretization_dir, buildcache_dir
def test_spack_from_cache_setup(tmp_path):
spack_operation, concretization_dir, buildcache_dir = setup(tmp_path)
assert isinstance(spack_operation, SpackOperationUseCache) assert isinstance(spack_operation, SpackOperationUseCache)
spack_operation.install_spack(bashrc_path=str(tmp_path / Path('.bashrc'))) spack_operation.install_spack(bashrc_path=str(tmp_path / Path('.bashrc')))
spack_operation.setup_spack_env() spack_operation.setup_spack_env()
...@@ -27,26 +32,54 @@ def test_spack_from_cache_setup(tmp_path): ...@@ -27,26 +32,54 @@ def test_spack_from_cache_setup(tmp_path):
assert file_exists_and_not_empty(concretization_download_file_path) == True assert file_exists_and_not_empty(concretization_download_file_path) == True
assert count_files_in_folder(buildcache_dir) == num_tags assert count_files_in_folder(buildcache_dir) == num_tags
assert 'local_cache' in spack_operation.mirror_list() assert 'local_cache' in spack_operation.mirror_list()
return spack_operation
def test_spack_from_cache_concretize(tmp_path): def test_spack_from_cache_concretize(tmp_path):
spack_operation = test_spack_from_cache_setup(tmp_path) spack_operation, concretization_dir, buildcache_dir = setup(tmp_path)
assert isinstance(spack_operation, SpackOperationUseCache)
spack_operation.install_spack(bashrc_path=str(tmp_path / Path('.bashrc')))
spack_operation.setup_spack_env()
num_tags = len(spack_operation.build_cache.list_tags())
concretization_download_file_path = concretization_dir / 'spack.lock'
assert file_exists_and_not_empty(concretization_download_file_path) == True
assert count_files_in_folder(buildcache_dir) == num_tags
assert 'local_cache' in spack_operation.mirror_list()
assert spack_operation.concretize_spack_env() == False assert spack_operation.concretize_spack_env() == False
concretization_file_path = spack_operation.env_path / 'spack.lock' concretization_file_path = spack_operation.env_path / 'spack.lock'
assert file_exists_and_not_empty(concretization_file_path) == True assert file_exists_and_not_empty(concretization_file_path) == True
return spack_operation
def test_spack_from_cache_install_1(tmp_path): def test_spack_from_cache_install_1(tmp_path):
spack_operation = test_spack_from_cache_concretize(tmp_path) spack_operation, concretization_dir, buildcache_dir = setup(tmp_path)
assert isinstance(spack_operation, SpackOperationUseCache)
spack_operation.install_spack(bashrc_path=str(tmp_path / Path('.bashrc')))
spack_operation.setup_spack_env()
num_tags = len(spack_operation.build_cache.list_tags())
concretization_download_file_path = concretization_dir / 'spack.lock'
assert file_exists_and_not_empty(concretization_download_file_path) == True
assert count_files_in_folder(buildcache_dir) == num_tags
assert 'local_cache' in spack_operation.mirror_list()
assert spack_operation.concretize_spack_env() == False
concretization_file_path = spack_operation.env_path / 'spack.lock'
assert file_exists_and_not_empty(concretization_file_path) == True
install_result = spack_operation.install_packages(jobs=2, signed=True, debug=False) install_result = spack_operation.install_packages(jobs=2, signed=True, debug=False)
assert install_result.returncode == 0 assert install_result.returncode == 0
check_installed_spack_packages(spack_operation, tmp_path) check_installed_spack_packages(spack_operation, tmp_path)
def test_spack_from_cache_install_2(tmp_path): def test_spack_from_cache_install_2(tmp_path):
spack_operation = test_spack_from_cache_concretize(tmp_path) spack_operation, concretization_dir, buildcache_dir = setup(tmp_path)
assert isinstance(spack_operation, SpackOperationUseCache)
spack_operation.install_spack(bashrc_path=str(tmp_path / Path('.bashrc')))
spack_operation.setup_spack_env()
num_tags = len(spack_operation.build_cache.list_tags())
concretization_download_file_path = concretization_dir / 'spack.lock'
assert file_exists_and_not_empty(concretization_download_file_path) == True
assert count_files_in_folder(buildcache_dir) == num_tags
assert 'local_cache' in spack_operation.mirror_list()
assert spack_operation.concretize_spack_env() == False
concretization_file_path = spack_operation.env_path / 'spack.lock'
assert file_exists_and_not_empty(concretization_file_path) == True
install_result = spack_operation.install_packages(jobs=2, signed=True, debug=False, test='root') install_result = spack_operation.install_packages(jobs=2, signed=True, debug=False, test='root')
assert install_result.returncode == 0 assert install_result.returncode == 0
check_installed_spack_packages(spack_operation, tmp_path) check_installed_spack_packages(spack_operation, tmp_path)
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment