Skip to content

Commit

Permalink
DE-11 pod logs for integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
Evgeny Dmitriev committed Mar 22, 2024
1 parent 961ab03 commit 8638539
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions helm/test/integration_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,25 @@

class Helpers:
@staticmethod
def subprocess_run(cmd: str) -> subprocess.CompletedProcess:
def get_container_logs(namespace: str):
describe_cmd = f'kubectl describe po -n {namespace} -l wallarm-sidecar=enabled'
describe = subprocess.run(shlex.split(describe_cmd), capture_output=True, text=True).stdout
logger.info(f'Describe pods in "{namespace}" namespace: \n\n{describe}')
logger.info(f'End of describe pod')

logs_cmd = f'kubectl logs -n {namespace} -l wallarm-sidecar=enabled --all-containers --ignore-errors --since=1h'
logs = subprocess.run(shlex.split(logs_cmd), capture_output=True, text=True).stdout
logger.info(f'Logs from "{namespace}" namespace: \n\n{logs}')
logger.info(f'End of logs')

@staticmethod
def subprocess_run(cmd: str, namespace=None) -> subprocess.CompletedProcess:
logger.info(f'Command: {cmd}')
completed_process = subprocess.run(shlex.split(cmd), capture_output=True, text=True)
if completed_process.returncode != 0:
logger.error(completed_process.stderr)
if namespace:
Helpers.get_container_logs(namespace)
raise Exception(f'Command: {cmd} '
f'Exit code: {completed_process.returncode} '
f'Stderr: {completed_process.stderr}')
Expand All @@ -52,7 +66,7 @@ def wait_pods(namespace: str) -> None:
cmd = f'kubectl --namespace {namespace} ' \
f'wait --for=condition=Ready pods --all --timeout={WAIT_PODS_TIMEOUT}'
logger.info('Wait for all Pods ready ...')
Helpers.subprocess_run(cmd)
Helpers.subprocess_run(cmd, namespace)

@staticmethod
def delete_namespace(namespace: str) -> None:
Expand Down

0 comments on commit 8638539

Please sign in to comment.