|
@@ -1404,6 +1404,89 @@ public class ClusterTest {
|
|
|
is(expectedServiceConfigResponses));
|
|
|
}
|
|
|
|
|
|
+ @Test
|
|
|
+ public void testAllServiceConfigVersionsWithDeletedConfigGroups() throws Exception {
|
|
|
+ // Given
|
|
|
+ createDefaultCluster();
|
|
|
+
|
|
|
+ Config hdfsSiteConfigV1 = configFactory.createNew(c1, "hdfs-site", ImmutableMap.of("p1", "v1"), ImmutableMap.<String, Map<String,String>>of());
|
|
|
+ hdfsSiteConfigV1.setTag("version1");
|
|
|
+ hdfsSiteConfigV1.persist();
|
|
|
+
|
|
|
+ c1.addConfig(hdfsSiteConfigV1);
|
|
|
+
|
|
|
+
|
|
|
+ ServiceConfigVersionResponse hdfsSiteConfigResponseV1 = c1.addDesiredConfig("admin", Collections.singleton(hdfsSiteConfigV1));
|
|
|
+ List<ConfigurationResponse> configResponsesDefaultGroup = Collections.singletonList(
|
|
|
+ new ConfigurationResponse(c1.getClusterName(), hdfsSiteConfigV1.getStackId(),
|
|
|
+ hdfsSiteConfigV1.getType(), hdfsSiteConfigV1.getTag(), hdfsSiteConfigV1.getVersion(),
|
|
|
+ hdfsSiteConfigV1.getProperties(), hdfsSiteConfigV1.getPropertiesAttributes(), hdfsSiteConfigV1.getPropertiesTypes())
|
|
|
+ );
|
|
|
+
|
|
|
+ hdfsSiteConfigResponseV1.setConfigurations(configResponsesDefaultGroup);
|
|
|
+
|
|
|
+ Config hdfsSiteConfigV2 = configFactory.createNew(c1, "hdfs-site", ImmutableMap.of("p1", "v2"), ImmutableMap.<String, Map<String,String>>of());
|
|
|
+ hdfsSiteConfigV2.setTag("version2");
|
|
|
+
|
|
|
+ ConfigGroup configGroup = configGroupFactory.createNew(c1, "configGroup1", "version1", "test description", ImmutableMap.of(hdfsSiteConfigV2.getType(), hdfsSiteConfigV2), ImmutableMap.<Long, Host>of());
|
|
|
+ configGroup.persist();
|
|
|
+
|
|
|
+ c1.addConfigGroup(configGroup);
|
|
|
+ ServiceConfigVersionResponse hdfsSiteConfigResponseV2 = c1.createServiceConfigVersion("HDFS", "admin", "test note", configGroup);
|
|
|
+ hdfsSiteConfigResponseV2.setConfigurations(Collections.singletonList(
|
|
|
+ new ConfigurationResponse(c1.getClusterName(), hdfsSiteConfigV2.getStackId(),
|
|
|
+ hdfsSiteConfigV2.getType(), hdfsSiteConfigV2.getTag(), hdfsSiteConfigV2.getVersion(),
|
|
|
+ hdfsSiteConfigV2.getProperties(), hdfsSiteConfigV2.getPropertiesAttributes(), hdfsSiteConfigV2.getPropertiesTypes())
|
|
|
+ ));
|
|
|
+
|
|
|
+ // delete the config group
|
|
|
+ c1.deleteConfigGroup(configGroup.getId());
|
|
|
+
|
|
|
+
|
|
|
+ // hdfs config v3
|
|
|
+ ServiceConfigVersionResponse hdfsSiteConfigResponseV3 = c1.createServiceConfigVersion("HDFS", "admin", "new config in default group", null);
|
|
|
+ hdfsSiteConfigResponseV3.setConfigurations(configResponsesDefaultGroup);
|
|
|
+ hdfsSiteConfigResponseV3.setIsCurrent(true); // this is the active config in default config group as it's more recent than V1
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ // When
|
|
|
+
|
|
|
+ List<ServiceConfigVersionResponse> allServiceConfigResponses = c1.getServiceConfigVersions();
|
|
|
+
|
|
|
+ Collections.sort(
|
|
|
+ allServiceConfigResponses,
|
|
|
+ new Comparator<ServiceConfigVersionResponse>() {
|
|
|
+ @Override
|
|
|
+ public int compare(ServiceConfigVersionResponse o1, ServiceConfigVersionResponse o2) {
|
|
|
+ return o1.getVersion().compareTo(o2.getVersion());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ );
|
|
|
+
|
|
|
+
|
|
|
+ // Then
|
|
|
+
|
|
|
+ assertEquals(3, allServiceConfigResponses.size());
|
|
|
+
|
|
|
+ // all configs that was created as member of config group 'configGroup1' should be marked as 'not current'
|
|
|
+ // as the parent config group has been deleted
|
|
|
+
|
|
|
+ // default group
|
|
|
+ assertEquals(false, allServiceConfigResponses.get(0).getIsCurrent());
|
|
|
+ assertEquals(ServiceConfigVersionResponse.DEFAULT_CONFIG_GROUP_NAME, allServiceConfigResponses.get(0).getGroupName());
|
|
|
+
|
|
|
+ assertEquals(true, allServiceConfigResponses.get(2).getIsCurrent());
|
|
|
+ assertEquals(ServiceConfigVersionResponse.DEFAULT_CONFIG_GROUP_NAME, allServiceConfigResponses.get(2).getGroupName());
|
|
|
+
|
|
|
+ // deleted group
|
|
|
+ assertEquals(false, allServiceConfigResponses.get(1).getIsCurrent());
|
|
|
+ assertEquals(ServiceConfigVersionResponse.DELETED_CONFIG_GROUP_NAME, allServiceConfigResponses.get(1).getGroupName());
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
@Test
|
|
|
public void testTransitionClusterVersion() throws Exception {
|
|
|
createDefaultCluster();
|