ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vbrodets...@apache.org
Subject ambari git commit: AMBARI-15095. Take into account "config group" logic in check database queries.(vbrodetskyi)
Date Mon, 22 Feb 2016 12:58:43 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-2.2 c459af890 -> 105ae990d


AMBARI-15095. Take into account "config group" logic in check database queries.(vbrodetskyi)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/105ae990
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/105ae990
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/105ae990

Branch: refs/heads/branch-2.2
Commit: 105ae990d471de9a8350d2f9073222da514d0043
Parents: c459af8
Author: Vitaly Brodetskyi <vbrodetskyi@hortonworks.com>
Authored: Mon Feb 22 14:58:18 2016 +0200
Committer: Vitaly Brodetskyi <vbrodetskyi@hortonworks.com>
Committed: Mon Feb 22 14:58:18 2016 +0200

----------------------------------------------------------------------
 .../server/checks/CheckDatabaseHelper.java      | 137 ++++++++++++-------
 .../server/checks/CheckDatabaseHelperTest.java  |  20 +--
 2 files changed, 97 insertions(+), 60 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/105ae990/ambari-server/src/main/java/org/apache/ambari/server/checks/CheckDatabaseHelper.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/checks/CheckDatabaseHelper.java
b/ambari-server/src/main/java/org/apache/ambari/server/checks/CheckDatabaseHelper.java
index 0396767..766e2c0 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/checks/CheckDatabaseHelper.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/checks/CheckDatabaseHelper.java
@@ -59,6 +59,7 @@ public class CheckDatabaseHelper {
   private AmbariMetaInfo ambariMetaInfo;
   private Injector injector;
   private boolean errorAvailable = false;
+  private boolean warningAvailable = false;
 
   @Inject
   public CheckDatabaseHelper(DBAccessor dbAccessor,
@@ -119,11 +120,19 @@ public class CheckDatabaseHelper {
     this.errorAvailable = errorAvailable;
   }
 
+  public boolean isWarningAvailable() {
+    return warningAvailable;
+  }
+
+  public void setWarningAvailable(boolean warningAvailable) {
+    this.warningAvailable = warningAvailable;
+  }
+
   /*
-  * This method checks if all configurations that we have in clusterconfig table
-  * have at least one mapping in clusterconfigmapping table. If we found not mapped config
-  * then we are showing warning message for user.
-  * */
+    * This method checks if all configurations that we have in clusterconfig table
+    * have at least one mapping in clusterconfigmapping table. If we found not mapped config
+    * then we are showing warning message for user.
+    * */
   protected void checkForNotMappedConfigsToCluster() {
     String GET_NOT_MAPPED_CONFIGS_QUERY = "select type_name from clusterconfig where type_name
not in (select type_name from clusterconfigmapping)";
     Set<String> nonSelectedConfigs = new HashSet<>();
@@ -137,7 +146,8 @@ public class CheckDatabaseHelper {
         }
       }
       if (!nonSelectedConfigs.isEmpty()) {
-        LOG.warn("You have config(s) that is(are) not mapped to any cluster: " + StringUtils.join(nonSelectedConfigs,
","));
+        LOG.warn("You have config(s): {} that is(are) not mapped (in clusterconfigmapping
table) to any cluster!", StringUtils.join(nonSelectedConfigs, ","));
+        warningAvailable = true;
       }
     } catch (SQLException e) {
       LOG.error("Exception occurred during check for not mapped configs to cluster procedure:
", e);
@@ -159,25 +169,27 @@ public class CheckDatabaseHelper {
   * than one selected version it's a bug and we are showing error message for user.
   * */
   protected void checkForConfigsSelectedMoreThanOnce() {
-    String GET_CONFIGS_SELECTED_MORE_THAN_ONCE_QUERY = "select c.cluster_name,type_name from
clusterconfigmapping ccm " +
+    String GET_CONFIGS_SELECTED_MORE_THAN_ONCE_QUERY = "select c.cluster_name, ccm.type_name
from clusterconfigmapping ccm " +
             "join clusters c on ccm.cluster_id=c.cluster_id " +
-            "group by c.cluster_name,type_name " +
+            "group by c.cluster_name, ccm.type_name " +
             "having sum(selected) > 1";
-    Multimap<String, String> configsSelectedMoreThanOnce = HashMultimap.create();
+    Multimap<String, String> clusterConfigTypeMap = HashMultimap.create();
     ResultSet rs = null;
     try {
       Statement statement = connection.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
       rs = statement.executeQuery(GET_CONFIGS_SELECTED_MORE_THAN_ONCE_QUERY);
       if (rs != null) {
         while (rs.next()) {
-          configsSelectedMoreThanOnce.put(rs.getString("cluster_name"), rs.getString("type_name"));
+          clusterConfigTypeMap.put(rs.getString("cluster_name"), rs.getString("type_name"));
+        }
+
+        for (String clusterName : clusterConfigTypeMap.keySet()) {
+          LOG.error("You have config(s), in cluster {}, that is(are) selected more than once
in clusterconfigmapping table: {}",
+                  clusterName ,StringUtils.join(clusterConfigTypeMap.get(clusterName), ","));
+          errorAvailable = true;
         }
       }
-      for (String clusterName : configsSelectedMoreThanOnce.keySet()) {
-        LOG.error(String.format("You have config(s), in cluster %s, that is(are) selected
more than once in clusterconfigmapping: %s",
-                clusterName ,StringUtils.join(configsSelectedMoreThanOnce.get(clusterName),
",")));
-        errorAvailable = true;
-      }
+
     } catch (SQLException e) {
       LOG.error("Exception occurred during check for config selected more than ones procedure:
", e);
     } finally {
@@ -207,12 +219,13 @@ public class CheckDatabaseHelper {
         while (rs.next()) {
           hostsWithoutStatus.add(rs.getString("host_name"));
         }
-      }
 
-      if (!hostsWithoutStatus.isEmpty()) {
-        LOG.error("You have host(s) without status: " + StringUtils.join(hostsWithoutStatus,
","));
-        errorAvailable = true;
+        if (!hostsWithoutStatus.isEmpty()) {
+          LOG.error("You have host(s) without state (in hoststate table): " + StringUtils.join(hostsWithoutStatus,
","));
+          errorAvailable = true;
+        }
       }
+
     } catch (SQLException e) {
       LOG.error("Exception occurred during check for host without state procedure: ", e);
     } finally {
@@ -236,7 +249,7 @@ public class CheckDatabaseHelper {
     String GET_HOST_COMPONENT_STATE_COUNT_QUERY = "select count(*) from hostcomponentstate";
     String GET_HOST_COMPONENT_DESIRED_STATE_COUNT_QUERY = "select count(*) from hostcomponentdesiredstate";
     String GET_MERGED_TABLE_ROW_COUNT_QUERY = "select count(*) FROM hostcomponentstate hcs
" +
-            "JOIN hostcomponentdesiredstate hcds ON hcs.service_name = hcds.service_name
AND hcs.component_name = hcds.component_name AND hcs.host_id = hcds.host_id";
+            "JOIN hostcomponentdesiredstate hcds ON hcs.service_name=hcds.service_name AND
hcs.component_name=hcds.component_name AND hcs.host_id=hcds.host_id";
     int hostComponentStateCount = 0;
     int hostComponentDesiredStateCount = 0;
     int mergedCount = 0;
@@ -266,7 +279,7 @@ public class CheckDatabaseHelper {
       }
 
       if (hostComponentStateCount != hostComponentDesiredStateCount || hostComponentStateCount
!= mergedCount) {
-        LOG.error("Your host component states(hostcomponentstate table) count not equals
host component desired states(hostcomponentdesiredstate table) count!");
+        LOG.error("Your host component states (hostcomponentstate table) count not equals
host component desired states (hostcomponentdesiredstate table) count!");
         errorAvailable = true;
       }
 
@@ -297,29 +310,31 @@ public class CheckDatabaseHelper {
     String GET_SERVICES_WITHOUT_CONFIGS_QUERY = "select c.cluster_name, service_name from
clusterservices cs " +
             "join clusters c on cs.cluster_id=c.cluster_id " +
             "where service_name not in (select service_name from serviceconfig sc where sc.cluster_id=cs.cluster_id
and sc.service_name=cs.service_name and sc.group_id is null)";
-    String GET_SERVICE_CONFIG_WITHOUT_MAPPING_QUERY = "select service_name from serviceconfig
where service_config_id not in (select service_config_id from serviceconfigmapping) and group_id
is null";
+    String GET_SERVICE_CONFIG_WITHOUT_MAPPING_QUERY = "select c.cluster_name, sc.service_name,
sc.version from serviceconfig sc " +
+            "join clusters c on sc.cluster_id=c.cluster_id " +
+            "where service_config_id not in (select service_config_id from serviceconfigmapping)
and group_id is null";
     String GET_STACK_NAME_VERSION_QUERY = "select c.cluster_name, s.stack_name, s.stack_version
from clusters c " +
             "join stack s on c.desired_stack_id = s.stack_id";
-    String GET_SERVICES_WITH_CONFIGS_QUERY = "select c.cluster_name, cs.service_name, type_name,
sc.version from clusterservices cs " +
+    String GET_SERVICES_WITH_CONFIGS_QUERY = "select c.cluster_name, cs.service_name, cc.type_name,
sc.version from clusterservices cs " +
             "join serviceconfig sc on cs.service_name=sc.service_name and cs.cluster_id=sc.cluster_id
" +
             "join serviceconfigmapping scm on sc.service_config_id=scm.service_config_id
" +
             "join clusterconfig cc on scm.config_id=cc.config_id and sc.cluster_id=cc.cluster_id
" +
             "join clusters c on cc.cluster_id=c.cluster_id " +
             "where sc.group_id is null " +
-            "group by c.cluster_name, cs.service_name, type_name, sc.version";
-    String GET_NOT_SELECTED_SERVICE_CONFIGS_QUERY = "select c.cluster_name, cs.service_name,cc.type_name
from clusterservices cs " +
+            "group by c.cluster_name, cs.service_name, cc.type_name, sc.version";
+    String GET_NOT_SELECTED_SERVICE_CONFIGS_QUERY = "select c.cluster_name, cs.service_name,
cc.type_name from clusterservices cs " +
             "join serviceconfig sc on cs.service_name=sc.service_name and cs.cluster_id=sc.cluster_id
" +
             "join serviceconfigmapping scm on sc.service_config_id=scm.service_config_id
" +
             "join clusterconfig cc on scm.config_id=cc.config_id and cc.cluster_id=sc.cluster_id
" +
             "join clusterconfigmapping ccm on cc.type_name=ccm.type_name and cc.version_tag=ccm.version_tag
and cc.cluster_id=ccm.cluster_id " +
             "join clusters c on ccm.cluster_id=c.cluster_id " +
             "where sc.group_id is null and sc.service_config_id = (select max(service_config_id)
from serviceconfig sc2 where sc2.service_name=sc.service_name and sc2.cluster_id=sc.cluster_id)
" +
-            "group by c.cluster_name,cs.service_name,cc.type_name " +
+            "group by c.cluster_name, cs.service_name, cc.type_name " +
             "having sum(ccm.selected) < 1";
-    Multimap<String, String> servicesWithoutConfigs = HashMultimap.create();
+    Multimap<String, String> clusterServiceMap = HashMultimap.create();
     Map<String, Map<String, String>>  clusterStackInfo = new HashMap<>();
-    Set<String> servicesWithoutMappedConfigs = new HashSet<>();
-    Map<String, Multimap<String, String>> notSelectedServiceConfigs = new HashMap<>();
+    Map<String, Multimap<String, String>> clusterServiceVersionMap = new HashMap<>();
+    Map<String, Multimap<String, String>> clusterServiceConfigType = new HashMap<>();
     ResultSet rs = null;
 
     try {
@@ -328,27 +343,45 @@ public class CheckDatabaseHelper {
       rs = statement.executeQuery(GET_SERVICES_WITHOUT_CONFIGS_QUERY);
       if (rs != null) {
         while (rs.next()) {
-          servicesWithoutConfigs.put(rs.getString("cluster_name"), rs.getString("service_name"));
+          clusterServiceMap.put(rs.getString("cluster_name"), rs.getString("service_name"));
+        }
+
+        for (String clusterName : clusterServiceMap.keySet()) {
+          LOG.error("Service(s): {}, from cluster {} has no config(s) in serviceconfig table!",
StringUtils.join(clusterServiceMap.get(clusterName), ","), clusterName);
+          errorAvailable = true;
         }
-      }
 
-      for (String clusterName : servicesWithoutConfigs.keySet()) {
-        LOG.error(String.format("Service(s): %s, from cluster %s has no config(s) in serviceconfig
table!", StringUtils.join(servicesWithoutConfigs.get(clusterName), ","), clusterName));
-        errorAvailable = true;
       }
 
       rs = statement.executeQuery(GET_SERVICE_CONFIG_WITHOUT_MAPPING_QUERY);
       if (rs != null) {
+        String serviceName = null, version = null, clusterName = null;
         while (rs.next()) {
-          servicesWithoutMappedConfigs.add(rs.getString("service_name"));
+          serviceName = rs.getString("service_name");
+          clusterName = rs.getString("cluster_name");
+          version = rs.getString("version");
+
+          if (clusterServiceVersionMap.get(clusterName) != null) {
+            Multimap<String, String> serviceVersion = clusterServiceVersionMap.get(clusterName);
+            serviceVersion.put(serviceName, version);
+          } else {
+            Multimap<String, String> serviceVersion = HashMultimap.create();;
+            serviceVersion.put(serviceName, version);
+            clusterServiceVersionMap.put(clusterName, serviceVersion);
+          }
+        }
+
+        for (String clName : clusterServiceVersionMap.keySet()) {
+          Multimap<String, String> serviceVersion = clusterServiceVersionMap.get(clName);
+          for (String servName : serviceVersion.keySet()) {
+            LOG.error("In cluster {}, service config mapping is unavailable (in table serviceconfigmapping)
for service {} with version(s) {}! ", clName, servName, StringUtils.join(serviceVersion.get(servName),
","));
+            errorAvailable = true;
+          }
         }
-      }
 
-      if (!servicesWithoutMappedConfigs.isEmpty()) {
-        LOG.error("You have service(s) without mapped configs in serviceconfigmapping: "
+ StringUtils.join(servicesWithoutMappedConfigs, ","));
-        errorAvailable = true;
       }
 
+      //get stack info from db
       rs = statement.executeQuery(GET_STACK_NAME_VERSION_QUERY);
       if (rs != null) {
         while (rs.next()) {
@@ -375,6 +408,7 @@ public class CheckDatabaseHelper {
 
           serviceNames.add(serviceName);
 
+          //collect data about mapped configs to services from db
           if (dbClusterServiceVersionConfigs.get(clusterName) != null) {
             Map<Integer, Multimap<String, String>> dbServiceVersionConfigs =
dbClusterServiceVersionConfigs.get(clusterName);
 
@@ -386,18 +420,18 @@ public class CheckDatabaseHelper {
               dbServiceVersionConfigs.put(serviceVersion, dbServiceConfigs);
             }
           } else {
-
             Map<Integer, Multimap<String, String>> dbServiceVersionConfigs =
new HashMap<>();
             Multimap<String, String> dbServiceConfigs = HashMultimap.create();
             dbServiceConfigs.put(serviceName, configType);
             dbServiceVersionConfigs.put(serviceVersion, dbServiceConfigs);
             dbClusterServiceVersionConfigs.put(clusterName, dbServiceVersionConfigs);
-
           }
         }
       }
 
+      //compare service configs from stack with configs that we got from db
       for (Map.Entry<String, Map<String, String>> clusterStackInfoEntry : clusterStackInfo.entrySet())
{
+        //collect required configs for all services from stack
         String clusterName = clusterStackInfoEntry.getKey();
         Map<String, String> stackInfo = clusterStackInfoEntry.getValue();
         String stackName = stackInfo.keySet().iterator().next();
@@ -411,6 +445,7 @@ public class CheckDatabaseHelper {
           }
         }
 
+        //compare required service configs from stack with mapped service configs from db
         Map<Integer, Multimap<String, String>> dbServiceVersionConfigs = dbClusterServiceVersionConfigs.get(clusterName);
         for (Integer serviceVersion : dbServiceVersionConfigs.keySet()) {
           Multimap<String, String> dbServiceConfigs = dbServiceVersionConfigs.get(serviceVersion);
@@ -420,8 +455,8 @@ public class CheckDatabaseHelper {
             if (serviceConfigsFromDB != null && serviceConfigsFromStack != null)
{
               serviceConfigsFromStack.removeAll(serviceConfigsFromDB);
               if (!serviceConfigsFromStack.isEmpty()) {
-                LOG.error(String.format("Required config(s): %s is(are) not available for
service %s with service config version %s for cluster %s",
-                        StringUtils.join(serviceConfigsFromStack, ","), serviceName, Integer.toString(serviceVersion),
clusterName));
+                LOG.error("Required config(s): {} is(are) not available for service {} with
service config version {} in cluster {}",
+                        StringUtils.join(serviceConfigsFromStack, ","), serviceName, Integer.toString(serviceVersion),
clusterName);
                 errorAvailable = true;
               }
             }
@@ -429,7 +464,7 @@ public class CheckDatabaseHelper {
         }
       }
 
-
+      //getting services which has mapped configs which are not selected in clusterconfigmapping
       rs = statement.executeQuery(GET_NOT_SELECTED_SERVICE_CONFIGS_QUERY);
       if (rs != null) {
         String serviceName = null, configType = null, clusterName = null;
@@ -439,24 +474,24 @@ public class CheckDatabaseHelper {
           configType = rs.getString("type_name");
 
 
-          if (notSelectedServiceConfigs.get(clusterName) != null) {
-            Multimap<String, String> serviceConfigs = notSelectedServiceConfigs.get(clusterName);
+          if (clusterServiceConfigType.get(clusterName) != null) {
+            Multimap<String, String> serviceConfigs = clusterServiceConfigType.get(clusterName);
             serviceConfigs.put(serviceName, configType);
           } else {
 
             Multimap<String, String> serviceConfigs = HashMultimap.create();
             serviceConfigs.put(serviceName, configType);
-            notSelectedServiceConfigs.put(clusterName, serviceConfigs);
+            clusterServiceConfigType.put(clusterName, serviceConfigs);
 
           }
 
         }
       }
 
-      for (String clusterName : notSelectedServiceConfigs.keySet()) {
-        Multimap<String, String> serviceConfig = notSelectedServiceConfigs.get(clusterName);
+      for (String clusterName : clusterServiceConfigType.keySet()) {
+        Multimap<String, String> serviceConfig = clusterServiceConfigType.get(clusterName);
         for (String serviceName : serviceConfig.keySet()) {
-          LOG.error(String.format("You have non selected configs: %s for service %s from
cluster %s!", StringUtils.join(serviceConfig.get(serviceName), ","), serviceName, clusterName));
+          LOG.error("You have non selected configs: {} for service {} from cluster {}!",
StringUtils.join(serviceConfig.get(serviceName), ","), serviceName, clusterName);
           errorAvailable = true;
         }
       }
@@ -515,8 +550,8 @@ public class CheckDatabaseHelper {
     } finally {
       if (checkDatabaseHelper != null) {
         checkDatabaseHelper.closeConnection();
-        if (checkDatabaseHelper.isErrorAvailable()) {
-          System.out.print("Some error(s) was(were) found. Please check ambari-server-check-database.log
for problem(s).");
+        if (checkDatabaseHelper.isErrorAvailable() || checkDatabaseHelper.isWarningAvailable())
{
+          System.out.print("Some error(s) or/and warning(s) was(were) found. Please check
ambari-server-check-database.log for problem(s).");
         } else {
           System.out.print("No erros were found.");
         }

http://git-wip-us.apache.org/repos/asf/ambari/blob/105ae990/ambari-server/src/test/java/org/apache/ambari/server/checks/CheckDatabaseHelperTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/checks/CheckDatabaseHelperTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/checks/CheckDatabaseHelperTest.java
index 67594b7..51ed42b 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/checks/CheckDatabaseHelperTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/checks/CheckDatabaseHelperTest.java
@@ -111,9 +111,9 @@ public class CheckDatabaseHelperTest {
 
     expect(mockDBDbAccessor.getConnection()).andReturn(mockConnection);
     expect(mockConnection.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE)).andReturn(mockStatement);
-    expect(mockStatement.executeQuery("select c.cluster_name,type_name from clusterconfigmapping
ccm " +
+    expect(mockStatement.executeQuery("select c.cluster_name, ccm.type_name from clusterconfigmapping
ccm " +
             "join clusters c on ccm.cluster_id=c.cluster_id " +
-            "group by c.cluster_name,type_name " +
+            "group by c.cluster_name, ccm.type_name " +
             "having sum(selected) > 1")).andReturn(mockResultSet);
 
     CheckDatabaseHelper checkDatabaseHelper = new CheckDatabaseHelper(mockDBDbAccessor, mockInjector,
null);
@@ -201,8 +201,8 @@ public class CheckDatabaseHelperTest {
     expect(mockStatement.executeQuery("select count(*) from hostcomponentstate")).andReturn(mockResultSet);
     expect(mockStatement.executeQuery("select count(*) from hostcomponentdesiredstate")).andReturn(mockResultSet);
     expect(mockStatement.executeQuery("select count(*) FROM hostcomponentstate hcs " +
-            "JOIN hostcomponentdesiredstate hcds ON hcs.service_name = hcds.service_name
AND " +
-            "hcs.component_name = hcds.component_name AND hcs.host_id = hcds.host_id")).andReturn(mockResultSet);
+            "JOIN hostcomponentdesiredstate hcds ON hcs.service_name=hcds.service_name AND
" +
+            "hcs.component_name=hcds.component_name AND hcs.host_id=hcds.host_id")).andReturn(mockResultSet);
 
     CheckDatabaseHelper checkDatabaseHelper = new CheckDatabaseHelper(mockDBDbAccessor, mockInjector,
null);
 
@@ -263,24 +263,26 @@ public class CheckDatabaseHelperTest {
     expect(mockStatement.executeQuery("select c.cluster_name, service_name from clusterservices
cs " +
             "join clusters c on cs.cluster_id=c.cluster_id " +
             "where service_name not in (select service_name from serviceconfig sc where sc.cluster_id=cs.cluster_id
and sc.service_name=cs.service_name and sc.group_id is null)")).andReturn(mockResultSet);
-    expect(mockStatement.executeQuery("select service_name from serviceconfig where service_config_id
not in (select service_config_id from serviceconfigmapping) and group_id is null")).andReturn(mockResultSet);
+    expect(mockStatement.executeQuery("select c.cluster_name, sc.service_name, sc.version
from serviceconfig sc " +
+            "join clusters c on sc.cluster_id=c.cluster_id " +
+            "where service_config_id not in (select service_config_id from serviceconfigmapping)
and group_id is null")).andReturn(mockResultSet);
     expect(mockStatement.executeQuery("select c.cluster_name, s.stack_name, s.stack_version
from clusters c " +
             "join stack s on c.desired_stack_id = s.stack_id")).andReturn(stackResultSet);
-    expect(mockStatement.executeQuery("select c.cluster_name, cs.service_name, type_name,
sc.version from clusterservices cs " +
+    expect(mockStatement.executeQuery("select c.cluster_name, cs.service_name, cc.type_name,
sc.version from clusterservices cs " +
             "join serviceconfig sc on cs.service_name=sc.service_name and cs.cluster_id=sc.cluster_id
" +
             "join serviceconfigmapping scm on sc.service_config_id=scm.service_config_id
" +
             "join clusterconfig cc on scm.config_id=cc.config_id and sc.cluster_id=cc.cluster_id
" +
             "join clusters c on cc.cluster_id=c.cluster_id " +
             "where sc.group_id is null " +
-            "group by c.cluster_name, cs.service_name, type_name, sc.version")).andReturn(serviceConfigResultSet);
-    expect(mockStatement.executeQuery("select c.cluster_name, cs.service_name,cc.type_name
from clusterservices cs " +
+            "group by c.cluster_name, cs.service_name, cc.type_name, sc.version")).andReturn(serviceConfigResultSet);
+    expect(mockStatement.executeQuery("select c.cluster_name, cs.service_name, cc.type_name
from clusterservices cs " +
             "join serviceconfig sc on cs.service_name=sc.service_name and cs.cluster_id=sc.cluster_id
" +
             "join serviceconfigmapping scm on sc.service_config_id=scm.service_config_id
" +
             "join clusterconfig cc on scm.config_id=cc.config_id and cc.cluster_id=sc.cluster_id
" +
             "join clusterconfigmapping ccm on cc.type_name=ccm.type_name and cc.version_tag=ccm.version_tag
and cc.cluster_id=ccm.cluster_id " +
             "join clusters c on ccm.cluster_id=c.cluster_id " +
             "where sc.group_id is null and sc.service_config_id = (select max(service_config_id)
from serviceconfig sc2 where sc2.service_name=sc.service_name and sc2.cluster_id=sc.cluster_id)
" +
-            "group by c.cluster_name,cs.service_name,cc.type_name " +
+            "group by c.cluster_name, cs.service_name, cc.type_name " +
             "having sum(ccm.selected) < 1")).andReturn(mockResultSet);
 
     CheckDatabaseHelper checkDatabaseHelper = new CheckDatabaseHelper(mockDBDbAccessor, mockInjector,
null);


Mime
View raw message