forked from community-security-team/liferay-portal
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
LRQA-54780 Add a target to replicate indices
- Loading branch information
1 parent
981b583
commit a52909e
Showing
1 changed file
with
60 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -880,6 +880,66 @@ xpack.monitoring.collection.enabled: true</echo> | |
<echo></echo> | ||
</target> | ||
|
||
<target name="replicate-indices"> | ||
<exec executable="curl" outputproperty="companyId"> | ||
<arg value="http://localhost:8080/api/jsonws/company/get-company-by-virtual-host/virtual-host/localhost" /> | ||
<arg value="-u" /> | ||
<arg value="[email protected]:test" /> | ||
</exec> | ||
|
||
<propertyregex | ||
input="${companyId}" | ||
override="true" | ||
property="companyId" | ||
regexp="(?<=companyId":")(.*)(?=","home)" | ||
select="\1" | ||
/> | ||
|
||
<exec executable="curl" outputproperty="curl.output"> | ||
<arg line="-X PUT "localhost:9202/_cluster/settings" -H 'Content-Type: application/json' -d '{"persistent":{"cluster":{"remote":{"leader":{"seeds":["127.0.0.1:9300"]}}}}}'" /> | ||
</exec> | ||
|
||
<echo>${curl.output}</echo> | ||
|
||
<exec executable="curl" outputproperty="curl.output"> | ||
<arg line="-X PUT "localhost:9202/liferay-${companyId}/_ccr/follow?wait_for_active_shards=1" -H 'Content-Type: application/json' -d '"remote_cluster": "leader","leader_index": "liferay-${companyId}"}'" /> | ||
</exec> | ||
|
||
<echo>${curl.output}</echo> | ||
|
||
<exec executable="curl" outputproperty="curl.output"> | ||
<arg line="-X PUT "localhost:9202/liferay-search-tuning-rankings/_ccr/follow?wait_for_active_shards=1" -H 'Content-Type: application/json' -d '"remote_cluster": "leader","leader_index": "liferay-search-tuning-rankings"}'" /> | ||
</exec> | ||
|
||
<echo>${curl.output}</echo> | ||
|
||
<exec executable="curl" outputproperty="curl.output"> | ||
<arg line="-X PUT "localhost:9202/liferay-search-tuning-synonyms-liferay-${companyId}/_ccr/follow?wait_for_active_shards=1" -H 'Content-Type: application/json' -d '"remote_cluster": "leader","leader_index": "liferay-search-tuning-synonyms-liferay-${companyId}"}'" /> | ||
</exec> | ||
|
||
<echo>${curl.output}</echo> | ||
|
||
<exec executable="curl" outputproperty="curl.output.indices"> | ||
<arg line="-X GET "localhost:9202/_cat/indices"" /> | ||
</exec> | ||
|
||
<echo>${curl.output.indices}</echo> | ||
|
||
<if> | ||
<and> | ||
<contains string="${curl.output.indices}" substring="liferay-${companyId}" /> | ||
<contains string="${curl.output.indices}" substring="liferay-search-tuning-rankings" /> | ||
<contains string="${curl.output.indices}" substring="liferay-search-tuning-synonyms-liferay-${companyId}" /> | ||
</and> | ||
<then> | ||
<echo>Elasticsearch indices replicate sucessfully.</echo> | ||
</then> | ||
<else> | ||
<fail>Elasticsearch indices Fail to replicate.</fail> | ||
</else> | ||
</if> | ||
</target> | ||
|
||
<target name="restore-backup"> | ||
<exec executable="curl" outputproperty="curl.output"> | ||
<arg line="-X PUT "localhost:${elasticsearch.port}/_snapshot/my_backup" -H 'Content-Type: application/json' -d'{"type": "fs","settings": {"location": "${liferay.home}/data/elasticsearch7/repo"}}'" /> | ||
|