<commit_before><?xml version="1.0"?>
<project name="elasticsearch-integration-tests">

  <!-- this is all to not run tests for 'pom' packaging. maven you fail -->
  <condition property="shouldskip">
    <istrue value="${skip.integ.tests}"/>
  </condition>

  <!-- our pid file for easy cleanup -->
  <property name="integ.pidfile" location="${integ.scratch}/es.pid"/>

  <!-- if this exists, ES is running (maybe) -->
  <available property="integ.pidfile.exists" file="${integ.pidfile}"/>

  <!-- arguments passed to elasticsearch when running -->
  <property name="integ.args"
            value="-Des.node.name=smoke_tester -Des.cluster.name=prepare_release
                   -Des.discovery.zen.ping.multicast.enabled=false -Des.script.inline=on
                   -Des.script.indexed=on -Des.pidfile=${integ.pidfile}"/>

  <!-- runs an OS script -->
  <macrodef name="run-script">
      <attribute name="script"/>
      <attribute name="dir"/>
      <attribute name="args"/>
      <attribute name="spawn" default="false"/>
    <sequential>
      <local name="failonerror"/>
      <condition property="failonerror">
          <isfalse value="@{spawn}"/>
      </condition>

      <exec executable="cmd" osfamily="winnt" dir="@{dir}" failonerror="${failonerror}" spawn="@{spawn}">
        <arg value="/c"/>
        <arg value="@{dir}/@{script}.bat"/>
        <arg line="@{args}"/>
      </exec>

      <exec executable="sh" osfamily="unix" dir="@{dir}" failonerror="${failonerror}" spawn="@{spawn}">
        <arg value="@{dir}/@{script}"/>
        <arg line="@{args}"/>
      </exec>
    </sequential>
  </macrodef>

  <!-- extracts PID from file -->
  <macrodef name="extract-pid">
      <attribute name="property"/>
    <sequential>
      <loadfile srcFile="${integ.pidfile}" property="@{property}">
        <filterchain>
          <striplinebreaks/>
        </filterchain>
      </loadfile>
    </sequential>
  </macrodef>

  <!-- unzip core release artifact and start ES -->
  <target name="start-external-cluster" depends="stop-external-cluster" unless="${shouldskip}">
    <local name="integ.finalname"/>
    <local name="integ.home"/>
    <local name="integ.repo.home"/>
    <local name="integ.pid"/>

    <delete dir="${integ.scratch}"/>
    <property name="integ.finalname" value="${project.artifactId}-${project.version}"/>

    <unzip src="${project.build.directory}/releases/${integ.finalname}.zip"
           dest="${integ.scratch}"/>

    <property name="integ.home" location="${integ.scratch}/${integ.finalname}"/>
    <property name="integ.repo.home" location="${integ.home}/repo"/>

    <!-- execute -->
    <echo>Starting up external cluster...</echo>
    <run-script dir="${integ.home}" script="bin/elasticsearch" spawn="true"
                args="${integ.args} -Des.path.repo=${integ.repo.home}" />

    <waitfor maxwait="3" maxwaitunit="minute" checkevery="500">
      <http url="http://127.0.0.1:9200"/>
    </waitfor>

    <extract-pid property="integ.pid"/>
    <echo>External cluster started PID ${integ.pid}</echo>
  </target>

  <!-- unzip core release artifact, install plugin, then start ES -->
  <target name="start-external-cluster-with-plugin" depends="stop-external-cluster" unless="${shouldskip}">
    <local name="integ.home"/>
    <local name="integ.repo.home"/>
    <local name="integ.plugin.url"/>
    <local name="integ.pid"/>

    <delete dir="${integ.scratch}"/>
    <unzip src="${org.elasticsearch:elasticsearch:zip}"
           dest="${integ.scratch}"/>

    <property name="integ.home" location="${integ.scratch}/elasticsearch-${elasticsearch.version}"/>
    <property name="integ.repo.home" location="${integ.home}/repo"/>

    <makeurl property="integ.plugin.url" file="${project.build.directory}/releases/${project.artifactId}-${project.version}.zip"/>

    <echo>Installing plugin ${project.artifactId}...</echo>
    <run-script dir="${integ.home}" script="bin/plugin"
                args="-u ${integ.plugin.url} -i ${project.artifactId}/${project.version}"/>

    <!-- execute --><commit_msg>enforce plugins are installed with correct name, and install correctly in integ tests<commit_after><?xml version="1.0"?>
