-
Notifications
You must be signed in to change notification settings - Fork 586
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
redpanda: verify enterprise license on upgrade
Introduces stict checking of the enterprise license on upgrade when enterprise features are used in the cluster.
- Loading branch information
Showing
4 changed files
with
202 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
# Copyright 2024 Redpanda Data, Inc. | ||
# | ||
# Use of this software is governed by the Business Source License | ||
# included in the file licenses/BSL.md | ||
# | ||
# As of the Change Date specified in that file, in accordance with | ||
# the Business Source License, use of this software will be governed | ||
# by the Apache License, Version 2.0 | ||
|
||
import re | ||
|
||
from ducktape.mark import parametrize | ||
|
||
from rptest.services.cluster import cluster | ||
from rptest.clients.rpk import RpkTool | ||
from rptest.services.redpanda import LoggingConfig | ||
from rptest.tests.redpanda_test import RedpandaTest | ||
from rptest.services.redpanda_installer import RedpandaVersionTriple | ||
from rptest.util import get_cluster_license | ||
|
||
|
||
class LicenseEnforcementTest(RedpandaTest): | ||
# Disable log checks because it is not very useful when we expect to crash nodes on license upgrades | ||
LOG_ALLOW_LIST = [re.compile(".*")] | ||
|
||
def __init__(self, *args, **kwargs): | ||
super().__init__(*args, | ||
num_brokers=5, | ||
extra_rp_conf={}, | ||
log_config=LoggingConfig('info', | ||
logger_levels={ | ||
'cluster': 'debug', | ||
'features': 'debug' | ||
}), | ||
**kwargs) | ||
|
||
self.rpk = RpkTool(self.redpanda) | ||
|
||
def setUp(self): | ||
# start the nodes manually | ||
pass | ||
|
||
@cluster(num_nodes=5, log_allow_list=LOG_ALLOW_LIST) | ||
@parametrize(clean_node=True) | ||
@parametrize(clean_node=False) | ||
def test_license_enforcement(self, clean_node): | ||
installer = self.redpanda._installer | ||
|
||
# TODO: use highest_from_prior_feature_version | ||
prev_version = RedpandaVersionTriple((24, 1, 16)) | ||
# prev_version = installer.highest_from_prior_feature_version(RedpandaInstaller.HEAD) | ||
latest_version = installer.head_version() | ||
self.logger.info( | ||
f"Testing with versions: {prev_version=} {latest_version=}") | ||
|
||
self.logger.info(f"Starting all nodes with version: {prev_version}") | ||
installer.install(self.redpanda.nodes, prev_version) | ||
self.redpanda.start(nodes=self.redpanda.nodes, | ||
omit_seeds_on_idx_one=False) | ||
|
||
self.redpanda.wait_until(self.redpanda.healthy, 60, 1) | ||
|
||
self.logger.info(f"Enabling an enterprise feature") | ||
self.rpk.create_role("XYZ") | ||
|
||
first_upgraded = self.redpanda.nodes[0] | ||
self.logger.info( | ||
f"Upgrading node {first_upgraded} expecting it to crash") | ||
installer.install([first_upgraded], latest_version) | ||
# TODO: consider using maintenance mode to more closely match the recommended upgrade process | ||
self.redpanda.stop_node(first_upgraded) | ||
|
||
if clean_node: | ||
self.logger.info(f"Cleaning node {first_upgraded}") | ||
self.redpanda.remove_local_data(first_upgraded) | ||
# We could decomissions the old node here for a cleaner test, | ||
# but having 1 ghost node in a 5(+1) node cluster is still okay | ||
|
||
self.redpanda.start_node(first_upgraded, | ||
auto_assign_node_id=True, | ||
omit_seeds_on_idx_one=False, | ||
expect_fail=True) | ||
|
||
self.logger.info( | ||
f"Recover the node by downgrading, installing a test license and trying again {first_upgraded}" | ||
) | ||
license = get_cluster_license() | ||
assert license, "Setting the license is required for this test" | ||
|
||
output = self.rpk.license_set("", license) | ||
assert "Successfully uploaded license" in output | ||
|
||
self.logger.info( | ||
f"Recover the node by downgrading and then upgrading again") | ||
installer.install([first_upgraded], prev_version) | ||
self.redpanda.start_node(first_upgraded, | ||
auto_assign_node_id=True, | ||
omit_seeds_on_idx_one=False) | ||
|
||
installer.install([first_upgraded], latest_version) | ||
|
||
# TODO: we could clean the data directory here again during restart to verify that | ||
# we can start a fresh node based on the controller snapshot of other nodes | ||
|
||
self.redpanda.restart_nodes(first_upgraded, | ||
auto_assign_node_id=True, | ||
omit_seeds_on_idx_one=False) | ||
|
||
@cluster(num_nodes=5) | ||
def test_enterprise_cluster_bootstrap(self): | ||
self.logger.info( | ||
"Bootstrapping an enterprise cluster without a license") | ||
# TODO: test with other enterprise features as well | ||
self.redpanda.add_extra_rp_conf( | ||
{"partition_autobalancing_mode": "continuous"}) | ||
self.redpanda.start(nodes=self.redpanda.nodes, | ||
omit_seeds_on_idx_one=False) | ||
|
||
self.redpanda.wait_until(self.redpanda.healthy, 60, 1) |