Debian Codegraph @

dirsrvtests/tests/suites/clu/dsctl_acceptance_test.py

raw
1 # --- BEGIN COPYRIGHT BLOCK ---
2 # Copyright (C) 2021 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 logging
10 import pytest
11 import os
12 import time
13 from test389.topologies import topology_st as topo
14 from lib389.paths import Paths
15
16 log = logging.getLogger(__name__)
17
18 def test_custom_path(topo):
19 """Test that a custom path, backup directory, is correctly used by lib389
20 when the server is stopped.
21
22 :id: 8659e209-ee83-477e-8183-1d2f555669ea
23 :setup: Standalone Instance
24 :steps:
25 1. Get the LDIF directory
26 2. Change the server's backup directory to the LDIF directory
27 3. Stop the server, and perform a backup
28 4. Backup was written to LDIF directory
29 :expectedresults:
30 1. Success
31 2. Success
32 3. Success
33 4. Success
34 """
35
36 # Get LDIF dir
37 ldif_dir = topo.standalone.get_ldif_dir()
38 bak_dir = topo.standalone.get_bak_dir()
39 log.info("ldif dir: " + ldif_dir + " items: " + str(len(os.listdir(ldif_dir))))
40 log.info("bak dir: " + bak_dir + " items: " + str(len(os.listdir(bak_dir))))
41
42 # Set backup directory to LDIF directory
43 topo.standalone.config.replace('nsslapd-bakdir', ldif_dir)
44 time.sleep(.5)
45
46 # Stop the server and take a backup
47 inst = topo.standalone
48 inst.stop()
49 # Refresh ds_paths
50 inst.ds_paths = Paths(inst.serverid, instance=inst, local=inst.isLocal)
51
52 time.sleep(.5)
53 inst.db2bak(None) # Bug, bak dir is being pulled from defaults.inf, and not from config
54
55 # Verify backup was written to LDIF directory
56 log.info("AFTER: ldif dir (new bak dir): " + ldif_dir + " items: " + str(len(os.listdir(ldif_dir))))
57 log.info("AFTER: bak dir: " + bak_dir + " items: " + str(len(os.listdir(bak_dir))))
58
59 assert len(os.listdir(ldif_dir))
60
61
62 if __name__ == '__main__':
63 # Run isolated
64 # -s for DEBUG mode
65 CURRENT_FILE = os.path.realpath(__file__)
66 pytest.main(["-s", CURRENT_FILE])