<project name="elasticsearch-integration-tests">

  <!-- this is all to not run tests for 'pom' packaging. maven you fail -->
  <condition property="shouldskip">
    <istrue value="${skip.integ.tests}"/>
  </condition>

  <!-- our pid file for easy cleanup -->
  <property name="integ.pidfile" location="${integ.scratch}/es.pid"/>

  <!-- if this exists, ES is running (maybe) -->
  <available property="integ.pidfile.exists" file="${integ.pidfile}"/>

  <!-- arguments passed to elasticsearch when running -->
  <property name="integ.args"
            value="-Des.node.name=smoke_tester -Des.cluster.name=prepare_release
                   -Des.discovery.zen.ping.multicast.enabled=false -Des.script.inline=on
                   -Des.script.indexed=on -Des.pidfile=${integ.pidfile}"/>

  <!-- runs an OS script -->
  <macrodef name="run-script">
      <attribute name="script"/>
      <attribute name="dir"/>
      <attribute name="args"/>
      <attribute name="spawn" default="false"/>
    <sequential>
      <local name="failonerror"/>
      <condition property="failonerror">
          <isfalse value="@{spawn}"/>
      </condition>

      <exec executable="cmd" osfamily="winnt" dir="@{dir}" failonerror="${failonerror}" spawn="@{spawn}">
        <arg value="/c"/>
        <arg value="@{dir}/@{script}.bat"/>
        <arg line="@{args}"/>
      </exec>

      <exec executable="sh" osfamily="unix" dir="@{dir}" failonerror="${failonerror}" spawn="@{spawn}">
        <arg value="@{dir}/@{script}"/>
        <arg line="@{args}"/>
      </exec>
    </sequential>
  </macrodef>

  <!-- extracts PID from file -->
  <macrodef name="extract-pid">
      <attribute name="property"/>
    <sequential>
      <loadfile srcFile="${integ.pidfile}" property="@{property}">
        <filterchain>
          <striplinebreaks/>
        </filterchain>
      </loadfile>
    </sequential>
  </macrodef>

  <!-- applies transformations to src and stores in dst -->
  <macrodef name="filter-property">
      <attribute name="src"/>
      <attribute name="dest"/>
      <element name="chain"/>
    <sequential>
      <loadresource property="@{dest}">
        <propertyresource name="@{src}"/>
        <filterchain>
          <tokenfilter>
            <chain/>
          </tokenfilter>
        </filterchain>
      </loadresource>
    </sequential>
  </macrodef>

  <!-- unzip core release artifact and start ES -->
  <target name="start-external-cluster" depends="stop-external-cluster" unless="${shouldskip}">
    <local name="integ.finalname"/>
    <local name="integ.home"/>
    <local name="integ.repo.home"/>
    <local name="integ.pid"/>

    <delete dir="${integ.scratch}"/>
    <property name="integ.finalname" value="${project.artifactId}-${project.version}"/>

    <unzip src="${project.build.directory}/releases/${integ.finalname}.zip"
           dest="${integ.scratch}"/>

    <property name="integ.home" location="${integ.scratch}/${integ.finalname}"/>
    <property name="integ.repo.home" location="${integ.home}/repo"/>

    <!-- execute -->
    <echo>Starting up external cluster...</echo>
    <run-script dir="${integ.home}" script="bin/elasticsearch" spawn="true"
                args="${integ.args} -Des.path.repo=${integ.repo.home}" />

    <waitfor maxwait="3" maxwaitunit="minute" checkevery="500">
      <http url="http://127.0.0.1:9200"/>
    </waitfor>

    <extract-pid property="integ.pid"/>
    <echo>External cluster started PID ${integ.pid}</echo>
  </target>

  <!-- unzip core release artifact, install plugin, then start ES -->
  <target name="start-external-cluster-with-plugin" depends="stop-external-cluster" unless="${shouldskip}">
    <local name="integ.home"/>
    <local name="integ.repo.home"/>
    <local name="integ.plugin.url"/>
    <local name="integ.pid"/>

    <delete dir="${integ.scratch}"/>
    <unzip src="${org.elasticsearch:elasticsearch:zip}"
           dest="${integ.scratch}"/>

    <property name="integ.home" location="${integ.scratch}/elasticsearch-${elasticsearch.version}"/>
    <property name="integ.repo.home" location="${integ.home}/repo"/>

    <makeurl property="integ.plugin.url" file="${project.build.directory}/releases/${project.artifactId}-${project.version}.zip"/>

    <!-- install plugin -->
    <echo>Installing plugin ${project.artifactId}...</echo>
    <run-script dir="${integ.home}" script="bin/plugin"
                args="-u ${integ.plugin.url} -i ${project.artifactId}"/>

    <!-- check that plugin was installed into correct place -->
    <local name="expected-shortname"/>
    <filter-property src="project.artifactId" dest="expected-shortname">
      <chain>
        <replaceregex pattern="^elasticsearch-" replace=""/>
      </chain>
    </filter-property>

    <fail message="did not find plugin installed as ${expected-shortname}">
      <condition>
        <not>
          <resourceexists>
            <file file="${integ.home}/plugins/${expected-shortname}"/>
          </resourceexists>
        </not>
      </condition>
    </fail>

    <!-- execute -->
{'fraction_non_alphanumeric': 0.19606350587211832, 'fraction_numerical': 0.0034797738147020443, 'mean_word_length': 3.135341726618705, 'pattern_counts': {'":': 0, '<': 200, '<?xml version=': 2, '>': 200, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7387436', 'n_tokens_mistral': 2843, 'n_tokens_neox': 2747, 'n_words': 533}