diff options
Diffstat (limited to 'tests/remotecache')
-rw-r--r-- | tests/remotecache/project/elements/autotools/amhello.bst | 26 | ||||
-rw-r--r-- | tests/remotecache/project/elements/base.bst | 5 | ||||
-rw-r--r-- | tests/remotecache/project/elements/base/base-alpine.bst | 17 | ||||
-rw-r--r-- | tests/remotecache/project/elements/build-shell/buildtree-fail.bst | 13 | ||||
-rw-r--r-- | tests/remotecache/project/elements/build-shell/buildtree.bst | 11 | ||||
-rw-r--r-- | tests/remotecache/project/elements/no-runtime-deps.bst | 9 | ||||
-rw-r--r-- | tests/remotecache/project/files/amhello.tar.gz | bin | 0 -> 30555 bytes | |||
-rw-r--r-- | tests/remotecache/project/files/dev-files/usr/include/pony.h | 12 | ||||
-rw-r--r-- | tests/remotecache/project/project.conf | 25 | ||||
-rw-r--r-- | tests/remotecache/simple.py | 65 |
10 files changed, 183 insertions, 0 deletions
diff --git a/tests/remotecache/project/elements/autotools/amhello.bst b/tests/remotecache/project/elements/autotools/amhello.bst new file mode 100644 index 000000000..3af67ef3c --- /dev/null +++ b/tests/remotecache/project/elements/autotools/amhello.bst @@ -0,0 +1,26 @@ +kind: autotools +description: Autotools test + +depends: +- base.bst + +sources: +- kind: tar + url: project_dir:/files/amhello.tar.gz + ref: 9ba123fa4e660929e9a0aa99f0c487b7eee59c5e7594f3284d015640b90f5590 + +config: + + configure-commands: + - | + %{autogen} + - | + %{configure} + - | + date +%s > config-time + + build-commands: + - | + %{make} + - | + date +%s > build-time diff --git a/tests/remotecache/project/elements/base.bst b/tests/remotecache/project/elements/base.bst new file mode 100644 index 000000000..428afa736 --- /dev/null +++ b/tests/remotecache/project/elements/base.bst @@ -0,0 +1,5 @@ +# elements/base.bst + +kind: stack +depends: + - base/base-alpine.bst diff --git a/tests/remotecache/project/elements/base/base-alpine.bst b/tests/remotecache/project/elements/base/base-alpine.bst new file mode 100644 index 000000000..c5833095d --- /dev/null +++ b/tests/remotecache/project/elements/base/base-alpine.bst @@ -0,0 +1,17 @@ +kind: import + +description: | + Alpine Linux base for tests + + Generated using the `tests/integration-tests/base/generate-base.sh` script. + +sources: + - kind: tar + base-dir: '' + (?): + - arch == "x86-64": + ref: 3eb559250ba82b64a68d86d0636a6b127aa5f6d25d3601a79f79214dc9703639 + url: "alpine:integration-tests-base.v1.x86_64.tar.xz" + - arch == "aarch64": + ref: 431fb5362032ede6f172e70a3258354a8fd71fcbdeb1edebc0e20968c792329a + url: "alpine:integration-tests-base.v1.aarch64.tar.xz" diff --git a/tests/remotecache/project/elements/build-shell/buildtree-fail.bst b/tests/remotecache/project/elements/build-shell/buildtree-fail.bst new file mode 100644 index 000000000..a3b515a9a --- /dev/null +++ b/tests/remotecache/project/elements/build-shell/buildtree-fail.bst @@ -0,0 +1,13 @@ +kind: manual +description: | + Puts a file in the build tree so that build tree caching and staging can be tested, + then deliberately failing to build so we can check the output. + +depends: + - filename: base.bst + type: build + +config: + build-commands: + - "echo 'Hi' > %{build-root}/test" + - "false" diff --git a/tests/remotecache/project/elements/build-shell/buildtree.bst b/tests/remotecache/project/elements/build-shell/buildtree.bst new file mode 100644 index 000000000..d5cf256be --- /dev/null +++ b/tests/remotecache/project/elements/build-shell/buildtree.bst @@ -0,0 +1,11 @@ +kind: manual +description: | + Puts a file in the build tree so that build tree caching and staging can be tested. + +depends: + - filename: base.bst + type: build + +config: + build-commands: + - "echo 'Hi' > %{build-root}/test" diff --git a/tests/remotecache/project/elements/no-runtime-deps.bst b/tests/remotecache/project/elements/no-runtime-deps.bst new file mode 100644 index 000000000..ca76aaf9f --- /dev/null +++ b/tests/remotecache/project/elements/no-runtime-deps.bst @@ -0,0 +1,9 @@ +kind: manual +description: Test element without runtime dependencies + +build-depends: +- autotools/amhello.bst + +config: + install-commands: + - echo Test > %{install-root}/test diff --git a/tests/remotecache/project/files/amhello.tar.gz b/tests/remotecache/project/files/amhello.tar.gz Binary files differnew file mode 100644 index 000000000..afe189908 --- /dev/null +++ b/tests/remotecache/project/files/amhello.tar.gz diff --git a/tests/remotecache/project/files/dev-files/usr/include/pony.h b/tests/remotecache/project/files/dev-files/usr/include/pony.h new file mode 100644 index 000000000..40bd0c2e7 --- /dev/null +++ b/tests/remotecache/project/files/dev-files/usr/include/pony.h @@ -0,0 +1,12 @@ +#ifndef __PONY_H__ +#define __PONY_H__ + +#define PONY_BEGIN "Once upon a time, there was a pony." +#define PONY_END "And they lived happily ever after, the end." + +#define MAKE_PONY(story) \ + PONY_BEGIN \ + story \ + PONY_END + +#endif /* __PONY_H__ */ diff --git a/tests/remotecache/project/project.conf b/tests/remotecache/project/project.conf new file mode 100644 index 000000000..27b5f5e34 --- /dev/null +++ b/tests/remotecache/project/project.conf @@ -0,0 +1,25 @@ +# Project config for frontend build test +name: test +min-version: 2.0 +element-path: elements +aliases: + alpine: https://bst-integration-test-images.ams3.cdn.digitaloceanspaces.com/ + project_dir: file://{project_dir} +options: + linux: + type: bool + description: Whether to expect a linux platform + default: True + arch: + type: arch + description: Current architecture + values: + - x86-64 + - aarch64 +split-rules: + test: + - | + /tests + - | + /tests/* + diff --git a/tests/remotecache/simple.py b/tests/remotecache/simple.py new file mode 100644 index 000000000..74c44ae1e --- /dev/null +++ b/tests/remotecache/simple.py @@ -0,0 +1,65 @@ +# Pylint doesn't play well with fixtures and dependency injection from pytest +# pylint: disable=redefined-outer-name + +import os +import pytest + +from buildstream.testing import cli_remote_execution as cli # pylint: disable=unused-import +from buildstream.testing.integration import assert_contains + + +pytestmark = pytest.mark.remotecache + + +DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "project") + +# Test building an executable with a remote cache: +@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" + + result = cli.run(project=project, args=["build", element_name]) + result.assert_success() + assert element_name in result.get_pushed_elements() + + 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", + ], + ) + + # then remove it locally + result = cli.run(project=project, args=["artifact", "delete", element_name]) + result.assert_success() + + result = cli.run(project=project, args=["build", element_name]) + result.assert_success() + assert element_name in result.get_pulled_elements() + + +# Test building an executable with a remote cache: +@pytest.mark.datafiles(DATA_DIR) +def test_remote_autotools_build_no_cache(cli, datafiles): + project = str(datafiles) + checkout = os.path.join(cli.directory, "checkout") + element_name = "autotools/amhello.bst" + + cli.configure({"artifacts": {"url": "http://fake.url.service", "push": True}}) + result = cli.run(project=project, args=["build", element_name]) + result.assert_success() + + assert """WARNING Failed to initialize remote""" in result.stderr + assert """Remote initialisation failed with status UNAVAILABLE: DNS resolution failed""" in result.stderr |