From 74c044d31ba0fb122996e3f9272d4b9a22cc98bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Billeter?= Date: Wed, 1 Jul 2020 18:24:51 +0200 Subject: tests/frontend/remote-caches.py: Split test_source_artifact_caches Use `bst source push` in a new test instead of manually deleting parts of a remote cache. --- tests/frontend/remote-caches.py | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/tests/frontend/remote-caches.py b/tests/frontend/remote-caches.py index b112e0882..ebafddf85 100644 --- a/tests/frontend/remote-caches.py +++ b/tests/frontend/remote-caches.py @@ -69,12 +69,34 @@ def test_source_artifact_caches(cli, tmpdir, datafiles): assert "Pulled artifact " in res.stderr assert "Pulled source " not in res.stderr - # remove the artifact from the repo and check it pulls sources, builds + +@pytest.mark.datafiles(DATA_DIR) +def test_source_cache_empty_artifact_cache(cli, tmpdir, datafiles): + cachedir = os.path.join(str(tmpdir), "cache") + project_dir = str(datafiles) + element_path = os.path.join(project_dir, "elements") + + with create_artifact_share(os.path.join(str(tmpdir), "share")) as share: + user_config_file = str(tmpdir.join("buildstream.conf")) + user_config = { + "scheduler": {"pushers": 1}, + "source-caches": {"url": share.repo, "push": True,}, + "artifacts": {"url": share.repo, "push": True,}, + "cachedir": cachedir, + } + _yaml.roundtrip_dump(user_config, file=user_config_file) + cli.configure(user_config) + + create_element_size("repo.bst", project_dir, element_path, [], 10000) + + res = cli.run(project=project_dir, args=["source", "push", "repo.bst"]) + res.assert_success() + assert "Pushed source " in res.stderr + + # delete local sources and check it pulls sources, builds # and then pushes the artifacts shutil.rmtree(os.path.join(cachedir, "cas")) - shutil.rmtree(os.path.join(cachedir, "artifacts")) - print(os.listdir(os.path.join(share.repodir, "artifacts", "refs"))) - shutil.rmtree(os.path.join(share.repodir, "artifacts", "refs", "test")) + shutil.rmtree(os.path.join(cachedir, "sources")) res = cli.run(project=project_dir, args=["build", "repo.bst"]) res.assert_success() -- cgit v1.2.1