From e3cac30d03688aa31cfdf7eabf3c26fe8a3925ff Mon Sep 17 00:00:00 2001 From: John Chilton Date: Sat, 11 Jun 2022 11:06:59 -0400 Subject: [PATCH] Test case to demonstrate disk usage update for work dir outputs is broken with celery_extended. --- lib/galaxy_test/api/test_tools.py | 3 +++ lib/galaxy_test/base/populators.py | 7 +++++ test/integration/test_metadata_strategy.py | 30 ++++++++++++++++++++++ 3 files changed, 40 insertions(+) create mode 100644 test/integration/test_metadata_strategy.py diff --git a/lib/galaxy_test/api/test_tools.py b/lib/galaxy_test/api/test_tools.py index fc8a9d4a66ab..32c40c3de54a 100644 --- a/lib/galaxy_test/api/test_tools.py +++ b/lib/galaxy_test/api/test_tools.py @@ -869,6 +869,7 @@ def test_multidata_param(self): @uses_test_history(require_new=False) def test_run_cat1(self, history_id): # Run simple non-upload tool with an input data parameter. + initial_disk_usage = self.dataset_populator.total_disk_usage() new_dataset = self.dataset_populator.new_dataset(history_id, content="Cat1Test") inputs = dict( input1=dataset_to_param(new_dataset), @@ -878,6 +879,8 @@ def test_run_cat1(self, history_id): output1 = outputs[0] output1_content = self.dataset_populator.get_history_dataset_content(history_id, dataset=output1) self.assertEqual(output1_content.strip(), "Cat1Test") + final_disk_usage = self.dataset_populator.total_disk_usage() + assert final_disk_usage >= initial_disk_usage + 9 * 2 @skip_without_tool("cat1") @uses_test_history(require_new=True) diff --git a/lib/galaxy_test/base/populators.py b/lib/galaxy_test/base/populators.py index 5971780112aa..cdd87d57838a 100644 --- a/lib/galaxy_test/base/populators.py +++ b/lib/galaxy_test/base/populators.py @@ -1057,6 +1057,13 @@ def user_private_role_id(self) -> str: assert "id" in role, role return role["id"] + def total_disk_usage(self) -> float: + response = self._get("users/current") + response.raise_for_status() + user_object = response.json() + assert "total_disk_usage" in user_object + return user_object["total_disk_usage"] + def create_role(self, user_ids: list, description: Optional[str] = None) -> dict: payload = { "name": self.get_random_name(prefix="testpop"), diff --git a/test/integration/test_metadata_strategy.py b/test/integration/test_metadata_strategy.py new file mode 100644 index 000000000000..ced8fbea84b2 --- /dev/null +++ b/test/integration/test_metadata_strategy.py @@ -0,0 +1,30 @@ +from galaxy_test.base.populators import ( + DatasetPopulator, + uses_test_history, +) +from galaxy_test.driver.integration_util import IntegrationTestCase + + +class TestDiskUsageUpdateDefault(IntegrationTestCase): + framework_tool_and_types = True + + def setUp(self): + super().setUp() + self.dataset_populator = DatasetPopulator(self.galaxy_interactor) + + @uses_test_history(require_new=False) + def test_run_work_dir_glob(self, history_id): + # Run a tool with a work dir glob and ensure content and disk usage is updated. + self.dataset_populator.new_dataset(history_id, content="fwd1Test", wait=True) + initial_disk_usage = self.dataset_populator.total_disk_usage() + response = self.dataset_populator.run_tool("from_work_dir_glob", {}, history_id, assert_ok=True) + self.dataset_populator.wait_for_job(job_id=response["jobs"][0]["id"]) + final_disk_usage = self.dataset_populator.total_disk_usage() + assert final_disk_usage == initial_disk_usage + 3 + + +class TestDiskUsageCeleryExtended(TestDiskUsageUpdateDefault): + @classmethod + def handle_galaxy_config_kwds(cls, config): + super().handle_galaxy_config_kwds(config) + config["metadata_strategy"] = "celery_extended"