[2/4] ambari git commit: AMBARI-18335. After upgrading cluster from HDP-2.4.x to HDP-2.5.x and added atlas service - missing kafka security properties (rlevas)
http://git-wip-us.apache.org/repos/asf/ambari/blob/7aff03f5/ambari-server/src/test/java/org/apache/ambari/server/state/kerberos/KerberosDescriptorUpdateHelperTest.java -- diff --git a/ambari-server/src/test/java/org/apache/ambari/server/state/kerberos/KerberosDescriptorUpdateHelperTest.java b/ambari-server/src/test/java/org/apache/ambari/server/state/kerberos/KerberosDescriptorUpdateHelperTest.java new file mode 100644 index 000..fca2f1f --- /dev/null +++ b/ambari-server/src/test/java/org/apache/ambari/server/state/kerberos/KerberosDescriptorUpdateHelperTest.java @@ -0,0 +1,2272 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ambari.server.state.kerberos; + +import com.google.gson.Gson; +import com.google.inject.AbstractModule; +import com.google.inject.Guice; +import com.google.inject.Injector; +import com.google.inject.assistedinject.FactoryModuleBuilder; +import junit.framework.Assert; +import org.apache.ambari.server.AmbariException; +import org.apache.ambari.server.api.services.AmbariMetaInfo; +import org.apache.ambari.server.configuration.Configuration; +import org.apache.ambari.server.orm.DBAccessor; +import org.apache.ambari.server.orm.dao.ExtensionLinkDAO; +import org.apache.ambari.server.orm.entities.ExtensionLinkEntity; +import org.apache.ambari.server.orm.entities.MetainfoEntity; +import org.apache.ambari.server.orm.entities.StackEntity; +import org.apache.ambari.server.stack.StackManagerFactory; +import org.apache.ambari.server.state.Clusters; +import org.apache.ambari.server.state.stack.OsFamily; +import org.easymock.EasyMock; +import org.easymock.EasyMockSupport; +import org.junit.Test; + +import javax.persistence.EntityManager; +import javax.persistence.TypedQuery; +import java.util.Collections; +import java.util.Properties; + +import static org.easymock.EasyMock.anyString; +import static org.easymock.EasyMock.expect; + +public class KerberosDescriptorUpdateHelperTest extends EasyMockSupport { + private static final KerberosDescriptorFactory KERBEROS_DESCRIPTOR_FACTORY = new KerberosDescriptorFactory(); + private static final Gson GSON = new Gson(); + + @Test + public void updateDefaultUserKerberosDescriptor() throws Exception { +Injector injector = Guice.createInjector(new AbstractModule() { + + @Override + protected void configure() { +Properties properties = new Properties(); +properties.put("metadata.path", "src/main/resources/stacks"); +properties.put("common.services.path", "src/main/resources/common-services"); +properties.put("server.version.file", "target/version"); +properties.put("custom.action.definitions", "/tmp/nofile"); +Configuration configuration = new Configuration(properties); + +install(new FactoryModuleBuilder().build(StackManagerFactory.class)); + +bind(Clusters.class).toInstance(createNiceMock(Clusters.class)); +bind(DBAccessor.class).toInstance(createNiceMock(DBAccessor.class)); + bind(EntityManager.class).toInstance(createNiceMock(EntityManager.class)); +bind(OsFamily.class).toInstance(createNiceMock(OsFamily.class)); +bind(Configuration.class).toInstance(configuration); + bind(ExtensionLinkDAO.class).toInstance(createNiceMock(ExtensionLinkDAO.class)); + } +}); + +OsFamily osFamily = injector.getInstance(OsFamily.class); + expect(osFamily.os_list()).andReturn(Collections.singleton("centos6")).anyTimes(); + +ExtensionLinkDAO linkDao = injector.getInstance(ExtensionLinkDAO.class); +expect(linkDao.findByStack(anyString(), anyString())).andReturn(Collections.emptyList()).anyTimes(); + +TypedQuery query = createNiceMock(TypedQuery.class); +expect(query.setMaxResults(1)).andReturn(query).anyTimes(); +expect(query.getSingleResult()).andReturn(null).anyTimes(); + +EntityManager entityManager = injector.getInstance(EntityManager.class); +expect(entityManager.createNamedQuery("StackEntity.findByNameAndVersion", StackEntity.class)).andReturn(query).anyTimes(); +expect(entityManager.find(EasyMock.eq(MetainfoEntity.class), anyString())).andReturn(
[2/4] ambari git commit: AMBARI-18335. After upgrading cluster from HDP-2.4.x to HDP-2.5.x and added atlas service - missing kafka security properties (rlevas)
http://git-wip-us.apache.org/repos/asf/ambari/blob/8f1b8c5f/ambari-server/src/test/java/org/apache/ambari/server/state/kerberos/KerberosDescriptorUpdateHelperTest.java -- diff --git a/ambari-server/src/test/java/org/apache/ambari/server/state/kerberos/KerberosDescriptorUpdateHelperTest.java b/ambari-server/src/test/java/org/apache/ambari/server/state/kerberos/KerberosDescriptorUpdateHelperTest.java new file mode 100644 index 000..fca2f1f --- /dev/null +++ b/ambari-server/src/test/java/org/apache/ambari/server/state/kerberos/KerberosDescriptorUpdateHelperTest.java @@ -0,0 +1,2272 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ambari.server.state.kerberos; + +import com.google.gson.Gson; +import com.google.inject.AbstractModule; +import com.google.inject.Guice; +import com.google.inject.Injector; +import com.google.inject.assistedinject.FactoryModuleBuilder; +import junit.framework.Assert; +import org.apache.ambari.server.AmbariException; +import org.apache.ambari.server.api.services.AmbariMetaInfo; +import org.apache.ambari.server.configuration.Configuration; +import org.apache.ambari.server.orm.DBAccessor; +import org.apache.ambari.server.orm.dao.ExtensionLinkDAO; +import org.apache.ambari.server.orm.entities.ExtensionLinkEntity; +import org.apache.ambari.server.orm.entities.MetainfoEntity; +import org.apache.ambari.server.orm.entities.StackEntity; +import org.apache.ambari.server.stack.StackManagerFactory; +import org.apache.ambari.server.state.Clusters; +import org.apache.ambari.server.state.stack.OsFamily; +import org.easymock.EasyMock; +import org.easymock.EasyMockSupport; +import org.junit.Test; + +import javax.persistence.EntityManager; +import javax.persistence.TypedQuery; +import java.util.Collections; +import java.util.Properties; + +import static org.easymock.EasyMock.anyString; +import static org.easymock.EasyMock.expect; + +public class KerberosDescriptorUpdateHelperTest extends EasyMockSupport { + private static final KerberosDescriptorFactory KERBEROS_DESCRIPTOR_FACTORY = new KerberosDescriptorFactory(); + private static final Gson GSON = new Gson(); + + @Test + public void updateDefaultUserKerberosDescriptor() throws Exception { +Injector injector = Guice.createInjector(new AbstractModule() { + + @Override + protected void configure() { +Properties properties = new Properties(); +properties.put("metadata.path", "src/main/resources/stacks"); +properties.put("common.services.path", "src/main/resources/common-services"); +properties.put("server.version.file", "target/version"); +properties.put("custom.action.definitions", "/tmp/nofile"); +Configuration configuration = new Configuration(properties); + +install(new FactoryModuleBuilder().build(StackManagerFactory.class)); + +bind(Clusters.class).toInstance(createNiceMock(Clusters.class)); +bind(DBAccessor.class).toInstance(createNiceMock(DBAccessor.class)); + bind(EntityManager.class).toInstance(createNiceMock(EntityManager.class)); +bind(OsFamily.class).toInstance(createNiceMock(OsFamily.class)); +bind(Configuration.class).toInstance(configuration); + bind(ExtensionLinkDAO.class).toInstance(createNiceMock(ExtensionLinkDAO.class)); + } +}); + +OsFamily osFamily = injector.getInstance(OsFamily.class); + expect(osFamily.os_list()).andReturn(Collections.singleton("centos6")).anyTimes(); + +ExtensionLinkDAO linkDao = injector.getInstance(ExtensionLinkDAO.class); +expect(linkDao.findByStack(anyString(), anyString())).andReturn(Collections.emptyList()).anyTimes(); + +TypedQuery query = createNiceMock(TypedQuery.class); +expect(query.setMaxResults(1)).andReturn(query).anyTimes(); +expect(query.getSingleResult()).andReturn(null).anyTimes(); + +EntityManager entityManager = injector.getInstance(EntityManager.class); +expect(entityManager.createNamedQuery("StackEntity.findByNameAndVersion", StackEntity.class)).andReturn(query).anyTimes(); +expect(entityManager.find(EasyMock.eq(MetainfoEntity.class), anyString())).andReturn(
[2/4] ambari git commit: AMBARI-18335. After upgrading cluster from HDP-2.4.x to HDP-2.5.x and added atlas service - missing kafka security properties (rlevas)
http://git-wip-us.apache.org/repos/asf/ambari/blob/f9abdafa/ambari-server/src/test/java/org/apache/ambari/server/state/kerberos/KerberosDescriptorUpdateHelperTest.java -- diff --git a/ambari-server/src/test/java/org/apache/ambari/server/state/kerberos/KerberosDescriptorUpdateHelperTest.java b/ambari-server/src/test/java/org/apache/ambari/server/state/kerberos/KerberosDescriptorUpdateHelperTest.java new file mode 100644 index 000..fca2f1f --- /dev/null +++ b/ambari-server/src/test/java/org/apache/ambari/server/state/kerberos/KerberosDescriptorUpdateHelperTest.java @@ -0,0 +1,2272 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ambari.server.state.kerberos; + +import com.google.gson.Gson; +import com.google.inject.AbstractModule; +import com.google.inject.Guice; +import com.google.inject.Injector; +import com.google.inject.assistedinject.FactoryModuleBuilder; +import junit.framework.Assert; +import org.apache.ambari.server.AmbariException; +import org.apache.ambari.server.api.services.AmbariMetaInfo; +import org.apache.ambari.server.configuration.Configuration; +import org.apache.ambari.server.orm.DBAccessor; +import org.apache.ambari.server.orm.dao.ExtensionLinkDAO; +import org.apache.ambari.server.orm.entities.ExtensionLinkEntity; +import org.apache.ambari.server.orm.entities.MetainfoEntity; +import org.apache.ambari.server.orm.entities.StackEntity; +import org.apache.ambari.server.stack.StackManagerFactory; +import org.apache.ambari.server.state.Clusters; +import org.apache.ambari.server.state.stack.OsFamily; +import org.easymock.EasyMock; +import org.easymock.EasyMockSupport; +import org.junit.Test; + +import javax.persistence.EntityManager; +import javax.persistence.TypedQuery; +import java.util.Collections; +import java.util.Properties; + +import static org.easymock.EasyMock.anyString; +import static org.easymock.EasyMock.expect; + +public class KerberosDescriptorUpdateHelperTest extends EasyMockSupport { + private static final KerberosDescriptorFactory KERBEROS_DESCRIPTOR_FACTORY = new KerberosDescriptorFactory(); + private static final Gson GSON = new Gson(); + + @Test + public void updateDefaultUserKerberosDescriptor() throws Exception { +Injector injector = Guice.createInjector(new AbstractModule() { + + @Override + protected void configure() { +Properties properties = new Properties(); +properties.put("metadata.path", "src/main/resources/stacks"); +properties.put("common.services.path", "src/main/resources/common-services"); +properties.put("server.version.file", "target/version"); +properties.put("custom.action.definitions", "/tmp/nofile"); +Configuration configuration = new Configuration(properties); + +install(new FactoryModuleBuilder().build(StackManagerFactory.class)); + +bind(Clusters.class).toInstance(createNiceMock(Clusters.class)); +bind(DBAccessor.class).toInstance(createNiceMock(DBAccessor.class)); + bind(EntityManager.class).toInstance(createNiceMock(EntityManager.class)); +bind(OsFamily.class).toInstance(createNiceMock(OsFamily.class)); +bind(Configuration.class).toInstance(configuration); + bind(ExtensionLinkDAO.class).toInstance(createNiceMock(ExtensionLinkDAO.class)); + } +}); + +OsFamily osFamily = injector.getInstance(OsFamily.class); + expect(osFamily.os_list()).andReturn(Collections.singleton("centos6")).anyTimes(); + +ExtensionLinkDAO linkDao = injector.getInstance(ExtensionLinkDAO.class); +expect(linkDao.findByStack(anyString(), anyString())).andReturn(Collections.emptyList()).anyTimes(); + +TypedQuery query = createNiceMock(TypedQuery.class); +expect(query.setMaxResults(1)).andReturn(query).anyTimes(); +expect(query.getSingleResult()).andReturn(null).anyTimes(); + +EntityManager entityManager = injector.getInstance(EntityManager.class); +expect(entityManager.createNamedQuery("StackEntity.findByNameAndVersion", StackEntity.class)).andReturn(query).anyTimes(); +expect(entityManager.find(EasyMock.eq(MetainfoEntity.class), anyString())).andReturn(