You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@slider.apache.org by el...@apache.org on 2015/12/28 22:03:43 UTC

incubator-slider git commit: SLIDER-1039 Run python tests from target directory

Repository: incubator-slider
Updated Branches:
  refs/heads/develop f61e3dce7 -> d26e84520


SLIDER-1039 Run python tests from target directory

We shouldn't be running any python tests from the src
directory as this is for the clean copy of the code. This
should be done in the target directory. Uses the maven-resources-plugin
to copy the src and test python code into target and changes the
configuration on the exec plugin to specify the right paths
rooted in target.

Also removes some duplicative configuration when building on *nixes.

This does not address the glaring problem of slider-assembly
reaching into slider-agent directly to access python files.


Project: http://git-wip-us.apache.org/repos/asf/incubator-slider/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-slider/commit/d26e8452
Tree: http://git-wip-us.apache.org/repos/asf/incubator-slider/tree/d26e8452
Diff: http://git-wip-us.apache.org/repos/asf/incubator-slider/diff/d26e8452

Branch: refs/heads/develop
Commit: d26e84520ceb750593557c60a4484c313d5351cc
Parents: f61e3dc
Author: Josh Elser <el...@apache.org>
Authored: Mon Dec 28 15:58:57 2015 -0500
Committer: Josh Elser <el...@apache.org>
Committed: Mon Dec 28 15:58:57 2015 -0500

----------------------------------------------------------------------
 .gitignore              |  1 -
 slider-agent/pom.xml    | 78 +++++++++++++++++++++++++++++++++++++++-----
 slider-assembly/pom.xml | 42 +++++++++++++++++++-----
 3 files changed, 104 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/d26e8452/.gitignore
----------------------------------------------------------------------
diff --git a/.gitignore b/.gitignore
index 6e8763e..c2d027c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,7 +1,6 @@
 *.iml
 *.ipr
 *.iws
-*.pyc
 .idea
 .svn
 .classpath

http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/d26e8452/slider-agent/pom.xml
----------------------------------------------------------------------
diff --git a/slider-agent/pom.xml b/slider-agent/pom.xml
index 43fc5d7..351ee86 100644
--- a/slider-agent/pom.xml
+++ b/slider-agent/pom.xml
@@ -32,8 +32,8 @@
     <package.release>1</package.release>
     <skipTests>false</skipTests>
     <python.ver>python &gt;= 2.6</python.ver>
-    <executable.python>${project.basedir}/../slider-agent/src/test/python/python-wrap</executable.python>
-    <python.path.l>${project.basedir}/src/main/python/jinja2:${project.basedir}/src/test/python:${project.basedir}/src/main/python:${project.basedir}/src/main/python/agent:${project.basedir}/src/main/python/resource_management:${project.basedir}/src/test/python/agent:${project.basedir}/src/test/python/resource_management:${project.basedir}/src/main/python/kazoo</python.path.l>
+    <executable.python>${project.build.directory}/test/python-wrap</executable.python>
+    <python.path.l>${project.build.directory}/src/jinja2:${project.build.directory}/test:${project.build.directory}/src:${project.build.directory}/src/agent:${project.build.directory}/src/resource_management:${project.build.directory}/test/agent:${project.build.directory}/test/resource_management:${project.build.directory}/src/kazoo</python.path.l>
   </properties>
   <build>
     <plugins>
@@ -57,6 +57,45 @@
         </executions>
       </plugin>
       
+      <!-- Copy src/main/python into target/src and src/test/python into target/test -->
+      <!-- This helps us keep the Maven workspace clean (no .pyc files laying around) -->
+      <plugin>
+        <artifactId>maven-resources-plugin</artifactId>
+        <version>${maven-resources-plugin.version}</version>
+        <executions>
+          <execution>
+            <id>copy-resources</id>
+            <phase>generate-resources</phase>
+            <goals>
+              <goal>copy-resources</goal>
+            </goals>
+            <configuration>
+              <outputDirectory>${basedir}/target/src</outputDirectory>
+              <resources>
+                <resource>
+                  <directory>${basedir}/src/main/python</directory>
+                </resource>
+              </resources>
+            </configuration>
+          </execution>
+          <execution>
+            <id>copy-test-resources</id>
+            <phase>generate-test-resources</phase>
+            <goals>
+              <goal>copy-resources</goal>
+            </goals>
+            <configuration>
+              <outputDirectory>${basedir}/target/test</outputDirectory>
+              <resources>
+                <resource>
+                  <directory>${basedir}/src/test/python</directory>
+                </resource>
+              </resources>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+
       <plugin>
         <groupId>org.codehaus.mojo</groupId>
         <artifactId>exec-maven-plugin</artifactId>
@@ -65,7 +104,7 @@
           <execution>
             <configuration>
               <executable>${executable.python}</executable>
-              <workingDirectory>src/test/python</workingDirectory>
+              <workingDirectory>${project.build.directory}/test</workingDirectory>
               <arguments>
                 <argument>unitTests.py</argument>
               </arguments>
@@ -102,7 +141,7 @@
       </activation>
       <properties>
         <executable.python>python</executable.python>
