KNOX-1019 - Remove test-driver "hack" to copy services
Project: http://git-wip-us.apache.org/repos/asf/knox/repo Commit: http://git-wip-us.apache.org/repos/asf/knox/commit/f4de8565 Tree: http://git-wip-us.apache.org/repos/asf/knox/tree/f4de8565 Diff: http://git-wip-us.apache.org/repos/asf/knox/diff/f4de8565 Branch: refs/heads/KNOX-998-Package_Restructuring Commit: f4de8565783976a912c87c14382680994f3f9375 Parents: 202b3dc Author: Colm O hEigeartaigh <cohei...@apache.org> Authored: Fri Sep 1 10:56:24 2017 +0100 Committer: Colm O hEigeartaigh <cohei...@apache.org> Committed: Fri Sep 1 10:56:24 2017 +0100 ---------------------------------------------------------------------- .../hadoop/gateway/GatewayTestConfig.java | 12 ++++---- .../hadoop/gateway/GatewayTestDriver.java | 15 ---------- gateway-test/pom.xml | 30 ++++++++++++++++++++ .../gateway/AmbariServiceDefinitionTest.java | 15 ---------- .../deploy/DeploymentFactoryFuncTest.java | 25 ---------------- 5 files changed, 37 insertions(+), 60 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/knox/blob/f4de8565/gateway-test-release-utils/src/main/java/org/apache/hadoop/gateway/GatewayTestConfig.java ---------------------------------------------------------------------- diff --git a/gateway-test-release-utils/src/main/java/org/apache/hadoop/gateway/GatewayTestConfig.java b/gateway-test-release-utils/src/main/java/org/apache/hadoop/gateway/GatewayTestConfig.java index dde5908..09b0d94 100644 --- a/gateway-test-release-utils/src/main/java/org/apache/hadoop/gateway/GatewayTestConfig.java +++ b/gateway-test-release-utils/src/main/java/org/apache/hadoop/gateway/GatewayTestConfig.java @@ -21,6 +21,7 @@ import org.apache.commons.lang.StringUtils; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.gateway.config.GatewayConfig; +import java.io.File; import java.net.InetSocketAddress; import java.net.UnknownHostException; import java.util.ArrayList; @@ -164,12 +165,12 @@ public class GatewayTestConfig extends Configuration implements GatewayConfig { public void setHadoopKerberosSecured(boolean hadoopKerberosSecured) { this.hadoopKerberosSecured = hadoopKerberosSecured; } - + @Override public String getKerberosConfig() { return kerberosConfig; } - + public void setKerberosConfig(String kerberosConfig) { this.kerberosConfig = kerberosConfig; } @@ -178,11 +179,11 @@ public class GatewayTestConfig extends Configuration implements GatewayConfig { public boolean isKerberosDebugEnabled() { return kerberosDebugEnabled; } - + public void setKerberosDebugEnabled(boolean kerberosDebugEnabled) { this.kerberosDebugEnabled = kerberosDebugEnabled; } - + @Override public String getKerberosLoginConfig() { return kerberosLoginConfig; @@ -309,7 +310,8 @@ public class GatewayTestConfig extends Configuration implements GatewayConfig { if( gatewayServicesDir != null ) { return gatewayServicesDir; } else { - return getGatewayDataDir() + "/services"; + File targetDir = new File( System.getProperty( "user.dir" ), "target/services" ); + return targetDir.getPath(); } } http://git-wip-us.apache.org/repos/asf/knox/blob/f4de8565/gateway-test-release-utils/src/main/java/org/apache/hadoop/gateway/GatewayTestDriver.java ---------------------------------------------------------------------- diff --git a/gateway-test-release-utils/src/main/java/org/apache/hadoop/gateway/GatewayTestDriver.java b/gateway-test-release-utils/src/main/java/org/apache/hadoop/gateway/GatewayTestDriver.java index 3135123..f3976fd 100644 --- a/gateway-test-release-utils/src/main/java/org/apache/hadoop/gateway/GatewayTestDriver.java +++ b/gateway-test-release-utils/src/main/java/org/apache/hadoop/gateway/GatewayTestDriver.java @@ -147,20 +147,6 @@ public class GatewayTestDriver { } catch (ServiceLifecycleException e) { e.printStackTrace(); // I18N not required. } - File stacksDir = new File( config.getGatewayServicesDir() ); - stacksDir.mkdirs(); - //TODO: [sumit] This is a hack for now, need to find a better way to locate the source resources for 'stacks' to be tested - String pathToStacksSource = "gateway-service-definitions/src/main/resources/services"; - File stacksSourceDir = new File( targetDir.getParent(), pathToStacksSource); - if (!stacksSourceDir.exists()) { - stacksSourceDir = new File( targetDir.getParentFile().getParent(), pathToStacksSource); - } - if (!stacksSourceDir.exists()) { - stacksSourceDir = new File( targetDir.getParentFile().getParentFile().getParent(), pathToStacksSource); - } - if (stacksSourceDir.exists()) { - FileUtils.copyDirectoryToDirectory(stacksSourceDir, stacksDir); - } gateway = GatewayServer.startGateway( config, srvcs ); MatcherAssert.assertThat( "Failed to start gateway.", gateway, CoreMatchers.notNullValue() ); @@ -178,7 +164,6 @@ public class GatewayTestDriver { FileUtils.deleteQuietly( new File( config.getGatewaySecurityDir() ) ); FileUtils.deleteQuietly( new File( config.getGatewayDeploymentDir() ) ); FileUtils.deleteQuietly( new File( config.getGatewayDataDir() ) ); - FileUtils.deleteQuietly( new File( config.getGatewayServicesDir() ) ); } for( Service service : services.values() ) { http://git-wip-us.apache.org/repos/asf/knox/blob/f4de8565/gateway-test/pom.xml ---------------------------------------------------------------------- diff --git a/gateway-test/pom.xml b/gateway-test/pom.xml index 5cbd385..d3ad73b 100644 --- a/gateway-test/pom.xml +++ b/gateway-test/pom.xml @@ -177,6 +177,36 @@ <artifactId>maven-failsafe-plugin</artifactId> <version>${failsafe-version}</version> </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-dependency-plugin</artifactId> + <executions> + <execution> + <id>copy-services</id> + <phase>generate-resources</phase> + <goals> + <goal>unpack</goal> + </goals> + <configuration> + <artifactItems> + <artifactItem> + <groupId>org.apache.knox</groupId> + <artifactId>gateway-service-definitions</artifactId> + <version>${project.version}</version> + <type>jar</type> + <overWrite>true</overWrite> + <outputDirectory>target</outputDirectory> + <includes>**/services/**</includes> + </artifactItem> + </artifactItems> + <outputAbsoluteArtifactFilename>true</outputAbsoluteArtifactFilename> + <overWriteSnapshots>true</overWriteSnapshots> + <overWriteIfNewer>true</overWriteIfNewer> + <stripVersion>true</stripVersion> + </configuration> + </execution> + </executions> + </plugin> </plugins> </build> http://git-wip-us.apache.org/repos/asf/knox/blob/f4de8565/gateway-test/src/test/java/org/apache/hadoop/gateway/AmbariServiceDefinitionTest.java ---------------------------------------------------------------------- diff --git a/gateway-test/src/test/java/org/apache/hadoop/gateway/AmbariServiceDefinitionTest.java b/gateway-test/src/test/java/org/apache/hadoop/gateway/AmbariServiceDefinitionTest.java index 5e976cc..a55a519 100644 --- a/gateway-test/src/test/java/org/apache/hadoop/gateway/AmbariServiceDefinitionTest.java +++ b/gateway-test/src/test/java/org/apache/hadoop/gateway/AmbariServiceDefinitionTest.java @@ -42,7 +42,6 @@ import org.slf4j.LoggerFactory; import java.io.File; import java.io.StringWriter; -import java.net.URL; import java.util.HashMap; import java.util.Map; import java.util.Properties; @@ -106,20 +105,6 @@ public class AmbariServiceDefinitionTest { config = new GatewayTestConfig(); config.setGatewayHomeDir( gatewayDir.getAbsolutePath() ); - URL svcsFileUrl = TestUtils.getResourceUrl( DAT, "test-svcs/readme.txt" ); - File svcsFile = new File( svcsFileUrl.getFile() ); - File svcsDir = svcsFile.getParentFile(); - config.setGatewayServicesDir( svcsDir.getAbsolutePath() ); - - String pathToStacksSource = "gateway-service-definitions/src/main/resources/services"; - File stacksSourceDir = new File( targetDir.getParent(), pathToStacksSource); - if (!stacksSourceDir.exists()) { - stacksSourceDir = new File( targetDir.getParentFile().getParent(), pathToStacksSource); - } - if (stacksSourceDir.exists()) { - FileUtils.copyDirectoryToDirectory(stacksSourceDir, svcsDir); - } - File topoDir = new File( config.getGatewayTopologyDir() ); topoDir.mkdirs(); http://git-wip-us.apache.org/repos/asf/knox/blob/f4de8565/gateway-test/src/test/java/org/apache/hadoop/gateway/deploy/DeploymentFactoryFuncTest.java ---------------------------------------------------------------------- diff --git a/gateway-test/src/test/java/org/apache/hadoop/gateway/deploy/DeploymentFactoryFuncTest.java b/gateway-test/src/test/java/org/apache/hadoop/gateway/deploy/DeploymentFactoryFuncTest.java index 6ccc934..6f0924c 100644 --- a/gateway-test/src/test/java/org/apache/hadoop/gateway/deploy/DeploymentFactoryFuncTest.java +++ b/gateway-test/src/test/java/org/apache/hadoop/gateway/deploy/DeploymentFactoryFuncTest.java @@ -90,7 +90,6 @@ public class DeploymentFactoryFuncTest { // ((GatewayTestConfig) config).setDeploymentDir( "clusters" ); - addStacksDir(config, targetDir); DefaultGatewayServices srvcs = new DefaultGatewayServices(); Map<String,String> options = new HashMap<>(); options.put("persist-master", "false"); @@ -153,7 +152,6 @@ public class DeploymentFactoryFuncTest { ((GatewayTestConfig) config).setGatewayHomeDir( gatewayDir.getAbsolutePath() ); File deployDir = new File( config.getGatewayDeploymentDir() ); deployDir.mkdirs(); - addStacksDir(config, targetDir); DefaultGatewayServices srvcs = new DefaultGatewayServices(); Map<String,String> options = new HashMap<>(); @@ -212,7 +210,6 @@ public class DeploymentFactoryFuncTest { ((GatewayTestConfig) config).setGatewayHomeDir( gatewayDir.getAbsolutePath() ); File deployDir = new File( config.getGatewayDeploymentDir() ); deployDir.mkdirs(); - addStacksDir(config, targetDir); DefaultGatewayServices srvcs = new DefaultGatewayServices(); Map<String,String> options = new HashMap<>(); @@ -414,7 +411,6 @@ public class DeploymentFactoryFuncTest { ((GatewayTestConfig) config).setGatewayHomeDir(gatewayDir.getAbsolutePath()); File deployDir = new File(config.getGatewayDeploymentDir()); deployDir.mkdirs(); - addStacksDir(config, targetDir); DefaultGatewayServices srvcs = new DefaultGatewayServices(); Map<String, String> options = new HashMap<>(); @@ -505,7 +501,6 @@ public class DeploymentFactoryFuncTest { ((GatewayTestConfig) config).setGatewayHomeDir(gatewayDir.getAbsolutePath()); File deployDir = new File(config.getGatewayDeploymentDir()); deployDir.mkdirs(); - addStacksDir(config, targetDir); URL serviceUrl = TestUtils.getResourceUrl( DeploymentFactoryFuncTest.class, "test-apps/minimal-test-app/service.xml" ); File serviceFile = new File( serviceUrl.toURI() ); File appsDir = serviceFile.getParentFile().getParentFile(); @@ -564,7 +559,6 @@ public class DeploymentFactoryFuncTest { ((GatewayTestConfig) config).setGatewayHomeDir(gatewayDir.getAbsolutePath()); File deployDir = new File(config.getGatewayDeploymentDir()); deployDir.mkdirs(); - addStacksDir(config, targetDir); URL serviceUrl = TestUtils.getResourceUrl( DeploymentFactoryFuncTest.class, "test-apps/minimal-test-app/service.xml" ); File serviceFile = new File( serviceUrl.toURI() ); File appsDir = serviceFile.getParentFile().getParentFile(); @@ -636,25 +630,6 @@ public class DeploymentFactoryFuncTest { LOG_EXIT(); } - private void addStacksDir(GatewayConfig config, File targetDir) { - File stacksDir = new File( config.getGatewayServicesDir() ); - stacksDir.mkdirs(); - //TODO: [sumit] This is a hack for now, need to find a better way to locate the source resources for 'stacks' to be tested - String pathToStacksSource = "gateway-service-definitions/src/main/resources/services"; - File stacksSourceDir = new File( targetDir.getParent(), pathToStacksSource); - if (!stacksSourceDir.exists()) { - stacksSourceDir = new File( targetDir.getParentFile().getParent(), pathToStacksSource); - } - if (stacksSourceDir.exists()) { - try { - FileUtils.copyDirectoryToDirectory(stacksSourceDir, stacksDir); - } catch ( IOException e) { - fail(e.getMessage()); - } - } - - } - private Node node( Node scope, String expression ) throws XPathExpressionException { return (Node)XPathFactory.newInstance().newXPath().compile( expression ).evaluate( scope, XPathConstants.NODE ); }