Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dt/audit: Wait for OCSF server to really come up #14775

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions tests/docker/ducktape-deps/ocsf-server
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,11 @@ mix local.hex --force && mix local.rebar --force

pushd /opt/ocsf-server
./build_server.sh
# The following is required because the server attempts to write logs
# to the `dist/tmp` directory. This is fine in docker ducktape as the user
# who kicks it off is root, but in CDT, the user is not root so the server
# fails to start causing audit log tests to fail
mkdir dist/tmp
chmod a+w dist/tmp
openssl req -new -newkey rsa:2048 -sha256 -days 365 -nodes -x509 -keyout server.key -out server.crt -subj "/O=Redpanda" -batch
popd
17 changes: 16 additions & 1 deletion tests/rptest/services/ocsf_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

from ducktape.cluster.remoteaccount import RemoteCommandError
from ducktape.services.service import Service
from rptest.util import wait_until_result
from rptest.util import wait_until, wait_until_result

SERVER_DIR = '/opt/ocsf-server'
SCHEMA_DIR = '/opt/ocsf-schema'
Expand Down Expand Up @@ -142,6 +142,21 @@ def start_node(self, node):
self.logger.debug(f'Starting OCSF Server with cmd "{cmd}"')
node.account.ssh(cmd, allow_fail=False)

def _wait_for_version():
try:
_ = self.get_api_version()
return True
except Exception:
# Ignore exceptions as server may be coming up and
# connections may time out
pass
return False

wait_until(_wait_for_version,
timeout_sec=10,
backoff_sec=1,
err_msg='Failed to get version from server during startup')

def stop_node(self, node):
cmd = self._stop_cmd()
self.logger.debug(f'Stopping OCSF server with cmd "{cmd}"')
Expand Down
Loading