Merge pull request #8042 from VJalili/os_tests

Extend ObjectStore integration tests
This commit is contained in:
Marius van den Beek
2019-06-18 11:46:55 +02:00
committed by GitHub
5 changed files with 49 additions and 9 deletions
@@ -34,6 +34,8 @@ DISTRIBUTED_OBJECT_STORE_CONFIG_TEMPLATE = string.Template("""<?xml version="1.0
</object_store>
""")
TEST_INPUT_FILES_CONTENT = "1 2 3"
class ObjectStoreJobsIntegrationTestCase(integration_util.IntegrationTestCase):
@@ -55,10 +57,8 @@ class ObjectStoreJobsIntegrationTestCase(integration_util.IntegrationTestCase):
def setUp(self):
super(ObjectStoreJobsIntegrationTestCase, self).setUp()
self.dataset_populator = DatasetPopulator(self.galaxy_interactor)
def test_tool_simple_constructs(self):
with self.dataset_populator.test_history() as history_id:
hda1 = self.dataset_populator.new_dataset(history_id, content="1 2 3")
hda1 = self.dataset_populator.new_dataset(history_id, content=TEST_INPUT_FILES_CONTENT)
create_10_inputs = {
"input1": {"src": "hda", "id": hda1["id"]},
"input2": {"src": "hda", "id": hda1["id"]},
@@ -71,6 +71,25 @@ class ObjectStoreJobsIntegrationTestCase(integration_util.IntegrationTestCase):
)
self.dataset_populator.wait_for_history(history_id)
def test_files_count_and_content_in_each_objectstore_backend(self):
"""
According to the ObjectStore configuration given in the
`DISTRIBUTED_OBJECT_STORE_CONFIG_TEMPLATE` variable, datasets
can be stored on three backends, named:
- primary/files1;
- primary/files2;
- secondary/files3.
Objectstore _randomly_ distributes tools outputs on
`primary/files1` and `primary/files2`, and will use
`secondary/files3` if both `primary` backends fail.
This test runs a tools that creates ten dummy datasets,
and asserts if ObjectStore correctly creates ten files
in `primary/files1` and `primary/files2`, and none in
`secondary/files3`, assuming it will not fail persisting
data in `primary` backend.
"""
files_1_count = _files_count(self.files1_path)
files_2_count = _files_count(self.files2_path)
files_3_count = _files_count(self.files3_path)
@@ -79,17 +98,39 @@ class ObjectStoreJobsIntegrationTestCase(integration_util.IntegrationTestCase):
assert files_3_count == 0
# Ensure the 10 inputs were written to one of the distributed object store's disk
# stores (it will have either 10 or 11 depeending on whether the input was also
# stores (it will have either 10 or 11 depending on whether the input was also
# written there. The other disk store may or may not have the input file so should
# have at most one file.
assert (files_1_count >= 10) or (files_2_count >= 10)
assert (files_1_count <= 1) or (files_2_count <= 1)
assert (files_1_count + files_2_count == 10) or (files_1_count + files_2_count == 11)
# Other sanity checks on the test - just make sure the test was setup as intended
# and not actually testing object store behavior.
assert (files_1_count <= 11) and (files_2_count <= 11)
assert (files_1_count >= 0) and (files_2_count >= 0)
# TODO: ideally the following assertion should be separated in a different test method.
contents = []
path1_files = _get_datasets_files_in_path(self.files1_path)
path2_files = _get_datasets_files_in_path(self.files2_path)
path3_files = _get_datasets_files_in_path(self.files3_path)
for filename in path1_files + path2_files + path3_files:
with open(filename) as f:
content = f.read().strip()
if content != TEST_INPUT_FILES_CONTENT:
contents.append(content)
for expected_content in range(1, 10):
assert str(expected_content) in contents
def _files_count(directory):
return sum(len(files) for _, _, files in os.walk(directory))
def _get_datasets_files_in_path(directory):
files = []
for path, _, filename in os.walk(directory):
for f in filename:
if f.endswith(".dat"):
files.append(os.path.join(path, f))
return files
@@ -9,8 +9,8 @@ from base.populators import (
)
SCRIPT_DIRECTORY = os.path.abspath(os.path.dirname(__file__))
JOB_CONFIG_FILE = os.path.join(SCRIPT_DIRECTORY, "objectstore_selection_job_conf.xml")
JOB_RESOURCE_PARAMETERS_CONFIG_FILE = os.path.join(SCRIPT_DIRECTORY, "objectstore_selection_job_resource_parameters_conf.xml")
JOB_CONFIG_FILE = os.path.join(SCRIPT_DIRECTORY, "selection_job_conf.xml")
JOB_RESOURCE_PARAMETERS_CONFIG_FILE = os.path.join(SCRIPT_DIRECTORY, "selection_job_resource_parameters_conf.xml")
DISTRIBUTED_OBJECT_STORE_CONFIG_TEMPLATE = string.Template("""<?xml version="1.0"?>
<object_store type="distributed" id="primary" order="0">
@@ -80,7 +80,6 @@ class ObjectStoreJobsIntegrationTestCase(integration_util.IntegrationTestCase):
assert dynamic_s3 == files_dynamic_s3_count
def test_tool_simple_constructs(self):
with self.dataset_populator.test_history() as history_id:
def _run_tool(tool_id, inputs):