Skip to content

Commit

Permalink
LRQA-54968 Clean up indices print logic
Browse files Browse the repository at this point in the history
  • Loading branch information
joshchong authored and brianchandotcom committed Feb 25, 2020
1 parent b613c27 commit b62d1f5
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 109 deletions.
8 changes: 7 additions & 1 deletion build-test-elasticsearch7.xml
Original file line number Diff line number Diff line change
Expand Up @@ -831,8 +831,14 @@ xpack.monitoring.collection.enabled: true</echo>
</target>

<target name="print-elasticsearch-indices">
<get-testcase-property property.name="remote.elasticsearch.enabled" />

<condition else="9201" property="elasticsearch.port" value="9200">
<equals arg1="${remote.elasticsearch.enabled}" arg2="true" />
</condition>

<exec executable="curl" outputproperty="curl.output.elasticsearch.indices">
<arg line="&apos;localhost:9201/liferay-${companyId}/_search?pretty&apos; -H &apos;Content-Type: application/json&apos; -d&apos;{&quot;query&quot;: {&quot;bool&quot;: {&quot;must&quot;: [{ &quot;match&quot;: { &quot;userName&quot;: &quot;test test&quot; } }],&quot;must_not&quot;: [{ &quot;match&quot;: { &quot;hidden&quot;: &quot;true&quot; } }]}}}&apos;" />
<arg line="&apos;localhost:${elasticsearch.port}/liferay-${companyId}/_search?pretty&apos; -H &apos;Content-Type: application/json&apos; -d&apos;{&quot;query&quot;: {&quot;bool&quot;: {&quot;must&quot;: [{ &quot;match&quot;: { &quot;userName&quot;: &quot;test test&quot; } }],&quot;must_not&quot;: [{ &quot;match&quot;: { &quot;hidden&quot;: &quot;true&quot; } }]}}}&apos;" />
</exec>

<echo></echo>
Expand Down
174 changes: 66 additions & 108 deletions build-test.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2691,6 +2691,70 @@ ${tomcat-gc-log}
</sequential>
</macrodef>

<macrodef name="print-search-indices">
<sequential>
<get-testcase-property property.name="solr.enabled" />
<propertycopy from="search.engine[${env.CI_TEST_SUITE}]" name="suite.search.engine" silent="true" />

<if>
<or>
<equals arg1="${solr.enabled}" arg2="true" />
<equals arg1="${suite.search.engine}" arg2="solr" />
</or>
<then>
<ant antfile="build-test-solr.xml" target="print-solr-indices" />
</then>
<else>
<get-testcase-property property.name="test.name.skip.portal.instance" />

<if>
<and>
<not>
<isset property="test.name.skip.portal.instance" />
</not>
<equals arg1="test.portal.instance" arg2="true" />
</and>
<then>
<var name="portalInstanceName" value="${env.HOSTNAME}" />
</then>
<else>
<var name="portalInstanceName" value="localhost" />
</else>
</if>

<exec executable="curl" outputproperty="companyId">
<arg value="http://localhost:8080/api/jsonws/company/get-company-by-virtual-host/virtual-host/${portalInstanceName}" />
<arg value="-u" />
<arg value="[email protected]:test" />
</exec>

<propertyregex
input="${companyId}"
override="true"
property="companyId"
regexp="(?&lt;=companyId&quot;:&quot;)(.*)(?=&quot;,&quot;home)"
select="\1"
/>

<get-testcase-property property.name="osgi.app.includes" />

<if>
<or>
<equals arg1="${suite.search.engine}" arg2="elasticsearch7" />
<contains string="${osgi.app.includes}" substring="portal-search-elasticsearch7" />
</or>
<then>
<ant antfile="build-test-elasticsearch7.xml" target="print-elasticsearch-indices" />
</then>
<else>
<ant antfile="build-test-elasticsearch6.xml" target="print-elasticsearch-indices" />
</else>
</if>
</else>
</if>
</sequential>
</macrodef>

<macrodef name="record-git-commit-plugins">
<sequential>
<beanshell>
Expand Down Expand Up @@ -12309,116 +12373,10 @@ url=${short.hostname}:8080</echo>
</then>
</if>

<print-search-indices />

<trycatch property="shutdown.error">
<try>
<get-testcase-property property.name="solr.enabled" />

<if>
<not>
<equals arg1="${solr.enabled}" arg2="true" />
</not>
<then>
<get-testcase-property property.name="test.name.skip.portal.instance" />

<if>
<and>
<not>
<isset property="test.name.skip.portal.instance" />
</not>
<equals arg1="test.portal.instance" arg2="true" />
</and>
<then>
<var name="portalInstanceName" value="${env.HOSTNAME}" />
</then>
<else>
<var name="portalInstanceName" value="localhost" />
</else>
</if>

<exec executable="curl" outputproperty="companyId">
<arg value="http://localhost:8080/api/jsonws/company/get-company-by-virtual-host/virtual-host/${portalInstanceName}" />
<arg value="-u" />
<arg value="[email protected]:test" />
</exec>

<propertyregex
input="${companyId}"
override="true"
property="companyId"
regexp="(?&lt;=companyId&quot;:&quot;)(.*)(?=&quot;,&quot;home)"
select="\1"
/>

<get-testcase-property property.name="portal.suite.search.engine" />
<get-testcase-property property.name="remote.elasticsearch.enabled" />

<if>
<contains string="${env.CI_TEST_SUITE}" substring="search" />
<then>
<propertycopy from="search.engine[${env.CI_TEST_SUITE}]" name="suite.search.engine" silent="true" />

<if>
<and>
<not>
<isset property="remote.elasticsearch.enabled" />
</not>
<equals arg1="${suite.search.engine}" arg2="elasticsearch7" />
</and>
<then>
<ant antfile="build-test-elasticsearch7.xml" target="print-elasticsearch-indices" />
</then>
<elseif>
<not>
<equals arg1="${suite.search.engine}" arg2="solr" />
</not>
<then>
<ant antfile="build-test-elasticsearch6.xml" target="print-elasticsearch-indices" />
</then>
</elseif>
</if>
</then>
<else>
<if>
<and>
<not>
<isset property="remote.elasticsearch.enabled" />
</not>
<equals arg1="${portal.suite.search.engine}" arg2="elasticsearch7" />
</and>
<then>
<ant antfile="build-test-elasticsearch7.xml" target="print-elasticsearch-indices" />
</then>
<else>
<ant antfile="build-test-elasticsearch6.xml" target="print-elasticsearch-indices" />
</else>
</if>
</else>
</if>
</then>
</if>

<get-testcase-property property.name="solr.enabled" />

<if>
<equals arg1="${solr.enabled}" arg2="true" />
<then>
<ant antfile="build-test-solr.xml" target="print-solr-indices" />
</then>
<elseif>
<isset property="env.CI_TEST_SUITE" />
<then>
<propertycopy from="search.engine[${env.CI_TEST_SUITE}]" name="suite.search.engine" silent="true" />

<if>
<equals arg1="${suite.search.engine}" arg2="solr" />
<then>
<ant antfile="build-test-solr.xml" target="print-solr-indices" />
</then>
</if>
</then>
</elseif>
</if>

<antcall target="clean-up-logs" />

<record action="start" name="${project.dir}/console-shut-down" />
Expand Down

0 comments on commit b62d1f5

Please sign in to comment.