'Check that Service instance and DB service and cluster are ok.'

def _check_app(self, app, cluster=None, cluster_exists=None, is_upgrading=False, svc_id=None, added_to_cluster=None):

    self.assertIsNotNone(app)
    self.assertTrue(hasattr(app, 'service_id'))
    if svc_id:
        self.assertEqual(svc_id, app.service_id)
    self.assertEqual(cluster, app.cluster)
    svc = objects.Service.get_by_id(self.ctxt, app.service_id)
    cluster_name = (cluster if (cluster_exists is not False) else None)
    self.assertEqual(cluster_name, svc.cluster_name)
    clusters = objects.ClusterList.get_all(self.ctxt)
    if (added_to_cluster is None):
        added_to_cluster = (not is_upgrading)
    if cluster_name:
        self.assertEqual(1, len(clusters))
        cluster = clusters[0]
        self.assertEqual(cluster_name, cluster.name)
        self.assertEqual(self.binary, cluster.binary)
    else:
        self.assertListEqual([], clusters.objects)
    self.assertEqual(added_to_cluster, app.added_to_cluster)
