diff options
author | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2017-09-08 11:45:13 -0400 |
---|---|---|
committer | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2017-09-08 11:47:11 -0400 |
commit | d1d5873ff50750c092a762ef851ff6ae915c414f (patch) | |
tree | 4af1ddf3829b40dbf0323ff36bde3315cb230270 | |
parent | 87423c55bc940f60107b48cbbe275b7c0be32389 (diff) | |
download | buildstream-d1d5873ff50750c092a762ef851ff6ae915c414f.tar.gz |
Removing artifact cache tests.
Except for the ArtifactCache.remove() test, all of these assertions are
covered by the frontend `push` and `pull` tests. The remove() API itself
is unused except for being tested, lets leave this functionality out
until it's used.
The highlevel tests are easier to write and exercise more of the
codebase to assert the right behaviors, so lets only maintain that.
-rw-r--r-- | tests/artifactcache/basics.py | 105 | ||||
-rw-r--r-- | tests/artifactcache/basics/project.conf | 3 | ||||
-rw-r--r-- | tests/artifactcache/basics/simple.bst | 5 |
3 files changed, 0 insertions, 113 deletions
diff --git a/tests/artifactcache/basics.py b/tests/artifactcache/basics.py deleted file mode 100644 index 97b57358a..000000000 --- a/tests/artifactcache/basics.py +++ /dev/null @@ -1,105 +0,0 @@ -import multiprocessing -import os -import pytest -import tempfile - -from buildstream import Context, Project, _yaml, _ostree -from buildstream.exceptions import _ArtifactError -from buildstream.element import _KeyStrength -from buildstream._artifactcache import ArtifactCache -from buildstream._pipeline import Pipeline - -DATA_DIR = os.path.join( - os.path.dirname(os.path.realpath(__file__)), - 'basics', -) - - -@pytest.fixture() -def pipeline(tmpdir): - context = Context('x86_64') - project = Project(DATA_DIR, 'x86_64') - context.artifactdir = os.path.join(str(tmpdir), 'artifact') - context.builddir = os.path.join(str(tmpdir), 'build') - - return Pipeline(context, project, "simple.bst", None) - - -def test_empty_contains(pipeline): - assert(not pipeline.artifacts.contains(pipeline.target)) - - -# Test that we get an ArtifactError when trying to extract a nonexistent artifact -def test_empty_extract(pipeline): - with pytest.raises(_ArtifactError) as exc: - pipeline.artifacts.extract(pipeline.target) - - -def build_commit(pipeline): - os.makedirs(pipeline.context.builddir, exist_ok=True) - with tempfile.TemporaryDirectory(dir=pipeline.context.builddir) as builddir: - filesdir = os.path.join(builddir, 'files') - metadir = os.path.join(builddir, 'meta') - os.mkdir(filesdir) - os.mkdir(metadir) - - # create file as mock build output - bindir = os.path.join(filesdir, 'bin') - os.mkdir(bindir) - with open(os.path.join(bindir, 'baz'), 'w') as f: - f.write('hello, world') - - meta = { - 'keys': { - 'strong': pipeline.target._get_cache_key(_KeyStrength.STRONG), - 'weak': pipeline.target._get_cache_key(_KeyStrength.WEAK), - } - } - _yaml.dump(_yaml.node_sanitize(meta), os.path.join(metadir, 'artifact.yaml')) - - # commit build output to artifact cache - pipeline.artifacts.commit(pipeline.target, builddir) - pipeline.target._cached(recalculate=True) - - -def test_commit_extract(pipeline): - build_commit(pipeline) - assert(pipeline.artifacts.contains(pipeline.target)) - - # extract artifact and verify the content - extractdir = pipeline.artifacts.extract(pipeline.target) - filesdir = os.path.join(extractdir, 'files') - with open(os.path.join(filesdir, 'bin', 'baz'), 'r') as f: - content = f.read() - assert(content == 'hello, world') - - -def test_push_pull(pipeline, tmpdir): - - pipeline.context.artifact_pull = os.path.join(str(tmpdir), 'share') - pipeline.context.artifact_push = os.path.join(str(tmpdir), 'share') - - build_commit(pipeline) - assert(pipeline.artifacts.contains(pipeline.target)) - - # push artifact in subprocess to avoid hang in the next OSTree operation - p = multiprocessing.Process(target=pipeline.artifacts.push, args=(pipeline.target,)) - p.start() - p.join() - - # generate summary file - push_repo = _ostree.ensure(pipeline.context.artifact_push, True) - push_repo.regenerate_summary() - - pipeline.artifacts.remove(pipeline.target) - assert(not pipeline.artifacts.contains(pipeline.target)) - - # read summary file - pipeline.artifacts.fetch_remote_refs() - - # Fetch artifact in subprocess to avoid hang in the next OSTree operation - p = multiprocessing.Process(target=pipeline.artifacts.pull, args=(pipeline.target,)) - p.start() - p.join() - - assert(pipeline.artifacts.contains(pipeline.target)) diff --git a/tests/artifactcache/basics/project.conf b/tests/artifactcache/basics/project.conf deleted file mode 100644 index 2027cc27a..000000000 --- a/tests/artifactcache/basics/project.conf +++ /dev/null @@ -1,3 +0,0 @@ -# Basic project configuration that doesnt override anything -# -name: pony diff --git a/tests/artifactcache/basics/simple.bst b/tests/artifactcache/basics/simple.bst deleted file mode 100644 index cd1f73968..000000000 --- a/tests/artifactcache/basics/simple.bst +++ /dev/null @@ -1,5 +0,0 @@ -kind: autotools -description: Some kinda autotools element -config: - configure-commands: - - pony |