'We use service replication fields to create the cluster.'

@mock.patch('cinder.service.Service.is_svc_upgrading_to_n', mock.Mock(return_value=False))
def test_ensure_cluster_exists_cluster_create_replicated_and_non(self):

    changes = dict(replication_status=fields.ReplicationStatus.FAILED_OVER, active_backend_id='secondary', frozen=True)
    app = service.Service.create(host=self.host, binary=self.binary, topic=self.topic)
    svc = objects.Service.get_by_id(self.ctxt, app.service_id)
    for (key, value) in changes.items():
        setattr(svc, key, value)
    app.cluster = 'cluster_name'
    app._ensure_cluster_exists(self.ctxt, svc)
    cluster = objects.Cluster.get_by_id(self.ctxt, None, name=app.cluster)
    for (key, value) in changes.items():
        self.assertEqual(value, getattr(cluster, key))
