Skip to content

Commit

Permalink
ducktape: Centralise has_license_nag
Browse files Browse the repository at this point in the history
Signed-off-by: Ben Pope <ben@redpanda.com>
  • Loading branch information
BenPope committed Nov 25, 2024
1 parent ee98e07 commit 5d58e71
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 38 deletions.
5 changes: 5 additions & 0 deletions tests/rptest/services/redpanda.py
Original file line number Diff line number Diff line change
Expand Up @@ -2477,6 +2477,8 @@ def copy_from_pod(params):

class RedpandaService(RedpandaServiceBase):

ENTERPRISE_LICENSE_NAG = "license is required to use enterprise features"

nodes: list[ClusterNode]

def __init__(self,
Expand Down Expand Up @@ -5414,6 +5416,9 @@ def license_observable():
err_msg="Inserted license not observable in time")
self.logger.debug("Enterprise License installed successfully")

def has_license_nag(self):
return self.search_log_any(self.ENTERPRISE_LICENSE_NAG)


def make_redpanda_service(context: TestContext,
num_brokers: int | None,
Expand Down
3 changes: 2 additions & 1 deletion tests/rptest/tests/audit_log_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2252,7 +2252,8 @@ def test_sanctioning_mode(self):
self.super_rpk.consume(self.audit_log)

self.redpanda.search_log_any(
"An enterprise license is required to consume the audit log topic")
f"{self.redpanda.ENTERPRISE_LICENSE_NAG} to consume the audit log topic"
)

self.redpanda.logger.debug(
"Install a license to get out of sanctioning mode")
Expand Down
8 changes: 2 additions & 6 deletions tests/rptest/tests/rbac_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -633,10 +633,6 @@ def __init__(self, test_ctx, **kwargs):
f'{self.LICENSE_CHECK_INTERVAL_SEC}'
})

def _has_license_nag(self):
return self.redpanda.search_log_any(
"license is required to use enterprise features")

def _license_nag_is_set(self):
return self.redpanda.search_log_all(
f"Overriding default license log annoy interval to: {self.LICENSE_CHECK_INTERVAL_SEC}s"
Expand All @@ -653,7 +649,7 @@ def test_license_nag(self):
time.sleep(self.LICENSE_CHECK_INTERVAL_SEC * 2)
# NOTE: This assertion will FAIL if running in FIPS mode because
# being in FIPS mode will trigger the license nag
assert not self._has_license_nag()
assert not self.redpanda.has_license_nag()

self.logger.debug("Adding a role")
self.superuser_admin.create_role(role=self.role_name0)
Expand All @@ -667,7 +663,7 @@ def test_license_nag(self):
err_msg="Failed to set license nag internal")

self.logger.debug("Waiting for license nag")
wait_until(self._has_license_nag,
wait_until(self.redpanda.has_license_nag,
timeout_sec=self.LICENSE_CHECK_INTERVAL_SEC * 2,
err_msg="License nag failed to appear")

Expand Down
6 changes: 1 addition & 5 deletions tests/rptest/tests/rbac_upgrade_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,6 @@ def setUp(self):
self.installer.install(self.redpanda.nodes, (23, 3))
super().setUp()

def _has_license_nag(self):
return self.redpanda.search_log_any(
"license is required to use enterprise features")

@cluster(num_nodes=3, log_allow_list=RESTART_LOG_ALLOW_LIST)
@skip_fips_mode # See NOTE below
def test_rbac_migration(self):
Expand Down Expand Up @@ -84,4 +80,4 @@ def default_role_created():
# NOTE: This assertion will FAIL if running in FIPS mode because
# being in FIPS mode will trigger the license nag
time.sleep(self.LICENSE_CHECK_INTERVAL_SEC * 2)
assert not self._has_license_nag()
assert not self.redpanda.has_license_nag()
8 changes: 2 additions & 6 deletions tests/rptest/tests/redpanda_kerberos_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,6 @@ def __init__(self, test_context, num_nodes=3, **kwargs):
f'{self.LICENSE_CHECK_INTERVAL_SEC}',
})

def _has_license_nag(self):
return self.redpanda.search_log_any(
"license is required to use enterprise features")

def _license_nag_is_set(self):
return self.redpanda.search_log_all(
f"Overriding default license log annoy interval to: {self.LICENSE_CHECK_INTERVAL_SEC}s"
Expand All @@ -190,7 +186,7 @@ def test_license_nag(self):
time.sleep(self.LICENSE_CHECK_INTERVAL_SEC * 2)
# NOTE: This assertion will FAIL if running in FIPS mode because
# being in FIPS mode will trigger the license nag
assert not self._has_license_nag()
assert not self.redpanda.has_license_nag()

self.logger.debug("Setting cluster config")
self.redpanda.set_cluster_config(
Expand All @@ -206,7 +202,7 @@ def test_license_nag(self):
err_msg="Failed to set license nag internal")

self.logger.debug("Waiting for license nag")
wait_until(self._has_license_nag,
wait_until(self.redpanda.has_license_nag,
timeout_sec=self.LICENSE_CHECK_INTERVAL_SEC * 2,
err_msg="License nag failed to appear")

Expand Down
8 changes: 2 additions & 6 deletions tests/rptest/tests/redpanda_oauth_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -612,10 +612,6 @@ def __init__(self, test_context, num_nodes=3, **kwargs):
f'{self.LICENSE_CHECK_INTERVAL_SEC}',
})

