Loading test/integration/objectstore/test_per_user.py +66 −0 Original line number Diff line number Diff line Loading @@ -409,3 +409,69 @@ class TestPerUserObjectStoreUpgradesWithSecretsIntegration( assert object_store_json["template_version"] == 2 assert "sec1" not in secrets assert "sec2" in secrets class TestPerUserObjectStoreQuotaIntegration(BaseUserObjectStoreIntegration): @classmethod def handle_galaxy_config_kwds(cls, config): cls._write_template_and_object_store_config(config, LIBRARY_2) config["enable_quotas"] = True def test_user_object_store_does_not_pause_jobs_over_quota(self): object_store_id = self._create_simple_object_store() with self.dataset_populator.test_history() as history_id: def _run_tool(tool_id, inputs, preferred_object_store_id=None): response = self.dataset_populator.run_tool( tool_id, inputs, history_id, preferred_object_store_id=preferred_object_store_id, ) self.dataset_populator.wait_for_history(history_id) return response # Create one dataset in the default object store hda1 = self.dataset_populator.new_dataset(history_id, content="1 2 3\n4 5 6\n7 8 9\n", wait=True) storage_info = self.dataset_populator.dataset_storage_info(hda1["id"]) assert storage_info["object_store_id"] == "default" # Set a quota of 1 byte so running a tool will pause the job self._define_quota_in_bytes(1) # Run a tool hda1_input = {"src": "hda", "id": hda1["id"]} response = _run_tool("multi_data_param", {"f1": hda1_input, "f2": hda1_input}) paused_job_id = response["jobs"][0]["id"] storage_info, _ = self._storage_info_for_job_output(response) assert storage_info["object_store_id"] == "default" # The job should be paused because the default object store is over quota state = self.dataset_populator.wait_for_job(paused_job_id) assert state == "paused" # Set the user object store as the preferred object store self.dataset_populator.set_user_preferred_object_store_id(object_store_id) # Run the tool again response = _run_tool("multi_data_param", {"f1": hda1_input, "f2": hda1_input}) job_id = response["jobs"][0]["id"] storage_info, _ = self._storage_info_for_job_output(response) assert storage_info["object_store_id"] == object_store_id # The job should not be paused because the user object store is not subject to quotas state = self.dataset_populator.wait_for_job(job_id) assert state == "ok" def _define_quota_in_bytes(self, bytes: int): quotas = self.dataset_populator.get_quotas() assert len(quotas) == 0 payload = { "name": "defaultquota1", "description": "first default quota", "amount": f"{bytes} bytes", "operation": "=", "default": "registered", } self.dataset_populator.create_quota(payload) Loading
test/integration/objectstore/test_per_user.py +66 −0 Original line number Diff line number Diff line Loading @@ -409,3 +409,69 @@ class TestPerUserObjectStoreUpgradesWithSecretsIntegration( assert object_store_json["template_version"] == 2 assert "sec1" not in secrets assert "sec2" in secrets class TestPerUserObjectStoreQuotaIntegration(BaseUserObjectStoreIntegration): @classmethod def handle_galaxy_config_kwds(cls, config): cls._write_template_and_object_store_config(config, LIBRARY_2) config["enable_quotas"] = True def test_user_object_store_does_not_pause_jobs_over_quota(self): object_store_id = self._create_simple_object_store() with self.dataset_populator.test_history() as history_id: def _run_tool(tool_id, inputs, preferred_object_store_id=None): response = self.dataset_populator.run_tool( tool_id, inputs, history_id, preferred_object_store_id=preferred_object_store_id, ) self.dataset_populator.wait_for_history(history_id) return response # Create one dataset in the default object store hda1 = self.dataset_populator.new_dataset(history_id, content="1 2 3\n4 5 6\n7 8 9\n", wait=True) storage_info = self.dataset_populator.dataset_storage_info(hda1["id"]) assert storage_info["object_store_id"] == "default" # Set a quota of 1 byte so running a tool will pause the job self._define_quota_in_bytes(1) # Run a tool hda1_input = {"src": "hda", "id": hda1["id"]} response = _run_tool("multi_data_param", {"f1": hda1_input, "f2": hda1_input}) paused_job_id = response["jobs"][0]["id"] storage_info, _ = self._storage_info_for_job_output(response) assert storage_info["object_store_id"] == "default" # The job should be paused because the default object store is over quota state = self.dataset_populator.wait_for_job(paused_job_id) assert state == "paused" # Set the user object store as the preferred object store self.dataset_populator.set_user_preferred_object_store_id(object_store_id) # Run the tool again response = _run_tool("multi_data_param", {"f1": hda1_input, "f2": hda1_input}) job_id = response["jobs"][0]["id"] storage_info, _ = self._storage_info_for_job_output(response) assert storage_info["object_store_id"] == object_store_id # The job should not be paused because the user object store is not subject to quotas state = self.dataset_populator.wait_for_job(job_id) assert state == "ok" def _define_quota_in_bytes(self, bytes: int): quotas = self.dataset_populator.get_quotas() assert len(quotas) == 0 payload = { "name": "defaultquota1", "description": "first default quota", "amount": f"{bytes} bytes", "operation": "=", "default": "registered", } self.dataset_populator.create_quota(payload)