| |
@@ -0,0 +1,53 @@
|
| |
+ # --- BEGIN COPYRIGHT BLOCK ---
|
| |
+ # Copyright (C) 2018 Red Hat, Inc.
|
| |
+ # All rights reserved.
|
| |
+ #
|
| |
+ # License: GPL (version 3 or any later version).
|
| |
+ # See LICENSE for details.
|
| |
+ # --- END COPYRIGHT BLOCK ---
|
| |
+
|
| |
+ import os
|
| |
+ import subprocess
|
| |
+ import pytest
|
| |
+ from lib389.instance.remove import remove_ds_instance
|
| |
+ from lib389._constants import ReplicaRole
|
| |
+ from lib389.topologies import create_topology
|
| |
+
|
| |
+
|
| |
+ @pytest.fixture(scope="module")
|
| |
+ def topology_st(request):
|
| |
+ """Create DS standalone instance"""
|
| |
+
|
| |
+ topology = create_topology({ReplicaRole.STANDALONE: 1})
|
| |
+
|
| |
+ def fin():
|
| |
+ if topology.standalone.exists():
|
| |
+ topology.standalone.delete()
|
| |
+ request.addfinalizer(fin)
|
| |
+
|
| |
+ return topology
|
| |
+
|
| |
+
|
| |
+ def test_basic(topology_st):
|
| |
+ """Check that all DS directories and systemd items were removed"""
|
| |
+
|
| |
+ inst = topology_st.standalone
|
| |
+
|
| |
+ remove_ds_instance(inst)
|
| |
+
|
| |
+ paths = [inst.ds_paths.backup_dir,
|
| |
+ inst.ds_paths.cert_dir,
|
| |
+ inst.ds_paths.config_dir,
|
| |
+ inst.ds_paths.db_dir,
|
| |
+ inst.get_changelog_dir(),
|
| |
+ inst.ds_paths.ldif_dir,
|
| |
+ inst.ds_paths.lock_dir,
|
| |
+ inst.ds_paths.log_dir,
|
| |
+ "{}/sysconfig/dirsrv-{}".format(inst.ds_paths.sysconf_dir, inst.serverid)]
|
| |
+ for path in paths:
|
| |
+ assert not os.path.exists(path)
|
| |
+
|
| |
+ try:
|
| |
+ subprocess.check_output(['systemctl', 'is-enabled', 'dirsrv@{}'.format(inst.serverid)], encoding='utf-8')
|
| |
+ except subprocess.CalledProcessError as ex:
|
| |
+ assert "disabled" in ex.output
|
| |
Bug description: When running remove_ds_instance(), it does not remove
the systemd files that identify this instance.
Also, in previous DS versions, the /etc/dirsrv/slapd-INSTANCE
would have been moved to /etc/dirsrv/slapd-INSTANCE.removed.
This does not happen now.
Fix description: Change remove_ds_instance function so it disables systemd unit
and, in the result, it will remove symlinks. Also make the function
move the config_dir to config_dir.removed as remove-ds.pl does.
Add a basic test to src/lib389/lib389/tests/instance/remove_test.py
Fix local_simple_allocate, so it sets serverid properly.
Reviewed by: ?
https://pagure.io/389-ds-base/issue/49612