issue48989_test.py 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. import os
  2. import time
  3. import ldap
  4. import logging
  5. import pytest
  6. from lib389.topologies import topology_st
  7. from lib389._constants import *
  8. from lib389.properties import *
  9. from lib389.tasks import *
  10. from lib389.utils import *
  11. DEBUGGING = False
  12. if DEBUGGING:
  13. logging.getLogger(__name__).setLevel(logging.DEBUG)
  14. else:
  15. logging.getLogger(__name__).setLevel(logging.INFO)
  16. log = logging.getLogger(__name__)
  17. def test_bytessent_overflow(topology_st):
  18. """
  19. Issue 48989 - Add 10k entries and run search until the value of bytessent is
  20. bigger than 2^32 or resets to 0
  21. """
  22. # Create users
  23. topology_st.standalone.ldclt.create_users('ou=People,%s' %
  24. DEFAULT_SUFFIX, min=0, max=10000)
  25. bytessent = int(topology_st.standalone.search_s(
  26. 'cn=monitor', ldap.SCOPE_BASE, attrlist=['bytessent'])[0].getValue('bytessent'))
  27. bytessent_old = bytessent
  28. while bytessent < 4300000000:
  29. # Do searches
  30. topology_st.standalone.search_s(DEFAULT_SUFFIX,
  31. ldap.SCOPE_SUBTREE,
  32. filterstr='(objectClass=*)')
  33. # Read bytessent value from cn=monitor
  34. bytessent = int(topology_st.standalone.search_s(
  35. 'cn=monitor', ldap.SCOPE_BASE, attrlist=['bytessent'])[0].getValue('bytessent'))
  36. if bytessent > bytessent_old:
  37. bytessent_old = bytessent
  38. else:
  39. # If it overflows - test failed
  40. assert(bytessent > 4294967295)
  41. if __name__ == '__main__':
  42. # Run isolated
  43. # -s for DEBUG mode
  44. CURRENT_FILE = os.path.realpath(__file__)
  45. pytest.main("-s %s" % CURRENT_FILE)