<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE stax SYSTEM "/shared/stax.dtd">
<!--
! 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 legal-notices/CDDLv1_0.txt
! or http://forgerock.org/license/CDDLv1.0.html.
! 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 legal-notices/CDDLv1_0.txt.
! 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 2007-2009 Sun Microsystems, Inc.
! Portions Copyright 2011-2013 ForgeRock AS.
! -->
<stax>
<defaultcall function="restore_db"/>
<function name="restore_db" scope="local">
<block name="STAXCurrentFunction">
<try>
<sequence>
<script>
CurrentTestPath['suite']=STAXCurrentFunction
</script>
<call function="'testSuite_Preamble'" />
<!--- Test Suite information
#@TestSuiteName Restore tasks
#@TestSuitePurpose Validate the restore functionality in mode task
#@TestSuiteID restore Tests
#@TestSuiteGroup restore
#@TestGroup tasks
#@TestScript restore_db.xml
#@TestHTMLLink http://opends.dev.java.net/
-->
<call function="'common_setup'">
{
'quickStart' : True ,
'startServer' : True ,
'stopServer' : False
}
</call>
<!--- Test Case information
#@TestMarker Restore tasks
#@TestName Create backup for the restore testcases
#@TestPurpose Create backup
#@TestPreamble
#@TestStep Execute backup in synchronous mode
#@TestPostamble
#@TestResult
-->
<testcase name="getTestCaseName('Create backup for the restore testcases')">
<sequence>
<call function="'testCase_Preamble'"/>
<call function="'backup'">
{ 'location' : STAF_REMOTE_HOSTNAME ,
'dsInstanceHost' : DIRECTORY_INSTANCE_HOST,
'dsInstanceAdminPort' : DIRECTORY_INSTANCE_ADMIN_PORT,
'dsInstanceDn' : DIRECTORY_INSTANCE_DN,
'dsInstancePswd' : DIRECTORY_INSTANCE_PSWD,
'backupDir' : '%s/tasks/backup_synchronous' % remote.temp,
'backupID' : 'recurring-restore-1',
'backEnd' : DIRECTORY_INSTANCE_BE}
</call>
<call function="'testCase_Postamble'"/>
</sequence>
</testcase>
<!--- Test Case information
#@TestMarker Restore tasks
#@TestName Restore task in asynchronous mode
#@TestPurpose schedule a restore in task mode to be executed immedialy in asynchronous mode
#@TestPreamble
#@TestStep Execute a restore in a task
#@TestStep Specify the -t option with the value 0 to schedule for immediate execution
#@TestPostamble
#@TestResult
-->
<testcase name="getTestCaseName('schedule restore task for immediate execution in asynchronous mode')">
<sequence>
<call function="'testCase_Preamble'"/>
<call function="'restore'">
{ 'location' : STAF_REMOTE_HOSTNAME ,
'dsInstanceHost' : DIRECTORY_INSTANCE_HOST,
'dsInstanceAdminPort' : DIRECTORY_INSTANCE_ADMIN_PORT,
'dsInstanceDn' : DIRECTORY_INSTANCE_DN,
'dsInstancePswd' : DIRECTORY_INSTANCE_PSWD,
'backupDir' : '%s/tasks/backup_synchronous' % remote.temp,
'startTask' : '0'}
</call>
<call function="'testCase_Postamble'"/>
</sequence>
</testcase>
<!--- Test Case information
#@TestMarker Restore tasks
#@TestName Restore task in synchronous mode
#@TestPurpose Schedule a restore in task mode to be executed immedialy in synchronous mode
#@TestPreamble
#@TestStep Execute a restore in a task
#@TestStep Execute manage-tasks tools and check an Restore tasks is managed
#@TestStep Don't specify the -t option
#@TestStep The task is scheduled for immediate execution and the script must wait the end of the restore
#@TestPostamble
#@TestResult
-->
<testcase name="getTestCaseName('schedule restore task for immediate execution in synchronous mode')">
<sequence>
<call function="'testCase_Preamble'"/>
<call function="'restore'">
{ 'location' : STAF_REMOTE_HOSTNAME ,
'dsInstanceHost' : DIRECTORY_INSTANCE_HOST,
'dsInstanceAdminPort' : DIRECTORY_INSTANCE_ADMIN_PORT,
'dsInstanceDn' : DIRECTORY_INSTANCE_DN,
'dsInstancePswd' : DIRECTORY_INSTANCE_PSWD,
'backupDir' : '%s/tasks/backup_synchronous' % remote.temp}
</call>
<script>checkRC=9999</script>
<loop from="1" to="10" var="loop" while="checkRC != 0">
<sequence>
<message>'MANAGE-TASKS LOOP %s' % loop</message>
<!-- manage-tasks -->
<call function="'manage-tasks'">
{ 'location' : STAF_REMOTE_HOSTNAME ,
'dsInstanceHost' : DIRECTORY_INSTANCE_HOST,
'dsInstanceDn' : DIRECTORY_INSTANCE_DN,
'dsInstancePswd' : DIRECTORY_INSTANCE_PSWD,
'dsQuiet' : ' '
}
</call>
<script>
returnString = STAXResult[0][1]
currentDate=strftime("%Y%m%d",localtime())
</script>
<call function="'searchString'">
{ 'expectedString' : '%s.* Restore Completed successfully' \
% currentDate,
'returnString' : returnString ,
'expectedRC' : 'noCheck' }
</call>
<script>
checkRC = STAXResult[0]
</script>
<call function="'Sleep'">
{ 'sleepForMilliSeconds' : 2000 }
</call>
</sequence>
</loop>
<call function="'checktestRC'">
{ 'returncode' : checkRC ,
'result' : "Restore fails" ,
'expected' : 0
}
</call>
<call function="'testCase_Postamble'"/>
</sequence>
</testcase>
<!--- Test Case information
#@TestMarker Restore tasks
#@TestName Schedule a Restore task
#@TestPurpose Schedule a restore in task mode
#@TestPreamble
#@TestStep Execute a restore in a task
#@TestStep Specify the -t option with the value non null to schedule an execution
#@TestPostamble
-->
<testcase name="getTestCaseName('schedule restore task for scheduled execution in asynchronous mode')">
<sequence>
<call function="'testCase_Preamble'"/>
<script>
import java.util.Calendar
import java.text.SimpleDateFormat
cal = java.util.Calendar.getInstance()
cal.add(java.util.Calendar.SECOND,600)
dateFormat = java.text.SimpleDateFormat("yyyyMMddHHmmss")
mydate = dateFormat.format(cal.getTime())
</script>
<call function="'restore'">
{ 'location' : STAF_REMOTE_HOSTNAME ,
'dsInstanceHost' : DIRECTORY_INSTANCE_HOST,
'dsInstanceAdminPort' : DIRECTORY_INSTANCE_ADMIN_PORT,
'dsInstanceDn' : DIRECTORY_INSTANCE_DN,
'dsInstancePswd' : DIRECTORY_INSTANCE_PSWD,
'startTask' : '%s' % mydate,
'backupDir' : '%s/tasks/backup_synchronous' % remote.temp
}
</call>
<call function="'testCase_Postamble'"/>
</sequence>
</testcase>
<!--- Test Case information
#@TestMarker Restore tasks
#@TestName Schedule a recurring Restore task
#@TestPurpose Schedule a recurring Restore in task mode
#@TestPreamble
#@TestStep Create a recurring Restore in task mode
#@TestStep specify the recurringTask option with the value
#@TestStep non null to schedule a recurring execution
#@TestPostamble
#@TestResult
-->
<testcase name="getTestCaseName('schedule recurring restore task for scheduled execution in asynchronous mode')">
<sequence>
<call function="'testCase_Preamble'"/>
<!--- ReStart DS to clear the output of manage-tasks-->
<call function="'StopDsWithScript'">
{ 'location' : STAF_REMOTE_HOSTNAME,
'dsHost' : DIRECTORY_INSTANCE_HOST,
'dsAdminPort' : DIRECTORY_INSTANCE_ADMIN_PORT,
'dsBindDN' : DIRECTORY_INSTANCE_DN,
'dsBindPwd' : DIRECTORY_INSTANCE_PSWD }
</call>
<call function="'StartDsWithScript'">
{ 'location' : STAF_REMOTE_HOSTNAME }
</call>
<!--- Check that DS started -->
<call function="'isAlive'">
{ 'noOfLoops' : 10 ,
'noOfMilliSeconds' : 2000
}
</call>
<call function="'restore'">
{ 'location' : STAF_REMOTE_HOSTNAME ,
'dsInstanceHost' : DIRECTORY_INSTANCE_HOST,
'dsInstanceAdminPort' : DIRECTORY_INSTANCE_ADMIN_PORT,
'dsInstanceDn' : DIRECTORY_INSTANCE_DN,
'dsInstancePswd' : DIRECTORY_INSTANCE_PSWD,
'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 * * * *"',
'backupDir' : '%s/tasks/backup_synchronous' % remote.temp,
'backupID' : 'recurring-restore-1'}
</call>
<!-- manage-tasks -->
<call function="'manage-tasks'">
{ 'location' : STAF_REMOTE_HOSTNAME ,
'dsInstanceHost' : DIRECTORY_INSTANCE_HOST,
'dsInstanceDn' : DIRECTORY_INSTANCE_DN,
'dsInstancePswd' : DIRECTORY_INSTANCE_PSWD,
'dsQuiet' : ' '
}
</call>
<script>
returnString = STAXResult[0][1]
</script>
<call function="'searchString'">
{ 'expectedString' : 'recurring-restore-1',
'returnString' : returnString }
</call>
<call function="'Sleep'">
{ 'sleepForMilliSeconds' : 120000 }
</call>
<script>checkRC=9999</script>
<loop from="1" to="10" var="loop" while="checkRC != 0">
<sequence>
<message>'MANAGE-TASKS LOOP %s' % loop</message>
<!-- manage-tasks -->
<call function="'manage-tasks'">
{ 'location' : STAF_REMOTE_HOSTNAME ,
'dsInstanceHost' : DIRECTORY_INSTANCE_HOST,
'dsInstanceDn' : DIRECTORY_INSTANCE_DN,
'dsInstancePswd' : DIRECTORY_INSTANCE_PSWD,
'dsQuiet' : ' '
}
</call>
<script>
returnString = STAXResult[0][1]
</script>
<call function="'searchString'">
{ 'expectedString' : 'recurring-restore-1',
'returnString' : returnString ,
'expectedRC' : 'noCheck' }
</call>
<script>
checkRC = STAXResult[0]
</script>
<call function="'searchString'">
{ 'expectedString' : 'Completed successfully',
'returnString' : returnString ,
'expectedRC' : 'noCheck' }
</call>
<script>
checkRC = checkRC + STAXResult[0]
</script>
<call function="'searchString'">
{ 'expectedString' : 'Waiting on start time',
'returnString' : returnString ,
'expectedRC' : 'noCheck' }
</call>
<script>
checkRC = checkRC + STAXResult[0]
</script>
<call function="'Sleep'">
{ 'sleepForMilliSeconds' : 2000 }
</call>
</sequence>
</loop>
<!-- cancel the recurring task recurring-restore-1 with manage-tasks -->
<call function="'manage-tasks'">
{ 'location' : STAF_REMOTE_HOSTNAME ,
'dsInstanceHost' : DIRECTORY_INSTANCE_HOST,
'dsInstanceDn' : DIRECTORY_INSTANCE_DN,
'dsInstancePswd' : DIRECTORY_INSTANCE_PSWD,
'dsCancel' : 'recurring-restore-1',
'dsQuiet' : ' '
}
</call>
<script>
returnString = STAXResult[0][1]
</script>
<call function="'searchString'">
{ 'expectedString' : 'Task recurring-restore-1 canceled',
'returnString' : returnString }
</call>
<call function="'testCase_Postamble'"/>
</sequence>
</testcase>
<!--- Test Case information
#@TestMarker Restore tasks
#@TestName Restore task in asynchronous mode with date in the past
#@TestPurpose Schedule a restore in task mode to be executed in asynchronous mode
with date in the past
#@TestPreamble
#@TestStep Execute a restore in task with date in the past
#@TestStep Specify the -t option with date in the past
#@TestPostamble
#@TestResult
-->
<testcase name="getTestCaseName('schedule restart task for scheduled execution with date in the past')">
<sequence>
<call function="'testCase_Preamble'"/>
<call function="'restore'">
{ 'location' : STAF_REMOTE_HOSTNAME ,
'dsInstanceHost' : DIRECTORY_INSTANCE_HOST,
'dsInstanceAdminPort' : DIRECTORY_INSTANCE_ADMIN_PORT,
'dsInstanceDn' : DIRECTORY_INSTANCE_DN,
'dsInstancePswd' : DIRECTORY_INSTANCE_PSWD,
'backupDir' : '%s/tasks/backup_synchronous' % remote.temp,
'startTask' : '20061212000000',
'expectedRC' : 1 }
</call>
<script>
returnString = STAXResult[0][1]
</script>
<call function="'checktestString'">
{'returnString' : returnString ,
'expectedString' : 'The specified start time \'20061212000000\' has already passed'
}
</call>
<call function="'testCase_Postamble'"/>
</sequence>
</testcase>
</sequence>
<finally>
<sequence>
<!-- Test Suite Cleanup -->
<message>'Finally: Tasks Cleanup.'</message>
<try>
<call function="'common_cleanup'" />
<catch exception="'STAFException'">
<sequence>
<message log="1" level="'fatal'">'Cleanup of test suite failed.'</message>
</sequence>
</catch>
<finally>
<call function="'testSuite_Postamble'"/>
</finally>
</try>
</sequence>
</finally>
</try>
</block>
</function>
</stax>