2788N/A<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2788N/A<!DOCTYPE stax SYSTEM "/stax.dtd">
2788N/A<!--
2788N/A ! CDDL HEADER START
2788N/A !
2788N/A ! The contents of this file are subject to the terms of the
2788N/A ! Common Development and Distribution License, Version 1.0 only
2788N/A ! (the "License"). You may not use this file except in compliance
2788N/A ! with the License.
2788N/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.
2788N/A ! See the License for the specific language governing permissions
2788N/A ! and limitations under the License.
2788N/A !
2788N/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:
2788N/A ! Portions Copyright [yyyy] [name of copyright owner]
2788N/A !
2788N/A ! CDDL HEADER END
2788N/A !
5061N/A ! Copyright 2007-2010 Sun Microsystems, Inc.
6273N/A ! Portions Copyright 2011-2013 ForgeRock AS.
2788N/A ! -->
2788N/A<stax>
2788N/A
2788N/A <function name="importSharedLibraries">
2788N/A <function-prolog>
2788N/A This function imports the shared function xml libraries.
2788N/A </function-prolog>
2788N/A
2788N/A <sequence>
2788N/A
2788N/A <!--- Import all the shared xml libraries -->
2788N/A
5362N/A <script>
5362N/A sharedLibs=[]
5362N/A sharedLibs.append('baselib.xml')
5362N/A sharedLibs.append('ldap.xml')
5362N/A sharedLibs.append('utils.xml')
5362N/A sharedLibs.append('stafcmd.xml')
5362N/A sharedLibs.append('staxcmd.xml')
5362N/A sharedLibs.append('dsadm.xml')
5362N/A sharedLibs.append('dsconfig.xml')
5362N/A sharedLibs.append('security.xml')
5362N/A sharedLibs.append('topology.xml')
5362N/A sharedLibs.append('signals.xml')
5362N/A sharedLibs.append('tools.xml')
5362N/A sharedLibs.append('webcontainer.xml')
5362N/A sharedLibs.append('snmp.xml')
5688N/A sharedLibs.append('sdk.xml')
5362N/A </script>
5362N/A
5362N/A <iterate var="sharedLib" in="sharedLibs">
5362N/A <import machine="STAF_LOCAL_HOSTNAME"
5654N/A file="'%s/%s' % (TESTS_FUNCTIONS_DIR,sharedLib)"/>
5362N/A </iterate>
3361N/A
2788N/A </sequence>
2788N/A
2788N/A </function>
2788N/A
2788N/A <function name="importPythonLibraries">
2788N/A <function-prolog>
2788N/A This function imports the Python libraries and objects,
5654N/A both standard and local shared ones.
2788N/A </function-prolog>
2788N/A
2788N/A <sequence>
2788N/A
2788N/A <!-- Load in any standard python libraries -->
2788N/A <script>
2788N/A import re
2788N/A import os
2788N/A import sys
5654N/A from org.python.core import PyString,PyList,PyDictionary
2788N/A </script>
2788N/A
3862N/A <!-- Load in any additional Java classes -->
3862N/A <script>
3862N/A import java.io.FileNotFoundException
3862N/A </script>
3862N/A
2788N/A <!-- Load in any standard python functions -->
2788N/A <script>
2788N/A from time import localtime,strftime
2788N/A </script>
2788N/A
2788N/A <!-- Load in the local shared python objects from libraries -->
2788N/A <script>
2788N/A sys.path.append("%s/shared/python" % TESTS_ROOT )
2788N/A from common import *
2788N/A from security import *
2788N/A from replication import *
3666N/A from snmp import *
4865N/A from schema import *
5429N/A from objects import *
2788N/A </script>
2788N/A
2788N/A
2788N/A </sequence>
2788N/A </function>
2788N/A
2788N/A
2788N/A
2788N/A
2788N/A
2788N/A <function name="initialiseGlobalVariables">
2788N/A <function-prolog>
4458N/A This function initialises a set of global variables.
4458N/A </function-prolog>
2788N/A
2788N/A <sequence>
4495N/A <!-- Default LDAP Server Object -->
4495N/A <script>
4495N/A server=directory_server()
4495N/A server.location = STAF_REMOTE_HOSTNAME
4495N/A server.host = DIRECTORY_INSTANCE_HOST
4495N/A server.port = DIRECTORY_INSTANCE_PORT
4495N/A server.adminport = DIRECTORY_INSTANCE_ADMIN_PORT
4495N/A server.dn = DIRECTORY_INSTANCE_DN
4495N/A server.password = DIRECTORY_INSTANCE_PSWD
4495N/A server.suffix = DIRECTORY_INSTANCE_SFX
4495N/A server.backend = DIRECTORY_INSTANCE_BE
5616N/A
5616N/A TestSuiteStartTime = STAXGlobal([])
4495N/A </script>
4495N/A
2788N/A <!-- Set the signal handlers -->
2788N/A <call function="'signals'"/>
2788N/A
2788N/A <!-- Initialize any global variables -->
2788N/A <script>
5061N/A True = 1
5061N/A False = 0
5061N/A
5061N/A STAXLogMessage = 1
5061N/A if is_windows_platform(STAF_REMOTE_HOSTNAME):
5061N/A fileExt='.bat'
5061N/A scriptExt='.bat'
5061N/A fileFolder='bat'
5061N/A pathSeparator=';'
5061N/A newLine='\r\n'
5061N/A else:
5061N/A fileExt=''
5061N/A scriptExt='.sh'
5061N/A fileFolder='bin'
5061N/A pathSeparator=':'
5061N/A newLine='\n'
5061N/A
5061N/A if DIRECTORY_INSTANCE_BIN != DIRECTORY_INSTANCE_DIR:
5061N/A IPS_PKG = True
5061N/A else:
5061N/A IPS_PKG = False
5061N/A
2788N/A CurrentTestPath={}
2788N/A DSInfoServersDict={}
5061N/A
4616N/A # threshold set so that functions such as getFile may not cause staf
4616N/A # process to run out of memory (value in bytes)
4616N/A MAX_READABLE_SIZE = 104800
2788N/A
3816N/A # this function return a well-formatted testcase name
3816N/A def getTestCaseName(name):
3816N/A return '%s: %s: %s' % (CurrentTestPath['group'],CurrentTestPath['suite'],name)
3816N/A
2788N/A DSCONFIG = 'dsconfig'
2788N/A DSREPLICATION = 'dsreplication'
2788N/A
2788N/A AdminUID = 'admin'
2788N/A AdminPswd = 'admin'
2788N/A
2788N/A # Replication configuration default names
2788N/A MultimasterSync = 'Multimaster Synchronization'
4458N/A MultimasterType = 'multimaster'
4458N/A
4458N/A # Create staf objects
4458N/A LOCAL_STAF_ROOT = test_env.staf(STAF_LOCAL_HOSTNAME).root
4458N/A REMOTE_STAF_ROOT = test_env.staf(STAF_REMOTE_HOSTNAME).root
2788N/A </script>
4458N/A
5061N/A </sequence>
2788N/A </function>
2788N/A
2788N/A <function name="GetDirectoryServerInformation">
2788N/A <function-prolog>
2788N/A This function gets information about the Directory Server
2788N/A </function-prolog>
2788N/A
2788N/A <try>
2788N/A
2788N/A <sequence>
2788N/A
2788N/A <script>
2788N/A InstanceInstallDir= '%s/%s' % (DIRECTORY_INSTANCE_DIR,OPENDSNAME)
2788N/A </script>
2788N/A
2788N/A <!-- Copy DS zip archive to remote host-->
2788N/A <message>
2788N/A 'Copy DS zip archive to %s %s.zip.' % (STAF_REMOTE_HOSTNAME,InstanceInstallDir)
2788N/A </message>
2788N/A <call function="'copyFile'">
2788N/A { 'srcfile' : '%s/%s' % (ZIPPATH,ZIPNAME),
2788N/A 'destfile' : '%s.zip' % InstanceInstallDir,
2788N/A 'remotehost' : STAF_REMOTE_HOSTNAME }
2788N/A </call>
2788N/A
2788N/A <if expr="RC != 0">
2788N/A <return>RC</return>
2788N/A </if>
2788N/A
2788N/A <!-- Install DS into temporary folder -->
2788N/A <message>
2788N/A 'Extract temporary DS zip archive to %s %s.' % (STAF_REMOTE_HOSTNAME,DIRECTORY_INSTANCE_DIR)
2788N/A </message>
2788N/A <call function="'unZipFile'">
2788N/A { 'location' : STAF_REMOTE_HOSTNAME,
2788N/A 'zipfile' : '%s.zip' % InstanceInstallDir,
2788N/A 'unzipdir' : '%s' % DIRECTORY_INSTANCE_DIR }
2788N/A </call>
2788N/A
2788N/A <if expr="RC != 0">
2788N/A <return>RC</return>
2788N/A </if>
2788N/A
2788N/A <!-- Get Directory Server Variables -->
2788N/A <call function="'GetDirectoryServerVars'">
2788N/A { 'location' : STAF_REMOTE_HOSTNAME,
4153N/A 'dsPath' : '%s/%s' % (DIRECTORY_INSTANCE_BIN,OPENDSNAME) }
2788N/A </call>
2788N/A
2788N/A <if expr="RC != 0">
2788N/A <throw exception="'TestExceptionResultFailed'">
2788N/A 'Invalid Result %s' % RC
2788N/A </throw>
2788N/A </if>
2788N/A
2788N/A <!-- Set Directory Server Variables -->
2788N/A <call function="'SetVar'">
2788N/A { 'location' : STAF_REMOTE_HOSTNAME,
2788N/A 'type' : 'shared',
2788N/A 'variable' : 'Job%s_ServerInfo=%s' % (STAXJobID,DSInfoServersDict) }
2788N/A </call>
2788N/A
2788N/A <if expr="RC != 0">
2788N/A <throw exception="'TestExceptionResultFailed'">
2788N/A 'Invalid Result %s' % RC
2788N/A </throw>
2788N/A </if>
2788N/A
2788N/A <!-- Uninstall DS from temporary folder -->
2788N/A <message>
2788N/A 'Remove temporary DS zip archive from %s %s' % (STAF_REMOTE_HOSTNAME,InstanceInstallDir)
2788N/A </message>
2788N/A
2788N/A <call function="'deleteFolder'">
2788N/A { 'location' : STAF_REMOTE_HOSTNAME ,
2788N/A 'foldername' : '%s' % InstanceInstallDir }
2788N/A </call>
2788N/A
2788N/A <call function="'deleteFile'">
2788N/A { 'location' : STAF_REMOTE_HOSTNAME ,
2788N/A 'filename' : '%s.zip' % InstanceInstallDir }
2788N/A </call>
2788N/A
2788N/A </sequence>
2788N/A
2788N/A <catch exception="'TestExceptionResultFailed'" typevar="eType" var="eInfo">
2788N/A <sequence>
2788N/A <message>'caught %s with %s' % (eType,eInfo)</message>
2788N/A <message>
2788N/A 'Remove temporary DS zip archive from %s %s' % (STAF_REMOTE_HOSTNAME,InstanceInstallDir)
2788N/A </message>
2788N/A <call function="'deleteFolder'">
2788N/A { 'location' : STAF_REMOTE_HOSTNAME ,
2788N/A 'foldername' : '%s' % InstanceInstallDir }
2788N/A </call>
2788N/A
2788N/A <call function="'deleteFile'">
2788N/A { 'location' : STAF_REMOTE_HOSTNAME ,
2788N/A 'filename' : '%s.zip' % InstanceInstallDir }
2788N/A </call>
2788N/A
2788N/A </sequence>
2788N/A </catch>
2788N/A
2788N/A </try>
2788N/A
2788N/A </function>
2788N/A
3816N/A <function name="SetFolders">
2788N/A <function-prolog>
3816N/A This function sets the folders to which test data are written.
2788N/A </function-prolog>
3816N/A <function-map-args>
3816N/A <function-arg-def name="sourceDir" type="required">
3816N/A <function-arg-description>
3816N/A A locally accessable directory to the tests source
3816N/A </function-arg-description>
3816N/A <function-arg-property name="type" value="structure"/>
3816N/A </function-arg-def>
3816N/A <function-arg-def name="localDir" type="required">
3816N/A <function-arg-description>
3816N/A A locally accessable directory to write test information
3816N/A </function-arg-description>
3816N/A <function-arg-property name="type" value="structure"/>
3816N/A </function-arg-def>
3816N/A <function-arg-def name="remoteDir" type="required">
3816N/A <function-arg-description>
3816N/A A remotely accessable directory to write test information
3816N/A </function-arg-description>
3816N/A <function-arg-property name="type" value="structure"/>
3816N/A </function-arg-def>
3816N/A </function-map-args>
2788N/A
2788N/A <sequence>
2788N/A
2788N/A <script>
3816N/A logs = test_env.logs(localDir)
4259N/A source = test_env.source(sourceDir,TESTS_TYPE)
3816N/A local = test_env.data(localDir)
5540N/A remote = test_env.data(remoteDir)
5540N/A
5540N/A if host_is_localhost(STAF_REMOTE_HOSTNAME):
5540N/A local.set_data(source.data)
5540N/A remote.set_data(source.data)
2788N/A </script>
2788N/A
3816N/A <message>'source.directory = %s' % source.directory</message>
3816N/A <message>'local.directory = %s' % local.directory</message>
3816N/A <message>'remote.directory = %s' % remote.directory</message>
3816N/A <message>'logs.directory = %s' % logs.directory</message>
5540N/A <message>'source.data = %s' % source.data</message>
5540N/A <message>'local.data = %s' % local.data</message>
5540N/A <message>'remote.data = %s' % remote.data</message>
5976N/A <message>'local.temp = %s' % local.temp</message>
5976N/A <message>'remote.temp = %s' % remote.temp</message>
5540N/A
3816N/A <return>
3816N/A local.directory
3816N/A </return>
3816N/A
3816N/A </sequence>
3816N/A
3816N/A </function>
3816N/A
3816N/A <function name="CreateFolders" scope="local">
3816N/A <function-prolog>
3816N/A This function sets the folders to which logs are written
3816N/A </function-prolog>
3816N/A
3816N/A <sequence>
3816N/A
3816N/A <!-- Create folders -->
3816N/A <message>'Create local folder %s' % logs.reports</message>
3816N/A <call function="'createFolder'">
3816N/A { 'location' : STAF_LOCAL_HOSTNAME,
3816N/A 'foldername' : '%s' % logs.reports }
3816N/A </call>
3816N/A
3816N/A <message>'Create local folder %s' % local.temp</message>
3816N/A <call function="'createFolder'">
3816N/A { 'location' : STAF_LOCAL_HOSTNAME,
3816N/A 'foldername' : '%s' % local.temp }
3816N/A </call>
3816N/A
3816N/A <message>'Create local folder %s' % logs.sut</message>
3816N/A <call function="'createFolder'">
3816N/A { 'location' : STAF_LOCAL_HOSTNAME,
3816N/A 'foldername' : '%s' % logs.sut }
3816N/A </call>
3816N/A
3816N/A <message>'Create local folder %s' % logs.tests</message>
3816N/A <call function="'createFolder'">
3816N/A { 'location' : STAF_LOCAL_HOSTNAME,
3816N/A 'foldername' : '%s' % logs.tests }
3816N/A </call>
2788N/A
3816N/A <message>'Create local folder %s' % local.testdata</message>
3816N/A <call function="'createFolder'">
3816N/A { 'location' : STAF_LOCAL_HOSTNAME,
3816N/A 'foldername' : '%s' % local.testdata }
2788N/A </call>
2788N/A
3816N/A <message>'Create remote folder %s' % remote.temp</message>
2788N/A <call function="'createFolder'">
3816N/A { 'location' : STAF_REMOTE_HOSTNAME,
3816N/A 'foldername' : '%s' % remote.temp }
2788N/A </call>
2788N/A
2788N/A </sequence>
2788N/A
2788N/A </function>
2788N/A
3816N/A <function name="loadGlobalEnvironment">
2788N/A <function-prolog>
2788N/A This function loads the environment (libraries, functions, variables)
3816N/A needed by the global test job farmer.
4458N/A </function-prolog>
2788N/A
2788N/A <sequence>
2788N/A
3816N/A <message>
3816N/A 'Load environment for test suite execution.'
3816N/A </message>
3816N/A
3816N/A <call function="'importSharedLibraries'"/>
3816N/A
3816N/A <call function="'importPythonLibraries'"/>
3816N/A
3816N/A <call function="'initialiseGlobalVariables'"/>
3949N/A
3949N/A <message>
3949N/A 'Remove files from previous runs under %s.' % DIRECTORY_INSTANCE_DIR
3949N/A </message>
3949N/A <call function="'deleteFolder'">
3949N/A { 'location' : STAF_REMOTE_HOSTNAME ,
4153N/A 'foldername' : '%s/%s' % (DIRECTORY_INSTANCE_DIR,OPENDSNAME) }
3949N/A </call>
3949N/A <call function="'createFolder'">
3949N/A { 'location' : STAF_REMOTE_HOSTNAME ,
4153N/A 'foldername' : '%s/%s' % (DIRECTORY_INSTANCE_DIR,OPENDSNAME) }
3949N/A </call>
3949N/A
2788N/A <call function="'GetDirectoryServerInformation'"/>
2788N/A
3816N/A <!-- Set variables to build unique path to store data -->
3816N/A <script>
3816N/A # Private
3816N/A logsArch=\
3816N/A DSInfo.getServerArch(DSInfo.ServerDict['system os'])
3816N/A logsOSName=\
3816N/A DSInfo.getServerOSName(DSInfo.ServerDict['system os'])
3816N/A logsOS='%s-%s' % (logsOSName,logsArch)
3816N/A logsJvm=\
3816N/A DSInfo.getServerJavaMajorMinor(DSInfo.ServerDict['java version'])
3816N/A </script>
3816N/A
3816N/A <call function="'SetFolders'">
3816N/A { 'sourceDir' : '%s' % TESTS_ROOT,
5061N/A 'localDir' : '%s' % LOGS_ROOT,
3816N/A 'remoteDir' : DIRECTORY_INSTANCE_DIR }
2788N/A </call>
3816N/A
3816N/A <call function="'SetVar'">
3816N/A { 'location' : STAF_REMOTE_HOSTNAME,
3816N/A 'type' : 'shared',
3816N/A 'variable' : 'Job%s_LogsDir=%s' % (STAXJobID,local.directory) }
3816N/A </call>
3816N/A
3816N/A <!-- Create the local folders to store data -->
3816N/A <call function="'CreateFolders'"/>
4458N/A
4458N/A <!-- Create folders -->
4458N/A <message>'Copy OpenDS css and png files under %s' % logs.reports</message>
4458N/A <call function="'copyFile'">
4458N/A {
4458N/A 'srcfile' : '%s/opends.css' % TESTS_RESOURCE_DIR,
4458N/A 'destfile' : '%s/opends.css' % logs.reports
4458N/A }
4458N/A </call>
4458N/A <call function="'copyFile'">
4458N/A {
5334N/A 'srcfile' : '%s/opendj_logo.png' % TESTS_RESOURCE_DIR,
5334N/A 'destfile' : '%s/opendj_logo.png' % logs.reports
4458N/A }
4458N/A </call>
5061N/A
5061N/A <message>'Copy xsl files under %s' % logs.reports</message>
5061N/A <call function="'copyFile'">
5061N/A {
5061N/A 'srcfile' : '%s/gen-groups-report.xsl' % TESTS_XSL_DIR,
5061N/A 'destfile' : '%s/gen-groups-report.xsl' % logs.reports
5061N/A }
5061N/A </call>
3816N/A </sequence>
2788N/A
2788N/A </function>
2788N/A
3816N/A <function name="loadJobEnvironment">
3816N/A <function-prolog>
3816N/A This function loads the environment (libraries, functions, variables)
3816N/A needed by the test jobs.
3816N/A </function-prolog>
3816N/A <function-map-args>
3816N/A <function-arg-def name="parent" type="optional" default="''">
3816N/A <function-arg-description>
3816N/A Location of target host
3816N/A </function-arg-description>
3816N/A <function-arg-property name="type" value="integer"/>
3816N/A </function-arg-def>
3816N/A </function-map-args>
3816N/A
3816N/A <sequence>
2788N/A
3816N/A <message>
3816N/A 'Load environment for test suite execution.'
3816N/A </message>
4116N/A
4116N/A <!-- All exceptions are logged to user log -->
4116N/A <script>
4116N/A STAXLogMessage = 1
4116N/A </script>
5654N/A
3816N/A <call function="'importSharedLibraries'"/>
5654N/A
3816N/A <call function="'importPythonLibraries'"/>
3816N/A
3816N/A <call function="'initialiseGlobalVariables'"/>
3816N/A
3816N/A <call function="'GetVar'">
3816N/A { 'location' : STAF_REMOTE_HOSTNAME,
3816N/A 'type' : 'shared',
3816N/A 'variable' : 'Job%s_LogsDir' % parent }
3816N/A </call>
3816N/A
3816N/A <!-- TODO: defend against mangled STAFResult -->
3816N/A <script>
3816N/A parentsLogDir=STAFResult
3816N/A </script>
3816N/A
3816N/A <message>'%s' % parentsLogDir</message>
3816N/A
3816N/A <call function="'SetFolders'">
3816N/A { 'sourceDir' : '%s' % TESTS_ROOT,
3816N/A 'localDir' : '%s' % parentsLogDir,
3816N/A 'remoteDir' : DIRECTORY_INSTANCE_DIR }
3816N/A </call>
3816N/A
3816N/A </sequence>
3816N/A
3816N/A </function>
2788N/A
2788N/A
2788N/A</stax>