<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!--
! CDDL HEADER START
!
! The contents of this file are subject to the terms of the
! Common Development and Distribution License, Version 1.0 only
! (the "License"). You may not use this file except in compliance
! with the License.
!
! You can obtain a copy of the license at
! See the License for the specific language governing permissions
! and limitations under the License.
!
! When distributing Covered Code, include this CDDL HEADER in each
! file and include the License file at
! trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
! add the following below this CDDL HEADER, with the fields enclosed
! by brackets "[]" replaced with your own identifying information:
! Portions Copyright [yyyy] [name of copyright owner]
!
! CDDL HEADER END
!
! Copyright 2008-2010 Sun Microsystems, Inc.
! Portions Copyright 2012-2013 ForgeRock AS
! -->
<stax>
<function name="main_snmp_setup">
<sequence>
<block name="'snmp_setup'">
<try>
<sequence>
<!--- Test Suite information
#@TestSuiteName setup
#@TestSuitePurpose Setup for the snmp test suite.
#@TestSuiteGroup setup
#@TestScript snmp_setup.xml
-->
<script>
if not CurrentTestPath.has_key('group'):
CurrentTestPath['group'] = 'snmp'
CurrentTestPath['suite'] = 'setup'
</script>
<call function="'testSuite_Preamble'"/>
<!--- Define default value for manager -->
<script>
opendmkPath = '%s/jdmkrt.jar' % snmpPath
</script>
<!--- Test Case information
#@TestMarker setup
#@TestName setup: create DS topology
#@TestIssue none
#@TestPurpose Create the topology necessary to the
test suite.
#@TestPreamble none
#@TestStep Create DS topology as described in config.py.
#@TestPostamble none
#@TestResult Success if createTopology returns 0.
-->
<testcase name="getTestCaseName('setup: create DS topology')">
<sequence>
<try>
<sequence>
<call function="'testCase_Preamble'"/>
<call function="'testStep'">
{ 'stepMessage' : 'create DS topology as described in config.py.' }
</call>
<call function="'createTopology'">
{ 'initialiseInstance' : False }
</call>
<call function="'checktestRC'">
{
'returncode' : RC ,
'result' : STAXResult
}
</call>
</sequence>
<catch exception="'STAXException'" typevar="eType" var="eInfo">
<message log="1" level="'fatal'">
'%s: Test failed. eInfo(%s)' % (eType,eInfo)
</message>
</catch>
<finally>
<sequence>
<call function="'testCase_Postamble'"/>
</sequence>
</finally>
</try>
</sequence>
</testcase>
<!-- Check if 'opendmkPath' exists -->
<call function="'GetEntry'">
{
'location' : STAF_REMOTE_HOSTNAME ,
'entry' : opendmkPath ,
'attribute' : 'TYPE'
}
</call>
<!-- 'opendmkPath' exists so we can continue -->
<if expr="RC != 48 or not PRODUCTNAME.startswith('OpenDJ')">
<sequence>
<!--- Test Case information
#@TestMarker setup
#@TestName setup: start DS
#@TestIssue none
#@TestPurpose Start DS.
#@TestPreamble none
#@TestStep Start the server.
#@TestStep Check that the server is alive.
#@TestPostamble none
#@TestResult Success if StartDsWithScript returns 0.
-->
<testcase name="getTestCaseName('setup: start DS')">
<sequence>
<try>
<sequence>
<call function="'testCase_Preamble'"/>
<call function="'testStep'">
{ 'stepMessage' : 'start DS to run on port %s.' % (DIRECTORY_INSTANCE_PORT) }
</call>
<!--- Start DS -->
<call function="'StartDsWithScript'">
{ 'location' : STAF_REMOTE_HOSTNAME }
</call>
<!--- Check that DS started -->
<call function="'isAlive'">
{
'noOfLoops' : 10 ,
'noOfMilliSeconds' : 2000
}
</call>
</sequence>
<catch exception="'STAXException'" typevar="eType" var="eInfo">
<message log="1" level="'fatal'">
'%s: Test failed. eInfo(%s)' % (eType,eInfo)
</message>
</catch>
<finally>
<sequence>
<call function="'testCase_Postamble'"/>
</sequence>
</finally>
</try>
</sequence>
</testcase>
<!--- Test Case information
#@TestMarker setup
#@TestName setup: add initial entries
#@TestIssue none
#@TestPurpose Load the data needed by the test suite.
#@TestPreamble none
#@TestStep Load the data needed by the test suite.
#@TestPostamble none
#@TestResult Success if importLdif returns 0.
-->
<testcase name="getTestCaseName('setup: add initial entries')">
<sequence>
<try>
<sequence>
<call function="'testCase_Preamble'"/>
<call function="'testStep'">
{ 'stepMessage' : 'Add initial entries' }
</call>
<call function="'dsconfigSet'">
{
'dsInstanceHost' : DIRECTORY_INSTANCE_HOST,
'dsInstanceAdminPort' : DIRECTORY_INSTANCE_ADMIN_PORT,
'dsInstanceDn' : DIRECTORY_INSTANCE_DN,
'dsInstancePswd' : DIRECTORY_INSTANCE_PSWD,
'objectName' : 'password-policy',
'propertyType' : 'policy',
'propertyName' : 'Default Password Policy',
'attributeName' : 'allow-pre-encoded-passwords',
'attributeValue' : 'true'
}
</call>
<call function="'addEntry'">
{ 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST,
'dsInstancePort' : DIRECTORY_INSTANCE_PORT,
'dsInstanceDn' : DIRECTORY_INSTANCE_DN,
'dsInstancePswd' : DIRECTORY_INSTANCE_PSWD,
% remote.data,
'verbose' : False
}
</call>
</sequence>
<catch exception="'STAXException'" typevar="eType" var="eInfo">
<message log="1" level="'fatal'">
'%s: Test failed. eInfo(%s)' % (eType,eInfo)
</message>
</catch>
<finally>
<sequence>
<call function="'testCase_Postamble'"/>
</sequence>
</finally>
</try>
</sequence>
</testcase>
<!--- Test Case information
#@TestMarker setup
#@TestName setup: get default SNMP connection handler
properties
#@TestIssue none
#@TestPurpose Get default SNMP connection handler
properties.
#@TestPreamble none
#@TestStep get default SNMP connection handler
properties using dsconfig.
#@TestPostamble none
#@TestResult Success if GetDSConfigProperties returns 0
-->
<testcase name="getTestCaseName
('setup: get default SNMP Connection Handler properties')">
<sequence>
<try>
<sequence>
<call function="'testCase_Preamble'"/>
<call function="'testStep'">
{ 'stepMessage' : 'Get default SNMP Connection Handler properties' }
</call>
<script>
options = '--handler-name "SNMP Connection Handler"'
</script>
<call function="'GetDSConfigProperties'">
{
'dsInstanceHost' : DIRECTORY_INSTANCE_HOST ,
'dsInstanceDn' : DIRECTORY_INSTANCE_DN ,
'dsInstancePswd' : DIRECTORY_INSTANCE_PSWD ,
'subcommand' : 'get-connection-handler-prop' ,
'optionsString' : options ,
'myVariableName' : 'DEFAULT_PROPERTIES'
}
</call>
</sequence>
<catch exception="'STAXException'" typevar="eType" var="eInfo">
<message log="1" level="'fatal'">
'%s: Test failed. eInfo(%s)' % (eType,eInfo)
</message>
</catch>
<finally>
<sequence>
<call function="'testCase_Postamble'"/>
</sequence>
</finally>
</try>
</sequence>
</testcase>
<!--- Test Case information
#@TestMarker setup
#@TestName setup: check SNMP Connection Handler is
disabled
#@TestIssue none
#@TestPurpose Check SNMP Connection Handler is disabled.
#@TestPreamble none
#@TestStep check SNMP Connection Handler is
disabled using status command
#@TestPostamble none
#@TestResult Success if output of status is correct.
-->
<testcase name="getTestCaseName
('setup: check SNMP Connection Handler is disabled')">
<sequence>
<try>
<sequence>
<call function="'testCase_Preamble'"/>
<call function="'testStep'">
{ 'stepMessage' : 'Check SNMP Connection Handler is disabled' }
</call>
<call function="'StatusWithScript'">
{
'dsBindDN' : DIRECTORY_INSTANCE_DN ,
'dsBindPwd' : DIRECTORY_INSTANCE_PSWD
}
</call>
<script>
returnString = STAXResult[0][1]
</script>
<call function="'checktestString'">
{
'returnString' : returnString ,
'expectedString' : ':\\s+SNMP\\s+:\\s+Disabled'
}
</call>
</sequence>
<catch exception="'STAXException'" typevar="eType" var="eInfo">
<message log="1" level="'fatal'">
'%s: Test failed. eInfo(%s)' % (eType,eInfo)
</message>
</catch>
<finally>
<sequence>
<call function="'testCase_Postamble'"/>
</sequence>
</finally>
</try>
</sequence>
</testcase>
<!--- Test Case information
#@TestMarker setup
#@TestName setup: enable SNMP Connection Handler
#@TestIssue none
#@TestPurpose Enable SNMP Connection Handler.
#@TestPreamble none
#@TestStep enable SNMP Connection Handler using
dsconfig.
#@TestPostamble none
#@TestResult Success if dsconfig returns 0.
-->
<testcase name="getTestCaseName
('setup: enable SNMP Connection Handler')">
<sequence>
<try>
<sequence>
<call function="'testCase_Preamble'"/>
<call function="'testStep'">
{ 'stepMessage' : 'Enable SNMP Connection Handler' }
</call>
<call function="'dsconfig'">
{
'dsInstanceHost' : DIRECTORY_INSTANCE_HOST ,
'dsInstanceDn' : DIRECTORY_INSTANCE_DN ,
'dsInstancePswd' : DIRECTORY_INSTANCE_PSWD ,
'subcommand' : 'set-connection-handler-prop' ,
'objectType' : 'handler-name' ,
'objectName' : 'SNMP Connection Handler' ,
'optionsString' : '--set enabled:true \
--set listen-port:%s \
--set trap-port:%s \
--set opendmk-jarfile:%s' \
% (SNMP_PORT, SNMP_TRAP_PORT, opendmkPath)
}
</call>
</sequence>
<catch exception="'STAXException'" typevar="eType" var="eInfo">
<message log="1" level="'fatal'">
'%s: Test failed. eInfo(%s)' % (eType,eInfo)
</message>
</catch>
<finally>
<sequence>
<call function="'testCase_Postamble'"/>
</sequence>
</finally>
</try>
</sequence>
</testcase>
<!--- Test Case information
#@TestMarker setup
#@TestName setup: check SNMP Connection Handler is
enabled
#@TestIssue none
#@TestPurpose Check SNMP Connection Handler is enabled.
#@TestPreamble none
#@TestStep check SNMP Connection Handler is
enabled using status command
#@TestPostamble none
#@TestResult Success if output of status is correct.
-->
<testcase name="getTestCaseName
('setup: check SNMP Connection Handler is enabled')">
<sequence>
<try>
<sequence>
<call function="'testCase_Preamble'"/>
<call function="'testStep'">
{ 'stepMessage' : 'Check SNMP Connection Handler is enabled' }
</call>
<call function="'StatusWithScript'">
{
'dsBindDN' : DIRECTORY_INSTANCE_DN ,
'dsBindPwd' : DIRECTORY_INSTANCE_PSWD
}
</call>
<script>
returnString = STAXResult[0][1]
</script>
<call function="'checktestString'">
{
'returnString' : returnString ,
'expectedString' : ':\\s+SNMP\\s+:\\s+Enabled'
}
</call>
</sequence>
<catch exception="'STAXException'" typevar="eType" var="eInfo">
<message log="1" level="'fatal'">
'%s: Test failed. eInfo(%s)' % (eType,eInfo)
</message>
</catch>
<finally>
<sequence>
<call function="'testCase_Postamble'"/>
</sequence>
</finally>
</try>
</sequence>
</testcase>
<!--- Test Case information
#@TestMarker setup
#@TestName setup: get SNMP connection handler
properties
#@TestIssue none
#@TestPurpose Get SNMP connection handler properties.
#@TestPreamble none
#@TestStep get SNMP connection handler properties
using dsconfig.
#@TestPostamble none
#@TestResult Success if GetDSConfigProperties returns 0
-->
<testcase name="getTestCaseName
('setup: get SNMP Connection Handler properties')">
<sequence>
<try>
<sequence>
<call function="'testCase_Preamble'"/>
<call function="'testStep'">
{ 'stepMessage' : 'Copy snmp files to the remote host' }
</call>
<message>
(local.data, STAXServiceMachine, remote.temp, STAF_REMOTE_HOSTNAME)
</message>
<call function="'copyFile'">
{
'location' : STAXServiceMachine ,
'remotehost' : STAF_REMOTE_HOSTNAME
}
</call>
<message>
(local.data, STAXServiceMachine, remote.temp, STAF_REMOTE_HOSTNAME)
</message>
<call function="'copyFile'">
{
'location' : STAXServiceMachine ,
'remotehost' : STAF_REMOTE_HOSTNAME
}
</call>
<call function="'testStep'">
{ 'stepMessage' : 'Get SNMP Connection Handler properties' }
</call>
<script>
options = '--handler-name "SNMP Connection Handler"'
</script>
<call function="'GetDSConfigProperties'">
{
'dsInstanceHost' : DIRECTORY_INSTANCE_HOST ,
'dsInstanceDn' : DIRECTORY_INSTANCE_DN ,
'dsInstancePswd' : DIRECTORY_INSTANCE_PSWD ,
'subcommand' : 'get-connection-handler-prop' ,
'optionsString' : options ,
'myVariableName' : 'SNMP_PROPERTIES'
}
</call>
</sequence>
<catch exception="'STAXException'" typevar="eType" var="eInfo">
<message log="1" level="'fatal'">
'%s: Test failed. eInfo(%s)' % (eType,eInfo)
</message>
</catch>
<finally>
<sequence>
<call function="'testCase_Postamble'"/>
</sequence>
</finally>
</try>
</sequence>
</testcase>
</sequence>
<else>
<sequence>
<!--- Test Case information
#@TestMarker setup
#@TestName setup: warning
#@TestIssue none
#@TestPurpose Warning
#@TestPreamble none
#@TestStep Print a warning message to indicate that
the SNMP_OPENDMK_LIBDIR is not set.
#@TestPostamble none
#@TestResult Always fails.
-->
<testcase name="getTestCaseName('setup: Warning')">
<sequence>
<try>
<sequence>
<call function="'testCase_Preamble'"/>
<script>
STOP_RUN = 'True'
</script>
<call function="'testStep'">
{ 'stepMessage' : 'Print a warning message' }
</call>
<message log="1" level="'Error'">
'WARNING: Check if SNMP_OPENDMK_LIBDIR is set \
in the config.py.stubs file.'
</message>
<tcstatus result="'fail'"></tcstatus>
</sequence>
<catch exception="'STAXException'" typevar="eType" var="eInfo">
<message log="1" level="'fatal'">
'%s: Test failed. eInfo(%s)' % (eType,eInfo)
</message>
</catch>
<finally>
<sequence>
<call function="'testCase_Postamble'"/>
</sequence>
</finally>
</try>
</sequence>
</testcase>
</sequence>
</else>
</if>
</sequence>
<finally>
<call function="'testSuite_Postamble'"/>
</finally>
</try>
</block>
</sequence>
</function>
</stax>