summaryrefslogtreecommitdiff
path: root/tests/integration/artifact.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/integration/artifact.py')
-rw-r--r--tests/integration/artifact.py36
1 files changed, 20 insertions, 16 deletions
diff --git a/tests/integration/artifact.py b/tests/integration/artifact.py
index a5e1f4d77..b942c1690 100644
--- a/tests/integration/artifact.py
+++ b/tests/integration/artifact.py
@@ -48,6 +48,7 @@ DATA_DIR = os.path.join(
def test_cache_buildtrees(cli, tmpdir, datafiles):
project = str(datafiles)
element_name = 'autotools/amhello.bst'
+ cwd = str(tmpdir)
# Create artifact shares for pull & push testing
with create_artifact_share(os.path.join(str(tmpdir), 'share1')) as share1,\
@@ -65,23 +66,26 @@ def test_cache_buildtrees(cli, tmpdir, datafiles):
result = cli.run(project=project, args=['build', element_name])
assert result.exit_code == 0
assert cli.get_element_state(project, element_name) == 'cached'
- assert share1.has_artifact('test', element_name, cli.get_element_key(project, element_name))
+ assert share1.has_artifact(cli.get_artifact_name(project, 'test', element_name))
# The buildtree dir should not exist, as we set the config to not cache buildtrees.
- cache_key = cli.get_element_key(project, element_name)
- elementdigest = share1.has_artifact('test', element_name, cache_key)
- with cli.artifact.extract_buildtree(tmpdir, elementdigest) as buildtreedir:
- assert not os.path.isdir(buildtreedir)
+
+ artifact_name = cli.get_artifact_name(project, 'test', element_name)
+ assert share1.has_artifact(artifact_name)
+ with cli.artifact.extract_buildtree(cwd, cwd, artifact_name) as buildtreedir:
+ assert not buildtreedir
# Delete the local cached artifacts, and assert the when pulled with --pull-buildtrees
# that is was cached in share1 as expected without a buildtree dir
shutil.rmtree(os.path.join(str(tmpdir), 'cas'))
+ shutil.rmtree(os.path.join(str(tmpdir), 'artifacts'))
assert cli.get_element_state(project, element_name) != 'cached'
result = cli.run(project=project, args=['--pull-buildtrees', 'artifact', 'pull', element_name])
assert element_name in result.get_pulled_elements()
- with cli.artifact.extract_buildtree(tmpdir, elementdigest) as buildtreedir:
- assert not os.path.isdir(buildtreedir)
+ with cli.artifact.extract_buildtree(cwd, cwd, artifact_name) as buildtreedir:
+ assert not buildtreedir
shutil.rmtree(os.path.join(str(tmpdir), 'cas'))
+ shutil.rmtree(os.path.join(str(tmpdir), 'artifacts'))
# Assert that the default behaviour of pull to not include buildtrees on the artifact
# in share1 which was purposely cached with an empty one behaves as expected. As such the
@@ -89,9 +93,10 @@ def test_cache_buildtrees(cli, tmpdir, datafiles):
# leading to no buildtreedir being extracted
result = cli.run(project=project, args=['artifact', 'pull', element_name])
assert element_name in result.get_pulled_elements()
- with cli.artifact.extract_buildtree(tmpdir, elementdigest) as buildtreedir:
- assert not os.path.isdir(buildtreedir)
+ with cli.artifact.extract_buildtree(cwd, cwd, artifact_name) as buildtreedir:
+ assert not buildtreedir
shutil.rmtree(os.path.join(str(tmpdir), 'cas'))
+ shutil.rmtree(os.path.join(str(tmpdir), 'artifacts'))
# Repeat building the artifacts, this time with cache-buildtrees set to
# 'always' via the cli, as such the buildtree dir should not be empty
@@ -102,24 +107,25 @@ def test_cache_buildtrees(cli, tmpdir, datafiles):
result = cli.run(project=project, args=['--cache-buildtrees', 'always', 'build', element_name])
assert result.exit_code == 0
assert cli.get_element_state(project, element_name) == 'cached'
- assert share2.has_artifact('test', element_name, cli.get_element_key(project, element_name))
+ assert share2.has_artifact(cli.get_artifact_name(project, 'test', element_name))
# Cache key will be the same however the digest hash will have changed as expected, so reconstruct paths
- elementdigest = share2.has_artifact('test', element_name, cache_key)
- with cli.artifact.extract_buildtree(tmpdir, elementdigest) as buildtreedir:
+ with cli.artifact.extract_buildtree(cwd, cwd, artifact_name) as buildtreedir:
assert os.path.isdir(buildtreedir)
assert os.listdir(buildtreedir)
# Delete the local cached artifacts, and assert that when pulled with --pull-buildtrees
# that it was cached in share2 as expected with a populated buildtree dir
shutil.rmtree(os.path.join(str(tmpdir), 'cas'))
+ shutil.rmtree(os.path.join(str(tmpdir), 'artifacts'))
assert cli.get_element_state(project, element_name) != 'cached'
result = cli.run(project=project, args=['--pull-buildtrees', 'artifact', 'pull', element_name])
assert element_name in result.get_pulled_elements()
- with cli.artifact.extract_buildtree(tmpdir, elementdigest) as buildtreedir:
+ with cli.artifact.extract_buildtree(cwd, cwd, artifact_name) as buildtreedir:
assert os.path.isdir(buildtreedir)
assert os.listdir(buildtreedir)
shutil.rmtree(os.path.join(str(tmpdir), 'cas'))
+ shutil.rmtree(os.path.join(str(tmpdir), 'artifacts'))
# Clarify that the user config option for cache-buildtrees works as the cli
# main option does. Point to share3 which does not have the artifacts cached to force
@@ -132,8 +138,6 @@ def test_cache_buildtrees(cli, tmpdir, datafiles):
result = cli.run(project=project, args=['build', element_name])
assert result.exit_code == 0
assert cli.get_element_state(project, element_name) == 'cached'
- cache_key = cli.get_element_key(project, element_name)
- elementdigest = share3.has_artifact('test', element_name, cache_key)
- with cli.artifact.extract_buildtree(tmpdir, elementdigest) as buildtreedir:
+ with cli.artifact.extract_buildtree(cwd, cwd, artifact_name) as buildtreedir:
assert os.path.isdir(buildtreedir)
assert os.listdir(buildtreedir)