[1/3] ambari git commit: AMBARI-18540: Unit test cases required for verifying Ambari username case sensitivity

2016-10-08 Thread jonathanhurley
Repository: ambari
Updated Branches:
  refs/heads/branch-feature-AMBARI-18456 0de69e10b -> 5cf5c8349


AMBARI-18540: Unit test cases required for verifying Ambari username case 
sensitivity


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/569020ca
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/569020ca
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/569020ca

Branch: refs/heads/branch-feature-AMBARI-18456
Commit: 569020caf1c6f39765d7da9efb8c57b66293844e
Parents: 8813b1f
Author: Nahappan Somasundaram 
Authored: Wed Oct 5 17:25:20 2016 -0700
Committer: Nahappan Somasundaram 
Committed: Fri Oct 7 14:22:27 2016 -0700

--
 .../internal/UserResourceProviderDBTest.java| 280 +++
 1 file changed, 280 insertions(+)
--


http://git-wip-us.apache.org/repos/asf/ambari/blob/569020ca/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UserResourceProviderDBTest.java
--
diff --git 
a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UserResourceProviderDBTest.java
 
b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UserResourceProviderDBTest.java
new file mode 100644
index 000..1629b49
--- /dev/null
+++ 
b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UserResourceProviderDBTest.java
@@ -0,0 +1,280 @@
+/**
+ * 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.controller.internal;
+
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+import com.google.inject.persist.PersistService;
+import org.apache.ambari.server.configuration.Configuration;
+import org.apache.ambari.server.controller.AmbariManagementController;
+import org.apache.ambari.server.controller.spi.Predicate;
+import org.apache.ambari.server.controller.spi.Request;
+import org.apache.ambari.server.controller.spi.RequestStatus;
+import org.apache.ambari.server.controller.spi.Resource;
+import org.apache.ambari.server.controller.utilities.PredicateBuilder;
+import org.apache.ambari.server.controller.utilities.PropertyHelper;
+import org.apache.ambari.server.orm.InMemoryDefaultTestModule;
+import org.apache.ambari.server.security.TestAuthenticationFactory;
+import org.apache.ambari.server.security.authorization.AuthorizationHelper;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.springframework.security.core.Authentication;
+import org.springframework.security.core.context.SecurityContextHolder;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Tests creation, retrieval and deletion of users using an in-memory database.
+ * Also tests user creation and retrieval using usernames that differ only by 
case.
+ * Verifies that usernames are stored as provided.
+ */
+@PrepareForTest({AuthorizationHelper.class})
+public class UserResourceProviderDBTest {
+private static Injector injector;
+private static AmbariManagementController amc;
+private static Resource.Type userType = Resource.Type.User;
+private static UserResourceProvider userResourceProvider;
+private static String JDBC_IN_MEMORY_URL_CREATE =
+String.format("jdbc:derby:memory:myDB/%s;create=true", 
Configuration.DEFAULT_DERBY_SCHEMA);
+private static String JDBC_IN_MEMORY_URL_DROP =
+String.format("jdbc:derby:memory:myDB/%s;drop=true", 
Configuration.DEFAULT_DERBY_SCHEMA);
+
+/**
+ * Sets up the in-memory database for the test suite.
+  

[3/3] ambari git commit: Merge branch 'trunk' into branch-feature-AMBARI-18456

2016-10-08 Thread jonathanhurley
Merge branch 'trunk' into branch-feature-AMBARI-18456


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/5cf5c834
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/5cf5c834
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/5cf5c834

Branch: refs/heads/branch-feature-AMBARI-18456
Commit: 5cf5c8349cef6e4605870ac59dd620db2053b02c
Parents: 0de69e1 72f1f6f
Author: Jonathan Hurley 
Authored: Sat Oct 8 23:10:24 2016 -0400
Committer: Jonathan Hurley 
Committed: Sat Oct 8 23:10:24 2016 -0400

--
 .../FALCON/0.5.0.2.1/package/scripts/falcon.py  |  11 +
 .../4.0.0.2.0/package/scripts/oozie_service.py  |   2 +-
 .../internal/UserResourceProviderDBTest.java| 280 +++
 .../stacks/2.1/FALCON/test_falcon_server.py |  14 +
 4 files changed, 306 insertions(+), 1 deletion(-)
--




[2/3] ambari git commit: AMBARI-18551. Enhance falcon integration to call falcon-config to make sure WEB-INF/lib is present in all cases (Venkat Ranganathan via alejandro)

2016-10-08 Thread jonathanhurley
AMBARI-18551. Enhance falcon integration to call falcon-config to make sure 
WEB-INF/lib is present in all cases (Venkat Ranganathan via alejandro)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/72f1f6f6
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/72f1f6f6
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/72f1f6f6

Branch: refs/heads/branch-feature-AMBARI-18456
Commit: 72f1f6f635b74e4fe3f5e21fed2d3a60aa6de0ad
Parents: 569020c
Author: Alejandro Fernandez 
Authored: Fri Oct 7 16:29:43 2016 -0700
Committer: Alejandro Fernandez 
Committed: Fri Oct 7 16:29:43 2016 -0700

--
 .../FALCON/0.5.0.2.1/package/scripts/falcon.py| 11 +++
 .../OOZIE/4.0.0.2.0/package/scripts/oozie_service.py  |  2 +-
 .../python/stacks/2.1/FALCON/test_falcon_server.py| 14 ++
 3 files changed, 26 insertions(+), 1 deletion(-)
--


http://git-wip-us.apache.org/repos/asf/ambari/blob/72f1f6f6/ambari-server/src/main/resources/common-services/FALCON/0.5.0.2.1/package/scripts/falcon.py
--
diff --git 
a/ambari-server/src/main/resources/common-services/FALCON/0.5.0.2.1/package/scripts/falcon.py
 
b/ambari-server/src/main/resources/common-services/FALCON/0.5.0.2.1/package/scripts/falcon.py
index 2ac79cb..3ecb65b 100644
--- 
a/ambari-server/src/main/resources/common-services/FALCON/0.5.0.2.1/package/scripts/falcon.py
+++ 
b/ambari-server/src/main/resources/common-services/FALCON/0.5.0.2.1/package/scripts/falcon.py
@@ -216,6 +216,17 @@ def falcon(type, action = None, upgrade_type=None):
 process_exists = format("ls {server_pid_file} && ps -p {pid}")
 
 if action == 'start':
+  try:
+Execute(format('{falcon_home}/bin/falcon-config.sh server falcon'),
+  user = params.falcon_user,
+  path = params.hadoop_bin_dir,
+  environment=environment_dictionary,
+  not_if = process_exists,
+)
+  except:
+show_logs(params.falcon_log_dir, params.falcon_user)
+raise
+
   if not os.path.exists(params.target_jar_file):
 try :
   File(params.target_jar_file,

http://git-wip-us.apache.org/repos/asf/ambari/blob/72f1f6f6/ambari-server/src/main/resources/common-services/OOZIE/4.0.0.2.0/package/scripts/oozie_service.py
--
diff --git 
a/ambari-server/src/main/resources/common-services/OOZIE/4.0.0.2.0/package/scripts/oozie_service.py
 
b/ambari-server/src/main/resources/common-services/OOZIE/4.0.0.2.0/package/scripts/oozie_service.py
index 3257653..a5bd59d 100644
--- 
a/ambari-server/src/main/resources/common-services/OOZIE/4.0.0.2.0/package/scripts/oozie_service.py
+++ 
b/ambari-server/src/main/resources/common-services/OOZIE/4.0.0.2.0/package/scripts/oozie_service.py
@@ -28,7 +28,7 @@ from resource_management.core import sudo
 from resource_management.core.shell import as_user
 from resource_management.core.logger import Logger
 from resource_management.core.resources.service import Service
-from resource_management.core.resources.system import Execute, File
+from resource_management.core.resources.system import Execute, File, Directory
 from resource_management.libraries.functions.format import format
 from resource_management.libraries.functions.show_logs import show_logs
 from resource_management.libraries.providers.hdfs_resource import WebHDFSUtil

http://git-wip-us.apache.org/repos/asf/ambari/blob/72f1f6f6/ambari-server/src/test/python/stacks/2.1/FALCON/test_falcon_server.py
--
diff --git 
a/ambari-server/src/test/python/stacks/2.1/FALCON/test_falcon_server.py 
b/ambari-server/src/test/python/stacks/2.1/FALCON/test_falcon_server.py
index ab053b7..4ad5c0f 100644
--- a/ambari-server/src/test/python/stacks/2.1/FALCON/test_falcon_server.py
+++ b/ambari-server/src/test/python/stacks/2.1/FALCON/test_falcon_server.py
@@ -43,6 +43,13 @@ class TestFalconServer(RMFTestCase):
 
 self.assert_configure_default()
 
+self.assertResourceCalled('Execute', '/usr/lib/falcon/bin/falcon-config.sh 
server falcon',
+  path = ['/usr/bin'],
+  user = 'falcon',
+  environment = {'HADOOP_HOME': '/usr/lib/hadoop'},
+  not_if = 'ls /var/run/falcon/falcon.pid && ps -p ',
+)
+
 self.assertResourceCalled('File', 
'/usr/lib/falcon/server/webapp/falcon/WEB-INF/lib/je-5.0.73.jar',
   
content=DownloadSource('http://c6401.ambari.apache.org:8080/resources//je-5.0.73.jar'),
   mode=0755
@@ -374,6 +381,13 @@ class TestFalconServer(RMFTestCase):
 create_parents = True,
 )

+self.assertResourceCalled('Execute', 

[2/2] ambari git commit: AMBARI-18556 - Remove Unnecessary Locks Inside Of Service Business Object Implementations (jonathanhurley)

2016-10-08 Thread jonathanhurley
AMBARI-18556 - Remove Unnecessary Locks Inside Of Service Business Object 
Implementations (jonathanhurley)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/0de69e10
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/0de69e10
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/0de69e10

Branch: refs/heads/branch-feature-AMBARI-18456
Commit: 0de69e10b30a1dadf6f508170548cd347095193a
Parents: fbfcf98
Author: Jonathan Hurley 
Authored: Fri Oct 7 15:59:42 2016 -0400
Committer: Jonathan Hurley 
Committed: Sat Oct 8 21:19:35 2016 -0400

--
 .../ambari/server/api/services/BaseRequest.java |  49 +-
 .../controller/AmbariManagementController.java  |   8 -
 .../AmbariManagementControllerImpl.java |   5 -
 .../internal/ServiceResourceProvider.java   |  38 +-
 .../orm/dao/HostComponentDesiredStateDAO.java   |   7 +-
 .../server/orm/dao/HostComponentStateDAO.java   |   9 +-
 .../apache/ambari/server/orm/dao/HostDAO.java   |   2 +-
 .../orm/entities/ClusterServiceEntity.java  |   2 +-
 .../HostComponentDesiredStateEntity.java|  11 +
 .../orm/entities/HostComponentStateEntity.java  |  11 +
 .../org/apache/ambari/server/state/Host.java|   2 -
 .../org/apache/ambari/server/state/Service.java |   6 -
 .../apache/ambari/server/state/ServiceImpl.java | 448 +++
 .../server/state/cluster/ClustersImpl.java  |   4 -
 .../ambari/server/state/host/HostImpl.java  |  15 -
 .../svccomphost/ServiceComponentHostImpl.java   |  18 +-
 .../apache/ambari/server/utils/RetryHelper.java |   1 +
 .../server/agent/HeartbeatProcessorTest.java|  12 -
 .../server/agent/TestHeartbeatHandler.java  |  10 -
 .../server/agent/TestHeartbeatMonitor.java  |   5 -
 .../server/api/services/AmbariMetaInfoTest.java |   3 +
 .../configuration/RecoveryConfigHelperTest.java |   6 -
 .../AmbariManagementControllerTest.java |  43 --
 .../PreUpgradeCheckResourceProviderTest.java|  52 +--
 .../internal/ServiceResourceProviderTest.java   |  63 ++-
 .../UpgradeResourceProviderHDP22Test.java   |   1 -
 .../internal/UpgradeResourceProviderTest.java   |   2 -
 .../UpgradeSummaryResourceProviderTest.java |   1 -
 .../GeneralServiceCalculatedStateTest.java  |  47 +-
 .../apache/ambari/server/events/EventsTest.java |   1 -
 .../apache/ambari/server/orm/OrmTestHelper.java |   2 -
 .../dao/HostComponentDesiredStateDAOTest.java   |  27 +-
 .../orm/dao/HostComponentStateDAOTest.java  |  28 +-
 .../ComponentVersionCheckActionTest.java|   1 -
 .../upgrades/ConfigureActionTest.java   |   1 -
 .../upgrades/UpgradeActionTest.java |   1 -
 .../server/state/ServiceComponentTest.java  |   1 -
 .../apache/ambari/server/state/ServiceTest.java |   4 -
 .../state/alerts/AlertEventPublisherTest.java   |   7 +-
 .../state/alerts/InitialAlertEventTest.java |   3 +-
 .../state/cluster/ClusterDeadlockTest.java  |   1 -
 .../server/state/cluster/ClusterImplTest.java   |   2 -
 .../server/state/cluster/ClusterTest.java   |  22 +-
 .../state/cluster/ClustersDeadlockTest.java |   1 -
 .../server/state/cluster/ClustersTest.java  |   1 -
 .../ConcurrentServiceConfigVersionTest.java |   1 -
 ...omponentHostConcurrentWriteDeadlockTest.java |   1 -
 .../svccomphost/ServiceComponentHostTest.java   |   1 -
 48 files changed, 340 insertions(+), 647 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/ambari/blob/0de69e10/ambari-server/src/main/java/org/apache/ambari/server/api/services/BaseRequest.java
--
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/api/services/BaseRequest.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/api/services/BaseRequest.java
index 9f7b949..73af2c8 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/api/services/BaseRequest.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/api/services/BaseRequest.java
@@ -18,40 +18,39 @@
 
 package org.apache.ambari.server.api.services;
 
+import java.io.UnsupportedEncodingException;
+import java.net.URLDecoder;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.UriInfo;
+
 import org.apache.ambari.server.api.handlers.RequestHandler;
 import org.apache.ambari.server.api.predicate.InvalidQueryException;
 import org.apache.ambari.server.api.predicate.PredicateCompiler;
 import 

[1/2] ambari git commit: AMBARI-18556 - Remove Unnecessary Locks Inside Of Service Business Object Implementations (jonathanhurley)

2016-10-08 Thread jonathanhurley
Repository: ambari
Updated Branches:
  refs/heads/branch-feature-AMBARI-18456 fbfcf98ab -> 0de69e10b


http://git-wip-us.apache.org/repos/asf/ambari/blob/0de69e10/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ServiceResourceProviderTest.java
--
diff --git 
a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ServiceResourceProviderTest.java
 
b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ServiceResourceProviderTest.java
index 84f8124..f99b5ff 100644
--- 
a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ServiceResourceProviderTest.java
+++ 
b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ServiceResourceProviderTest.java
@@ -18,6 +18,31 @@
 
 package org.apache.ambari.server.controller.internal;
 
+import static org.easymock.EasyMock.anyBoolean;
+import static org.easymock.EasyMock.anyObject;
+import static org.easymock.EasyMock.capture;
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.createNiceMock;
+import static org.easymock.EasyMock.createStrictMock;
+import static org.easymock.EasyMock.eq;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.expectLastCall;
+import static org.easymock.EasyMock.isNull;
+import static org.easymock.EasyMock.newCapture;
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.verify;
+
+import java.lang.reflect.Field;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
 import org.apache.ambari.server.AmbariException;
 import org.apache.ambari.server.RoleCommand;
 import org.apache.ambari.server.api.services.AmbariMetaInfo;
@@ -57,31 +82,6 @@ import org.junit.Test;
 import org.springframework.security.core.Authentication;
 import org.springframework.security.core.context.SecurityContextHolder;
 
-import java.lang.reflect.Field;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.LinkedHashMap;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import static org.easymock.EasyMock.anyBoolean;
-import static org.easymock.EasyMock.anyObject;
-import static org.easymock.EasyMock.capture;
-import static org.easymock.EasyMock.createMock;
-import static org.easymock.EasyMock.createNiceMock;
-import static org.easymock.EasyMock.createStrictMock;
-import static org.easymock.EasyMock.eq;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.expectLastCall;
-import static org.easymock.EasyMock.isNull;
-import static org.easymock.EasyMock.newCapture;
-import static org.easymock.EasyMock.replay;
-import static org.easymock.EasyMock.verify;
-
 /**
  * ServiceResourceProvider tests.
  */
@@ -117,9 +117,8 @@ public class ServiceResourceProviderTest {
 
 expect(managementController.getClusters()).andReturn(clusters).anyTimes();
 expect(managementController.getAmbariMetaInfo()).andReturn(ambariMetaInfo);
-expect(managementController.getServiceFactory()).andReturn(serviceFactory);
 
-expect(serviceFactory.createNew(cluster, "Service100")).andReturn(service);
+expect(cluster.addService("Service100")).andReturn(service);
 
 expect(clusters.getCluster("Cluster100")).andReturn(cluster).anyTimes();
 
@@ -202,7 +201,6 @@ public class ServiceResourceProviderTest {
 // set expectations
 expect(managementController.getClusters()).andReturn(clusters).anyTimes();
 
expect(managementController.getAmbariMetaInfo()).andReturn(ambariMetaInfo).anyTimes();
-
expect(managementController.getServiceFactory()).andReturn(serviceFactory).anyTimes();
 
expect(managementController.getHostComponents(EasyMock.anyObject())).
 
andReturn(Collections.emptySet()).anyTimes();
 
@@ -321,7 +319,6 @@ public class ServiceResourceProviderTest {
 // set expectations
 expect(managementController.getClusters()).andReturn(clusters).anyTimes();
 
expect(managementController.getAmbariMetaInfo()).andReturn(ambariMetaInfo).anyTimes();
-
expect(managementController.getServiceFactory()).andReturn(serviceFactory).anyTimes();
 
expect(managementController.getHostComponents(EasyMock.anyObject())).
 
andReturn(Collections.emptySet()).anyTimes();
 
@@ -390,7 +387,6 @@ public class ServiceResourceProviderTest {
 // set expectations
 expect(managementController.getClusters()).andReturn(clusters).anyTimes();
 
expect(managementController.getAmbariMetaInfo()).andReturn(ambariMetaInfo).anyTimes();
-
expect(managementController.getServiceFactory()).andReturn(serviceFactory).anyTimes();