AMBARI-7180 ambari build failure caused by ApacheDSContainer's working directory conflict (jun aoki via alejandro)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/91a01f1c Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/91a01f1c Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/91a01f1c Branch: refs/heads/branch-alerts-dev Commit: 91a01f1cd548ff35883c5a4f894a524d21a835ea Parents: 9ed5e3b Author: Alejandro Fernandez <afernan...@hortonworks.com> Authored: Thu Sep 11 15:32:43 2014 -0700 Committer: Alejandro Fernandez <afernan...@hortonworks.com> Committed: Thu Sep 11 15:32:43 2014 -0700 ---------------------------------------------------------------------- ...mbariLdapAuthenticationProviderBaseTest.java | 50 ++++++++++++++++++++ ...uthenticationProviderForDNWithSpaceTest.java | 4 +- .../AmbariLdapAuthenticationProviderTest.java | 4 +- 3 files changed, 54 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/91a01f1c/ambari-server/src/test/java/org/apache/ambari/server/security/authorization/AmbariLdapAuthenticationProviderBaseTest.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/java/org/apache/ambari/server/security/authorization/AmbariLdapAuthenticationProviderBaseTest.java b/ambari-server/src/test/java/org/apache/ambari/server/security/authorization/AmbariLdapAuthenticationProviderBaseTest.java new file mode 100644 index 0000000..2a323f8 --- /dev/null +++ b/ambari-server/src/test/java/org/apache/ambari/server/security/authorization/AmbariLdapAuthenticationProviderBaseTest.java @@ -0,0 +1,50 @@ +/** + * 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.security.authorization; + +import org.apache.commons.io.FileUtils; +import org.easymock.EasyMockSupport; + +import java.io.File; +import java.io.IOException; +import java.text.SimpleDateFormat; +import java.util.Date; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +public class AmbariLdapAuthenticationProviderBaseTest extends EasyMockSupport { + + private static final Log logger = LogFactory.getLog(AmbariLdapAuthenticationProviderBaseTest.class); + + protected static void createCleanApacheDSContainerWorkDir() throws IOException{ + // Set ApacheDsContainer's work dir under the current folder (Jenkins' job workspace) instead of the default /tmp/apacheds-spring-security. See AMBARI-7180 + SimpleDateFormat sdf = new SimpleDateFormat("HHmmss"); + String timestamp = sdf.format(new Date()); + final String workParent = new File(".").getAbsolutePath() + File.separator + "target" + File.separator + timestamp; + new File(workParent).mkdirs(); + // The folder structure looks like {job-root}/target/{timestamp}/apacheds-spring-security + final String apacheDSWorkDir = workParent + File.separator + "apacheds-spring-security"; + FileUtils.deleteDirectory(new File(apacheDSWorkDir)); + System.setProperty("apacheDSWorkDir", apacheDSWorkDir ); + logger.info("System property apacheDSWorkDir was set to " + apacheDSWorkDir); + + } + +} http://git-wip-us.apache.org/repos/asf/ambari/blob/91a01f1c/ambari-server/src/test/java/org/apache/ambari/server/security/authorization/AmbariLdapAuthenticationProviderForDNWithSpaceTest.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/java/org/apache/ambari/server/security/authorization/AmbariLdapAuthenticationProviderForDNWithSpaceTest.java b/ambari-server/src/test/java/org/apache/ambari/server/security/authorization/AmbariLdapAuthenticationProviderForDNWithSpaceTest.java index ae8054b..c04af86 100644 --- a/ambari-server/src/test/java/org/apache/ambari/server/security/authorization/AmbariLdapAuthenticationProviderForDNWithSpaceTest.java +++ b/ambari-server/src/test/java/org/apache/ambari/server/security/authorization/AmbariLdapAuthenticationProviderForDNWithSpaceTest.java @@ -24,7 +24,6 @@ import com.google.inject.persist.PersistService; import org.apache.ambari.server.configuration.Configuration; import org.apache.ambari.server.orm.GuiceJpaInitializer; import org.apache.ambari.server.orm.dao.UserDAO; -import org.apache.ambari.server.orm.entities.UserEntity; import org.apache.ambari.server.security.ClientSecurityType; import org.junit.*; import org.springframework.security.authentication.BadCredentialsException; @@ -34,7 +33,7 @@ import org.springframework.security.ldap.server.ApacheDSContainer; import static org.junit.Assert.*; -public class AmbariLdapAuthenticationProviderForDNWithSpaceTest { +public class AmbariLdapAuthenticationProviderForDNWithSpaceTest extends AmbariLdapAuthenticationProviderBaseTest{ private static ApacheDSContainer apacheDSContainer; private static Injector injector; @@ -47,6 +46,7 @@ public class AmbariLdapAuthenticationProviderForDNWithSpaceTest { @BeforeClass public static void beforeClass() throws Exception{ + createCleanApacheDSContainerWorkDir(); apacheDSContainer = new ApacheDSContainer("dc=ambari,dc=the apache,dc=org", "classpath:/users_for_dn_with_space.ldif"); apacheDSContainer.setPort(33389); apacheDSContainer.afterPropertiesSet(); http://git-wip-us.apache.org/repos/asf/ambari/blob/91a01f1c/ambari-server/src/test/java/org/apache/ambari/server/security/authorization/AmbariLdapAuthenticationProviderTest.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/java/org/apache/ambari/server/security/authorization/AmbariLdapAuthenticationProviderTest.java b/ambari-server/src/test/java/org/apache/ambari/server/security/authorization/AmbariLdapAuthenticationProviderTest.java index 2a2d3dd..6bc692c 100644 --- a/ambari-server/src/test/java/org/apache/ambari/server/security/authorization/AmbariLdapAuthenticationProviderTest.java +++ b/ambari-server/src/test/java/org/apache/ambari/server/security/authorization/AmbariLdapAuthenticationProviderTest.java @@ -27,7 +27,6 @@ import org.apache.ambari.server.configuration.Configuration; import org.apache.ambari.server.orm.GuiceJpaInitializer; import org.apache.ambari.server.orm.dao.UserDAO; import org.apache.ambari.server.security.ClientSecurityType; -import org.easymock.EasyMockSupport; import org.easymock.IAnswer; import org.junit.After; import org.junit.AfterClass; @@ -43,7 +42,7 @@ import static org.easymock.EasyMock.*; import static org.junit.Assert.*; -public class AmbariLdapAuthenticationProviderTest extends EasyMockSupport { +public class AmbariLdapAuthenticationProviderTest extends AmbariLdapAuthenticationProviderBaseTest { private static ApacheDSContainer apacheDSContainer; private static Injector injector; @@ -57,6 +56,7 @@ public class AmbariLdapAuthenticationProviderTest extends EasyMockSupport { @BeforeClass public static void beforeClass() throws Exception{ + createCleanApacheDSContainerWorkDir(); apacheDSContainer = new ApacheDSContainer("dc=ambari,dc=apache,dc=org", "classpath:/users.ldif"); apacheDSContainer.setPort(33389); apacheDSContainer.afterPropertiesSet();