Skip to content

Commit

Permalink
fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
XaverStiensmeier committed Jun 20, 2024
1 parent b479e29 commit 49ce93f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 27 deletions.
36 changes: 15 additions & 21 deletions tests/test_ansible_configurator.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,16 +92,15 @@ def test_generate_site_file_yaml_all_role(self):
{'role': 'resistance_nextflow', 'tags': ['rn']}],
'vars_files': ['vars/common_configuration.yml', 'vars/hosts.yml', 'vars/rn']}]
self.assertEqual(site_yaml, ansible_configurator.generate_site_file_yaml(user_roles))

def test_generate_common_configuration_false(self):
cidrs = "42"
cluster_id = "21"
default_user = "ubuntu"
ssh_user = "test"
configuration = [{}]
common_configuration_yaml = {'auto_mount': False, 'bibigrid_version': version.__version__,
'cloud_scheduling': {'sshTimeout': 4}, 'cluster_cidrs': cidrs,
'cluster_id': cluster_id, 'default_user': default_user,
common_configuration_yaml = {'bibigrid_version': version.__version__, 'cloud_scheduling': {'sshTimeout': 4},
'cluster_cidrs': cidrs, 'cluster_id': cluster_id, 'default_user': default_user,
'dns_server_list': ['8.8.8.8'], 'enable_ide': False, 'enable_nfs': False,
'enable_slurm': False, 'enable_zabbix': False, 'local_dns_lookup': False,
'local_fs': False, 'slurm': True,
Expand All @@ -125,9 +124,8 @@ def test_generate_common_configuration_true(self):
ssh_user = "test"
configuration = [
{elem: "True" for elem in ["localFS", "localDNSlookup", "useMasterAsCompute", "slurm", "zabbix", "ide"]}]
common_configuration_yaml = {'auto_mount': False, 'bibigrid_version': version.__version__,
'cloud_scheduling': {'sshTimeout': 4}, 'cluster_cidrs': cidrs,
'cluster_id': cluster_id, 'default_user': default_user,
common_configuration_yaml = {'bibigrid_version': version.__version__, 'cloud_scheduling': {'sshTimeout': 4},
'cluster_cidrs': cidrs, 'cluster_id': cluster_id, 'default_user': default_user,
'dns_server_list': ['8.8.8.8'], 'enable_ide': 'True', 'enable_nfs': False,
'enable_slurm': 'True', 'enable_zabbix': 'True',
'ide_conf': {'build': False, 'ide': False, 'port_end': 8383, 'port_start': 8181,
Expand All @@ -154,9 +152,8 @@ def test_generate_common_configuration_nfs_shares(self):
cluster_id = "21"
default_user = "ubuntu"
ssh_user = "test"
common_configuration_yaml = {'auto_mount': False, 'bibigrid_version': version.__version__,
'cloud_scheduling': {'sshTimeout': 4}, 'cluster_cidrs': cidrs,
'cluster_id': cluster_id, 'default_user': default_user,
common_configuration_yaml = {'bibigrid_version': version.__version__, 'cloud_scheduling': {'sshTimeout': 4},
'cluster_cidrs': cidrs, 'cluster_id': cluster_id, 'default_user': default_user,
'dns_server_list': ['8.8.8.8'], 'enable_ide': False, 'enable_nfs': 'True',
'enable_slurm': False, 'enable_zabbix': False, 'ext_nfs_mounts': [],
'local_dns_lookup': False, 'local_fs': False,
Expand All @@ -180,9 +177,8 @@ def test_generate_common_configuration_nfs(self):
cluster_id = "21"
default_user = "ubuntu"
ssh_user = "test"
common_configuration_yaml = {'auto_mount': False, 'bibigrid_version': version.__version__,
'cloud_scheduling': {'sshTimeout': 4}, 'cluster_cidrs': cidrs,
'cluster_id': cluster_id, 'default_user': default_user,
common_configuration_yaml = {'bibigrid_version': version.__version__, 'cloud_scheduling': {'sshTimeout': 4},
'cluster_cidrs': cidrs, 'cluster_id': cluster_id, 'default_user': default_user,
'dns_server_list': ['8.8.8.8'], 'enable_ide': False, 'enable_nfs': 'True',
'enable_slurm': False, 'enable_zabbix': False, 'ext_nfs_mounts': [],
'local_dns_lookup': False, 'local_fs': False,
Expand All @@ -205,9 +201,8 @@ def test_generate_common_configuration_ext_nfs_shares(self):
cluster_id = "21"
default_user = "ubuntu"
ssh_user = "test"
common_configuration_yaml = {'auto_mount': False, 'bibigrid_version': version.__version__,
'cloud_scheduling': {'sshTimeout': 4}, 'cluster_cidrs': cidrs,
'cluster_id': cluster_id, 'default_user': default_user,
common_configuration_yaml = {'bibigrid_version': version.__version__, 'cloud_scheduling': {'sshTimeout': 4},
'cluster_cidrs': cidrs, 'cluster_id': cluster_id, 'default_user': default_user,
'dns_server_list': ['8.8.8.8'], 'enable_ide': False, 'enable_nfs': 'True',
'enable_slurm': False, 'enable_zabbix': False,
'ext_nfs_mounts': [{'dst': '/vil/mil', 'src': '/vil/mil'}],
Expand All @@ -231,9 +226,8 @@ def test_generate_common_configuration_ide(self):
cluster_id = "21"
default_user = "ubuntu"
ssh_user = "test"
common_configuration_yaml = {'auto_mount': False, 'bibigrid_version': version.__version__,
'cloud_scheduling': {'sshTimeout': 4}, 'cluster_cidrs': cidrs,
'cluster_id': cluster_id, 'default_user': default_user,
common_configuration_yaml = {'bibigrid_version': version.__version__, 'cloud_scheduling': {'sshTimeout': 4},
'cluster_cidrs': cidrs, 'cluster_id': cluster_id, 'default_user': default_user,
'dns_server_list': ['8.8.8.8'], 'enable_ide': 'Some1', 'enable_nfs': False,
'enable_slurm': False, 'enable_zabbix': False,
'ide_conf': {'build': False, 'ide': False, 'key1': 'Some2', 'port_end': 8383,
Expand Down Expand Up @@ -351,8 +345,8 @@ def test_write_yaml_alias(self, mock_yaml):
@patch("bibigrid.core.utility.ansible_configurator.generate_site_file_yaml")
@patch("bibigrid.core.utility.ansible_configurator.write_yaml")
@patch("bibigrid.core.utility.ansible_configurator.get_cidrs")
def test_configure_ansible_yaml(self, mock_cidrs, mock_yaml, mock_site, mock_hosts, mock_list,
mock_common, mock_worker, mock_write):
def test_configure_ansible_yaml(self, mock_cidrs, mock_yaml, mock_site, mock_hosts, mock_list, mock_common,
mock_worker, mock_write):
mock_cidrs.return_value = 421
mock_list.return_value = {2: 422}
provider = MagicMock()
Expand Down
14 changes: 8 additions & 6 deletions tests/test_validate_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,8 @@ def test_check_volumes_mismatch(self):
provider1.get_volume_snapshot_by_id_or_name = MagicMock(return_value=None)
provider1.cloud_specification = {"identifier": "1"}
v_c = validate_configuration.ValidateConfiguration(providers=[provider1],
configurations=[{"masterMounts": ["Test"]}], log=Mock())
configurations=[{"masterMounts": [{"name": "Test"}]}],
log=Mock())
self.assertFalse(v_c.check_volumes())

def test_check_volumes_match_snapshot(self):
Expand All @@ -220,7 +221,8 @@ def test_check_volumes_match_snapshot(self):
provider1.get_volume_snapshot_by_id_or_name = MagicMock(return_value={"size": 1})
provider1.cloud_specification = {"identifier": "1"}
v_c = validate_configuration.ValidateConfiguration(providers=[provider1],
configurations=[{"masterMounts": ["Test"]}], log=Mock())
configurations=[{"masterMounts": [{"name": "Test"}]}],
log=Mock())
self.assertTrue(v_c.check_volumes())

def test_check_volumes_match_snapshot_count(self):
Expand All @@ -229,9 +231,8 @@ def test_check_volumes_match_snapshot_count(self):
provider1.get_volume_by_id_or_name = MagicMock(return_value=None)
provider1.get_volume_snapshot_by_id_or_name = MagicMock(return_value={"size": i})
provider1.cloud_specification = {"identifier": i}
v_c = validate_configuration.ValidateConfiguration(providers=[provider1] * i,
configurations=[{"masterMounts": ["Test"] * i}],
log=Mock())
v_c = validate_configuration.ValidateConfiguration(providers=[provider1] * i, configurations=[
{"masterMounts": [{"name": "Test"}] * i}], log=Mock())
self.assertTrue(v_c.check_volumes())
self.assertTrue(v_c.required_resources_dict[i]["volumes"] == i)
self.assertTrue(v_c.required_resources_dict[i]["volume_gigabytes"] == i ** 2)
Expand All @@ -242,7 +243,8 @@ def test_check_volumes_match_volume(self):
provider1.get_volume_snapshot_by_id_or_name = MagicMock(return_value=None)
provider1.cloud_specification = {"identifier": "1"}
v_c = validate_configuration.ValidateConfiguration(providers=[provider1],
configurations=[{"masterMounts": ["Test"]}], log=Mock())
configurations=[{"masterMounts": [{"name": "Test"}]}],
log=Mock())
self.assertTrue(v_c.check_volumes())
self.assertTrue(v_c.required_resources_dict["1"]["volumes"] == 0)
self.assertTrue(v_c.required_resources_dict["1"]["volume_gigabytes"] == 0)
Expand Down

0 comments on commit 49ce93f

Please sign in to comment.