'Don\'t copy replication fields from cluster if replication error.'

@mock.patch('cinder.service.Service.is_svc_upgrading_to_n', mock.Mock(return_value=False))
@mock.patch('cinder.objects.Cluster.get_by_id')
def test_ensure_cluster_exists_cluster_no_change(self, get_mock):

    changes = dict(replication_status=fields.ReplicationStatus.FAILED_OVER, active_backend_id='secondary', frozen=True)
    cluster = objects.Cluster(name='cluster_name', **changes)
    get_mock.return_value = cluster
    app = service.Service.create(host=self.host, binary=self.binary, topic=self.topic)
    svc = objects.Service.get_by_id(self.ctxt, app.service_id)
    svc.replication_status = fields.ReplicationStatus.ERROR
    svc.obj_reset_changes()
    app.cluster = cluster.name
    app._ensure_cluster_exists(self.ctxt, svc)
    get_mock.assert_called_once_with(self.ctxt, None, name=cluster.name, binary=app.binary)
    self.assertEqual({}, svc.cinder_obj_get_changes())
