3612N/A<?xml version="1.0" encoding="UTF-8" standalone="no"?>
3612N/A<!DOCTYPE stax SYSTEM "/shared/stax.dtd">
3612N/A<!--
3612N/A ! CDDL HEADER START
3612N/A !
3612N/A ! The contents of this file are subject to the terms of the
3612N/A ! Common Development and Distribution License, Version 1.0 only
3612N/A ! (the "License"). You may not use this file except in compliance
3612N/A ! with the License.
3612N/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.
3612N/A ! See the License for the specific language governing permissions
3612N/A ! and limitations under the License.
3612N/A !
6982N/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:
3612N/A ! Portions Copyright [yyyy] [name of copyright owner]
3612N/A !
3612N/A ! CDDL HEADER END
3612N/A !
5116N/A ! Copyright 2008-2010 Sun Microsystems, Inc.
6184N/A ! Portions Copyright 2011-2013 ForgeRock AS
3612N/A ! -->
3612N/A<stax>
3612N/A
3612N/A <defaultcall function="import"/>
3612N/A
3612N/A <function name="import">
3612N/A
3612N/A <sequence>
3612N/A
3612N/A <!--- Test Suite information
3612N/A #@TestSuiteName Setup-Uninstall import Tests
3612N/A #@TestSuitePurpose Test all options of the setup command relative
3612N/A to initial data generation and data import
3612N/A (ie: all options that feed DS with data at setup
3612N/A time)
3612N/A #@TestSuiteGroup import
3612N/A #@TestSuiteID import Tests
3612N/A #@TestGroup Setup-Uninstall
3612N/A #@TestScript import.xml
3612N/A #@TestHTMLLink http://opends.dev.java.net/
3612N/A -->
3612N/A
3612N/A <script>
3612N/A if not CurrentTestPath.has_key('group'):
3612N/A CurrentTestPath['group'] = 'setup'
3612N/A CurrentTestPath['suite'] = 'import'
3612N/A </script>
3612N/A
3612N/A <call function="'testSuite_Preamble'"/>
3612N/A
3612N/A <call function="'getFreePort'">
3612N/A {
3612N/A 'host' : STAF_REMOTE_HOSTNAME,
3612N/A 'port' : 5500,
3612N/A }
3612N/A </call>
3612N/A <script>IMP_I1_PORT = STAXResult</script>
3612N/A
3612N/A <call function="'getFreePort'">
3612N/A {
3612N/A 'host' : STAF_REMOTE_HOSTNAME,
3853N/A 'port' : 5544,
3853N/A }
3853N/A </call>
4865N/A <script>IMP_I1_ADMIN_PORT = STAXResult</script>
4865N/A
3853N/A <call function="'getFreePort'">
3853N/A {
3853N/A 'host' : STAF_REMOTE_HOSTNAME,
3612N/A 'port' : 5600,
3612N/A }
3612N/A </call>
3612N/A <script>IMP_I2_PORT = STAXResult</script>
3612N/A
3853N/A <call function="'getFreePort'">
3853N/A {
3853N/A 'host' : STAF_REMOTE_HOSTNAME,
3853N/A 'port' : 5644,
3853N/A }
3853N/A </call>
3853N/A <script>IMP_I2_ADMIN_PORT = STAXResult</script>
3853N/A
3612N/A <message>
3853N/A 'Got these free ports: %s, %s, %sand %s' % (IMP_I1_PORT, \
3853N/A IMP_I1_ADMIN_PORT, IMP_I2_PORT, IMP_I2_ADMIN_PORT)
3612N/A </message>
3612N/A
3612N/A <!--- Test Case information
3612N/A #@TestMarker Setup-Uninstall Import options
3612N/A #@TestName Setup-Uninstall: import:
3612N/A setup_uninstall_import_sample
3612N/A #@TestID setup_uninstall_import_sample
3612N/A #@TestPurpose Test the ability of the setup command to
3612N/A generate and import LDAP entries
3612N/A #@TestPreamble
3612N/A #@TestStep Unzip OpenDS distribution
3612N/A Setup OpenDS with 2 suffixes and generate 5
3612N/A entries per suffix
3612N/A Check entries are here
3612N/A Uninstall OpenDS
3612N/A #@TestPostamble
3612N/A #@TestResult PASS if all steps ran without errors
3612N/A -->
3612N/A <testcase name="getTestCaseName('setup_uninstall_import_sample')">
3612N/A <sequence>
3612N/A
3612N/A <script>
3612N/A IMP_I1_BASE = '%s/imp_i1' % (OUT_GROUP)
3612N/A IMP_I1_ROOT = '%s/%s' % (IMP_I1_BASE, OPENDSNAME)
3612N/A </script>
3612N/A
3612N/A
3612N/A <call function="'testCase_Preamble'"/>
3612N/A <message>'Setup Uninstall: Sample data options'</message>
3612N/A
3612N/A <!-- 1. Setup options: baseDN baseDN sampleData -->
3612N/A <message>'Prepare Open DS ZIP (in %s)' % IMP_I1_ROOT</message>
3612N/A
3612N/A <call function="'runSTAFCommand'">
3612N/A { 'name' : 'Create directory to contain I1',
3612N/A 'location' : STAF_REMOTE_HOSTNAME,
3612N/A 'service' : 'FS',
3612N/A 'request' : 'CREATE',
3612N/A 'arguments' : 'DIRECTORY %s FAILIFEXISTS' % IMP_I1_BASE
3612N/A }
3612N/A </call>
3612N/A
3612N/A <call function="'checktestRC'">
3612N/A { 'returncode' : RC,
3612N/A 'expected' : 0,
3612N/A 'result' : 'FAIL to create directory',
3612N/A }
3612N/A </call>
3612N/A
3612N/A <call function="'runSTAFCommand'">
5369N/A { 'name' : 'Extract OpenDJ ZIP file',
3612N/A 'location' : STAF_REMOTE_HOSTNAME,
3612N/A 'service' : 'ZIP',
3612N/A 'request' : 'UNZIP',
3612N/A 'arguments' : 'ZIPFILE %s/%s TODIRECTORY %s RESTOREPERMISSION' \
3690N/A % (DIRECTORY_INSTANCE_DIR, ZIPNAME, IMP_I1_BASE)
3612N/A }
3612N/A </call>
3612N/A
3612N/A <call function="'checktestRC'">
3612N/A { 'returncode' : RC,
3612N/A 'expected' : 0,
5369N/A 'result' : 'FAIL to unzip OpenDJ ZIP file',
3612N/A }
3612N/A </call>
3612N/A
3612N/A <script>
3612N/A c = '%s/setup%s' % (IMP_I1_ROOT, fileExt)
3612N/A p = []
3612N/A p.append('--cli --no-prompt --ldapPort %s' % (IMP_I1_PORT))
3853N/A p.append('--adminConnectorPort %s' % IMP_I1_ADMIN_PORT)
3612N/A p.append('--rootUserPassword "kangourou"')
3612N/A p.append('--baseDN "o=o1"')
3612N/A p.append('--baseDN "o=o2"')
6401N/A p.append('--sampleData 5 %s' % licenseOption)
3612N/A p = ' '.join(p)
3612N/A </script>
3612N/A
3612N/A <message>'%s %s' % (c, p)</message>
3612N/A <call function="'runCommand'">
3612N/A { 'location' : STAF_REMOTE_HOSTNAME,
3612N/A 'name' : 'Launch setup command for I1',
3612N/A 'command' : c,
3612N/A 'arguments' : p,
3612N/A 'path' : IMP_I1_ROOT,
3612N/A 'expectedRC': 0,
3612N/A 'outputFile': '%s/imp-setup-i1.txt' % OUT_GROUP,
3612N/A }
3612N/A </call>
3612N/A
3612N/A <!-- Check StartTLS is refused -->
3612N/A <call function="'ldapSearchWithScript'">
3612N/A { 'dsInstancePort' : IMP_I1_PORT,
3612N/A 'dsInstanceDn' : "cn=Directory Manager",
3612N/A 'dsInstancePswd' : "kangourou",
3612N/A 'dsBaseDN' : "o=o2",
3612N/A 'dsFilter' : 'dn=*',
3612N/A 'expectedRC' : 52,
3612N/A 'dsUseStartTLS' : 'True',
3612N/A }
3612N/A </call>
3612N/A
3612N/A <!-- Check Data have been generated under o=o1 -->
3612N/A <message>'Check Data have been generated under o=o1'</message>
3612N/A <call function="'ldapSearchWithScript'">
3612N/A { 'dsInstancePort' : IMP_I1_PORT,
3612N/A 'dsInstanceDn' : "cn=Directory Manager",
3612N/A 'dsInstancePswd' : "kangourou",
3612N/A 'dsBaseDN' : "o=o1",
3612N/A 'dsFilter' : 'objectclass=*',
3612N/A 'dsAttributes' : 'dn',
3612N/A 'expectedRC' : 0,
3612N/A }
3612N/A </call>
3612N/A
3612N/A <call function="'CheckMatches'">
3612N/A {
3612N/A 'string2find' : 'dn',
3612N/A 'mainString' : STAXResult[0][1],
3612N/A 'nbExpected' : 7,
3612N/A 'caseSensitive' : 'True'
3612N/A }
3612N/A </call>
3612N/A
3612N/A <!-- Check Data have been generated under o=o2 -->
3612N/A <message>'Check Data have been generated under o=o2'</message>
3612N/A <call function="'ldapSearchWithScript'">
3612N/A { 'dsInstancePort' : IMP_I1_PORT,
3612N/A 'dsInstanceDn' : "cn=Directory Manager",
3612N/A 'dsInstancePswd' : "kangourou",
3612N/A 'dsBaseDN' : "o=o2",
3612N/A 'dsFilter' : 'objectclass=*',
3612N/A 'dsAttributes' : 'dn',
6184N/A 'expectedRC' : 0
3612N/A }
3612N/A </call>
3612N/A
3612N/A <call function="'CheckMatches'">
3612N/A {
3612N/A 'string2find' : 'dn',
3612N/A 'mainString' : STAXResult[0][1],
3612N/A 'nbExpected' : 7,
3612N/A 'caseSensitive' : 'True'
3612N/A }
3612N/A </call>
3612N/A
3612N/A <!-- 2. Uninstall options: quiet forceOnError remove-all-->
3612N/A <message>'Uninstall options: quiet forceOnError remove-all'</message>
3612N/A <script>
3612N/A c = '%s/uninstall%s' % (IMP_I1_ROOT, fileExt)
3612N/A p = []
3612N/A p.append('--cli --no-prompt')
3612N/A p.append('--quiet --forceOnError --remove-all')
3612N/A p.append('--referencedHostName %s' % STAF_REMOTE_HOSTNAME)
3612N/A p = ' '.join(p)
3612N/A </script>
3612N/A
3612N/A <message>'%s %s' % (c, p)</message>
3612N/A <call function="'runCommand'">
3612N/A { 'location' : STAF_REMOTE_HOSTNAME,
3612N/A 'name' : 'Uninstall I1',
3612N/A 'command' : c,
3612N/A 'arguments' : p,
3612N/A 'path' : IMP_I1_ROOT,
3612N/A 'expectedRC': 0,
3612N/A 'outputFile': '%s/imp-uninstall-i1.txt' % OUT_GROUP,
3612N/A }
3612N/A </call>
3612N/A
3612N/A <call function="'testCase_Postamble'"/>
3612N/A
3612N/A
3612N/A </sequence>
3612N/A </testcase>
3612N/A
3612N/A <!--- Test Case information
3612N/A #@TestMarker Setup-Uninstall Import options
3612N/A #@TestName Setup-Uninstall: import:
3612N/A import_reject_skip
3612N/A #@TestID import_reject_skip
3612N/A #@TestPurpose Test the ability of the setup command to
3612N/A import LDAP entries and manage rejected and
3612N/A skipped entries
3612N/A #@TestPreamble
5369N/A #@TestStep Unzip OpenDJ distribution
5369N/A Setup OpenDJ with a LDIF file to import, and
3612N/A files for rejected and skipped entries
3822N/A Check skipped and rejected entries
5369N/A Stop OpenDJ
5369N/A Uninstall OpenDJ
3612N/A #@TestPostamble
3612N/A #@TestResult PASS if all steps ran without errors
3612N/A -->
3612N/A <testcase name="getTestCaseName('import_reject_skip')">
3612N/A <sequence>
3612N/A
3612N/A <script>
3612N/A IMP_I2_BASE = '%s/imp_i2' % (OUT_GROUP)
3612N/A IMP_I2_ROOT = '%s/%s' % (IMP_I2_BASE, OPENDSNAME)
3612N/A
3816N/A IMP_LDIF_FILE = '%s/setup/imp-o1.ldif' % remote.data
3612N/A IMP_SKIP_FILE = '%s/imp-skip.ldif' % (OUT_GROUP)
3612N/A IMP_REJECT_FILE = '%s/imp-reject.ldif' % (OUT_GROUP)
3612N/A </script>
3612N/A
3612N/A <call function="'testCase_Preamble'"/>
3612N/A <message>'Setup and Import: Reject / Skip entries'</message>
3612N/A
3612N/A
3612N/A <!-- 1. Setup options: baseDN "o=o1" ldifFile rejectFile
3612N/A skipFile verbose -->
3612N/A <message>'Prepare Open DS ZIP (in %s)' % IMP_I2_ROOT</message>
3612N/A
3612N/A <call function="'runSTAFCommand'">
3612N/A { 'name' : 'Create directory to contain I2',
3612N/A 'location' : STAF_REMOTE_HOSTNAME,
3612N/A 'service' : 'FS',
3612N/A 'request' : 'CREATE',
3612N/A 'arguments' : 'DIRECTORY %s FAILIFEXISTS' % IMP_I2_BASE
3612N/A }
3612N/A </call>
3612N/A
3612N/A <call function="'checktestRC'">
3612N/A { 'returncode' : RC,
3612N/A 'expected' : 0,
3612N/A 'result' : 'FAIL to create directory',
3612N/A }
3612N/A </call>
3612N/A
3612N/A <call function="'runSTAFCommand'">
3612N/A { 'name' : 'Extract OpenDS ZIP file',
3612N/A 'location' : STAF_REMOTE_HOSTNAME,
3612N/A 'service' : 'ZIP',
3612N/A 'request' : 'UNZIP',
3612N/A 'arguments' : 'ZIPFILE %s/%s TODIRECTORY %s RESTOREPERMISSION' \
3690N/A % (DIRECTORY_INSTANCE_DIR, ZIPNAME, IMP_I2_BASE)
3612N/A }
3612N/A </call>
3612N/A
3612N/A <call function="'checktestRC'">
3612N/A { 'returncode' : RC,
3612N/A 'expected' : 0,
3612N/A 'result' : 'FAIL to unzip OpenDS ZIP file',
3612N/A }
3612N/A </call>
3612N/A
3612N/A <script>
3612N/A c = '%s/setup%s' % (IMP_I2_ROOT, fileExt)
3612N/A p = []
3612N/A p.append('--cli --no-prompt --rootUserDN "cn=DM"')
3612N/A p.append('--rootUserPassword "kangourou"')
3612N/A p.append('--ldapPort %s' % IMP_I2_PORT)
3853N/A p.append('--adminConnectorPort %s' % IMP_I2_ADMIN_PORT)
3612N/A p.append('--baseDN "o=o1"')
3612N/A p.append('--ldifFile %s' % IMP_LDIF_FILE)
3612N/A p.append('--rejectFile %s' % IMP_REJECT_FILE)
3612N/A p.append('--skipFile %s' % IMP_SKIP_FILE)
6401N/A p.append('--verbose %s' % licenseOption)
3612N/A p = ' '.join(p)
3612N/A </script>
3612N/A
3612N/A <message>'%s %s' % (c, p)</message>
3612N/A <call function="'runCommand'">
3612N/A { 'location' : STAF_REMOTE_HOSTNAME,
3612N/A 'name' : 'Launch setup command for I2',
3612N/A 'command' : c,
3612N/A 'arguments' : p,
3612N/A 'path' : IMP_I2_ROOT,
3612N/A 'expectedRC': 0,
3612N/A 'outputFile': '%s/imp-setup-i2.txt' % OUT_GROUP,
3612N/A }
3612N/A </call>
3612N/A
3612N/A <call function="'runSTAFCommand'">
3612N/A { 'name' : 'Get content of reject file',
3612N/A 'location' : STAF_REMOTE_HOSTNAME,
3612N/A 'service' : 'FS',
3612N/A 'request' : 'GET',
3612N/A 'arguments' : 'FILE %s TEXT' % IMP_REJECT_FILE
3612N/A }
3612N/A </call>
3612N/A
3612N/A <call function="'checktestRC'">
3612N/A { 'returncode' : RC,
3612N/A 'expected' : 0,
3612N/A 'result' : 'FAIL to get content of reject file ',
3612N/A }
3612N/A </call>
3612N/A
3612N/A <call function="'CheckMatches'">
3612N/A {
3612N/A 'string2find' : 'violates',
3612N/A 'mainString' : STAFResult,
3612N/A 'nbExpected' : 4,
3612N/A 'caseSensitive' : 'True'
3612N/A }
3612N/A </call>
3612N/A
3612N/A <call function="'runSTAFCommand'">
3612N/A { 'name' : 'Get content of skip file',
3612N/A 'location' : STAF_REMOTE_HOSTNAME,
3612N/A 'service' : 'FS',
3612N/A 'request' : 'GET',
3612N/A 'arguments' : 'FILE %s TEXT' % IMP_SKIP_FILE
3612N/A }
3612N/A </call>
3612N/A
3612N/A <call function="'checktestRC'">
3612N/A { 'returncode' : RC,
3612N/A 'expected' : 0,
3612N/A 'result' : 'FAIL to get content of skip file ',
3612N/A }
3612N/A </call>
3612N/A
3612N/A <call function="'CheckMatches'">
3612N/A {
3612N/A 'string2find' : 'Skipping',
3612N/A 'mainString' : STAFResult,
3612N/A 'nbExpected' : 1,
3612N/A 'caseSensitive' : 'True'
3612N/A }
3612N/A </call>
3612N/A
3612N/A <call function="'ldapSearchWithScript'">
3612N/A { 'dsInstancePort' : IMP_I2_PORT,
3612N/A 'dsInstanceDn' : "cn=DM",
3612N/A 'dsInstancePswd' : "kangourou",
3612N/A 'dsBaseDN' : "o=o1",
3612N/A 'dsFilter' : 'objectclass=*',
3612N/A 'dsAttributes' : 'dn',
3612N/A 'expectedRC' : 0,
3612N/A }
3612N/A </call>
3612N/A
3612N/A <call function="'CheckMatches'">
3612N/A {
3612N/A 'string2find' : 'dn',
3612N/A 'mainString' : STAXResult[0][1],
3612N/A 'nbExpected' : 2,
3612N/A 'caseSensitive' : 'True'
3612N/A }
3612N/A </call>
3612N/A
3612N/A <!-- 2. Stop DS -->
3612N/A <message>'Stop DS'</message>
3612N/A <call function="'StopDsWithScript'">
3853N/A { 'location' : STAF_REMOTE_HOSTNAME,
3853N/A 'dsPath' : '%s' % IMP_I2_ROOT,
3853N/A 'dsAdminPort' : IMP_I2_ADMIN_PORT,
3853N/A 'dsBindDN' : 'cn=DM',
3853N/A 'dsBindPwd' : 'kangourou',
3612N/A }
3612N/A </call>
3612N/A
3612N/A <!-- 3. Uninstall options: verbose forceOnError remove-all
3612N/A noPropertiesFile -->
3612N/A <message>
3612N/A 'Uninstall opts: verbose forceOnError remove-all noPropertiesFile'
3612N/A </message>
3612N/A <script>
3612N/A c = '%s/uninstall%s' % (IMP_I2_ROOT, fileExt)
3612N/A p = []
3612N/A p.append('--cli --no-prompt --noPropertiesFile')
3612N/A p.append('--verbose --forceOnError --remove-all')
3612N/A p.append('--referencedHostName %s' % STAF_REMOTE_HOSTNAME)
3612N/A p = ' '.join(p)
3612N/A </script>
3612N/A
3612N/A <message>'%s %s' % (c, p)</message>
3612N/A <call function="'runCommand'">
3612N/A { 'location' : STAF_REMOTE_HOSTNAME,
3612N/A 'name' : 'Uninstall I2',
3612N/A 'command' : c,
3612N/A 'arguments' : p,
3612N/A 'path' : IMP_I2_ROOT,
3612N/A 'expectedRC': 0,
3612N/A 'outputFile': '%s/imp-uninstall-i2.txt' % OUT_GROUP,
3612N/A }
3612N/A </call>
3612N/A
3612N/A <!-- Do some post-uninstall checks -->
3612N/A <message>'Do some post-uninstall checks'</message>
3612N/A <call function="'runSTAFCommand'">
3612N/A { 'name' : 'Get content of skip file',
3612N/A 'location' : STAF_REMOTE_HOSTNAME,
3612N/A 'service' : 'FS',
3612N/A 'request' : 'LIST',
3612N/A 'arguments' : 'DIRECTORY %s' % IMP_I2_ROOT
3612N/A }
3612N/A </call>
3612N/A
3949N/A <script>
5116N/A res = STAFResult
5116N/A if 'coverage.ec' in res:
5116N/A res.remove('coverage.ec')
5116N/A
5116N/A nb = len(res)
5116N/A ct = (res[0] == 'lib')
3949N/A a = ' '
3949N/A </script>
3949N/A
3612N/A <call function="'checktestRC'">
3612N/A { 'returncode' : RC,
3612N/A 'expected' : 0,
3612N/A 'result' : 'FAIL to get content of install directory',
3612N/A }
3612N/A </call>
3612N/A
4716N/A <script>
5369N/A if PRODUCTNAME.startswith('OpenDJ'):
4865N/A if is_windows_platform(STAF_REMOTE_HOSTNAME):
4865N/A expectedNb = 2
4865N/A else:
4865N/A expectedNb = 1
4716N/A else:
4865N/A if is_windows_platform(STAF_REMOTE_HOSTNAME):
4865N/A expectedNb = 3
4865N/A else:
4865N/A expectedNb = 2
4716N/A </script>
3612N/A <call function="'checktestRC'">
3612N/A { 'returncode' : nb,
3612N/A 'result' : a,
4716N/A 'expected' : expectedNb
3612N/A }
3612N/A </call>
3612N/A
4865N/A <!--
3612N/A <call function="'checktestRC'">
3612N/A { 'returncode' : ct,
3612N/A 'result' : a,
3612N/A 'expected' : 1
3612N/A }
3612N/A </call>
4865N/A -->
3612N/A
3612N/A <call function="'testCase_Postamble'"/>
3612N/A
3612N/A </sequence>
3612N/A </testcase>
3612N/A
3612N/A <call function="'testSuite_Postamble'"/>
3612N/A
3612N/A </sequence>
3612N/A
3612N/A </function>
3612N/A
3612N/A</stax>