aop.xml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  1. <!--
  2. Licensed to the Apache Software Foundation (ASF) under one or more
  3. contributor license agreements. See the NOTICE file distributed with
  4. this work for additional information regarding copyright ownership.
  5. The ASF licenses this file to You under the Apache License, Version 2.0
  6. (the "License"); you may not use this file except in compliance with
  7. the License. You may obtain a copy of the License at
  8. http://www.apache.org/licenses/LICENSE-2.0
  9. Unless required by applicable law or agreed to in writing, software
  10. distributed under the License is distributed on an "AS IS" BASIS,
  11. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. See the License for the specific language governing permissions and
  13. limitations under the License.
  14. -->
  15. <project name="aspects"
  16. xmlns:artifact="urn:maven-artifact-ant">
  17. <!-- Properties common for all fault injections -->
  18. <property name="build-fi.dir" value="${basedir}/build-fi"/>
  19. <property name="hadoop-fi.jar" location="${build.dir}/${final.name}-fi.jar" />
  20. <property name="compile-inject.output" value="${build-fi.dir}/compile-fi.log"/>
  21. <property name="aspectversion" value="1.6.5"/>
  22. <property file="${basedir}/build.properties"/>
  23. <!-- Properties related to system fault injection and tests -->
  24. <property name="system-test-build-dir" value="${build-fi.dir}/system"/>
  25. <!-- Properties specifically for system fault-injections and system tests -->
  26. <property name="herriot.suffix" value="instrumented"/>
  27. <property name="herriot.final.name" value="${name}-${herriot.suffix}-${version}"/>
  28. <property name="hadoop-common-instrumented.pom"
  29. location="${ivy.dir}/hadoop-common-${herriot.suffix}.xml" />
  30. <property name="hadoop-common-instrumented.jar"
  31. location="${system-test-build-dir}/${herriot.final.name}.jar" />
  32. <property name="hadoop-common-instrumented-sources.jar"
  33. location="${system-test-build-dir}/${herriot.final.name}-sources.jar" />
  34. <!--All Fault Injection (FI) related targets are located in this session -->
  35. <target name="clean-fi">
  36. <delete dir="${build-fi.dir}"/>
  37. </target>
  38. <!-- Weaving aspects in place
  39. Later on one can run 'ant jar-fault-inject' to create
  40. Hadoop jar file with instrumented classes
  41. -->
  42. <!-- Target -classes-compilation has to be defined in build.xml and
  43. needs to depend on classes compilation and test classes compilation
  44. targets. This is a poor man parametrization for targets -->
  45. <target name="-compile-fault-inject" depends="-classes-compilation" >
  46. <!-- AspectJ task definition -->
  47. <taskdef
  48. resource="org/aspectj/tools/ant/taskdefs/aspectjTaskdefs.properties">
  49. <classpath>
  50. <pathelement
  51. location="${common.ivy.lib.dir}/aspectjtools-${aspectversion}.jar"/>
  52. </classpath>
  53. </taskdef>
  54. <echo message="Start weaving aspects in place"/>
  55. <iajc
  56. encoding="${build.encoding}"
  57. srcdir="${java.src.dir};${build.src};${src.dir.path}"
  58. includes="org/apache/hadoop/**/*.java, org/apache/hadoop/**/*.aj"
  59. excludes="org/apache/hadoop/classification/tools/**/*, org/apache/hadoop/record/**/*"
  60. destDir="${dest.dir}"
  61. debug="${javac.debug}"
  62. target="${javac.version}"
  63. source="${javac.version}"
  64. deprecation="${javac.deprecation}">
  65. <classpath>
  66. <path refid="test.classpath"/>
  67. </classpath>
  68. </iajc>
  69. <loadfile property="injection.failure" srcfile="${compile-inject.output}">
  70. <filterchain>
  71. <linecontainsregexp>
  72. <regexp pattern='iajc.*warning'/>
  73. </linecontainsregexp>
  74. </filterchain>
  75. </loadfile>
  76. <fail if="injection.failure">
  77. Broken binding of advises: ${line.separator}${injection.failure}
  78. </fail>
  79. <echo message="Weaving of aspects is finished"/>
  80. </target>
  81. <!-- Classpath for running system tests -->
  82. <path id="test.system.classpath">
  83. <pathelement location="${hadoop.conf.dir.deployed}" />
  84. <pathelement location="${system-test-build-dir}/test/extraconf" />
  85. <pathelement location="${system-test-build-dir}/test/classes" />
  86. <pathelement location="${system-test-build-dir}/classes" />
  87. <pathelement location="${test.src.dir}" />
  88. <pathelement location="${build-fi.dir}" />
  89. <pathelement location="${build-fi.dir}/tools" />
  90. <pathelement path="${clover.jar}" />
  91. <fileset dir="${test.lib.dir}">
  92. <include name="**/*.jar" />
  93. <exclude name="**/excluded/" />
  94. </fileset>
  95. <fileset dir="${system-test-build-dir}">
  96. <include name="**/*.jar" />
  97. <exclude name="**/excluded/" />
  98. </fileset>
  99. <path refid="classpath" />
  100. </path>
  101. <target name="injectfaults"
  102. description="Instrument classes with faults and other AOP advices">
  103. <!--mkdir to prevent <subant> failure in case the folder has been removed-->
  104. <mkdir dir="${build-fi.dir}"/>
  105. <delete file="${compile-inject.output}"/>
  106. <weave-injectfault-aspects dest.dir="${build-fi.dir}/classes"
  107. src.dir="${test.src.dir}/aop">
  108. </weave-injectfault-aspects>
  109. </target>
  110. <!-- =============================================================== -->
  111. <!-- Create hadoop-{version}-dev-common.jar required to be deployed on -->
  112. <!-- cluster for system tests -->
  113. <!-- =============================================================== -->
  114. <target name="jar-system"
  115. depends="inject-system-faults"
  116. description="make hadoop.jar">
  117. <macro-jar-fault-inject target.name="jar"
  118. build.dir="${system-test-build-dir}"
  119. jar.final.name="final.name"
  120. jar.final.value="${herriot.final.name}">
  121. </macro-jar-fault-inject>
  122. <jar jarfile="${system-test-build-dir}/${herriot.final.name}-sources.jar"
  123. update="yes">
  124. <fileset dir="${test.src.dir}/system/java" includes="org/apache/hadoop/**/*.java"/>
  125. <fileset dir="${test.src.dir}/system/aop" includes="org/apache/hadoop/**/*.aj"/>
  126. </jar>
  127. </target>
  128. <macrodef name="weave-injectfault-aspects">
  129. <attribute name="dest.dir" />
  130. <attribute name="src.dir" />
  131. <sequential>
  132. <subant buildpath="build.xml" target="-compile-fault-inject"
  133. output="${compile-inject.output}">
  134. <property name="build.dir" value="${build-fi.dir}" />
  135. <property name="src.dir.path" value="@{src.dir}" />
  136. <property name="dest.dir" value="@{dest.dir}" />
  137. </subant>
  138. </sequential>
  139. </macrodef>
  140. <target name="inject-system-faults" description="Inject system faults">
  141. <property name="build-fi.dir" value="${system-test-build-dir}" />
  142. <mkdir dir="${build-fi.dir}"/>
  143. <delete file="${compile-inject.output}"/>
  144. <weave-injectfault-aspects dest.dir="${system-test-build-dir}/classes"
  145. src.dir="${test.src.dir}/system/java;${test.src.dir}/system/aop">
  146. </weave-injectfault-aspects>
  147. </target>
  148. <macrodef name="macro-run-tests-fault-inject">
  149. <attribute name="target.name" />
  150. <attribute name="testcasesonly" />
  151. <sequential>
  152. <subant buildpath="build.xml" target="@{target.name}">
  153. <property name="build.dir" value="${build-fi.dir}"/>
  154. <property name="test.fault.inject" value="yes"/>
  155. <property name="test.include" value="TestFi*"/>
  156. <!-- This one is needed for the special "regression" target only -->
  157. <property name="special.fi.testcasesonly" value="@{testcasesonly}"/>
  158. </subant>
  159. </sequential>
  160. </macrodef>
  161. <!-- ================================================================== -->
  162. <!-- Make hadoop-fi.jar including all Fault injected artifacts -->
  163. <!-- ================================================================== -->
  164. <macrodef name="macro-jar-fault-inject">
  165. <attribute name="target.name" />
  166. <attribute name="build.dir" />
  167. <attribute name="jar.final.name" />
  168. <attribute name="jar.final.value" />
  169. <sequential>
  170. <subant buildpath="build.xml" target="@{target.name}">
  171. <property name="build.dir" value="@{build.dir}"/>
  172. <property name="@{jar.final.name}" value="@{jar.final.value}"/>
  173. <property name="jar.extra.properties.list"
  174. value="${test.src.dir}/fi-site.xml" />
  175. </subant>
  176. </sequential>
  177. </macrodef>
  178. <!-- ================================================================== -->
  179. <!-- Make test jar files including all Fault Injected artifacts -->
  180. <!-- ================================================================== -->
  181. <macrodef name="macro-jar-test-fault-inject">
  182. <attribute name="target.name" />
  183. <attribute name="jar.final.name" />
  184. <attribute name="jar.final.value" />
  185. <sequential>
  186. <subant buildpath="build.xml" target="@{target.name}">
  187. <property name="build.dir" value="${build-fi.dir}"/>
  188. <property name="@{jar.final.name}"
  189. value="@{jar.final.value}"/>
  190. </subant>
  191. </sequential>
  192. </macrodef>
  193. <!--End of Fault Injection (FI) related session-->
  194. <!-- Start of cluster controller binary target -->
  195. <property name="runAs.src"
  196. value ="${test.src.dir}/system/c++/runAs"/>
  197. <property name="runAs.build.dir"
  198. value="${system-test-build-dir}/c++-build"/>
  199. <property name="runAs.configure.script"
  200. value="${runAs.build.dir}/configure"/>
  201. <target name="init-runAs-build">
  202. <condition property="runAs.parameters.passed">
  203. <not>
  204. <equals arg1="${run-as.hadoop.home.dir}"
  205. arg2="$${run-as.hadoop.home.dir}"/>
  206. </not>
  207. </condition>
  208. <fail unless="runAs.parameters.passed"
  209. message="Required parameters run-as.hadoop.home.dir not passed to the build"/>
  210. <mkdir dir="${runAs.build.dir}"/>
  211. <copy todir="${runAs.build.dir}" overwrite="true">
  212. <fileset dir="${runAs.src}" includes="**/*"/>
  213. </copy>
  214. <chmod perm="+x" file="${runAs.configure.script}">
  215. </chmod>
  216. </target>
  217. <target name="configure-runAs"
  218. depends="init-runAs-build">
  219. <exec executable="${runAs.configure.script}"
  220. dir="${runAs.build.dir}" failonerror="true">
  221. <arg value="--with-home=${run-as.hadoop.home.dir}"/>
  222. </exec>
  223. </target>
  224. <target name="run-as" depends="configure-runAs">
  225. <exec executable="${make.cmd}" dir="${runAs.build.dir}"
  226. searchpath="yes" failonerror="yes">
  227. <arg value="all" />
  228. </exec>
  229. </target>
  230. <!-- End of cluster controller binary target -->
  231. <!-- Maven -->
  232. <target name="-mvn-system-install" depends="mvn-taskdef, jar-system">
  233. <artifact:pom file="${hadoop-common-instrumented.pom}" id="hadoop.core.${herriot.suffix}"/>
  234. <artifact:install file="${hadoop-common-instrumented.jar}">
  235. <pom refid="hadoop.core.${herriot.suffix}"/>
  236. <attach file="${hadoop-common-instrumented-sources.jar}" classifier="sources" />
  237. </artifact:install>
  238. </target>
  239. <!-- -mvn-system-deploy target is no more called from the root
  240. build.xml -->
  241. <target name="-mvn-system-deploy" depends="mvn-taskdef, jar-system">
  242. <artifact:pom file="${hadoop-common-instrumented.pom}"
  243. id="hadoop.core.${herriot.suffix}"/>
  244. <artifact:install-provider artifactId="wagon-http" version="1.0-beta-2"/>
  245. <artifact:deploy file="${hadoop-common-instrumented.jar}">
  246. <remoteRepository id="apache.snapshots.https" url="${asfrepo}"/>
  247. <pom refid="hadoop.core.${herriot.suffix}"/>
  248. <attach file="${hadoop-common-instrumented-sources.jar}" classifier="sources"/>
  249. </artifact:deploy>
  250. </target>
  251. <!-- End of Maven -->
  252. </project>