@Test public void testUpdateAccumuloConfigs() throws Exception { EasyMockSupport easyMockSupport = new EasyMockSupport(); final AmbariManagementController mockAmbariManagementController = easyMockSupport.createNiceMock(AmbariManagementController.class); final Clusters mockClusters = easyMockSupport.createStrictMock(Clusters.class); final Cluster mockClusterExpected = easyMockSupport.createNiceMock(Cluster.class); final Map<String, String> originalClientProperties = new HashMap<String, String>(); final Map<String, String> updatedClientProperties = new HashMap<String, String>() { { put("kerberos.server.primary", "{{bare_accumulo_principal}}"); } }; final Config clientConfig = easyMockSupport.createNiceMock(Config.class); final Injector mockInjector = Guice.createInjector(new AbstractModule() { @Override protected void configure() { bind(AmbariManagementController.class).toInstance(mockAmbariManagementController); bind(Clusters.class).toInstance(mockClusters); bind(EntityManager.class).toInstance(entityManager); 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.getSecurityType()).andReturn(SecurityType.KERBEROS).once(); expect(mockClusterExpected.getDesiredConfigByType("client")).andReturn(clientConfig).atLeastOnce(); expect(clientConfig.getProperties()).andReturn(originalClientProperties).atLeastOnce(); UpgradeCatalog220 upgradeCatalog220 = createMockBuilder(UpgradeCatalog220.class) .withConstructor(Injector.class) .withArgs(mockInjector) .addMockedMethod("updateConfigurationPropertiesForCluster", Cluster.class, String.class, Map.class, boolean.class, boolean.class) .createMock(); upgradeCatalog220.updateConfigurationPropertiesForCluster(mockClusterExpected, "client", updatedClientProperties, true, false); expectLastCall().once(); easyMockSupport.replayAll(); replay(upgradeCatalog220); upgradeCatalog220.updateAccumuloConfigs(); easyMockSupport.verifyAll(); }
protected void updateAccumuloConfigs() throws AmbariException { AmbariManagementController ambariManagementController = injector.getInstance(AmbariManagementController.class); for (final Cluster cluster : getCheckedClusterMap(ambariManagementController.getClusters()).values()) { if(cluster.getSecurityType() == SecurityType.KERBEROS) { Config clientProps = cluster.getDesiredConfigByType("client"); if (clientProps != null) { Map<String, String> properties = clientProps.getProperties(); if (properties == null) { properties = new HashMap<String, String>(); } properties.put("kerberos.server.primary", "{{bare_accumulo_principal}}"); updateConfigurationPropertiesForCluster(cluster, "client", properties, true, false); } } } }
UpgradeCatalog220 extends AbstractUpgradeCatalog { protected void updateAccumuloConfigs() throws AmbariException { AmbariManagementController ambariManagementController = injector.getInstance(AmbariManagementController.class); for (final Cluster cluster : getCheckedClusterMap(ambariManagementController.getClusters()).values()) { if(cluster.getSecurityType() == SecurityType.KERBEROS) { Config clientProps = cluster.getDesiredConfigByType("client"); if (clientProps != null) { Map<String, String> properties = clientProps.getProperties(); if (properties == null) { properties = new HashMap<String, String>(); } properties.put("kerberos.server.primary", "{{bare_accumulo_principal}}"); updateConfigurationPropertiesForCluster(cluster, "client", properties, true, false); } } } } }
UpgradeCatalog220 extends AbstractUpgradeCatalog { protected void updateAccumuloConfigs() throws AmbariException { AmbariManagementController ambariManagementController = injector.getInstance(AmbariManagementController.class); for (final Cluster cluster : getCheckedClusterMap(ambariManagementController.getClusters()).values()) { if(cluster.getSecurityType() == SecurityType.KERBEROS) { Config clientProps = cluster.getDesiredConfigByType("client"); if (clientProps != null) { Map<String, String> properties = clientProps.getProperties(); if (properties == null) { properties = new HashMap<String, String>(); } properties.put("kerberos.server.primary", "{{bare_accumulo_principal}}"); updateConfigurationPropertiesForCluster(cluster, "client", properties, true, false); } } } } @Inject  UpgradeCatalog220(Injector injector); }
UpgradeCatalog220 extends AbstractUpgradeCatalog { protected void updateAccumuloConfigs() throws AmbariException { AmbariManagementController ambariManagementController = injector.getInstance(AmbariManagementController.class); for (final Cluster cluster : getCheckedClusterMap(ambariManagementController.getClusters()).values()) { if(cluster.getSecurityType() == SecurityType.KERBEROS) { Config clientProps = cluster.getDesiredConfigByType("client"); if (clientProps != null) { Map<String, String> properties = clientProps.getProperties(); if (properties == null) { properties = new HashMap<String, String>(); } properties.put("kerberos.server.primary", "{{bare_accumulo_principal}}"); updateConfigurationPropertiesForCluster(cluster, "client", properties, true, false); } } } } @Inject  UpgradeCatalog220(Injector injector); @Override String getTargetVersion(); @Override String getSourceVersion(); @Transactional void bootstrapRepoVersionForHDP21(); }
UpgradeCatalog220 extends AbstractUpgradeCatalog { protected void updateAccumuloConfigs() throws AmbariException { AmbariManagementController ambariManagementController = injector.getInstance(AmbariManagementController.class); for (final Cluster cluster : getCheckedClusterMap(ambariManagementController.getClusters()).values()) { if(cluster.getSecurityType() == SecurityType.KERBEROS) { Config clientProps = cluster.getDesiredConfigByType("client"); if (clientProps != null) { Map<String, String> properties = clientProps.getProperties(); if (properties == null) { properties = new HashMap<String, String>(); } properties.put("kerberos.server.primary", "{{bare_accumulo_principal}}"); updateConfigurationPropertiesForCluster(cluster, "client", properties, true, false); } } } } @Inject  UpgradeCatalog220(Injector injector); @Override String getTargetVersion(); @Override String getSourceVersion(); @Transactional void bootstrapRepoVersionForHDP21(); static final String UPGRADE_PACKAGE_COL; static final String UPGRADE_TYPE_COL; static final String REPO_VERSION_TABLE; }