def test_succeeds_with_recommended_disk_space(group_names, ansible_mounts): task_vars = dict( group_names=group_names, ansible_mounts=ansible_mounts, ) check = DiskAvailability(execute_module=fake_execute_module) result = check.run(tmp=None, task_vars=task_vars) assert not result.get('failed', False)
def test_succeeds_with_recommended_disk_space(group_names, configured_min, ansible_mounts): task_vars = dict( group_names=group_names, openshift_check_min_host_disk_gb=configured_min, ansible_mounts=ansible_mounts, ) result = DiskAvailability(fake_execute_module, task_vars).run() assert not result.get('failed', False)
def test_succeeds_with_recommended_disk_space(group_names, configured_min, ansible_mounts): task_vars = dict( group_names=group_names, openshift_check_min_host_disk_gb=configured_min, ansible_mounts=ansible_mounts, ) result = DiskAvailability(fake_execute_module, task_vars).run() assert not result.get('failed', False)
def test_cannot_determine_available_disk(ansible_mounts, extra_words): task_vars = dict( group_names=['masters'], ansible_mounts=ansible_mounts, ) check = DiskAvailability(execute_module=fake_execute_module) with pytest.raises(OpenShiftCheckException) as excinfo: check.run(tmp=None, task_vars=task_vars) for word in 'determine disk availability'.split() + extra_words: assert word in str(excinfo.value)
def test_cannot_determine_available_disk(ansible_mounts, extra_words): task_vars = dict( group_names=['masters'], ansible_mounts=ansible_mounts, ) check = DiskAvailability(execute_module=fake_execute_module) with pytest.raises(OpenShiftCheckException) as excinfo: check.run(tmp=None, task_vars=task_vars) for word in 'determine disk availability'.split() + extra_words: assert word in str(excinfo.value)
def test_fails_with_insufficient_disk_space(name, group_names, configured_min, ansible_mounts, expect_chunks): task_vars = dict( group_names=group_names, openshift_check_min_host_disk_gb=configured_min, ansible_mounts=ansible_mounts, ) result = DiskAvailability(fake_execute_module, task_vars).run() assert result['failed'] for chunk in 'below recommended'.split() + expect_chunks: assert chunk in result.get('msg', '')
def test_fails_with_insufficient_disk_space(name, group_names, configured_min, ansible_mounts, expect_chunks): task_vars = dict( group_names=group_names, openshift_check_min_host_disk_gb=configured_min, ansible_mounts=ansible_mounts, ) result = DiskAvailability(fake_execute_module, task_vars).run() assert result['failed'] for chunk in 'below recommended'.split() + expect_chunks: assert chunk in result.get('msg', '')
def test_fails_with_insufficient_disk_space(group_names, configured_min, ansible_mounts, extra_words): task_vars = dict( group_names=group_names, openshift_check_min_host_disk_gb=configured_min, ansible_mounts=ansible_mounts, ) check = DiskAvailability(execute_module=fake_execute_module) result = check.run(tmp=None, task_vars=task_vars) assert result['failed'] for word in 'below recommended'.split() + extra_words: assert word in result['msg']
def test_fails_with_insufficient_disk_space(group_names, ansible_mounts, extra_words): task_vars = dict( group_names=group_names, ansible_mounts=ansible_mounts, ) check = DiskAvailability(execute_module=fake_execute_module) result = check.run(tmp=None, task_vars=task_vars) assert result['failed'] for word in 'below recommended'.split() + extra_words: assert word in result['msg']
def test_min_required_space_changes_with_upgrade_context(name, group_names, context, ansible_mounts, failed, extra_words): task_vars = dict( r_openshift_health_checker_playbook_context=context, group_names=group_names, ansible_mounts=ansible_mounts, ) check = DiskAvailability(fake_execute_module, task_vars) result = check.run() assert result.get("failed", False) == failed for word in extra_words: assert word in result.get('msg', '')
def test_min_required_space_changes_with_upgrade_context(name, group_names, context, ansible_mounts, failed, extra_words): task_vars = dict( r_openshift_health_checker_playbook_context=context, group_names=group_names, ansible_mounts=ansible_mounts, ) check = DiskAvailability(fake_execute_module, task_vars) check.run() assert bool(check.failures) == failed for word in extra_words: assert word in str(check.failures[0])
def test_min_required_space_changes_with_upgrade_context( name, group_names, context, ansible_mounts, failed, extra_words): task_vars = dict( r_openshift_health_checker_playbook_context=context, group_names=group_names, ansible_mounts=ansible_mounts, ) check = DiskAvailability(fake_execute_module, task_vars) check.run() assert bool(check.failures) == failed for word in extra_words: assert word in str(check.failures[0])
def test_min_required_space_changes_with_upgrade_context( name, group_names, context, ansible_mounts, failed, extra_words): task_vars = dict( r_openshift_health_checker_playbook_context=context, group_names=group_names, ansible_mounts=ansible_mounts, ) check = DiskAvailability(fake_execute_module, task_vars) result = check.run() assert result.get("failed", False) == failed for word in extra_words: assert word in result.get('msg', '')
def test_cannot_determine_available_disk(desc, ansible_mounts, expect_chunks): task_vars = dict( group_names=['oo_masters_to_config'], ansible_mounts=ansible_mounts, ) with pytest.raises(OpenShiftCheckException) as excinfo: DiskAvailability(fake_execute_module, task_vars).run() for chunk in expect_chunks: assert chunk in str(excinfo.value)
def test_is_active(group_names, is_containerized, is_active): task_vars = dict( group_names=group_names, openshift=dict(common=dict(is_containerized=is_containerized)), ) assert DiskAvailability.is_active(task_vars=task_vars) == is_active
def test_is_active(group_names, is_active): task_vars = dict(group_names=group_names, ) assert DiskAvailability(None, task_vars).is_active() == is_active
def test_is_active(group_names, is_containerized, is_active): task_vars = dict( group_names=group_names, openshift=dict(common=dict(is_containerized=is_containerized)), ) assert DiskAvailability.is_active(task_vars=task_vars) == is_active
def test_is_active(group_names, is_active): task_vars = dict( group_names=group_names, ) assert DiskAvailability.is_active(task_vars=task_vars) == is_active