Debian Codegraph @

dirsrvtests/tests/suites/config/removed_config_49298_test.py

raw
1 # --- BEGIN COPYRIGHT BLOCK ---
2 # Copyright (C) 2017 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 pytest
10 import os
11 import logging
12 import subprocess
13
14 from test389.topologies import topology_st as topo
15
16 pytestmark = pytest.mark.tier0
17
18 DEBUGGING = os.getenv("DEBUGGING", default=False)
19 if DEBUGGING:
20 logging.getLogger(__name__).setLevel(logging.DEBUG)
21 else:
22 logging.getLogger(__name__).setLevel(logging.INFO)
23 log = logging.getLogger(__name__)
24
25 def test_restore_config(topo):
26 """
27 Check that if a dse.ldif and backup are removed, that the server still starts.
28
29 :id: e1c38fa7-30bc-46f2-a934-f8336f387581
30 :setup: Standalone instance
31 :steps:
32 1. Stop the instance
33 2. Delete 'dse.ldif'
34 3. Start the instance
35 :expectedresults:
36 1. Steps 1 and 2 succeed.
37 2. Server will succeed to start with restored cfg.
38 """
39 topo.standalone.stop()
40
41 dse_path = topo.standalone.get_config_dir()
42
43 log.info(dse_path)
44
45 for i in ('dse.ldif', 'dse.ldif.startOK'):
46 p = os.path.join(dse_path, i)
47 d = os.path.join(dse_path, i + '.49298')
48 os.rename(p, d)
49
50 # This will pass.
51 topo.standalone.start()
52
53 def test_removed_config(topo):
54 """
55 Check that if a dse.ldif and backup are removed, that the server
56 exits better than "segfault".
57
58 :id: b45272d1-c197-473e-872f-07257fcb2ec0
59 :setup: Standalone instance
60 :steps:
61 1. Stop the instance
62 2. Delete 'dse.ldif', 'dse.ldif.bak', 'dse.ldif.startOK'
63 3. Start the instance
64 :expectedresults:
65 1. Steps 1 and 2 succeed.
66 2. Server will fail to start, but will not crash.
67 """
68 topo.standalone.stop()
69
70 dse_path = topo.standalone.get_config_dir()
71
72 log.info(dse_path)
73
74 for i in ('dse.ldif', 'dse.ldif.bak', 'dse.ldif.startOK'):
75 p = os.path.join(dse_path, i)
76 d = os.path.join(dse_path, i + '.49298')
77 os.rename(p, d)
78
79 # We actually can't check the log output, because it can't read dse.ldif,
80 # don't know where to write it yet! All we want is the server fail to
81 # start here, rather than infinite run + segfault.
82 with pytest.raises(subprocess.CalledProcessError):
83 topo.standalone.start()
84
85 # Restore the files so that setup-ds.l can work
86 for i in ('dse.ldif', 'dse.ldif.bak', 'dse.ldif.startOK'):
87 p = os.path.join(dse_path, i)
88 d = os.path.join(dse_path, i + '.49298')
89 os.rename(d, p)
90