#50109 Issue 49618 - Set nsslapd-cachememsize to custom value
Closed 3 years ago by spichugi. Opened 5 years ago by bsmejkal.
bsmejkal/389-ds-base ds49618  into  master

@@ -8,12 +8,69 @@ 

  #

  import logging

  import pytest

+ from lib389.utils import *

  from lib389.dseldif import DSEldif

+ from lib389.config import LDBMConfig

+ from lib389.backend import Backends

  from lib389.topologies import topology_st as topo

  

  logging.getLogger(__name__).setLevel(logging.INFO)

  log = logging.getLogger(__name__)

  

+ CUSTOM_MEM = '9100100100'

+ 

+ 

+ # Function to return value of available memory in kb

+ def get_available_memory():

+     with open('/proc/meminfo') as file:

+         for line in file:

+             if 'MemAvailable' in line:

+                 free_mem_in_kb = line.split()[1]

+     return int(free_mem_in_kb)

+ 

+ 

+ @pytest.mark.skipif(get_available_memory() < (int(CUSTOM_MEM)/1024), reason="available memory is too low")

+ @pytest.mark.bz1627512

+ @pytest.mark.ds49618

+ def test_set_cachememsize_to_custom_value(topo):

+     """Test if value nsslapd-cachememsize remains set

+      at the custom setting of value above 3805132804 bytes

+      after changing the value to 9100100100 bytes

+ 

+     :id: 8a3efc00-65a9-4ee7-b8ee-e35840991ea9

+     :setup: Standalone Instance

+     :steps:

+         1. Disable in the cn=config,cn=ldbm database,cn=plugins,cn=config:

+            nsslapd-cache-autosize by setting it to 0

+         2. Disable in the cn=config,cn=ldbm database,cn=plugins,cn=config:

+            nsslapd-cache-autosize-split by setting it to 0

+         3. Restart the instance

+         4. Set in the cn=UserRoot,cn=ldbm database,cn=plugins,cn=config:

+            nsslapd-cachememsize: CUSTOM_MEM

+     :expectedresults:

+         1. nsslapd-cache-autosize is successfully disabled

+         2. nsslapd-cache-autosize-split is successfully disabled

+         3. The instance should be successfully restarted

+         4. nsslapd-cachememsize is successfully set

+     """

+ 

+     config_ldbm = LDBMConfig(topo.standalone)

+     backends = Backends(topo.standalone)

+     userroot_ldbm = backends.get("userroot")

+ 

+     log.info("Disabling nsslapd-cache-autosize by setting it to 0")

+     assert config_ldbm.set('nsslapd-cache-autosize', '0')

+ 

+     log.info("Disabling nsslapd-cache-autosize-split by setting it to 0")

+     assert config_ldbm.set('nsslapd-cache-autosize-split', '0')

+ 

+     log.info("Restarting instance")

+     topo.standalone.restart()

+     log.info("Instance restarted successfully")

+ 

+     log.info("Set nsslapd-cachememsize to value {}".format(CUSTOM_MEM))

+     assert userroot_ldbm.set('nsslapd-cachememsize', CUSTOM_MEM)

+ 

  

  def test_maxbersize_repl(topo):

      """Check that instance starts when nsslapd-errorlog-maxlogsize
@@ -52,3 +109,4 @@ 

      inst.start()

      log.info("Assert no init_dse_file errors in the error log")

      assert not inst.ds_error_log.match('.*ERR - init_dse_file.*')

+ 

Description:
Added function for getting available memory.
Added test case to set nsslapd-cachememsize to custom value above 3805132804 bytes. Test is skipped if available memory is lower than we want to set.

https://pagure.io/389-ds-base/issue/49618

Reviewed by: vashirov (Thanks!)

We avoid using DSLdapObject directly. It is a private class by design.
You can use LDBMConfig(DSLdapObject) here (config.py)

And for particular backends you can use Backends(DSLdapObjects) object and get the one you need like this

backends = Backends(topo.standalone)
userroot_ldbm = backends.get("userroot")

Besides that - looks really good!
Nice job!

rebased onto 068e248e538dffcb144be321bb0273085d7516a8

5 years ago

@spichugi
Thanks! Could you please review the last change? :)

LGTM! Ack
Please, rebase with the latest master and we can merge

Agreed, this looks good. Was this test addressing a specific problem though? I think the auto tuning tests that @spichugi wrote a long time ago would have already checked this case ....

This issue was reported by customer, when autotuning is off. The tests that you have mentioned were checking correctness with autotuning on.

rebased onto f574332

5 years ago

Pull-Request has been merged by vashirov

5 years ago

389-ds-base is moving from Pagure to Github. This means that new issues and pull requests
will be accepted only in 389-ds-base's github repository.

This pull request has been cloned to Github as issue and is available here:
- https://github.com/389ds/389-ds-base/issues/3168

If you want to continue to work on the PR, please navigate to the github issue,
download the patch from the attachments and file a new pull request.

Thank you for understanding. We apologize for all inconvenience.

Pull-Request has been closed by spichugi

3 years ago
Metadata