summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRaoul Hidalgo Charman <raoul.hidalgocharman@codethink.co.uk>2019-06-13 15:14:06 +0100
committerRaoul Hidalgo Charman <raoul.hidalgocharman@codethink.co.uk>2019-06-21 11:09:07 +0100
commit4f6113d26bcff1775c88bbfa0c1e3683a6efdda6 (patch)
tree7d51f96b0fedd545f83faffe0103ce4dc9b4a4a4
parenteb791ceb66fdc3160e9b0ed72c807e19b760b908 (diff)
downloadbuildstream-4f6113d26bcff1775c88bbfa0c1e3683a6efdda6.tar.gz
tests: Add shell test with pull option
Part of #1044
-rw-r--r--doc/examples/autotools/project.conf4
-rw-r--r--tests/integration/shell.py50
2 files changed, 54 insertions, 0 deletions
diff --git a/doc/examples/autotools/project.conf b/doc/examples/autotools/project.conf
index 96e0284e0..9c9dc8d58 100644
--- a/doc/examples/autotools/project.conf
+++ b/doc/examples/autotools/project.conf
@@ -11,3 +11,7 @@ element-path: elements
aliases:
alpine: https://bst-integration-test-images.ams3.cdn.digitaloceanspaces.com/
gnu: http://ftpmirror.gnu.org/gnu/automake/
+
+artifacts:
+ url: http://localhost:50053
+ push: True
diff --git a/tests/integration/shell.py b/tests/integration/shell.py
index d0c9f1f99..f7de3e462 100644
--- a/tests/integration/shell.py
+++ b/tests/integration/shell.py
@@ -7,6 +7,10 @@ import pytest
from buildstream import _yaml
from buildstream.testing import cli_integration as cli # pylint: disable=unused-import
from buildstream.testing._utils.site import HAVE_SANDBOX
+from buildstream._exceptions import ErrorDomain
+from buildstream import utils
+
+from tests.testutils import create_artifact_share
pytestmark = pytest.mark.integration
@@ -391,3 +395,49 @@ def test_integration_external_workspace(cli, tmpdir_factory, datafiles, build_sh
command.extend([element_name, '--', 'true'])
result = cli.run(project=project, cwd=workspace_dir, args=command)
result.assert_success()
+
+
+@pytest.mark.datafiles(DATA_DIR)
+@pytest.mark.skipif(not HAVE_SANDBOX, reason='Only available with a functioning sandbox')
+def test_integration_partial_artifact(cli, datafiles, tmpdir, integration_cache):
+
+ project = str(datafiles)
+ element_name = 'autotools/amhello.bst'
+
+ # push to an artifact server so we can pull from it later.
+ with create_artifact_share(os.path.join(str(tmpdir), 'artifactshare')) as share:
+ cli.configure({'artifacts': {
+ 'url': share.repo,
+ 'push': True
+ }})
+ result = cli.run(project=project, args=['build', element_name])
+ result.assert_success()
+
+ # If the build is cached then it might not push to the artifact cache
+ result = cli.run(project=project, args=['artifact', 'push', element_name])
+ result.assert_success()
+
+ result = cli.run(project=project, args=['shell', element_name])
+ result.assert_success()
+
+ # do a checkout and get the digest of the hello binary.
+ result = cli.run(project=project, args=[
+ 'artifact', 'checkout', '--deps', 'none',
+ '--directory', os.path.join(str(tmpdir), 'tmp'),
+ 'autotools/amhello.bst'])
+ result.assert_success()
+ digest = utils.sha256sum(os.path.join(str(tmpdir), 'tmp', 'usr', 'bin', 'hello'))
+
+ # Remove the binary from the CAS
+ cachedir = cli.config['cachedir']
+ objpath = os.path.join(cachedir, 'cas', 'objects', digest[:2], digest[2:])
+ os.unlink(objpath)
+
+ # check shell doesn't work
+ result = cli.run(project=project, args=['shell', element_name, '--', 'hello'])
+ result.assert_main_error(ErrorDomain.APP, None)
+
+ # check the artifact gets completed with '--pull' specified
+ result = cli.run(project=project, args=['shell', '--pull', element_name, '--', 'hello'])
+ result.assert_success()
+ assert 'autotools/amhello.bst' in result.get_pulled_elements()