From d7c09b0ef0431e6d87f4bdf90fe6982bc787b004 Mon Sep 17 00:00:00 2001
From: Christophe Sovant <christophe.sovant@forgerock.com>
Date: Thu, 12 Mar 2009 09:55:47 +0000
Subject: [PATCH] Fix random tests failed in logging and tasks testsuites + add knownIssue tag in snmp testsuite
---
opendj-sdk/opends/tests/staf-tests/functional-tests/testcases/tasks/backup_db.xml | 54 ++++++----
opendj-sdk/opends/tests/staf-tests/shared/functions/utils.xml | 111 +++++++++++++++++++++
opendj-sdk/opends/tests/staf-tests/functional-tests/testcases/logging/logging_retention.xml | 7 +
opendj-sdk/opends/tests/staf-tests/functional-tests/testcases/snmp/snmp_status.xml | 66 ++++++++-----
opendj-sdk/opends/tests/staf-tests/shared/functions/snmp.xml | 14 ++
opendj-sdk/opends/tests/staf-tests/functional-tests/testcases/snmp/snmp_mibvalues.xml | 30 +++--
opendj-sdk/opends/tests/staf-tests/shared/tests/config.py.stubs | 2
7 files changed, 218 insertions(+), 66 deletions(-)
diff --git a/opendj-sdk/opends/tests/staf-tests/functional-tests/testcases/logging/logging_retention.xml b/opendj-sdk/opends/tests/staf-tests/functional-tests/testcases/logging/logging_retention.xml
index e4245fa..1d5fd85 100755
--- a/opendj-sdk/opends/tests/staf-tests/functional-tests/testcases/logging/logging_retention.xml
+++ b/opendj-sdk/opends/tests/staf-tests/functional-tests/testcases/logging/logging_retention.xml
@@ -218,7 +218,12 @@
'expectedRC' : 0
}
</call>
-
+
+ <call function="'Sleep'">
+ { 'location' : STAF_REMOTE_HOSTNAME,
+ 'sleepForMilliSeconds' : 5000 }
+ </call>
+
<call function="'listFolder'">
{ 'location' : DIRECTORY_INSTANCE_HOST,
'foldername' : '%s/%s/logs' % (DIRECTORY_INSTANCE_DIR,OPENDSNAME),
diff --git a/opendj-sdk/opends/tests/staf-tests/functional-tests/testcases/snmp/snmp_mibvalues.xml b/opendj-sdk/opends/tests/staf-tests/functional-tests/testcases/snmp/snmp_mibvalues.xml
index 69173d4..07dc6e7 100644
--- a/opendj-sdk/opends/tests/staf-tests/functional-tests/testcases/snmp/snmp_mibvalues.xml
+++ b/opendj-sdk/opends/tests/staf-tests/functional-tests/testcases/snmp/snmp_mibvalues.xml
@@ -303,7 +303,7 @@
<!--- Test Case information
#@TestMarker SNMP MIB values
#@TestName snmp_mibvalues: TODO
- #@TestIssue none
+ #@TestIssue 3862
#@TestPurpose TODO.
#@TestPreamble none
#@TestStep TODO.
@@ -370,7 +370,8 @@
'snmpHost' : DIRECTORY_INSTANCE_HOST ,
'snmpPort' : SNMP_PORT ,
'snmpCommunity' : community ,
- 'index' : indexLDAP
+ 'index' : indexLDAP ,
+ 'knownIssue' : '3862'
}
</call>
@@ -404,7 +405,7 @@
<!--- Test Case information
#@TestMarker SNMP MIB values
#@TestName snmp_mibvalues: TODO
- #@TestIssue none
+ #@TestIssue 3862
#@TestPurpose TODO.
#@TestPreamble none
#@TestStep TODO.
@@ -482,7 +483,8 @@
'snmpHost' : DIRECTORY_INSTANCE_HOST ,
'snmpPort' : SNMP_PORT ,
'snmpCommunity' : community ,
- 'index' : indexLDAP
+ 'index' : indexLDAP ,
+ 'knownIssue' : '3862'
}
</call>
@@ -516,7 +518,7 @@
<!--- Test Case information
#@TestMarker SNMP MIB values
#@TestName snmp_mibvalues: TODO
- #@TestIssue none
+ #@TestIssue 3862
#@TestPurpose TODO.
#@TestPreamble none
#@TestStep TODO.
@@ -583,7 +585,8 @@
'snmpHost' : DIRECTORY_INSTANCE_HOST ,
'snmpPort' : SNMP_PORT ,
'snmpCommunity' : community ,
- 'index' : indexLDAP
+ 'index' : indexLDAP ,
+ 'knownIssue' : '3862'
}
</call>
@@ -617,7 +620,7 @@
<!--- Test Case information
#@TestMarker SNMP MIB values
#@TestName snmp_mibvalues: TODO
- #@TestIssue none
+ #@TestIssue 3862
#@TestPurpose TODO.
#@TestPreamble none
#@TestStep TODO.
@@ -683,7 +686,8 @@
'snmpHost' : DIRECTORY_INSTANCE_HOST ,
'snmpPort' : SNMP_PORT ,
'snmpCommunity' : community ,
- 'index' : indexLDAP
+ 'index' : indexLDAP ,
+ 'knownIssue' : '3862'
}
</call>
@@ -717,7 +721,7 @@
<!--- Test Case information
#@TestMarker SNMP MIB values
#@TestName snmp_mibvalues: TODO
- #@TestIssue none
+ #@TestIssue 3862
#@TestPurpose TODO.
#@TestPreamble none
#@TestStep TODO.
@@ -785,7 +789,8 @@
'snmpHost' : DIRECTORY_INSTANCE_HOST ,
'snmpPort' : SNMP_PORT ,
'snmpCommunity' : community ,
- 'index' : indexLDAP
+ 'index' : indexLDAP ,
+ 'knownIssue' : '3862'
}
</call>
@@ -819,7 +824,7 @@
<!--- Test Case information
#@TestMarker SNMP MIB values
#@TestName snmp_mibvalues: TODO
- #@TestIssue none
+ #@TestIssue 3862
#@TestPurpose TODO.
#@TestPreamble none
#@TestStep TODO.
@@ -935,7 +940,8 @@
'snmpHost' : DIRECTORY_INSTANCE_HOST ,
'snmpPort' : SNMP_PORT ,
'snmpCommunity' : community ,
- 'index' : indexLDAP
+ 'index' : indexLDAP ,
+ 'knownIssue' : '3862'
}
</call>
diff --git a/opendj-sdk/opends/tests/staf-tests/functional-tests/testcases/snmp/snmp_status.xml b/opendj-sdk/opends/tests/staf-tests/functional-tests/testcases/snmp/snmp_status.xml
index 1cf70cb..1c404a8 100644
--- a/opendj-sdk/opends/tests/staf-tests/functional-tests/testcases/snmp/snmp_status.xml
+++ b/opendj-sdk/opends/tests/staf-tests/functional-tests/testcases/snmp/snmp_status.xml
@@ -64,7 +64,7 @@
#@TestMarker SNMP Connection Handler status
#@TestName status: check status when the server is
stopped/started
- #@TestIssue none
+ #@TestIssue 3865
#@TestPurpose Check status when the server is
stopped/started.
#@TestPreamble none
@@ -114,11 +114,13 @@
returnString = STAXResult[0][1]
</script>
- <call function="'checktestString'">
+ <call function="'searchString'">
{
- 'returnString' : returnString ,
'expectedString' : '0.0.0.0:%s : SNMP : Enabled' \
- % SNMP_PORT
+ % SNMP_PORT ,
+ 'returnString' : returnString ,
+ 'knownIssue' : '3865' ,
+ 'expectedRC' : expectedRC
}
</call>
@@ -153,11 +155,13 @@
returnString = STAXResult[0][1]
</script>
- <call function="'checktestString'">
+ <call function="'searchString'">
{
- 'returnString' : returnString ,
'expectedString' : '0.0.0.0:%s : SNMP : Enabled' \
- % SNMP_PORT
+ % SNMP_PORT ,
+ 'returnString' : returnString ,
+ 'knownIssue' : '3865' ,
+ 'expectedRC' : expectedRC
}
</call>
@@ -186,7 +190,7 @@
#@TestMarker SNMP Connection Handler status
#@TestName status: check status when the connection
handler is disabled/enabled
- #@TestIssue none
+ #@TestIssue 3865
#@TestPurpose Check status when the SNMP connection handler
is disabled/enabled.
#@TestPreamble none
@@ -235,11 +239,13 @@
returnString = STAXResult[0][1]
</script>
- <call function="'checktestString'">
+ <call function="'searchString'">
{
- 'returnString' : returnString ,
'expectedString' : '0.0.0.0:%s : SNMP : Disabled' \
- % SNMP_PORT
+ % SNMP_PORT ,
+ 'returnString' : returnString ,
+ 'knownIssue' : '3865' ,
+ 'expectedRC' : expectedRC
}
</call>
@@ -289,11 +295,13 @@
returnString = STAXResult[0][1]
</script>
- <call function="'checktestString'">
+ <call function="'searchString'">
{
- 'returnString' : returnString ,
'expectedString' : '0.0.0.0:%s : SNMP : Enabled' \
- % SNMP_PORT
+ % SNMP_PORT ,
+ 'returnString' : returnString ,
+ 'knownIssue' : '3865' ,
+ 'expectedRC' : expectedRC
}
</call>
@@ -323,7 +331,7 @@
#@TestName status: check error message and status when
the opendmk-jarfile property is set to a
wrong value
- #@TestIssue none
+ #@TestIssue 3865
#@TestPurpose Check error message and status when
the opendmk-jarfile property is set to a
wrong value.
@@ -420,11 +428,13 @@
returnString = STAXResult[0][1]
</script>
- <call function="'checktestString'">
+ <call function="'searchString'">
{
- 'returnString' : returnString ,
'expectedString' : '0.0.0.0:%s : SNMP : Enabled' \
- % SNMP_PORT
+ % SNMP_PORT ,
+ 'returnString' : returnString ,
+ 'knownIssue' : '3865' ,
+ 'expectedRC' : expectedRC
}
</call>
@@ -483,7 +493,7 @@
#@TestName status: check error message and status when
the security-agent-file property is set to a
wrong value
- #@TestIssue none
+ #@TestIssue 3865
#@TestPurpose Check error message and status when
the security-agent-file property is set to a
wrong value.
@@ -597,11 +607,13 @@
returnString = STAXResult[0][1]
</script>
- <call function="'checktestString'">
+ <call function="'searchString'">
{
- 'returnString' : returnString ,
'expectedString' : '0.0.0.0:%s : SNMP : Enabled' \
- % SNMP_PORT
+ % SNMP_PORT ,
+ 'returnString' : returnString ,
+ 'knownIssue' : '3865' ,
+ 'expectedRC' : expectedRC
}
</call>
@@ -660,7 +672,7 @@
#@TestName status: check error message and status when
the listen-port property is set to a wrong
value
- #@TestIssue none
+ #@TestIssue 3865
#@TestPurpose Check error message and status when
the listen-port property is set to a wrong
value.
@@ -765,11 +777,13 @@
returnString = STAXResult[0][1]
</script>
- <call function="'checktestString'">
+ <call function="'searchString'">
{
- 'returnString' : returnString ,
'expectedString' : '0.0.0.0:%s : SNMP : Enabled' \
- % DEFAULT_PROPERTIES['listen-port']
+ % DEFAULT_PROPERTIES['listen-port'] ,
+ 'returnString' : returnString ,
+ 'knownIssue' : '3865' ,
+ 'expectedRC' : expectedRC
}
</call>
diff --git a/opendj-sdk/opends/tests/staf-tests/functional-tests/testcases/tasks/backup_db.xml b/opendj-sdk/opends/tests/staf-tests/functional-tests/testcases/tasks/backup_db.xml
index 998e6d7..9c43915 100644
--- a/opendj-sdk/opends/tests/staf-tests/functional-tests/testcases/tasks/backup_db.xml
+++ b/opendj-sdk/opends/tests/staf-tests/functional-tests/testcases/tasks/backup_db.xml
@@ -206,27 +206,39 @@
'backEnd' : DIRECTORY_INSTANCE_BE}
</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="'searchStringForSubstring'">
- { 'returnString' : returnString,
- 'testString' : 'Backup',
- 'expectedResult' : '1' }
- </call>
-
-
+ <script>checkRC=9999</script>
+ <loop from="1" to="10" var="loop" while="checkRC != 0">
+ <sequence>
+ <message>'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.* Backup Completed successfully' \
+ % currentDate,
+ 'returnString' : returnString ,
+ 'expectedRC' : 'noCheck' }
+ </call>
+
+ <script>
+ checkRC = STAXResult[0]
+ </script>
+
+ </sequence>
+ </loop>
+
<message>'--- Check log files backup_asynchronous ---'</message>
<call function="'listFolder'">
{ 'location' : '%s' % (STAF_REMOTE_HOSTNAME),
diff --git a/opendj-sdk/opends/tests/staf-tests/shared/functions/snmp.xml b/opendj-sdk/opends/tests/staf-tests/shared/functions/snmp.xml
index fad2232..38322e7 100755
--- a/opendj-sdk/opends/tests/staf-tests/shared/functions/snmp.xml
+++ b/opendj-sdk/opends/tests/staf-tests/shared/functions/snmp.xml
@@ -664,6 +664,12 @@
</function-arg-description>
<function-arg-property name="type" value="string"/>
</function-arg-def>
+ <function-arg-def name="knownIssue" type="optional" default="None">
+ <function-arg-description>
+ Known issue. Corresponds to an issue number.
+ </function-arg-description>
+ <function-arg-property name="type" value="string" />
+ </function-arg-def>
<function-arg-def name="expectedRC" type="optional" default="0">
<function-arg-description>
Expected return code value. Default value is 0
@@ -703,10 +709,12 @@
'result: %s' % result
</message>
- <call function="'checktestStringNotPresent'">
+ <call function="'searchString'">
{
- 'returnString' : result ,
- 'testString' : 'ERROR'
+ 'expectedString' : 'ERROR' ,
+ 'returnString' : result ,
+ 'knownIssue' : knownIssue ,
+ 'expectedRC' : 1
}
</call>
diff --git a/opendj-sdk/opends/tests/staf-tests/shared/functions/utils.xml b/opendj-sdk/opends/tests/staf-tests/shared/functions/utils.xml
index 01c861d..7188643 100755
--- a/opendj-sdk/opends/tests/staf-tests/shared/functions/utils.xml
+++ b/opendj-sdk/opends/tests/staf-tests/shared/functions/utils.xml
@@ -221,8 +221,113 @@
<tcstatus result="'fail'"/>
</sequence>
</function>
-
-<!-- checktestString -->
+
+ <!-- Search string -->
+ <function name="searchString" scope="local">
+ <function-prolog>
+ This function search for a string in the retrun string of a testcase
+ Return 0 if the string is found, 1 otherwise
+ </function-prolog>
+
+ <function-map-args>
+ <function-arg-def name="expectedString" type="required">
+ <function-arg-description>
+ the substring expected from the command
+ </function-arg-description>
+ <function-arg-property name="type" value="string"/>
+ </function-arg-def>
+ <function-arg-def name="returnString" type="required">
+ <function-arg-description>
+ the return string received from command
+ </function-arg-description>
+ <function-arg-property name="type" value="string"/>
+ </function-arg-def>
+ <function-arg-def name="knownIssue" type="optional" default="None">
+ <function-arg-description>
+ Known issue. Corresponds to an issue number.
+ </function-arg-description>
+ <function-arg-property name="type" value="string"/>
+ </function-arg-def>
+ <function-arg-def name="expectedRC" type="optional" default="0">
+ <function-arg-description>
+ Expected return code value. Default value is 0.
+ Wildcard 'noCheck' to not check the RC
+ </function-arg-description>
+ <function-arg-property name="type" value="string"/>
+ </function-arg-def>
+ </function-map-args>
+
+ <sequence>
+ <script>
+ searchre = re.compile('%s' % expectedString)
+ myRC = 0
+ myReason = 'None'
+ </script>
+
+ <!-- Check that returnString is really a string -->
+ <if expr='returnString.__class__ is not org.python.core.PyString'>
+ <sequence>
+ <message log="1" level="'Error'">
+ 'ERROR : Invalid returnString type (%s), requires org.python.core.PyString.' \
+ % returnString.__class__
+ </message>
+ <script>
+ myRC = 1
+ myReason = 'Python error'
+ </script>
+
+ <return>[myRC, myReason]</return>
+ </sequence>
+ </if>
+
+ <!-- Search for the expectedString -->
+ <if expr='re.search(searchre, returnString) != None'>
+ <sequence>
+ <message log="1">
+ 'SUCCESS : Found substring, %s, in the return string' \
+ % (expectedString)
+ </message>
+ <script>
+ myRC = 0
+ myReason = 'String found'
+ </script>
+ </sequence>
+ <else>
+ <sequence>
+ <message log="1" level="'Error'">
+ 'ERROR : Did not find substring, %s, in the return string, %s' \
+ % (expectedString, returnString)
+ </message>
+ <script>
+ myRC = 1
+ myReason = 'String not found'
+ </script>
+ </sequence>
+ </else>
+ </if>
+
+ <!-- Manage expectedRC and knownIssue -->
+ <if expr="expectedRC != 'noCheck'">
+ <if expr="myRC == expectedRC">
+ <tcstatus result="'pass'"/>
+ <else>
+ <if expr="knownIssue == None">
+ <tcstatus result="'fail'"/>
+ <else>
+ <call function="'setKnownIssue'">
+ { 'issueId' : knownIssue }
+ </call>
+ </else>
+ </if>
+ </else>
+ </if>
+ </if>
+
+ <return>[myRC, myReason]</return>
+ </sequence>
+ </function>
+
+ <!-- DEPRECATED, use searchString function -->
<function name="checktestString">
<function-prolog>
This function checks the return string against an expected return substring for a testcase
@@ -291,6 +396,7 @@
</sequence>
</function>
+ <!-- DEPRECATED, use searchString function -->
<function name="checktestStringNotPresent">
<function-prolog>
This function checks the return string against an expected return substring that should not be present for a testcase
@@ -348,6 +454,7 @@
</sequence>
</function>
+ <!-- DEPRECATED, use searchString function -->
<function name="searchStringForSubstring">
<function-prolog>
This function simply searches a string for a substring
diff --git a/opendj-sdk/opends/tests/staf-tests/shared/tests/config.py.stubs b/opendj-sdk/opends/tests/staf-tests/shared/tests/config.py.stubs
index bc56310..cc8b2df 100644
--- a/opendj-sdk/opends/tests/staf-tests/shared/tests/config.py.stubs
+++ b/opendj-sdk/opends/tests/staf-tests/shared/tests/config.py.stubs
@@ -63,7 +63,7 @@
WC_PORT = '9000'
WC_SSL_PORT = '9001'
WC_HOST = 'localhost'
-DSML_WARNAME = 'opends-DSML.war'
+DSML_WARNAME = '%s-DSML.war' % OPENDSNAME
DSML_WARPATH = '%s/build/package/%s' % (OPENDSDIR, DSML_WARNAME)
SNMP_OPENDS_JARFILE = '%s/lib/extensions/snmp-mib2605.jar' % OPENDSNAME
SNMP_OPENDMK_LIBDIR = '/path/to/opendmk/lib'
--
Gitblit v1.10.0