From c86f83667d31602ffe2e6e60c4b0ec30a4e065c3 Mon Sep 17 00:00:00 2001
From: al_xipe <al_xipe@localhost>
Date: Tue, 17 Jul 2007 22:42:13 +0000
Subject: [PATCH] Refactored the index test suite to leverage the best-practices of the sample suite
---
opends/tests/functional-tests/testcases/indexes/search.filters | 6
opends/tests/functional-tests/shared/functions/utils.xml | 121 +++++++++++++++++
opends/tests/functional-tests/testcases/sample/sample.xml | 113 ----------------
opends/tests/functional-tests/testcases/indexes/indexes.xml | 173 +++++++++--------------
4 files changed, 194 insertions(+), 219 deletions(-)
diff --git a/opends/tests/functional-tests/shared/functions/utils.xml b/opends/tests/functional-tests/shared/functions/utils.xml
index 8349234..3b26f61 100755
--- a/opends/tests/functional-tests/shared/functions/utils.xml
+++ b/opends/tests/functional-tests/shared/functions/utils.xml
@@ -789,5 +789,126 @@
</sequence>
</function>
+ <function name="runFunction">
+ <function-map-args>
+ <function-arg-def name="functionName" type="required">
+ <function-arg-description>
+ Name of the function to run
+ </function-arg-description>
+ </function-arg-def>
+
+ <function-arg-def name="functionArguments" type="optional">
+ <function-arg-description>
+ Arguments to be passed on to the called function.
+ This can be a map or a list of arguments, whatever the called function
+ expects will be carried on here.
+ . for a map, pass the arguments like this:
+ { 'argumentA' : 'argumentAvalue' ,
+ 'argumentB' : 1 ,
+ ...
+ }
+ . for a list, pass the arguments like this:
+ [ 'argumentAvalue, 1, ... ]
+ </function-arg-description>
+ </function-arg-def>
+
+ <function-arg-def name="expectedRC" type="optional" default="0">
+ <function-arg-description>
+ The expected return code of the function to run.
+ This is then passed onto the checkRC function.
+ It is also used to throw an exception if the argument
+ functionException is provided and set the test case status if the
+ argument functionSetsTCStatus is provided
+ </function-arg-description>
+ <function-arg-property name="type" value="integer"/>
+ </function-arg-def>
+
+ <function-arg-def name="functionException" type="optional">
+ <function-arg-description>
+ The exception to throw if the return code differs from the expected
+ RC. The exception is appended to STAXException.
+ </function-arg-description>
+ </function-arg-def>
+
+ <function-arg-def name="functionMessage" type="optional">
+ <function-arg-description>
+ An optional message to display before running the function
+ </function-arg-description>
+ </function-arg-def>
+
+ <function-arg-def name="functionSetsTCStatus" type="optional">
+ <function-arg-description>
+ Whether the function to run sets the testcase status or not.
+ If this is set, the test case status is set according to whether
+ or not the function meets the expected return code.
+ True or False should be used for this argument.
+ </function-arg-description>
+ </function-arg-def>
+ </function-map-args>
+ <sequence>
+ <script>
+ <!-- defining the booleans here should temporary while I find a nicer
+ solution. We have a chicken and egg problem between the
+ loadGlobalEnvironment and loadSharedLibraries functions in
+ environment.xml at the moment.
+ -->
+ if not False:
+ False=0
+
+ if not True:
+ True=1
+
+ _throwException=False
+ if functionException:
+ _throwException=True
+
+ _displayMessage=False
+ if functionMessage:
+ _displayMessage=True
+
+ _tcStatus='fail'
+ _doSetTCStatus=False
+ if functionSetsTCStatus:
+ _doSetTCStatus=True
+ </script>
+ <message log="1" level="'info'" if="_displayMessage == True">'%s' % functionMessage</message>
+ <message log="1" level="'debug'">'runFunction: %s: called with parameters [%s]' % (functionName,functionArguments)</message>
+ <call function="'%s' % functionName">functionArguments</call>
+ <message log="1" level="'debug'">'runFunction: %s: returned [%s]' % (functionName,RC)</message>
+ <script>
+ _functionRC = RC
+ </script>
+ <call function="'checkRC'" >
+ { 'returncode' : RC ,
+ 'result' : STAXResult,
+ 'expected' : expectedRC
+ }
+ </call>
+
+ <!-- this section handles the optional case when we need to set the
+ test case status
+ -->
+ <if expr="_doSetTCStatus == True">
+ <sequence>
+ <if expr="_functionRC == expectedRC">
+ <script>_tcStatus='pass'</script>
+ </if>
+ <tcstatus result="_tcStatus" />
+ </sequence>
+ </if>
+
+ <!-- this section handles the optional case when we need to throw an
+ exception upon unexpected function return code
+ -->
+ <if expr="_throwException == True" >
+ <if expr="_functionRC != expectedRC" >
+ <throw exception="'STAXException.%s' % functionException" />
+ </if>
+ </if>
+
+ <!-- bubble the function return code up one level -->
+ <return>_functionRC</return>
+ </sequence>
+ </function>
</stax>
diff --git a/opends/tests/functional-tests/testcases/indexes/indexes.xml b/opends/tests/functional-tests/testcases/indexes/indexes.xml
index e555553..ca17c47 100644
--- a/opends/tests/functional-tests/testcases/indexes/indexes.xml
+++ b/opends/tests/functional-tests/testcases/indexes/indexes.xml
@@ -29,31 +29,32 @@
<defaultcall function="indexes" />
<function name="indexes">
<sequence>
- <block name="'indexes'">
- <sequence>
- <script>
- CurrentTestPath={}
- envAlreadyLoaded='true'
- CurrentTestPath['group']='indexes'
- CurrentTestPath['suite']=STAXCurrentBlock
- </script>
-
- <call function="'testGroup_Preamble'" />
- <call function="'testSuite_Preamble'"/>
- <call function="'setup'" />
- <call function="'search'" />
- <call function="'cleanup'" />
- <call function="'testSuite_Postamble'"/>
- <call function="'testGroup_Postamble'" />
-
- </sequence>
- </block>
+ <script>
+ CurrentTestPath={'group':'indexes','suite':'indexes'}
+ envAlreadyLoaded='true'
+ </script>
+ <try>
+ <iterate in="['testGroup_Preamble','testSuite_Preamble','indexes_setup','indexes_search']" var="testStep">
+ <call function="testStep" />
+ </iterate>
+ <catch exception="'STAXException.Topology.CreationException'">
+ <message log="1" level="'fatal'">'Could not create the topology. Bailing out.'</message>
+ </catch>
+ <catch exception="'STAXException.Topology.StartException'">
+ <message log="1" level="'fatal'">'Could not start at least one server in the topology. Bailing out.'</message>
+ </catch>
+ <finally>
+ <iterate in="['indexes_cleanup','testSuite_Postamble','testGroup_Postamble']" var="testStep">
+ <call function="'%s' % testStep" />
+ </iterate>
+ </finally>
+ </try>
</sequence>
</function>
- <function name="search" >
+ <function name="indexes_search" >
<sequence>
- <message>
+ <message log="1" level="'info'">
'starting the search tests'
</message>
@@ -126,17 +127,18 @@
<testcase name="'Indexes: 1.Search: %03d-%03d.%s: %s%02d' % ( len(indexTests)-iteration, iteration, test.getAttribute(), test.getName(), testNumber)" >
<sequence>
<call function="'testCase_Preamble'" />
- <message>
+ <message log="1" level="'trace'">
'Searching attribute [%s] with filter[%s]' % (test.getAttribute(),test.getFilter())
</message>
<call function="'SearchObject'">
- { 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST ,
- 'dsInstancePort' : DIRECTORY_INSTANCE_PORT ,
- 'dsInstanceDn' : DIRECTORY_INSTANCE_DN ,
- 'dsInstancePswd' : DIRECTORY_INSTANCE_PSWD ,
+ { 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST ,
+ 'dsInstancePort' : DIRECTORY_INSTANCE_PORT ,
+ 'dsInstanceDn' : DIRECTORY_INSTANCE_DN ,
+ 'dsInstancePswd' : DIRECTORY_INSTANCE_PSWD ,
'dsBaseDN' : 'ou=People,dc=example,%s' % DIRECTORY_INSTANCE_SFX ,
- 'dsFilter' : '%s' % test.getFilter() ,
- 'attributes' : 'debugsearchindex' }
+ 'dsFilter' : '%s' % test.getFilter() ,
+ 'attributes' : 'debugsearchindex' ,
+ 'expectedRC' : 'noCheck' }
</call>
<script>
searchReturnCode, searchResultString = STAXResult[0]
@@ -146,7 +148,7 @@
test.pass()
</script>
- <message level="'debug'">'%s searchReturnCode=[%s] srt=[%s] searchResultString=[%s] string looked for=[%s]' % (test.desc(), searchReturnCode, srt, searchResultString, test.getSearchString())</message>
+ <message level="'trace'">'%s searchReturnCode=[%s] srt=[%s] searchResultString=[%s] string looked for=[%s]' % (test.desc(), searchReturnCode, srt, searchResultString, test.getSearchString())</message>
<tcstatus result="'%s' % test.getStatus()" />
<call function="'testCase_Postamble'" />
<script>
@@ -160,87 +162,50 @@
</function>
<!-- Setup the instance for indexes tests -->
- <function name="setup">
+ <function name="indexes_setup">
<sequence>
- <block name="'setup'">
- <sequence>
- <script>
- CurrentTestPath['group']='indexes'
- </script>
- <block name="'Create OpenDS instance'">
- <sequence>
- <message>
- 'Create DS topology as described in config.py'
- </message>
- <call function="'createTopology'">
- { 'initialiseInstance' : True }
- </call>
- <call function="'checkRC'">
- { 'returncode' : RC ,
- 'result' : STAXResult }
- </call>
- </sequence>
- </block>
- <block name="'Start OpenDS'">
- <sequence>
- <message>
- 'Start DS to run on port %s' % (DIRECTORY_INSTANCE_PORT)
- </message>
- <call function="'StartDsWithScript'">
- { 'location' : STAF_REMOTE_HOSTNAME }
- </call>
- <call function="'checkRC'">
- { 'returncode' : RC ,
- 'result' : STAXResult }
- </call>
- <call function="'isAlive'">
- { 'noOfLoops' : 5 ,
- 'noOfMilliSeconds' : 2000 }
- </call>
- </sequence>
- </block>
- </sequence>
- </block>
+ <call function="'runFunction'">
+ { 'functionName' : 'createTopology' ,
+ 'functionMessage' : 'Create DS topology as described in config.py',
+ 'functionException' : 'Topology.CreationException' ,
+ 'functionArguments' : { 'initialiseInstance' : True }
+ }
+ </call>
+ <call function="'runFunction'">
+ { 'functionName' : 'StartDsWithScript' ,
+ 'functionMessage' : 'Start DS to run on port %s' % (DIRECTORY_INSTANCE_PORT) ,
+ 'functionArguments' : { 'location' : STAF_REMOTE_HOSTNAME }
+ }
+ </call>
+ <call function="'runFunction'">
+ { 'functionName' : 'isAlive' ,
+ 'functionMessage' : 'Checking if the server is available' ,
+ 'functionException' : 'Topology.StartException' ,
+ 'functionArguments' : { 'noOfLoops' : 5 ,
+ 'noOfMilliSeconds' : 2000 }
+ }
+ </call>
</sequence>
</function>
<!-- cleanup after the tests -->
- <function name="cleanup">
+ <function name="indexes_cleanup">
<sequence>
- <block name="'cleanup'">
- <sequence>
- <block name="'Block DS Process Stop'">
- <sequence>
- <message>
- 'Stop DS running on port %s' % (DIRECTORY_INSTANCE_PORT)
- </message>
- <call function="'StopDsWithScript'">
- { 'location' : STAF_REMOTE_HOSTNAME,
- 'dsHost' : DIRECTORY_INSTANCE_HOST,
- 'dsPort' : DIRECTORY_INSTANCE_PORT,
- 'dsBindDN' : DIRECTORY_INSTANCE_DN,
- 'dsBindPwd' : DIRECTORY_INSTANCE_PSWD }
- </call>
- <call function="'checkRC'">
- { 'returncode' : RC ,
- 'result' : STAXResult }
- </call>
- </sequence>
- </block>
- <block name="'Block Remove DS Topology'">
- <sequence>
- <message>
- 'Remove DS topology created for the Test Suite'
- </message>
- <call function="'removeTopology'"/>
- <call function="'checkRC'">
- { 'returncode' : RC ,
- 'result' : STAXResult }
- </call>
- </sequence>
- </block>
- </sequence>
- </block>
+ <call function="'runFunction'">
+ { 'functionName' : 'StopDsWithScript' ,
+ 'functionMessage' : 'Stop DS running on port %s' % (DIRECTORY_INSTANCE_PORT),
+ 'functionArguments' : { 'location' : STAF_REMOTE_HOSTNAME ,
+ 'dsHost' : DIRECTORY_INSTANCE_HOST ,
+ 'dsPort' : DIRECTORY_INSTANCE_PORT ,
+ 'dsBindDN' : DIRECTORY_INSTANCE_DN ,
+ 'dsBindPwd' : DIRECTORY_INSTANCE_PSWD }
+ }
+ </call>
+ <call function="'runFunction'">
+ { 'functionName' : 'removeTopology',
+ 'functionMessage' : 'Remove DS topology created for the Test Suite'
+ }
+ </call>
</sequence>
</function>
</stax>
diff --git a/opends/tests/functional-tests/testcases/indexes/search.filters b/opends/tests/functional-tests/testcases/indexes/search.filters
index e8b079e..7134ea2 100644
--- a/opends/tests/functional-tests/testcases/indexes/search.filters
+++ b/opends/tests/functional-tests/testcases/indexes/search.filters
@@ -30,9 +30,9 @@
uid negate (!(&(uid=jwallace))) 0 NOT-INDEXED
uid negate (!(|(uid=jwallace))) 0 NOT-INDEXED
uid complexAnd (uid=j*&l=sunnyvale) 0 INDEXED
-uid complexAnd &(uid=j*)(l=sunnyvale) 0 INDEXED
-uid complexAnd (&(uid=j*)(l=~sunyvale)) 0 INDEXED
-uid complexAnd (&(&(uid=j*)(l=~sunyvale))) 0 INDEXED
+uid complexAnd &(uid=j*)(l=sunnyvale) 0 NOT-INDEXED
+uid complexAnd (&(uid=j*)(l=~sunyvale)) 0 NOT-INDEXED
+uid complexAnd (&(&(uid=j*)(l=~sunyvale))) 0 NOT-INDEXED
uid complexAnd (uid=j*&!l=cupertino) 0 INDEXED
uid complexAnd (uid=j*&l=sun*) 0 INDEXED
uid complexAnd (&(uid=j*)(l=sun*)) 0 INDEXED
diff --git a/opends/tests/functional-tests/testcases/sample/sample.xml b/opends/tests/functional-tests/testcases/sample/sample.xml
index 073fba4..0182690 100644
--- a/opends/tests/functional-tests/testcases/sample/sample.xml
+++ b/opends/tests/functional-tests/testcases/sample/sample.xml
@@ -115,7 +115,6 @@
<!-- Setup the instance for sample test -->
<function name="sample_setup">
<sequence>
- <message>'That is the right setup being called here'</message>
<call function="'runFunction'">
{ 'functionName' : 'createTopology' ,
'functionMessage' : 'Create DS topology as described in config.py',
@@ -124,7 +123,7 @@
}
</call>
<call function="'runFunction'">
- { 'functionName' : 'StartDSWithScript' ,
+ { 'functionName' : 'StartDsWithScript' ,
'functionMessage' : 'Start DS to run on port %s' % (DIRECTORY_INSTANCE_PORT) ,
'functionArguments' : { 'location' : STAF_REMOTE_HOSTNAME }
}
@@ -161,114 +160,4 @@
</sequence>
</function>
- <function name="runFunction" scope="local">
- <function-map-args>
- <function-arg-def name="functionName" type="required">
- <function-arg-description>
- Name of the function to run
- </function-arg-description>
- </function-arg-def>
-
- <function-arg-def name="functionArguments" type="optional">
- <function-arg-description>
- Arguments to be passed on to the called function.
- This can be a map or a list of arguments, whatever the called function
- expects will be carried on here.
- . for a map, pass the arguments like this:
- { 'argumentA' : 'argumentAvalue' ,
- 'argumentB' : 1 ,
- ...
- }
- . for a list, pass the arguments like this:
- [ 'argumentAvalue, 1, ... ]
- </function-arg-description>
- </function-arg-def>
-
- <function-arg-def name="expectedRC" type="optional" default="0">
- <function-arg-description>
- The expected return code of the function to run.
- This is then passed onto the checkRC function.
- It is also used to throw an exception if the argument
- functionException is provided and set the test case status if the
- argument functionSetsTCStatus is provided
- </function-arg-description>
- <function-arg-property name="type" value="integer"/>
- </function-arg-def>
-
- <function-arg-def name="functionException" type="optional">
- <function-arg-description>
- The exception to throw if the return code differs from the expected
- RC. The exception is appended to STAXException.
- </function-arg-description>
- </function-arg-def>
-
- <function-arg-def name="functionMessage" type="optional">
- <function-arg-description>
- An optional message to display before running the function
- </function-arg-description>
- </function-arg-def>
-
- <function-arg-def name="functionSetsTCStatus" type="optional">
- <function-arg-description>
- Whether the function to run sets the testcase status or not.
- If this is set, the test case status is set according to whether
- or not the function meets the expected return code.
- True or False should be used for this argument.
- </function-arg-description>
- </function-arg-def>
- </function-map-args>
- <sequence>
- <script>
- throwException=False
- if functionException:
- throwException=True
-
- displayMessage=False
- if functionMessage:
- displayMessage=True
-
- tcStatus='fail'
- doSetTCStatus=False
- if functionSetsTCStatus:
- doSetTCStatus=True
- </script>
- <message log="1" level="'info'" if="displayMessage == True">'%s' % functionMessage</message>
- <message log="1" level="'debug'">'runFunction: %s: called with parameters [%s]' % (functionName,functionArguments)</message>
- <call function="'%s' % functionName">functionArguments</call>
- <message log="1" level="'debug'">'runFunction: %s: returned [%s]' % (functionName,RC)</message>
- <script>
- functionRC = RC
- </script>
- <call function="'checkRC'" >
- { 'returncode' : RC ,
- 'result' : STAXResult,
- 'expected' : expectedRC
- }
- </call>
-
- <!-- this section handles the optional case when we need to set the
- test case status
- -->
- <if expr="doSetTCStatus == True">
- <sequence>
- <if expr="functionRC == expectedRC">
- <script>tcStatus='pass'</script>
- </if>
- <tcstatus result="tcStatus" />
- </sequence>
- </if>
-
- <!-- this section handles the optional case when we need to throw an
- exception upon unexpected function return code
- -->
- <if expr="throwException == True" >
- <if expr="functionRC != expectedRC" >
- <throw exception="'STAXException.%s' % functionException" />
- </if>
- </if>
-
- <!-- bubble the function return code up one level -->
- <return>functionRC</return>
- </sequence>
- </function>
</stax>
--
Gitblit v1.10.0