2852N/A<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2887N/A<!DOCTYPE stax SYSTEM "/shared/stax.dtd">
2852N/A<!--
2852N/A ! CDDL HEADER START
2852N/A !
2852N/A ! The contents of this file are subject to the terms of the
2852N/A ! Common Development and Distribution License, Version 1.0 only
2852N/A ! (the "License"). You may not use this file except in compliance
2852N/A ! with the License.
2852N/A !
6982N/A ! You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
6982N/A ! or http://forgerock.org/license/CDDLv1.0.html.
2852N/A ! See the License for the specific language governing permissions
2852N/A ! and limitations under the License.
2852N/A !
2852N/A ! When distributing Covered Code, include this CDDL HEADER in each
6982N/A ! file and include the License file at legal-notices/CDDLv1_0.txt.
6982N/A ! If applicable, add the following below this CDDL HEADER, with the
6982N/A ! fields enclosed by brackets "[]" replaced with your own identifying
6982N/A ! information:
2852N/A ! Portions Copyright [yyyy] [name of copyright owner]
2852N/A !
2852N/A ! CDDL HEADER END
2852N/A !
4347N/A ! Copyright 2007-2009 Sun Microsystems, Inc.
6665N/A ! Portions Copyright 2011-2013 ForgeRock AS.
2938N/A! -->
2852N/A<stax>
2852N/A <defaultcall function="export-ldif"/>
2852N/A <function name="export-ldif" scope="local">
4865N/A <block name="STAXCurrentFunction">
4618N/A <try>
4618N/A <sequence>
4618N/A <script>
4618N/A CurrentTestPath['suite']=STAXCurrentFunction
4618N/A </script>
4865N/A <call function="'testSuite_Preamble'" />
4618N/A
4618N/A <!--- Test Suite information
4618N/A #@TestSuiteName Export tasks
4618N/A #@TestSuitePurpose Validate the export functionality in mode task
4618N/A #@TestSuiteID export Tests
4618N/A #@TestSuiteGroup export
4618N/A #@TestGroup tasks
4618N/A #@TestScript export_ldif.xml
4618N/A #@TestHTMLLink http://opends.dev.java.net/
4618N/A -->
4618N/A
4618N/A <call function="'common_setup'">
4618N/A {
4618N/A 'quickStart' : True ,
4618N/A 'startServer' : True ,
4618N/A 'stopServer' : False
4618N/A }
4865N/A </call>
4618N/A
4618N/A <!--- Test Case information
4618N/A #@TestMarker Export tasks
4618N/A #@TestName Export task in asynchronous mode
4618N/A #@TestPurpose Schedule a Export in task mode to be executed immedialy in asynchronous mode
4618N/A #@TestPreamble
4618N/A #@TestStep Execute a export-ldif in a task
4618N/A #@TestStep Specify the -t option with the value 0
4618N/A #@TestStep The task is scheduled for immediate execution
4618N/A #@TestStep The script returns immedialy after scheduling the task
4618N/A #@TestPostamble
4618N/A #@TestResult
4618N/A -->
4618N/A
4618N/A <testcase name="getTestCaseName('schedule export-ldif task for immediate execution in asynchronous mode')">
4618N/A <sequence>
4865N/A <call function="'testCase_Preamble'"/>
4618N/A
4865N/A <call function="'exportLdifWithScript'">
4618N/A { 'location' : STAF_REMOTE_HOSTNAME ,
4618N/A 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST,
4618N/A 'dsInstanceAdminPort' : DIRECTORY_INSTANCE_ADMIN_PORT,
4618N/A 'dsInstanceDn' : DIRECTORY_INSTANCE_DN,
4618N/A 'dsInstancePswd' : DIRECTORY_INSTANCE_PSWD,
5554N/A 'ldifFile' : '%s/tasks/export_asynchronous' % remote.temp,
4618N/A 'startTask' : '0',
4618N/A 'backEnd' : DIRECTORY_INSTANCE_BE}
4618N/A </call>
4618N/A
4618N/A <script>checkRC=9999</script>
4618N/A <loop from="1" to="10" var="loop" while="checkRC != 0">
4618N/A <sequence>
6665N/A <message>'MANAGE-TASKS LOOP %s' % loop</message>
6665N/A
4618N/A <!-- manage-tasks -->
4618N/A <call function="'manage-tasks'">
4618N/A {'location' : STAF_REMOTE_HOSTNAME,
4618N/A 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST,
4618N/A 'dsInstanceDn' : DIRECTORY_INSTANCE_DN,
4618N/A 'dsInstancePswd' : DIRECTORY_INSTANCE_PSWD,
4618N/A 'dsQuiet' : ' '
4618N/A }
4618N/A </call>
4618N/A
4618N/A <script>
4618N/A returnString = STAXResult[0][1]
4618N/A currentDate=strftime("%Y%m%d",localtime())
4618N/A </script>
4618N/A
4618N/A <call function="'searchString'">
4618N/A { 'expectedString' : '%s.* Export Completed successfully' \
4618N/A % currentDate,
4618N/A 'returnString' : returnString ,
4618N/A 'expectedRC' : 'noCheck' }
4618N/A </call>
4618N/A
4618N/A <script>
4618N/A checkRC = STAXResult[0]
4618N/A </script>
4865N/A
4865N/A <call function="'Sleep'">
4865N/A { 'sleepForMilliSeconds' : 2000 }
4865N/A </call>
4865N/A
4865N/A </sequence>
4865N/A </loop>
4618N/A
4618N/A <message>'--- Check log files export_asynchronous ---'</message>
4618N/A <call function="'listFolder'">
4618N/A { 'location' : '%s' % (STAF_REMOTE_HOSTNAME),
5554N/A 'foldername' : '%s/tasks' % remote.temp,
4618N/A 'filename' : 'export_asynchronous'
4618N/A }
4865N/A </call>
4618N/A
4618N/A <!-- check the export ldif file has been created-->
4618N/A <if expr="len(cmdResult) == 0">
4618N/A <call function="'testFailed'"/>
4618N/A <else>
4865N/A <call function="'testPassed'"/>
4618N/A </else>
4865N/A </if>
4618N/A
4618N/A <call function="'testCase_Postamble'"/>
4618N/A </sequence>
4618N/A </testcase>
3175N/A
4618N/A
4618N/A <!--- Test Case information
4618N/A #@TestMarker Export tasks
4618N/A #@TestName Export task in synchronous mode
4618N/A #@TestPurpose Schedule a Export in task mode to be executed immedialy in synchronous mode
4618N/A #@TestPreamble
4618N/A #@TestStep Execute a export-ldif in a task
4618N/A #@TestStep Execute manage-tasks output and check the Export task is returned
4618N/A #@TestStep Don't specify the -t option
4618N/A #@TestStep The task is scheduled for immediate execution and the script must wait the end of the export
4618N/A #@TestPostamble
4618N/A #@TestResult
4618N/A -->
4618N/A
4618N/A <testcase name="getTestCaseName('schedule export-ldif task for immediate execution in synchronous mode')">
4618N/A <sequence>
4865N/A <call function="'testCase_Preamble'"/>
4618N/A
4865N/A <call function="'exportLdifWithScript'">
4618N/A { 'location' : STAF_REMOTE_HOSTNAME ,
4618N/A 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST,
4618N/A 'dsInstanceAdminPort' : DIRECTORY_INSTANCE_ADMIN_PORT,
4618N/A 'dsInstanceDn' : DIRECTORY_INSTANCE_DN,
4618N/A 'dsInstancePswd' : DIRECTORY_INSTANCE_PSWD,
5554N/A 'ldifFile' : '%s/tasks/export_synchronous' % remote.temp,
4618N/A 'backEnd' : DIRECTORY_INSTANCE_BE}
4618N/A </call>
4618N/A
4713N/A <script>checkRC=9999</script>
4713N/A <loop from="1" to="10" var="loop" while="checkRC != 0">
4713N/A <sequence>
6665N/A <message>'MANAGE-TASKS LOOP %s' % loop</message>
6665N/A
4713N/A <!-- manage-tasks -->
4713N/A <call function="'manage-tasks'">
4713N/A { 'location' : STAF_REMOTE_HOSTNAME ,
4713N/A 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST,
4713N/A 'dsInstanceDn' : DIRECTORY_INSTANCE_DN,
4713N/A 'dsInstancePswd' : DIRECTORY_INSTANCE_PSWD,
4713N/A 'dsQuiet' : ' '
4713N/A }
4713N/A </call>
4713N/A
4713N/A <script>
4713N/A returnString = STAXResult[0][1]
4713N/A currentDate=strftime("%Y%m%d",localtime())
4713N/A </script>
4713N/A
4713N/A <call function="'searchString'">
4713N/A { 'expectedString' : '%s.* Export Completed successfully' \
4713N/A % currentDate,
4713N/A 'returnString' : returnString ,
4713N/A 'expectedRC' : 'noCheck' }
4713N/A </call>
4713N/A
4713N/A <script>
4713N/A checkRC = STAXResult[0]
4713N/A </script>
4713N/A
4865N/A <call function="'Sleep'">
4865N/A { 'sleepForMilliSeconds' : 2000 }
4865N/A </call>
4865N/A
4713N/A </sequence>
4713N/A </loop>
4618N/A
4618N/A <message>'--- Check log files ---'</message>
4618N/A <call function="'listFolder'">
4618N/A { 'location' : '%s' % (STAF_REMOTE_HOSTNAME),
5554N/A 'foldername' : '%s/tasks' % remote.temp,
4618N/A 'filename' : 'export_synchronous'
4618N/A }
4618N/A </call>
4618N/A <!-- check the export ldif file has been created-->
4618N/A <if expr="len(cmdResult) == 0">
4618N/A <call function="'testFailed'"/>
4618N/A <else>
4865N/A <call function="'testPassed'"/>
4618N/A </else>
4865N/A </if>
4618N/A
4618N/A <call function="'testCase_Postamble'"/>
4618N/A </sequence>
4865N/A </testcase>
4618N/A
4618N/A
4618N/A <!--- Test Case information
4618N/A #@TestMarker Export tasks
4618N/A #@TestName Schedule a Export task
4618N/A #@TestPurpose Schedule a Export in task mode
4618N/A #@TestPreamble
4618N/A #@TestStep Execute a export-ldif in a task
4618N/A #@TestStep Specify the -t option with the value non null to schedule an execution
4618N/A #@TestPostamble
4618N/A #@TestResult
4618N/A -->
4618N/A
4618N/A <testcase name="getTestCaseName('schedule export-ldif task for scheduled execution in asynchronous mode')">
4618N/A <sequence>
4865N/A <call function="'testCase_Preamble'"/>
5942N/A
5942N/A <script>
5942N/A startTask = '20061212000000'
5942N/A </script>
5942N/A
4865N/A <call function="'exportLdifWithScript'">
4618N/A { 'location' : STAF_REMOTE_HOSTNAME ,
4618N/A 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST,
4618N/A 'dsInstanceAdminPort' : DIRECTORY_INSTANCE_ADMIN_PORT,
4618N/A 'dsInstanceDn' : DIRECTORY_INSTANCE_DN,
4618N/A 'dsInstancePswd' : DIRECTORY_INSTANCE_PSWD,
5554N/A 'ldifFile' : '%s/tasks/export_schedule_asynchronous' % remote.temp,
5942N/A 'startTask' : startTask,
5942N/A 'expectedRC' : 1,
4618N/A 'backEnd' : DIRECTORY_INSTANCE_BE}
4618N/A </call>
4865N/A
5942N/A <script>
5942N/A returnString = STAXResult[0][1]
5942N/A </script>
5942N/A
4618N/A <call function="'searchString'">
5942N/A { 'expectedString' : 'The specified start time \'%s\' has already passed' % startTask ,
5942N/A 'returnString' : returnString,
4865N/A }
4865N/A </call>
4865N/A
4618N/A <call function="'testCase_Postamble'"/>
4618N/A </sequence>
4618N/A </testcase>
4618N/A
4618N/A <!--- Test Case information
4618N/A #@TestMarker Export tasks
4618N/A #@TestName Schedule a recurring Export task
4618N/A #@TestPurpose Schedule a recurring Export in task mode
4618N/A #@TestPreamble
4618N/A #@TestStep Create a recurring Export in task mode
4618N/A #@TestStep specify the recurringTask option with the value
4618N/A #@TestStep non null to schedule a recurring execution
4618N/A #@TestPostamble
4618N/A #@TestResult
4618N/A -->
4618N/A
4618N/A <testcase name="getTestCaseName('schedule recurring export task')">
4618N/A <sequence>
4618N/A <call function="'testCase_Preamble'"/>
4618N/A
4618N/A <!--- ReStart DS to clear the output of manage-tasks-->
4618N/A <call function="'StopDsWithScript'">
4618N/A { 'location' : STAF_REMOTE_HOSTNAME,
4618N/A 'dsHost' : DIRECTORY_INSTANCE_HOST,
4618N/A 'dsAdminPort' : DIRECTORY_INSTANCE_ADMIN_PORT,
4618N/A 'dsBindDN' : DIRECTORY_INSTANCE_DN,
4618N/A 'dsBindPwd' : DIRECTORY_INSTANCE_PSWD }
4618N/A </call>
4618N/A
4618N/A <call function="'StartDsWithScript'">
4618N/A { 'location' : STAF_REMOTE_HOSTNAME }
4618N/A </call>
4618N/A
4618N/A <!--- Check that DS started -->
4618N/A <call function="'isAlive'">
4618N/A { 'noOfLoops' : 10 ,
4618N/A 'noOfMilliSeconds' : 2000
4618N/A }
4618N/A </call>
4618N/A
4865N/A <call function="'exportLdifWithScript'">
4618N/A { 'location' : STAF_REMOTE_HOSTNAME ,
4618N/A 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST,
4618N/A 'dsInstanceAdminPort' : DIRECTORY_INSTANCE_ADMIN_PORT,
4618N/A 'dsInstanceDn' : DIRECTORY_INSTANCE_DN,
4618N/A 'dsInstancePswd' : DIRECTORY_INSTANCE_PSWD,
5554N/A 'ldifFile' : '%s/tasks/export_schedule_recurring' % remote.temp,
4618N/A 'schedulePattern' : '"0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58 * * * *"',
4618N/A 'backEnd' : DIRECTORY_INSTANCE_BE}
4618N/A </call>
6665N/A
6665N/A <script>checkRC=9999</script>
6665N/A <loop from="1" to="10" var="loop" while="checkRC != 0">
6665N/A <sequence>
6665N/A <message>'MANAGE-TASKS LOOP %s' % loop</message>
6665N/A
6665N/A <!-- manage-tasks -->
6665N/A <call function="'manage-tasks'">
6665N/A { 'location' : STAF_REMOTE_HOSTNAME ,
6665N/A 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST,
6665N/A 'dsInstanceDn' : DIRECTORY_INSTANCE_DN,
6665N/A 'dsInstancePswd' : DIRECTORY_INSTANCE_PSWD,
6665N/A 'dsQuiet' : ' '
6665N/A }
6665N/A </call>
4618N/A
6665N/A <script>
6665N/A returnString = STAXResult[0][1]
6665N/A </script>
6665N/A
6665N/A <call function="'searchString'">
6665N/A { 'expectedString' : 'ExportTask-',
6665N/A 'returnString' : returnString ,
6665N/A 'expectedRC' : 'noCheck' }
6665N/A </call>
6665N/A
6665N/A <script>
6665N/A checkRC = STAXResult[0]
6665N/A </script>
6665N/A
6665N/A <call function="'searchString'">
6665N/A { 'expectedString' : 'Waiting on start time',
6665N/A 'returnString' : returnString ,
6665N/A 'expectedRC' : 'noCheck' }
6665N/A </call>
6665N/A
6665N/A <script>
6665N/A checkRC = checkRC + STAXResult[0]
6665N/A </script>
6665N/A
6665N/A <call function="'Sleep'">
6665N/A { 'sleepForMilliSeconds' : 2000 }
6665N/A </call>
6665N/A
6665N/A </sequence>
6665N/A </loop>
6665N/A
4618N/A <call function="'Sleep'">
4680N/A { 'sleepForMilliSeconds' : 120000 }
4618N/A </call>
6665N/A
6665N/A <script>checkRC=9999</script>
6665N/A <loop from="1" to="10" var="loop" while="checkRC != 0">
6665N/A <sequence>
6665N/A <message>'MANAGE-TASKS LOOP %s' % loop</message>
6665N/A
6665N/A <!-- manage-tasks -->
6665N/A <call function="'manage-tasks'">
6665N/A { 'location' : STAF_REMOTE_HOSTNAME ,
6665N/A 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST,
6665N/A 'dsInstanceDn' : DIRECTORY_INSTANCE_DN,
6665N/A 'dsInstancePswd' : DIRECTORY_INSTANCE_PSWD,
6665N/A 'dsQuiet' : ' '
6665N/A }
6665N/A </call>
6665N/A
6665N/A <script>
6665N/A returnString = STAXResult[0][1]
6665N/A </script>
6665N/A
6665N/A <call function="'searchString'">
6665N/A { 'expectedString' : 'ExportTask-*',
6665N/A 'returnString' : returnString ,
6665N/A 'expectedRC' : 'noCheck' }
6665N/A </call>
6665N/A
6665N/A <script>
6665N/A checkRC = STAXResult[0]
6665N/A </script>
6665N/A
6665N/A <call function="'searchString'">
6665N/A { 'expectedString' : 'Completed successfully',
6665N/A 'returnString' : returnString ,
6665N/A 'expectedRC' : 'noCheck' }
6665N/A </call>
6665N/A
6665N/A <script>
6665N/A checkRC = checkRC + STAXResult[0]
6665N/A </script>
6665N/A
6665N/A <call function="'searchString'">
6665N/A { 'expectedString' : 'Waiting on start time',
6665N/A 'returnString' : returnString ,
6665N/A 'expectedRC' : 'noCheck' }
6665N/A </call>
6665N/A
6665N/A <script>
6665N/A checkRC = checkRC + STAXResult[0]
6665N/A </script>
6665N/A
6665N/A <call function="'Sleep'">
6665N/A { 'sleepForMilliSeconds' : 2000 }
6665N/A </call>
6665N/A
6665N/A </sequence>
6665N/A </loop>
6665N/A
4618N/A <!-- cancel the recurring task ExportTask-* with manage-tasks -->
4618N/A <call function="'manage-tasks'">
4618N/A { 'location' : STAF_REMOTE_HOSTNAME ,
4618N/A 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST,
4618N/A 'dsInstanceDn' : DIRECTORY_INSTANCE_DN,
4618N/A 'dsInstancePswd' : DIRECTORY_INSTANCE_PSWD,
4618N/A 'dsCancel' : 'ExportTask-*',
4618N/A 'dsQuiet' : ' '
4618N/A }
4618N/A </call>
4618N/A
4618N/A <script>
4618N/A returnString = STAXResult[0][1]
4618N/A </script>
4618N/A
6665N/A <call function="'searchString'">
6665N/A { 'expectedString' : 'Task ExportTask-\* canceled',
6665N/A 'returnString' : returnString }
4618N/A </call>
6665N/A
4618N/A <call function="'testCase_Postamble'"/>
4618N/A </sequence>
4618N/A </testcase>
4618N/A
4618N/A </sequence>
4618N/A <finally>
2938N/A <sequence>
4618N/A <!-- Test Suite Cleanup -->
4618N/A <message>'Finally: Tasks Cleanup.'</message>
4618N/A <try>
4618N/A <call function="'common_cleanup'" />
4865N/A <catch exception="'STAFException'">
4865N/A <sequence>
4865N/A <message log="1" level="'fatal'">'Cleanup of test suite failed.'</message>
4865N/A </sequence>
4865N/A </catch>
4865N/A <finally>
4865N/A <call function="'testSuite_Postamble'"/>
4865N/A </finally>
4618N/A </try>
2938N/A </sequence>
4618N/A </finally>
4618N/A
4618N/A </try>
4865N/A </block>
2938N/A </function>
2852N/A</stax>