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, ) check = DiskAvailability(fake_execute_module, task_vars) check.run() assert not check.failures
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_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_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, ) check = DiskAvailability(fake_execute_module, task_vars) check.run() assert check.failures for chunk in 'below recommended'.split() + expect_chunks: assert chunk 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_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, ) check = DiskAvailability(execute_module=fake_execute_module) result = check.run(tmp=None, task_vars=task_vars) assert not result.get('failed', False)
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_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', '')