-        <python.path.l>${project.basedir}\src\main\python\jinja2;${project.basedir}\src\test\python;${project.basedir}\src\main\python;${project.basedir}\src\main\python\agent;${project.basedir}\src\main\python\resource_management;${project.basedir}\src\test\python\agent;${project.basedir}\src\test\python\resource_management;${project.basedir}\src\main\python\kazoo</python.path.l>
+        <python.path.l>${project.build.directory}\src\jinja2;${project.build.directory}\test;${project.build.directory}\src;${project.build.directory}\src\agent;${project.build.directory}\src\resource_management;${project.build.directory}\test\agent;${project.build.directory}\test\resource_management;${project.build.directory}\src\kazoo</python.path.l>
       </properties>
     </profile>
 
@@ -111,10 +150,33 @@
       <activation>
         <os><family>!windows</family></os>
       </activation>
-      <properties>
-        <executable.python>${project.basedir}/../slider-agent/src/test/python/python-wrap</executable.python>
-        <python.path.l>${project.basedir}/src/main/python/jinja2:${project.basedir}/src/test/python:${project.basedir}/src/main/python:${project.basedir}/src/main/python/agent:${project.basedir}/src/main/python/resource_management:${project.basedir}/src/test/python/agent:${project.basedir}/src/test/python/resource_management:${project.basedir}/src/main/python/kazoo</python.path.l>
-      </properties>
+      <build>
+        <!-- The maven-resources-plugin doesn't preserve file permissions (MRESOURCES-132), chmod python-wrap before running the tests -->
+        <plugins>
+          <plugin>
+            <groupId>org.codehaus.mojo</groupId>
+            <artifactId>exec-maven-plugin</artifactId>
+            <version>${maven-exec-plugin.version}</version>
+            <executions>
+              <execution>
+                <configuration>
+                  <executable>chmod</executable>
+                  <arguments>
+                    <argument>+x</argument>
+                    <argument>${executable.python}</argument>
+                  </arguments>
+                </configuration>
+                <id>chmod-python-wrap</id>
+                <phase>test-compile</phase>
+                <goals>
+                  <goal>exec</goal>
+                </goals>
+              </execution>
+            </executions>
+          </plugin>
+        </plugins>
+      </build>
+
     </profile>
     <profile>
       <id>rat</id>

http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/d26e8452/slider-assembly/pom.xml
----------------------------------------------------------------------
diff --git a/slider-assembly/pom.xml b/slider-assembly/pom.xml
index 001f2ae..a8f15dc 100644
--- a/slider-assembly/pom.xml
+++ b/slider-assembly/pom.xml
@@ -39,8 +39,8 @@
     <src.libdir>${project.build.directory}/lib</src.libdir>
     <src.agent.ini.dir>${project.build.directory}/../../slider-agent/conf</src.agent.ini.dir>
     <python.ver>python &gt;= 2.6</python.ver>
-    <executable.python>${project.basedir}/../slider-agent/src/test/python/python-wrap</executable.python>
-    <python.path.l>${project.basedir}/src/main/scripts:${project.basedir}/../slider-agent/src/test/python/mock:${project.basedir}/src/test/python/scripts</python.path.l>
+    <executable.python>${project.basedir}/../slider-agent/target/test/python-wrap</executable.python>
+    <python.path.l>${project.build.directory}/python-src:${project.basedir}/../slider-agent/target/test/mock:${project.build.directory}/python-test/scripts</python.path.l>
     <skipTests>false</skipTests>
   </properties>
 
@@ -76,7 +76,7 @@
           <execution>
             <configuration>
               <executable>${executable.python}</executable>
-              <workingDirectory>src/test/python</workingDirectory>
+              <workingDirectory>${project.build.directory}/python-test</workingDirectory>
               <arguments>
                 <argument>unitTests.py</argument>
               </arguments>
@@ -246,6 +246,36 @@
               </resources>
             </configuration>            
           </execution>
+          <execution>
+            <id>copy-python-resources</id>
+            <phase>generate-resources</phase>
+            <goals>
+              <goal>copy-resources</goal>
+            </goals>
+            <configuration>
+              <outputDirectory>${basedir}/target/python-src</outputDirectory>
+              <resources>
+                <resource>
+                  <directory>${basedir}/src/main/scripts</directory>
+                </resource>
+              </resources>
+            </configuration>
+          </execution>
+          <execution>
+            <id>copy-python-test-resources</id>
+            <phase>generate-test-resources</phase>
+            <goals>
+              <goal>copy-resources</goal>
+            </goals>
+            <configuration>
+              <outputDirectory>${basedir}/target/python-test</outputDirectory>
+              <resources>
+                <resource>
+                  <directory>${basedir}/src/test/python</directory>
+                </resource>
+              </resources>
+            </configuration>
+          </execution>
         </executions>
       </plugin>
       <plugin>
@@ -310,7 +340,7 @@
       </activation>
       <properties>
         <executable.python>python</executable.python>
-        <python.path.l>${project.basedir}\src\main\scripts;${project.basedir}\..\slider-agent\src\test\python\mock;${project.basedir}\src\test\python\scripts</python.path.l>
+        <python.path.l>${project.build.directory}\python-src;${project.basedir}\..\slider-agent\target\test\mock;${project.basedir}\python-test\scripts</python.path.l>
       </properties>
     </profile>
 
@@ -319,10 +349,6 @@
       <activation>
         <os><family>!windows</family></os>
       </activation>
-      <properties>
-        <executable.python>${project.basedir}/../slider-agent/src/test/python/python-wrap</executable.python>
-        <python.path.l>${project.basedir}/src/main/scripts:${project.basedir}/../slider-agent/src/test/python/mock:${project.basedir}/src/test/python/scripts</python.path.l>
-      </properties>
     </profile>
     <profile>
       <id>rpm</id>