def _has_license_nag(self):
return self.redpanda.search_log_any(
"license is required to use enterprise features")

def _license_nag_is_set(self):
return self.redpanda.search_log_all(
f"Overriding default license log annoy interval to: {self.LICENSE_CHECK_INTERVAL_SEC}s"
Expand All @@ -634,7 +630,7 @@ def test_license_nag(self, authn_config):
time.sleep(self.LICENSE_CHECK_INTERVAL_SEC * 2)
# NOTE: This assertion will FAIL if running in FIPS mode because
# being in FIPS mode will trigger the license nag
assert not self._has_license_nag()
assert not self.redpanda.has_license_nag()

self.logger.debug("Setting cluster config")
self.redpanda.set_cluster_config(authn_config)
Expand All @@ -649,6 +645,6 @@ def test_license_nag(self, authn_config):
err_msg="Failed to set license nag internal")

self.logger.debug("Waiting for license nag")
wait_until(self._has_license_nag,
wait_until(self.redpanda.has_license_nag,
timeout_sec=self.LICENSE_CHECK_INTERVAL_SEC * 2,
err_msg="License nag failed to appear")
8 changes: 2 additions & 6 deletions tests/rptest/tests/redpanda_startup_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,10 +249,6 @@ def __init__(self, test_context):
True
})

def _has_license_nag(self) -> bool:
return self.redpanda.search_log_any(
"license is required to use enterprise features")

def _license_nag_is_set(self) -> bool:
return self.redpanda.search_log_all(
f"Overriding default license log annoy interval to: {self.LICENSE_CHECK_INTERVAL_SEC}s"
Expand All @@ -267,7 +263,7 @@ def test_fips_license_nag(self):

self.logger.debug("Ensuring no license nag")
sleep(self.LICENSE_CHECK_INTERVAL_SEC * 2)
assert not self._has_license_nag(
assert not self.redpanda.has_license_nag(
), "Should not have license nag yet, FIPS mode not enabled"

fips_mode = RedpandaServiceBase.FIPSMode.enabled if in_fips_environment(
Expand All @@ -282,6 +278,6 @@ def test_fips_license_nag(self):
self.redpanda.restart_nodes(self.redpanda.nodes,
override_cfg_params=fips_config)

wait_until(self._has_license_nag,
wait_until(self.redpanda.has_license_nag,
timeout_sec=30,
err_msg="License nag failed to appear")
8 changes: 2 additions & 6 deletions tests/rptest/tests/schema_registry_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3843,10 +3843,6 @@ def __init__(self, *args, **kwargs):
f'{self.LICENSE_CHECK_INTERVAL_SEC}',
})

def _has_license_nag(self):
return self.redpanda.search_log_any(
"license is required to use enterprise features")

def _license_nag_is_set(self):
return self.redpanda.search_log_all(
f"Overriding default license log annoy interval to: {self.LICENSE_CHECK_INTERVAL_SEC}s"
Expand All @@ -3865,7 +3861,7 @@ def test_license_nag(self, mode):
time.sleep(self.LICENSE_CHECK_INTERVAL_SEC * 2)
# NOTE: This assertion will FAIL if running in FIPS mode because
# being in FIPS mode will trigger the license nag
assert not self._has_license_nag()
assert not self.redpanda.has_license_nag()

self.logger.debug("Setting cluster config")
self.redpanda.set_cluster_config({"enable_schema_id_validation": mode})
Expand All @@ -3880,7 +3876,7 @@ def test_license_nag(self, mode):
err_msg="Failed to set license nag internal")

self.logger.debug("Waiting for license nag")
wait_until(self._has_license_nag,
wait_until(self.redpanda.has_license_nag,
timeout_sec=self.LICENSE_CHECK_INTERVAL_SEC * 2,
err_msg="License nag failed to appear")

Expand Down
3 changes: 1 addition & 2 deletions tests/rptest/tests/workload_license.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,7 @@ def on_cluster_upgraded(self, version: tuple[int, int, int]) -> int:
return PWorkload.NOT_DONE

# check for License nag in the log
assert self.ctx.redpanda.search_log_any(
"license is required to use enterprise features"
assert self.ctx.redpanda.has_license_nag(
), "License nag log not found"

# Install license
Expand Down

0 comments on commit 5d58e71

Please sign in to comment.