| 1 |
# --- BEGIN COPYRIGHT BLOCK --- |
| 2 |
# Copyright (C) 2018 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 os |
| 10 |
import subprocess |
| 11 |
import pytest |
| 12 |
import logging |
| 13 |
from lib389 import DirSrv |
| 14 |
from lib389.instance.remove import remove_ds_instance |
| 15 |
from lib389._constants import ReplicaRole |
| 16 |
from test389.topologies import create_topology |
| 17 |
from lib389.utils import ds_is_older |
| 18 |
|
| 19 |
pytestmark = pytest.mark.tier0 |
| 20 |
|
| 21 |
|
| 22 |
@pytest.fixture(scope="function") |
| 23 |
def topology_st(request): |
| 24 |
"""Create DS standalone instance""" |
| 25 |
|
| 26 |
topology = create_topology({ReplicaRole.STANDALONE: 1}) |
| 27 |
|
| 28 |
def fin(): |
| 29 |
if topology.standalone.exists(): |
| 30 |
topology.standalone.delete() |
| 31 |
request.addfinalizer(fin) |
| 32 |
|
| 33 |
return topology |
| 34 |
|
| 35 |
@pytest.mark.skipif(ds_is_older('1.4.3'), reason="Backend split, lib389 supports only cn=bdb,cn=config...") |
| 36 |
@pytest.mark.parametrize("simple_allocate", (True, False)) |
| 37 |
def test_basic(topology_st, simple_allocate): |
| 38 |
"""Check that all DS directories and systemd items were removed |
| 39 |
|
| 40 |
:id: 9e8bbcda-358d-4e9c-a38c-9b4c3b63308e |
| 41 |
:parametrized: yes |
| 42 |
""" |
| 43 |
|
| 44 |
inst = topology_st.standalone |
| 45 |
|
| 46 |
# FreeIPA uses local_simple_allocate for the removal process |
| 47 |
if simple_allocate: |
| 48 |
inst = DirSrv(verbose=inst.verbose) |
| 49 |
inst.local_simple_allocate(topology_st.standalone.serverid) |
| 50 |
|
| 51 |
remove_ds_instance(inst) |
| 52 |
|
| 53 |
paths = [inst.ds_paths.backup_dir, |
| 54 |
inst.ds_paths.cert_dir, |
| 55 |
inst.ds_paths.config_dir, |
| 56 |
inst.ds_paths.db_dir, |
| 57 |
inst.get_changelog_dir(), |
| 58 |
inst.ds_paths.ldif_dir, |
| 59 |
inst.ds_paths.lock_dir, |
| 60 |
inst.ds_paths.log_dir] |
| 61 |
for path in paths: |
| 62 |
assert not os.path.exists(path) |
| 63 |
|
| 64 |
try: |
| 65 |
subprocess.check_output(['systemctl', 'is-enabled', 'dirsrv@{}'.format(inst.serverid)], encoding='utf-8') |
| 66 |
except subprocess.CalledProcessError as ex: |
| 67 |
assert "disabled" in ex.output |
| 68 |
|
| 69 |
|