blob: 52c8bbcf7c7d507c5a591d5027e1d8410bd15873 [file] [log] [blame]
<!--
Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved.
This program and the accompanying materials are made available under the
terms of the Eclipse Public License v. 2.0, which is available at
http://www.eclipse.org/legal/epl-2.0.
This Source Code may also be made available under the following Secondary
Licenses when the conditions for such availability set forth in the
Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
version 2 with the GNU Classpath Exception, which is available at
https://www.gnu.org/software/classpath/license.html.
SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
-->
<!--
This is the common targets for all selfmanagement tests
-->
<!-- ================================================================ -->
<!-- Setup and Restart the server instance-->
<target name="norestart">
<echo message="The tests will not restart the server before running" />
<property name="no.restart" value="true"/>
</target>
<target name="pre-start" depends="printmessage">
<antcall target="restart-before-test"/>
</target>
<target name="restart-before-test" unless="no.restart.test">
<antcall target="restart-server-internal"/>
</target>
<target name="restart-server" depends="printmessage">
<antcall target="restart-server-internal"/>
</target>
<target name="restart-server-internal" unless="no.restart">
<antcall target="stopDomain"/>
<antcall target="startDomain"/>
</target>
<target name="printmessage" if="no.retstart">
<echo message="The test will be run without restarting the server"/>
</target>
<target name="startDomain" depends="startDomainUnix, startDomainWindows"/>
<target name="startDomainUnix" depends="init-common" if="isUnix">
<exec executable="${ASADMIN}" failonerror="true">
<arg line="start-domain"/>
<arg line="--user ${admin.user}"/>
<arg line="--password ${admin.password}"/>
<arg line="--domaindir ${admin.domain.dir}"/>
<arg line="${admin.domain}"/>
</exec>
</target>
<target name="startDomainWindows" depends="init-common" if="isWindows">
<exec executable="start" failonerror="true">
<arg line="${ASADMIN}"/>
<arg line="start-domain"/>
<arg line="--user ${admin.user}"/>
<arg line="--password ${admin.password}"/>
<arg line="--domaindir ${admin.domain.dir}"/>
<arg line="${admin.domain}"/>
</exec>
</target>
<target name="stopDomain" depends="init-common">
<echo message="run.xml:stopping domain..."/>
<exec executable="${ASADMIN}" failonerror="true">
<arg line="stop-domain"/>
<arg line="--domaindir ${admin.domain.dir}"/>
<arg line="${admin.domain}"/>
</exec>
</target>
<!-- ================================================================ -->
<!-- Target to create a Self Management Rule,after creating event and action mbeans -->
<!-- ================================================================ -->
<target name="deploy-selfmgmt-rule-common" depends="init-common">
<antcall target="create-event-mbean-common" />
<antcall target="create-action-mbean-common" />
<antcall target="create-management-rule-common" />
</target>
<target name="create-event-mbean-common" depends="init-common">
<echo message="created Event MBean ${event.mbean.impl.class.name}"
level="verbose"/>
<exec executable="${ASADMIN}" failonerror="false">
<arg line="create-mbean"/>
<arg line="${as.props}"/> <!-- To set user, password, host and port properties -->
<arg line="--name ${event.mbean.name}"/>
<arg line="${event.mbean.attribute}"/>
<arg line="${event.mbean.impl.class.name}"/>
</exec>
</target>
<target name="create-action-mbean-common" depends="init-common">
<echo message="created Action MBean ${action.mbean.impl.class.name}"
level="verbose"/>
<exec executable="${ASADMIN}" failonerror="false">
<arg line="create-mbean"/>
<arg line="${as.props}"/> <!-- To set user, password, host and port properties -->
<arg line="--name ${action.mbean.name}"/>
<arg line="${action.mbean.impl.class.name}"/>
</exec>
</target>
<target name="create-management-rule-common" depends="init-common">
<echo message="created Self Management Rule ${selfmanagement.rule.name}"
level="verbose"/>
<exec executable="${ASADMIN}" failonerror="false">
<arg line="create-management-rule"/>
<arg line="${as.props}"/> <!-- To set user, password, host and port properties -->
<arg line="--action ${action.mbean.name}"/>
<arg line="--eventtype ${selfmanagement.rule.eventtype}"/>
<arg line="--eventloglevel ${selfmanagement.rule.eventloglevel}"/>
<arg line="--eventproperties ${selfmanagement.rule.eventproperties}"/>
<arg line="${selfmanagement.rule.name}"/>
</exec>
</target>
<target name="undeploy-selfmgmt-rule-common" depends="init-common">
<antcall target="delete-event-mbean-common" />
<antcall target="delete-action-mbean-common" />
</target>
<target name="delete-management-rule-common" depends="init-common">
<echo message="deleted Self Management Rule ${selfmanagement.rule.name}"
level="verbose"/>
<exec executable="${ASADMIN}" failonerror="false">
<arg line="delete-management-rule"/>
<arg line="${as.props}"/> <!-- To set user, password, host and port properties -->
<arg line="${selfmanagement.rule.name}"/>
</exec>
</target>
<target name="delete-event-mbean-common" depends="init-common">
<echo message="deleted Event MBean ${event.mbean.name}"
level="verbose"/>
<exec executable="${ASADMIN}" failonerror="false">
<arg line="delete-mbean"/>
<arg line="${as.props}"/> <!-- To set user, password, host and port properties -->
<arg line="${event.mbean.name}"/>
</exec>
</target>
<target name="delete-action-mbean-common" depends="init-common">
<echo message="deleted Action MBean ${action.mbean.name}"
level="verbose"/>
<exec executable="${ASADMIN}" failonerror="false">
<arg line="delete-mbean"/>
<arg line="${as.props}"/> <!-- To set user, password, host and port properties -->
<arg line="${action.mbean.name}"/>
</exec>
</target>
<target name="deploy-selfmgmt-jar-common" depends="init-common">
<copy file="${assemble.dir}/${appclient.jar.name}"
tofile="${app.lib}/${appclient.jar.name}"
overwrite="true" />
<copy file="${env.APS_HOME}/lib/reporter.jar"
tofile="${app.lib}/reporter.jar"
overwrite="true" />
</target>
<target name="delete-selfmanagement-jar" depends="init-common">
<delete file="${assemble.dir}/${appclient.jar.name}"/>
<delete file="${env.APS_HOME}/../../publish/glassfish/lib/${appclient.jar.name}"/>
<delete file="${app.lib}/reporter.jar"/>
<!--<delete file="/space/selfmanagementResult.txt"/>-->
</target>
<target name="run-selfmanagement-client-common" depends="init-common">
<echo message="appclient -client ${appclient.jar}"/>
<exec executable="${APPCLIENT}" failonerror="true">
<arg line="-client ${appclient.jar}"/>
<arg line="${as.props}"/>
</exec>
<!-- confirming report generation... -->
<!-- <antcall target="checkReporting-common">
<param name="test.name" value="${appname}"/>
<param name="test.description" value="${test.description}"/>
</antcall>-->
</target>