Example #1
0
def test_generate_shard_prune_playbook(plan_name):
    migration = _get_migration(plan_name)
    mock_shard_allocation = _get_expected_yml(plan_name, 'mock_shard_allocation.yml')
    mock_func = get_shard_allocation_func(mock_shard_allocation)
    with patch('couchdb_cluster_admin.file_plan.get_shard_allocation', mock_func):
        nodes = generate_shard_prune_playbook(migration)

    if nodes:
        actual = _get_yml(migration.prune_playbook_path)
        expected = _get_expected_yml(plan_name, 'expected_{}'.format(PRUNE_PLAYBOOK_NAME))
        assert expected == actual, "file lists mismatch:\n\nExpected\n{}\nActual\n{}".format(expected, actual)
    else:
        assert not os.path.exists(migration.prune_playbook_path), migration.prune_playbook_path
def test_generate_shard_prune_playbook(plan_name):
    migration = _get_migration(plan_name)
    mock_shard_allocation = _get_expected_yml(plan_name, 'mock_shard_allocation_post_migration.yml')
    mock_func = get_shard_allocation_func(mock_shard_allocation)
    with patch('commcare_cloud.commands.migrations.couchdb.get_shard_allocation', mock_func),\
            patch('commcare_cloud.commands.migrations.couchdb.get_db_list', return_value=['commcarehq', 'commcarehq__apps']):
        nodes = generate_shard_prune_playbook(migration)

    if nodes:
        actual = _get_yml(migration.prune_playbook_path)
        expected = _get_expected_yml(plan_name, 'expected_{}'.format(PRUNE_PLAYBOOK_NAME))
        assert expected == actual, "file lists mismatch:\n\nExpected\n{}\nActual\n{}".format(expected, actual)
    else:
        assert not os.path.exists(migration.prune_playbook_path), migration.prune_playbook_path
Example #3
0
def test_generate_shard_prune_playbook(plan_name):
    migration = _get_migration(plan_name)
    mock_shard_allocation = _get_expected_yml(
        plan_name, 'mock_shard_allocation_post_migration.yml')
    mock_func = get_shard_allocation_func(mock_shard_allocation)
    with patch('commcare_cloud.commands.migrations.couchdb.get_shard_allocation', mock_func),\
            patch('commcare_cloud.commands.migrations.couchdb.get_db_list', return_value=['commcarehq', 'commcarehq__apps']):
        nodes = generate_shard_prune_playbook(migration)

    if nodes:
        actual = _get_yml(migration.prune_playbook_path)
        expected = _get_expected_yml(plan_name,
                                     'expected_{}'.format(PRUNE_PLAYBOOK_NAME))
        assert expected == actual, "file lists mismatch:\n\nExpected\n{}\nActual\n{}".format(
            expected, actual)
    else:
        assert not os.path.exists(
            migration.prune_playbook_path), migration.prune_playbook_path