Skip to content

Commit

Permalink
ADCM-2979 command clearaudit added (#97)
Browse files Browse the repository at this point in the history
* ADCM-2979 command `clearaudit` added

* ADCM-2979 logrotate call fixed

* Update setup.py
  • Loading branch information
Sealwing authored Aug 18, 2022
1 parent 85b4aae commit 1d14a98
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
packages=find_packages(where="src"),
package_dir={"": "src"},
include_package_data=True,
version="4.21.0",
version="4.22.0",
# the following makes a plugin available to pytest
entry_points={"pytest11": ["adcm_pytest_plugin = adcm_pytest_plugin.plugin"]},
# custom PyPI classifier for pytest plugins
Expand Down
21 changes: 14 additions & 7 deletions src/adcm_pytest_plugin/steps/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import os.path
import subprocess
from contextlib import contextmanager
from typing import List, Generator, Tuple, Optional, Literal
from typing import List, Generator, Tuple, Optional, Literal, Collection

import allure

Expand Down Expand Up @@ -56,21 +56,28 @@ def load_cluster(adcm: ADCM, file_path: str, password: str) -> None:

def logrotate(
adcm: ADCM, target: Optional[Literal["all", "job", "config", "nginx"]] = None, disable_logs: bool = False
):
) -> None:
"""
Run rotation of logs (job/config/nginx) with "logrotate" command.
"""
step_message = 'Run ADCM command "logrotate"'
options = []
if target is not None:
options.append(f"--target {target}")
if disable_logs:
options.append("--disable-logs")
if options:
step_message += f"with options: {' '.join(options)}"

with allure.step(step_message):
command = "logrotate"
_run_command(adcm, "logrotate", options)


def clearaudit(adcm: ADCM) -> None:
"""
Run audit log cleanup with "clearaudit" command
"""
_run_command(adcm, "clearaudit")


def _run_command(adcm: ADCM, command: str, options: Optional[Collection[str]] = ()):
with allure.step(f'Run ADCM command "{command}"' + (f" with options {' '.join(options)}" if options else "")):
exit_code, output = _run_with_docker_exec(
adcm,
[
Expand Down

0 comments on commit 1d14a98

Please sign in to comment.