summaryrefslogtreecommitdiff
path: root/tests/remoteexecution
diff options
context:
space:
mode:
authorChandan Singh <csingh43@bloomberg.net>2019-11-11 17:07:09 +0000
committerChandan Singh <chandan@chandansingh.net>2019-11-14 21:21:06 +0000
commit122177153b14664a0e4fed85aa4f22b87cfabf56 (patch)
tree032c2e46825af91f6fe27f22b5b567eea2b7935d /tests/remoteexecution
parenta3ee349558f36a220f79665873b36c1b0f990c8e (diff)
downloadbuildstream-122177153b14664a0e4fed85aa4f22b87cfabf56.tar.gz
Reformat code using Black
As discussed over the mailing list, reformat code using Black. This is a one-off change to reformat all our codebase. Moving forward, we shouldn't expect such blanket reformats. Rather, we expect each change to already comply with the Black formatting style.
Diffstat (limited to 'tests/remoteexecution')
-rw-r--r--tests/remoteexecution/buildfail.py35
-rw-r--r--tests/remoteexecution/buildtree.py39
-rw-r--r--tests/remoteexecution/junction.py66
-rw-r--r--tests/remoteexecution/partial.py59
-rw-r--r--tests/remoteexecution/simple.py43
5 files changed, 96 insertions, 146 deletions
diff --git a/tests/remoteexecution/buildfail.py b/tests/remoteexecution/buildfail.py
index 0fb4cdb95..22d9c825f 100644
--- a/tests/remoteexecution/buildfail.py
+++ b/tests/remoteexecution/buildfail.py
@@ -28,48 +28,33 @@ from buildstream.testing import cli_remote_execution as cli # pylint: disable=u
pytestmark = pytest.mark.remoteexecution
# Project directory
-DATA_DIR = os.path.join(
- os.path.dirname(os.path.realpath(__file__)),
- "project",
-)
+DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "project",)
@pytest.mark.datafiles(DATA_DIR)
def test_build_remote_failure(cli, datafiles):
project = str(datafiles)
- element_path = os.path.join(project, 'elements', 'element.bst')
- checkout_path = os.path.join(cli.directory, 'checkout')
+ element_path = os.path.join(project, "elements", "element.bst")
+ checkout_path = os.path.join(cli.directory, "checkout")
# Write out our test target
element = {
- 'kind': 'script',
- 'depends': [
- {
- 'filename': 'base.bst',
- 'type': 'build',
- },
- ],
- 'config': {
- 'commands': [
- 'touch %{install-root}/foo',
- 'false',
- ],
- },
+ "kind": "script",
+ "depends": [{"filename": "base.bst", "type": "build",},],
+ "config": {"commands": ["touch %{install-root}/foo", "false",],},
}
_yaml.roundtrip_dump(element, element_path)
services = cli.ensure_services()
- assert set(services) == set(['action-cache', 'execution', 'storage'])
+ assert set(services) == set(["action-cache", "execution", "storage"])
# Try to build it, this should result in a failure that contains the content
- result = cli.run(project=project, args=['build', 'element.bst'])
+ result = cli.run(project=project, args=["build", "element.bst"])
result.assert_main_error(ErrorDomain.STREAM, None)
- result = cli.run(project=project, args=[
- 'artifact', 'checkout', 'element.bst', '--directory', checkout_path
- ])
+ result = cli.run(project=project, args=["artifact", "checkout", "element.bst", "--directory", checkout_path])
result.assert_success()
# check that the file created before the failure exists
- filename = os.path.join(checkout_path, 'foo')
+ filename = os.path.join(checkout_path, "foo")
assert os.path.isfile(filename)
diff --git a/tests/remoteexecution/buildtree.py b/tests/remoteexecution/buildtree.py
index a64b8716c..57e25cd14 100644
--- a/tests/remoteexecution/buildtree.py
+++ b/tests/remoteexecution/buildtree.py
@@ -28,54 +28,43 @@ from tests.testutils import create_artifact_share
pytestmark = pytest.mark.remoteexecution
# Project directory
-DATA_DIR = os.path.join(
- os.path.dirname(os.path.realpath(__file__)),
- "project",
-)
+DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "project",)
@pytest.mark.datafiles(DATA_DIR)
def test_buildtree_remote(cli, tmpdir, datafiles):
project = str(datafiles)
- element_name = 'build-shell/buildtree.bst'
- share_path = os.path.join(str(tmpdir), 'share')
+ element_name = "build-shell/buildtree.bst"
+ share_path = os.path.join(str(tmpdir), "share")
services = cli.ensure_services()
- assert set(services) == set(['action-cache', 'execution', 'storage'])
+ assert set(services) == set(["action-cache", "execution", "storage"])
with create_artifact_share(share_path) as share:
- cli.configure({
- 'artifacts': {'url': share.repo, 'push': True},
- 'cache': {'pull-buildtrees': False}
- })
+ cli.configure({"artifacts": {"url": share.repo, "push": True}, "cache": {"pull-buildtrees": False}})
- res = cli.run(project=project, args=[
- '--cache-buildtrees', 'always', 'build', element_name])
+ res = cli.run(project=project, args=["--cache-buildtrees", "always", "build", element_name])
res.assert_success()
# remove local cache
- shutil.rmtree(os.path.join(str(tmpdir), 'cache', 'cas'))
- shutil.rmtree(os.path.join(str(tmpdir), 'cache', 'artifacts'))
+ shutil.rmtree(os.path.join(str(tmpdir), "cache", "cas"))
+ shutil.rmtree(os.path.join(str(tmpdir), "cache", "artifacts"))
# pull without buildtree
- res = cli.run(project=project, args=[
- 'artifact', 'pull', '--deps', 'all', element_name])
+ res = cli.run(project=project, args=["artifact", "pull", "--deps", "all", element_name])
res.assert_success()
# check shell doesn't work
- res = cli.run(project=project, args=[
- 'shell', '--build', element_name, '--', 'cat', 'test'
- ])
+ res = cli.run(project=project, args=["shell", "--build", element_name, "--", "cat", "test"])
res.assert_shell_error()
# pull with buildtree
- res = cli.run(project=project, args=[
- '--pull-buildtrees', 'artifact', 'pull', '--deps', 'all', element_name])
+ res = cli.run(project=project, args=["--pull-buildtrees", "artifact", "pull", "--deps", "all", element_name])
res.assert_success()
# check it works this time
- res = cli.run(project=project, args=[
- 'shell', '--build', element_name, '--use-buildtree', 'always', '--', 'cat', 'test'
- ])
+ res = cli.run(
+ project=project, args=["shell", "--build", element_name, "--use-buildtree", "always", "--", "cat", "test"]
+ )
res.assert_success()
assert "Hi" in res.output
diff --git a/tests/remoteexecution/junction.py b/tests/remoteexecution/junction.py
index db087fd90..2b0261612 100644
--- a/tests/remoteexecution/junction.py
+++ b/tests/remoteexecution/junction.py
@@ -28,92 +28,70 @@ from tests.testutils import generate_junction
pytestmark = pytest.mark.remoteexecution
# Project directory
-DATA_DIR = os.path.join(
- os.path.dirname(os.path.realpath(__file__)),
- "project",
-)
+DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "project",)
def configure_project(path, config):
- config['name'] = 'test'
- config['element-path'] = 'elements'
- _yaml.roundtrip_dump(config, os.path.join(path, 'project.conf'))
+ config["name"] = "test"
+ config["element-path"] = "elements"
+ _yaml.roundtrip_dump(config, os.path.join(path, "project.conf"))
def create_element(repo, name, path, dependencies, ref=None):
- element = {
- 'kind': 'import',
- 'sources': [
- repo.source_config(ref=ref)
- ],
- 'depends': dependencies
- }
+ element = {"kind": "import", "sources": [repo.source_config(ref=ref)], "depends": dependencies}
_yaml.roundtrip_dump(element, os.path.join(path, name))
@pytest.mark.datafiles(DATA_DIR)
def test_junction_build_remote(cli, tmpdir, datafiles):
project = str(datafiles)
- subproject_path = os.path.join(project, 'files', 'sub-project')
- subproject_element_path = os.path.join(subproject_path, 'elements')
- amhello_files_path = os.path.join(subproject_path, 'files')
- element_path = os.path.join(project, 'elements')
- junction_path = os.path.join(element_path, 'junction.bst')
+ subproject_path = os.path.join(project, "files", "sub-project")
+ subproject_element_path = os.path.join(subproject_path, "elements")
+ amhello_files_path = os.path.join(subproject_path, "files")
+ element_path = os.path.join(project, "elements")
+ junction_path = os.path.join(element_path, "junction.bst")
# We need a repo for real trackable elements
- repo = create_repo('git', str(tmpdir))
+ repo = create_repo("git", str(tmpdir))
ref = repo.create(amhello_files_path)
# ensure that the correct project directory is also listed in the junction
- subproject_conf = os.path.join(subproject_path, 'project.conf')
+ subproject_conf = os.path.join(subproject_path, "project.conf")
with open(subproject_conf) as f:
config = f.read()
config = config.format(project_dir=subproject_path)
- with open(subproject_conf, 'w') as f:
+ with open(subproject_conf, "w") as f:
f.write(config)
# Create a trackable element to depend on the cross junction element,
# this one has it's ref resolved already
- create_element(repo, 'sub-target.bst', subproject_element_path, ['autotools/amhello.bst'], ref=ref)
+ create_element(repo, "sub-target.bst", subproject_element_path, ["autotools/amhello.bst"], ref=ref)
# Create a trackable element to depend on the cross junction element
- create_element(repo, 'target.bst', element_path, [
- {
- 'junction': 'junction.bst',
- 'filename': 'sub-target.bst'
- }
- ])
+ create_element(repo, "target.bst", element_path, [{"junction": "junction.bst", "filename": "sub-target.bst"}])
# Create a repo to hold the subproject and generate a junction element for it
generate_junction(tmpdir, subproject_path, junction_path, store_ref=False)
# Now create a compose element at the top level
- element = {
- 'kind': 'compose',
- 'depends': [
- {
- 'filename': 'target.bst',
- 'type': 'build'
- }
- ]
- }
- _yaml.roundtrip_dump(element, os.path.join(element_path, 'composed.bst'))
+ element = {"kind": "compose", "depends": [{"filename": "target.bst", "type": "build"}]}
+ _yaml.roundtrip_dump(element, os.path.join(element_path, "composed.bst"))
# We're doing remote execution so ensure services are available
services = cli.ensure_services()
- assert set(services) == set(['action-cache', 'execution', 'storage'])
+ assert set(services) == set(["action-cache", "execution", "storage"])
# track the junction first to ensure we have refs
- result = cli.run(project=project, args=['source', 'track', 'junction.bst'])
+ result = cli.run(project=project, args=["source", "track", "junction.bst"])
result.assert_success()
# track target to ensure we have refs
- result = cli.run(project=project, args=['source', 'track', '--deps', 'all', 'composed.bst'])
+ result = cli.run(project=project, args=["source", "track", "--deps", "all", "composed.bst"])
result.assert_success()
# build
- result = cli.run(project=project, silent=True, args=['build', 'composed.bst'])
+ result = cli.run(project=project, silent=True, args=["build", "composed.bst"])
result.assert_success()
# Assert that the main target is cached as a result
- assert cli.get_element_state(project, 'composed.bst') == 'cached'
+ assert cli.get_element_state(project, "composed.bst") == "cached"
diff --git a/tests/remoteexecution/partial.py b/tests/remoteexecution/partial.py
index a640f27d5..a452d6613 100644
--- a/tests/remoteexecution/partial.py
+++ b/tests/remoteexecution/partial.py
@@ -14,75 +14,68 @@ from tests.testutils.artifactshare import create_artifact_share
pytestmark = pytest.mark.remoteexecution
-DATA_DIR = os.path.join(
- os.path.dirname(os.path.realpath(__file__)),
- "project"
-)
+DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "project")
# Test that `bst build` does not download file blobs of a build-only dependency
# to the local cache.
@pytest.mark.datafiles(DATA_DIR)
-@pytest.mark.parametrize('pull_artifact_files', [True, False])
-@pytest.mark.parametrize('build_all', [True, False])
+@pytest.mark.parametrize("pull_artifact_files", [True, False])
+@pytest.mark.parametrize("build_all", [True, False])
def test_build_dependency_partial_local_cas(cli, datafiles, pull_artifact_files, build_all):
project = str(datafiles)
- element_name = 'no-runtime-deps.bst'
- builddep_element_name = 'autotools/amhello.bst'
- checkout = os.path.join(cli.directory, 'checkout')
- builddep_checkout = os.path.join(cli.directory, 'builddep-checkout')
+ element_name = "no-runtime-deps.bst"
+ builddep_element_name = "autotools/amhello.bst"
+ checkout = os.path.join(cli.directory, "checkout")
+ builddep_checkout = os.path.join(cli.directory, "builddep-checkout")
services = cli.ensure_services()
- assert set(services) == set(['action-cache', 'execution', 'storage'])
+ assert set(services) == set(["action-cache", "execution", "storage"])
# configure pull blobs
if build_all:
- cli.configure({
- 'build': {
- 'dependencies': 'all'
- }
- })
- cli.config['remote-execution']['pull-artifact-files'] = pull_artifact_files
-
- result = cli.run(project=project, args=['build', element_name])
+ cli.configure({"build": {"dependencies": "all"}})
+ cli.config["remote-execution"]["pull-artifact-files"] = pull_artifact_files
+
+ result = cli.run(project=project, args=["build", element_name])
result.assert_success()
# Verify artifact is pulled bar files when ensure artifact files is set
- result = cli.run(project=project, args=['artifact', 'checkout', element_name,
- '--directory', checkout])
+ result = cli.run(project=project, args=["artifact", "checkout", element_name, "--directory", checkout])
if pull_artifact_files:
result.assert_success()
- assert_contains(checkout, ['/test'])
+ assert_contains(checkout, ["/test"])
else:
- result.assert_main_error(ErrorDomain.STREAM, 'uncached-checkout-attempt')
+ result.assert_main_error(ErrorDomain.STREAM, "uncached-checkout-attempt")
# Verify build dependencies is pulled for ALL and BUILD
- result = cli.run(project=project, args=['artifact', 'checkout', builddep_element_name,
- '--directory', builddep_checkout])
+ result = cli.run(
+ project=project, args=["artifact", "checkout", builddep_element_name, "--directory", builddep_checkout]
+ )
if build_all and pull_artifact_files:
result.assert_success()
else:
- result.assert_main_error(ErrorDomain.STREAM, 'uncached-checkout-attempt')
+ result.assert_main_error(ErrorDomain.STREAM, "uncached-checkout-attempt")
@pytest.mark.datafiles(DATA_DIR)
def test_build_partial_push(cli, tmpdir, datafiles):
project = str(datafiles)
share_dir = os.path.join(str(tmpdir), "artifactshare")
- element_name = 'no-runtime-deps.bst'
- builddep_element_name = 'autotools/amhello.bst'
+ element_name = "no-runtime-deps.bst"
+ builddep_element_name = "autotools/amhello.bst"
with create_artifact_share(share_dir) as share:
services = cli.ensure_services()
- assert set(services) == set(['action-cache', 'execution', 'storage'])
+ assert set(services) == set(["action-cache", "execution", "storage"])
- cli.config['artifacts'] = {
- 'url': share.repo,
- 'push': True,
+ cli.config["artifacts"] = {
+ "url": share.repo,
+ "push": True,
}
- res = cli.run(project=project, args=['build', element_name])
+ res = cli.run(project=project, args=["build", element_name])
res.assert_success()
assert builddep_element_name in res.get_pushed_elements()
diff --git a/tests/remoteexecution/simple.py b/tests/remoteexecution/simple.py
index 1b7f7818a..cb8f80930 100644
--- a/tests/remoteexecution/simple.py
+++ b/tests/remoteexecution/simple.py
@@ -11,49 +11,54 @@ from buildstream.testing.integration import assert_contains
pytestmark = pytest.mark.remoteexecution
-DATA_DIR = os.path.join(
- os.path.dirname(os.path.realpath(__file__)),
- "project"
-)
+DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "project")
# Test building an executable with remote-execution:
@pytest.mark.datafiles(DATA_DIR)
def test_remote_autotools_build(cli, datafiles):
project = str(datafiles)
- checkout = os.path.join(cli.directory, 'checkout')
- element_name = 'autotools/amhello.bst'
+ checkout = os.path.join(cli.directory, "checkout")
+ element_name = "autotools/amhello.bst"
services = cli.ensure_services()
- assert set(services) == set(['action-cache', 'execution', 'storage'])
+ assert set(services) == set(["action-cache", "execution", "storage"])
- result = cli.run(project=project, args=['build', element_name])
+ result = cli.run(project=project, args=["build", element_name])
result.assert_success()
- result = cli.run(project=project, args=['artifact', 'checkout', element_name, '--directory', checkout])
+ result = cli.run(project=project, args=["artifact", "checkout", element_name, "--directory", checkout])
result.assert_success()
- assert_contains(checkout, ['/usr', '/usr/lib', '/usr/bin',
- '/usr/share',
- '/usr/bin/hello', '/usr/share/doc',
- '/usr/share/doc/amhello',
- '/usr/share/doc/amhello/README'])
+ assert_contains(
+ checkout,
+ [
+ "/usr",
+ "/usr/lib",
+ "/usr/bin",
+ "/usr/share",
+ "/usr/bin/hello",
+ "/usr/share/doc",
+ "/usr/share/doc/amhello",
+ "/usr/share/doc/amhello/README",
+ ],
+ )
# Test running an executable built with remote-execution:
@pytest.mark.datafiles(DATA_DIR)
def test_remote_autotools_run(cli, datafiles):
project = str(datafiles)
- element_name = 'autotools/amhello.bst'
+ element_name = "autotools/amhello.bst"
services = cli.ensure_services()
- assert set(services) == set(['action-cache', 'execution', 'storage'])
+ assert set(services) == set(["action-cache", "execution", "storage"])
services = cli.ensure_services()
- result = cli.run(project=project, args=['build', element_name])
+ result = cli.run(project=project, args=["build", element_name])
result.assert_success()
- result = cli.run(project=project, args=['shell', element_name, '/usr/bin/hello'])
+ result = cli.run(project=project, args=["shell", element_name, "/usr/bin/hello"])
result.assert_success()
- assert result.output == 'Hello World!\nThis is amhello 1.0.\n'
+ assert result.output == "Hello World!\nThis is amhello 1.0.\n"