mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Gary Williams
19.59.2012 a53a0b38214c0bc708fa0e9c1e6a22aae4158ec0
Functional tests show tail of error log on stopping server
3 files modified
58 ■■■■ changed files
opends/tests/staf-tests/shared/functions/dsadm.xml 33 ●●●●● patch | view | raw | blame | history
opends/tests/staf-tests/shared/functions/utils.xml 13 ●●●●● patch | view | raw | blame | history
opends/tests/staf-tests/shared/python/common.py 12 ●●●● patch | view | raw | blame | history
opends/tests/staf-tests/shared/functions/dsadm.xml
@@ -657,6 +657,15 @@
          STAFCmdParamsList.append('-H')
 
        STAFCmdParams=' '.join(STAFCmdParamsList)
        from java.util import Date
        from java.text import SimpleDateFormat
        import re
        pattern=re.compile("\[(.*)\]")
        formatter = SimpleDateFormat("dd/MMM/yy:H:m:s Z")
        stop_current_time = Date()
      </script>
      
      <message>
@@ -700,6 +709,28 @@
          </else>
        </if>
      </if>
      <!-- Get Errors log -->
      <message>
        'Getting tail of error log on %s/logs/errors' % dsPath
      </message>
      <call function="'getFile'">
        { 'location'    : location,
          'filename'    : '%s/logs/errors' % dsPath
        }
      </call>
      <script>
        for line in STAXResult[1].split('\n'):
          mymatch = pattern.match(line)
          if mymatch:
            timestamp=mymatch.group(1)
            timestamp_object = formatter.parse(timestamp)
            if date_compare(stop_current_time,timestamp_object) == 'Less':
              print line
      </script>
      <message>
        'Result = %s' % STAXResult
      </message>
    </sequence>
  </function>
@@ -1041,7 +1072,7 @@
      </call>
      <script>
         savSTAXResult = STAXResult
        savSTAXResult = STAXResult
        resultString = STAXResult[0][1]
      </script>
opends/tests/staf-tests/shared/functions/utils.xml
@@ -798,11 +798,14 @@
      </loop>
      <if expr="checkRC != 48">
        <message>
          'Server is not stopped after %sms \
          (%s/logs/server.pid still exists on %s)' \
          % (noOfLoops*noOfMilliSeconds,dsPath,location)
        </message>
        <sequence>
          <message>
            'Server is not stopped after %sms \
            (%s/logs/server.pid still exists on %s)' \
            % (noOfLoops*noOfMilliSeconds,dsPath,location)
          </message>
          <tcstatus result="'fail'"/>
        </sequence>
      </if>
    </sequence>
  </function>
opends/tests/staf-tests/shared/python/common.py
@@ -24,7 +24,7 @@
#
#
#      Copyright 2007-2009 Sun Microsystems, Inc.
#      Portions Copyright 2011 ForgeRock AS.
#      Portions Copyright 2011-2012 ForgeRock AS.
__version__ = "$Revision$"
# $Source$
@@ -57,7 +57,8 @@
            "host_is_localhost" ,
            "md5_hash" ,
            "value_not_string" ,
            "get_system_uid"
            "get_system_uid" ,
            "date_compare"
            ]
class format_testcase:
@@ -881,3 +882,10 @@
  from java.lang import System
  return System.getProperty("user.name")
def date_compare(date1,date2):
  if date1.compareTo(date2) > 0:
    return "Greater"
  elif date1.compareTo(date2) < 0:
    return "Less"
  else:
    return "Equal"