Debian Codegraph @

dirsrvtests/tests/suites/upgrade/upgrade_repl_plugin_test.py

raw
1 # --- BEGIN COPYRIGHT BLOCK ---
2 # Copyright (C) 2022 Red Hat, Inc.
3 # All rights reserved.
4 #
5 # License: GPL (version 3 or any later version).
6 # See LICENSE for details.
7 # --- END COPYRIGHT BLOCK ---
8 #
9 import ldap
10 import logging
11 import pytest
12 import os
13 from test389.topologies import topology_st as topo
14 from lib389.dseldif import DSEldif
15 from lib389.plugins import Plugins
16
17 log = logging.getLogger(__name__)
18
19
20 def test_repl_plugin_name_change(topo):
21 """Test that the replication plugin name is updated to the new name at
22 server startup.
23
24 :id: c2a7b7fb-6524-4391-8883-683b6af2a1cf
25 :setup: Standalone Instance
26 :steps:
27 1. Stop Server
28 2. Edit repl plugin in dse.ldif
29 3. Add repl plugin dependency to retro changelog plugin.
30 4. Start server
31 5. Verify old plugin is not found
32 6. Verify new plugin is found
33 7. Verify plugin dependency was updated in retro changelog plugin
34 8. Restart and repeat steps 5-7
35 :expectedresults:
36 1. Success
37 2. Success
38 3. Success
39 4. Success
40 5. Success
41 6. Success
42 7. Success
43 8. Success
44 """
45
46 REPL_PLUGIN_DN = "cn=Multisupplier Replication Plugin,cn=plugins,cn=config"
47 REPL_PLUGIN_NAME = "Multisupplier Replication Plugin"
48 REPL_PLUGIN_INIT_ATTR = "nsslapd-pluginInitfunc"
49 REPL_PLUGIN_INIT_FUNC = "replication_multisupplier_plugin_init"
50 REPL_DEPENDS_ATTR = "nsslapd-plugin-depends-on-named"
51 OLD_REPL_PLUGIN_NAME = "Replication Plugin"
52 OLD_REPL_PLUGIN_DN = "cn=Replication Plugin,cn=plugins,cn=config"
53 RETROCL_PLUGIN_DN = "cn=Retro Changelog Plugin,cn=plugins,cn=config"
54 RETROCL_PLUGIN_NAME = "Retro Changelog Plugin"
55
56 MEP_PLUGIN_DN = "cn=Managed Entries,cn=plugins,cn=config"
57 MEP_PLUGIN_NAME = "Managed Entries"
58
59 # Stop the server
60 topo.standalone.stop()
61
62 # Edit repl plugin in dse.ldif
63 dse_ldif = DSEldif(topo.standalone)
64 dse_ldif.replace(REPL_PLUGIN_DN, REPL_PLUGIN_INIT_ATTR, "multi_old_init_function")
65 dse_ldif.rename(REPL_PLUGIN_DN, OLD_REPL_PLUGIN_DN)
66
67 # Add dependency for repl plugin in retro changelog plugin and managed entries
68 dse_ldif.replace(RETROCL_PLUGIN_DN, REPL_DEPENDS_ATTR, OLD_REPL_PLUGIN_NAME)
69 dse_ldif.replace(MEP_PLUGIN_DN, REPL_DEPENDS_ATTR, OLD_REPL_PLUGIN_NAME)
70 # assert 0
71
72 # Restart the server, loop twice to verify settings stick after restart
73 for loop in [0, 1]:
74 topo.standalone.restart()
75
76 # Verify old plugin is deleted
77 with pytest.raises(ldap.NO_SUCH_OBJECT):
78 Plugins(topo.standalone).get(OLD_REPL_PLUGIN_NAME)
79
80 # Verify repl plugin name was changed to the new name
81 plugin = Plugins(topo.standalone).get(REPL_PLUGIN_NAME)
82 assert plugin is not None
83 assert plugin.get_attr_val_utf8_l(REPL_PLUGIN_INIT_ATTR) == REPL_PLUGIN_INIT_FUNC
84 assert len(plugin.get_attr_vals_utf8_l(REPL_PLUGIN_INIT_ATTR)) == 1
85
86 # Verify dependency was updated in retro changelog plugin
87 plugin = Plugins(topo.standalone).get(RETROCL_PLUGIN_NAME)
88 assert plugin is not None
89 assert plugin.get_attr_val_utf8_l(REPL_DEPENDS_ATTR) == REPL_PLUGIN_NAME.lower()
90 assert len(plugin.get_attr_vals_utf8_l(REPL_DEPENDS_ATTR)) == 1
91
92 # Verify dependency was updated in MEP plugin
93 plugin = Plugins(topo.standalone).get(MEP_PLUGIN_NAME)
94 assert plugin is not None
95 assert plugin.get_attr_val_utf8_l(REPL_DEPENDS_ATTR) == REPL_PLUGIN_NAME.lower()
96
97
98 if __name__ == '__main__':
99 # Run isolated
100 # -s for DEBUG mode
101 CURRENT_FILE = os.path.realpath(__file__)
102 pytest.main(["-s", CURRENT_FILE])
103