Merge branch 'trunk' into branch-alerts-dev Conflicts: ambari-server/src/test/java/org/apache/ambari/server/api/services/AmbariMetaInfoTest.java
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/7f86e75c Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/7f86e75c Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/7f86e75c Branch: refs/heads/branch-alerts-dev Commit: 7f86e75c0c1e4868973340197b7cab112a319cb1 Parents: e2e7966 327accb Author: Jonathan Hurley <jhur...@hortonworks.com> Authored: Sat Sep 20 10:54:04 2014 -0400 Committer: Jonathan Hurley <jhur...@hortonworks.com> Committed: Sat Sep 20 10:54:04 2014 -0400 ---------------------------------------------------------------------- .../main/resources/ui/admin-web/app/index.html | 1 - .../app/scripts/controllers/NavbarCtrl.js | 22 +- .../ui/admin-web/app/scripts/services/ldap.js | 60 - .../resources/ui/admin-web/app/styles/main.css | 10 +- .../ui/admin-web/app/views/leftNavbar.html | 9 - ambari-server/sbin/ambari-server | 4 + .../LdapSyncEventResourceDefinition.java | 57 + .../resources/ResourceInstanceFactoryImpl.java | 4 + .../api/services/LdapSyncEventService.java | 144 ++ .../controller/AmbariManagementController.java | 10 +- .../AmbariManagementControllerImpl.java | 31 +- .../internal/ControllerResourceProvider.java | 53 +- .../internal/DefaultProviderModule.java | 2 + .../internal/LdapSyncEventResourceProvider.java | 438 ++++++ .../controller/internal/URLStreamProvider.java | 4 + .../ambari/server/controller/spi/Resource.java | 4 +- .../orm/entities/LdapSyncEventEntity.java | 284 ++++ .../server/orm/entities/LdapSyncSpecEntity.java | 143 ++ .../ambari/server/proxy/ProxyService.java | 17 +- .../server/security/authorization/Users.java | 17 +- .../security/ldap/AmbariLdapDataPopulator.java | 268 +++- .../ambari/server/state/ConfigHelper.java | 39 + .../server/state/stack/LatestRepoCallable.java | 59 +- .../server/upgrade/AbstractUpgradeCatalog.java | 215 ++- .../server/upgrade/UpgradeCatalog161.java | 2 +- .../server/upgrade/UpgradeCatalog170.java | 27 +- .../server/view/HttpImpersonatorImpl.java | 167 +++ .../server/view/ImpersonatorSettingImpl.java | 63 + .../ambari/server/view/ViewContextImpl.java | 18 +- .../ambari/server/view/ViewProviderModule.java | 26 +- .../apache/ambari/server/view/ViewRegistry.java | 22 +- ambari-server/src/main/python/ambari-server.py | 74 + .../scripts/application_timeline_server.py | 2 + .../YARN/package/scripts/status_params.py | 1 + .../services/SLIDER/package/scripts/params.py | 4 +- .../services/SLIDER/package/scripts/slider.py | 22 +- .../SLIDER/package/templates/slider-env.sh.j2 | 38 + .../SLIDER/package/templates/slider-wrapper.j2 | 42 - .../LdapSyncEventResourceDefinitionTest.java | 49 + .../server/api/services/AmbariMetaInfoTest.java | 205 ++- .../api/services/LdapSyncEventServiceTest.java | 97 ++ .../LdapSyncEventResourceProviderTest.java | 114 ++ .../orm/entities/LdapSyncEventEntityTest.java | 166 +++ .../orm/entities/LdapSyncSpecEntityTest.java | 95 ++ .../ambari/server/proxy/ProxyServiceTest.java | 14 + .../ldap/AmbariLdapDataPopulatorTest.java | 1329 +++++++++++++++++- .../security/ldap/LdapPerformanceTest.java | 10 +- .../server/upgrade/UpgradeCatalog161Test.java | 2 +- .../server/upgrade/UpgradeCatalog170Test.java | 35 +- .../server/view/HttpImpersonatorImplTest.java | 128 ++ .../ambari/server/view/ViewRegistryTest.java | 20 + .../stacks/2.2/SLIDER/test_slider_client.py | 29 +- .../apache/ambari/view/HttpImpersonator.java | 53 + .../apache/ambari/view/ImpersonatorSetting.java | 46 + .../org/apache/ambari/view/ViewContext.java | 15 + ambari-web/app/utils/ajax/ajax.js | 22 - contrib/views/jobs/pom.xml | 15 + .../apache/ambari/view/jobs/ProxyServlet.java | 68 + .../jobs/src/main/resources/WEB-INF/web.xml | 37 + .../app/scripts/controllers/jobs_controller.js | 10 +- .../resources/ui/app/scripts/helpers/ajax.js | 25 +- .../resources/ui/app/scripts/helpers/jobs.js | 15 +- .../ui/app/scripts/routes/application_route.js | 8 + .../ui/app/controllers/slider_app_controller.js | 2 +- .../ui/app/mappers/slider_apps_mapper.js | 9 + .../main/resources/ui/app/models/slider_app.js | 5 + .../resources/ui/app/styles/application.less | 6 +- .../ui/app/templates/slider_app/summary.hbs | 2 +- .../resources/ui/app/templates/slider_apps.hbs | 2 +- 69 files changed, 4458 insertions(+), 578 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/7f86e75c/ambari-server/src/main/java/org/apache/ambari/server/api/resources/ResourceInstanceFactoryImpl.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/7f86e75c/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Resource.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/7f86e75c/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog170.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/7f86e75c/ambari-server/src/test/java/org/apache/ambari/server/api/services/AmbariMetaInfoTest.java ---------------------------------------------------------------------- diff --cc ambari-server/src/test/java/org/apache/ambari/server/api/services/AmbariMetaInfoTest.java index 23d0efa,b08ccc0..4c59a36 --- a/ambari-server/src/test/java/org/apache/ambari/server/api/services/AmbariMetaInfoTest.java +++ b/ambari-server/src/test/java/org/apache/ambari/server/api/services/AmbariMetaInfoTest.java @@@ -30,11 -27,8 +27,9 @@@ import static org.junit.Assert.fail import java.io.File; import java.lang.reflect.Method; - import java.util.ArrayList; import java.util.Collection; - import java.util.HashMap; import java.util.HashSet; +import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.ListIterator; @@@ -61,20 -53,14 +54,16 @@@ import org.apache.ambari.server.state.D import org.apache.ambari.server.state.OperatingSystemInfo; import org.apache.ambari.server.state.PropertyInfo; import org.apache.ambari.server.state.RepositoryInfo; - import org.apache.ambari.server.state.Service; import org.apache.ambari.server.state.ServiceInfo; import org.apache.ambari.server.state.Stack; - import org.apache.ambari.server.state.StackId; import org.apache.ambari.server.state.StackInfo; import org.apache.ambari.server.state.alert.AlertDefinition; - import org.apache.ambari.server.state.alert.AlertDefinitionFactory; +import org.apache.ambari.server.state.alert.PortSource; +import org.apache.ambari.server.state.alert.Reporting; +import org.apache.ambari.server.state.alert.Source; import org.apache.ambari.server.state.stack.MetricDefinition; import org.apache.commons.io.FileUtils; - import org.easymock.EasyMock; import org.junit.Before; -import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; import org.junit.rules.TemporaryFolder; @@@ -124,9 -109,9 +113,12 @@@ public class AmbariMetaInfoTest @Before public void before() throws Exception { - injector = Guice.createInjector(new InMemoryDefaultTestModule()); + injector = Guice.createInjector(Modules.override( + new InMemoryDefaultTestModule()).with(new MockModule())); + + injector.getInstance(GuiceJpaInitializer.class); + injector.getInstance(EntityManager.class); ++ File stackRoot = new File("src/test/resources/stacks"); LOG.info("Stacks file " + stackRoot.getAbsolutePath()); metaInfo = new AmbariMetaInfo(stackRoot, new File("target/version")); @@@ -1450,109 -1559,17 +1566,66 @@@ Assert.assertNotNull(set); Assert.assertTrue(set.size() > 0); + // find two different definitions and test each one + AlertDefinition nameNodeProcess = null; + AlertDefinition nameNodeCpu = null; + + Iterator<AlertDefinition> iterator = set.iterator(); + while (iterator.hasNext()) { + AlertDefinition definition = iterator.next(); + if (definition.getName().equals("namenode_process")) { + nameNodeProcess = definition; + } + + if (definition.getName().equals("namenode_cpu")) { + nameNodeCpu = definition; + } + } + + assertNotNull(nameNodeProcess); + assertNotNull(nameNodeCpu); + + assertEquals("NameNode host CPU Utilization", nameNodeCpu.getLabel()); + + // test namenode_process + Source source = nameNodeProcess.getSource(); + assertNotNull(source); + assertNotNull(((PortSource) source).getPort()); + Reporting reporting = source.getReporting(); + assertNotNull(reporting); + assertNotNull(reporting.getOk()); + assertNotNull(reporting.getOk().getText()); + assertNull(reporting.getOk().getValue()); + assertNotNull(reporting.getCritical()); + assertNotNull(reporting.getCritical().getText()); + assertNull(reporting.getCritical().getValue()); + assertNull(reporting.getWarning()); + + // test namenode_cpu + source = nameNodeCpu.getSource(); + assertNotNull(source); + reporting = source.getReporting(); + assertNotNull(reporting); + assertNotNull(reporting.getOk()); + assertNotNull(reporting.getOk().getText()); + assertNull(reporting.getOk().getValue()); + assertNotNull(reporting.getCritical()); + assertNotNull(reporting.getCritical().getText()); + assertNotNull(reporting.getCritical().getValue()); + assertNotNull(reporting.getWarning()); + assertNotNull(reporting.getWarning().getText()); + assertNotNull(reporting.getWarning().getValue()); } - /** - * @throws Exception - */ - @Test - public void testAlertReconcile() throws Exception { - Clusters clusters = createMock(Clusters.class); - Cluster cluster = createMock(Cluster.class); - AlertDefinitionDAO dao = createMock(AlertDefinitionDAO.class); - - metaInfo.alertDefinitionDao = dao; - Set<AlertDefinition> alertDefinitions = metaInfo.getAlertDefinitions( - STACK_NAME_HDP, "2.0.6", "HDFS"); - - assertEquals(4, alertDefinitions.size()); - - Map<String, Cluster> clustersMap = new HashMap<String, Cluster>(); - clustersMap.put("c1", cluster); - - StackId stackId = new StackId(STACK_NAME_HDP, "2.0.6"); - Map<String, Service> clusterServiceMap = new HashMap<String, Service>(); - clusterServiceMap.put("HDFS", null); - - List<AlertDefinitionEntity> entities = new ArrayList<AlertDefinitionEntity>(); - - expect(clusters.getClusters()).andReturn(clustersMap).anyTimes(); - expect(clusters.getCluster((String) anyObject())).andReturn(cluster).atLeastOnce(); - expect(cluster.getClusterId()).andReturn(Long.valueOf(1)).anyTimes(); - expect(cluster.getDesiredStackVersion()).andReturn(stackId).anyTimes(); - expect(cluster.getServices()).andReturn(clusterServiceMap).anyTimes(); - expect(dao.findAll(EasyMock.anyInt())).andReturn(entities).atLeastOnce(); - dao.createOrUpdate(EasyMock.anyObject(AlertDefinitionEntity.class)); - EasyMock.expectLastCall().times(4); - - EasyMock.replay(clusters, cluster, dao); - metaInfo.reconcileAlertDefinitions(clusters); - EasyMock.verify(cluster, cluster, dao); - - AlertDefinitionFactory alertDefinitionFactory = injector.getInstance(AlertDefinitionFactory.class); - for (AlertDefinition definition : alertDefinitions) { - entities.add(alertDefinitionFactory.coerce(1, definition)); - } - - EasyMock.reset(clusters, cluster, dao); - expect(clusters.getClusters()).andReturn(clustersMap).anyTimes(); - expect(clusters.getCluster((String) anyObject())).andReturn(cluster).atLeastOnce(); - expect(cluster.getClusterId()).andReturn(Long.valueOf(1)).anyTimes(); - expect(cluster.getDesiredStackVersion()).andReturn(stackId).anyTimes(); - expect(cluster.getServices()).andReturn(clusterServiceMap).anyTimes(); - expect(dao.findAll(EasyMock.anyInt())).andReturn(entities).atLeastOnce(); - - EasyMock.replay(clusters, cluster, dao); - metaInfo.reconcileAlertDefinitions(clusters); - EasyMock.verify(cluster, cluster, dao); + private AmbariMetaInfo setupTempAmbariMetaInfo(String buildDir) + throws Exception { + File stackRootTmp = new File(buildDir + "/ambari-metaInfo"); + File stackRoot = new File("src/test/resources/stacks"); + stackRootTmp.mkdir(); + FileUtils.copyDirectory(stackRoot, stackRootTmp); + AmbariMetaInfo ambariMetaInfo = new AmbariMetaInfo(stackRootTmp, new File( + "target/version")); + injector.injectMembers(ambariMetaInfo); + return ambariMetaInfo; } } http://git-wip-us.apache.org/repos/asf/ambari/blob/7f86e75c/ambari-web/app/utils/ajax/ajax.js ----------------------------------------------------------------------