|
@@ -37,6 +37,7 @@ import org.apache.ambari.server.state.Cluster;
|
|
|
import org.apache.ambari.server.state.Clusters;
|
|
|
import org.apache.ambari.server.state.Config;
|
|
|
import org.apache.ambari.server.state.ConfigHelper;
|
|
|
+import org.apache.ambari.server.state.Service;
|
|
|
import org.apache.ambari.server.state.StackId;
|
|
|
import org.apache.ambari.server.state.stack.OsFamily;
|
|
|
import org.easymock.EasyMockSupport;
|
|
@@ -94,6 +95,7 @@ public class UpgradeCatalog213Test {
|
|
|
@Test
|
|
|
public void testExecuteDMLUpdates() throws Exception {
|
|
|
Method updateAMSConfigs = UpgradeCatalog213.class.getDeclaredMethod("updateAMSConfigs");
|
|
|
+ Method updateKafkaConfigs = UpgradeCatalog213.class.getDeclaredMethod("updateKafkaConfigs");
|
|
|
Method updateStormConfigs = UpgradeCatalog213.class.getDeclaredMethod("updateStormConfigs");
|
|
|
Method addNewConfigurationsFromXml = AbstractUpgradeCatalog.class.getDeclaredMethod("addNewConfigurationsFromXml");
|
|
|
Method updateHbaseEnvConfig = UpgradeCatalog213.class.getDeclaredMethod("updateHbaseEnvConfig");
|
|
@@ -105,6 +107,7 @@ public class UpgradeCatalog213Test {
|
|
|
.addMockedMethod(addNewConfigurationsFromXml)
|
|
|
.addMockedMethod(updateHbaseEnvConfig)
|
|
|
.addMockedMethod(updateAlertDefinitions)
|
|
|
+ .addMockedMethod(updateKafkaConfigs)
|
|
|
.createMock();
|
|
|
|
|
|
upgradeCatalog213.updateHbaseEnvConfig();
|
|
@@ -117,6 +120,8 @@ public class UpgradeCatalog213Test {
|
|
|
expectLastCall().once();
|
|
|
upgradeCatalog213.updateAlertDefinitions();
|
|
|
expectLastCall().once();
|
|
|
+ upgradeCatalog213.updateKafkaConfigs();
|
|
|
+ expectLastCall().once();
|
|
|
|
|
|
replay(upgradeCatalog213);
|
|
|
|
|
@@ -328,6 +333,54 @@ public class UpgradeCatalog213Test {
|
|
|
Assert.assertEquals(expected, upgradeCatalog213.modifyJournalnodeProcessAlertSource(alertSource));
|
|
|
}
|
|
|
|
|
|
+ @Test
|
|
|
+ public void testUpdateKafkaConfigs() throws Exception {
|
|
|
+ EasyMockSupport easyMockSupport = new EasyMockSupport();
|
|
|
+ final AmbariManagementController mockAmbariManagementController = easyMockSupport.createNiceMock(AmbariManagementController.class);
|
|
|
+ final ConfigHelper mockConfigHelper = easyMockSupport.createMock(ConfigHelper.class);
|
|
|
+
|
|
|
+ final Clusters mockClusters = easyMockSupport.createStrictMock(Clusters.class);
|
|
|
+ final Cluster mockClusterExpected = easyMockSupport.createNiceMock(Cluster.class);
|
|
|
+ final Map<String, String> propertiesAmsEnv = new HashMap<String, String>() {
|
|
|
+ {
|
|
|
+ put("kafka.metrics.reporters", "{{kafka_metrics_reporters}}");
|
|
|
+ }
|
|
|
+ };
|
|
|
+ final Map<String, Service> installedServices = new HashMap<String, Service>() {
|
|
|
+ {
|
|
|
+ put("KAFKA", null);
|
|
|
+ put("AMBARI_METRICS", null);
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ final Config mockAmsEnv = easyMockSupport.createNiceMock(Config.class);
|
|
|
+
|
|
|
+ final Injector mockInjector = Guice.createInjector(new AbstractModule() {
|
|
|
+ @Override
|
|
|
+ protected void configure() {
|
|
|
+ bind(AmbariManagementController.class).toInstance(mockAmbariManagementController);
|
|
|
+ bind(ConfigHelper.class).toInstance(mockConfigHelper);
|
|
|
+ bind(Clusters.class).toInstance(mockClusters);
|
|
|
+
|
|
|
+ bind(DBAccessor.class).toInstance(createNiceMock(DBAccessor.class));
|
|
|
+ bind(OsFamily.class).toInstance(createNiceMock(OsFamily.class));
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ expect(mockAmbariManagementController.getClusters()).andReturn(mockClusters).once();
|
|
|
+ expect(mockClusters.getClusters()).andReturn(new HashMap<String, Cluster>() {{
|
|
|
+ put("normal", mockClusterExpected);
|
|
|
+ }}).once();
|
|
|
+
|
|
|
+ expect(mockClusterExpected.getServices()).andReturn(installedServices).atLeastOnce();
|
|
|
+ expect(mockClusterExpected.getDesiredConfigByType("kafka-broker")).andReturn(mockAmsEnv).atLeastOnce();
|
|
|
+ expect(mockAmsEnv.getProperties()).andReturn(propertiesAmsEnv).atLeastOnce();
|
|
|
+
|
|
|
+ easyMockSupport.replayAll();
|
|
|
+ mockInjector.getInstance(UpgradeCatalog213.class).updateKafkaConfigs();
|
|
|
+ easyMockSupport.verifyAll();
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* @param dbAccessor
|
|
|
* @return
|