-
Notifications
You must be signed in to change notification settings - Fork 599
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Bugen Zhao <[email protected]>
- Loading branch information
Showing
3 changed files
with
71 additions
and
4 deletions.
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
67 changes: 67 additions & 0 deletions
67
src/tests/simulation/tests/integration_tests/license_cpu_limit.rs
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,67 @@ | ||
// Copyright 2025 RisingWave Labs | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
use anyhow::Result; | ||
use risingwave_common::error::AsReport; | ||
use risingwave_simulation::cluster::{Cluster, Configuration}; | ||
use risingwave_simulation::utils::AssertResult; | ||
|
||
const KEY_20: &str = "eyJhbGciOiJSUzUxMiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJwYWlkLXRlc3QtMzIiLCJpc3MiOiJ0ZXN0LnJpc2luZ3dhdmUuY29tIiwidGllciI6InBhaWQiLCJleHAiOjIxNTA0OTU5OTksImlhdCI6MTczNzYxNTI2NywiY3B1X2NvcmVfbGltaXQiOjIwfQ.V8546BDZydv1aNk8IlVaSVlCriDtMC_75nq8CIaRPKlrltcwRJYKfK-Ru3WbKj-MDFebmW_3CqA4jR77BBtmmmtj-lPHa4qrdgrMItxm9RC_qoSU1YbI8Kb_ClYkrnFug5MAbK3wGlO8CrrjqOOt-Q5ggKChtl0uFj4zgI-S80d8Hse5LYSKHv8cU-ECKvEFe451kXE9x7nN_f8MqTSOqBwfY5o17gTD8oU3XH2k1mpesdci18kDmJPK5DeLPDYht_nRt7WGbVQvx7iiol1nzj5OBjdH_eVbX7pfk9M-JNwqZKaqfOmBbwV2F-Sf7-tK33O-XqSfXjnLAzflfjkoLQ"; | ||
const KEY_100: &str = "eyJhbGciOiJSUzUxMiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJwYWlkLXRlc3QtMzIiLCJpc3MiOiJ0ZXN0LnJpc2luZ3dhdmUuY29tIiwidGllciI6InBhaWQiLCJleHAiOjIxNTA0OTU5OTksImlhdCI6MTczNzYyMzc2MywiY3B1X2NvcmVfbGltaXQiOjEwMH0.ZGQjZa6t3va5MHMHKvgMgOXVLymEvvy1Yvd6teRUgCIF7en5BYaKXWuXwwtWLpLxr7LXyIQ3LQeDXag4k_fQOUTwV4oYTLTFVF8GcJ8JvGdTjBfjnM_2helLEhjZFgXSnhEy-xTOj5yM0BbqKCwanYlSODXQtp5owalt7a0JDwpId9_O8Pl24CjImZzPZLevJ_wSu4wv2IhVjK5QhkfBKBeaOxCeJaKfMVT5AzDQ-WwtJwahr1Dk0H2BxD6Hmp4KKBFRlVwGxq9-8uKBpbrmlClSuxPreBJ_xhP3SHtBFbVfcr38uaT_Bdh-gPRPgi-59tKOWPCY2FytO-Ls1U2l7w"; | ||
|
||
#[tokio::test] | ||
async fn test_license_cpu_limit() -> Result<()> { | ||
let mut cluster = Cluster::start(Configuration { | ||
compute_nodes: 3, | ||
compute_node_cores: 8, | ||
..Default::default() | ||
}) | ||
.await?; | ||
|
||
let mut session = cluster.start_session(); | ||
|
||
macro_rules! set_license_key { | ||
($key:expr) => { | ||
session | ||
.run(format!("ALTER SYSTEM SET license_key TO '{}';", $key)) | ||
.await?; | ||
}; | ||
} | ||
|
||
macro_rules! test_paid_tier { | ||
() => { | ||
session.run("SELECT rw_test_paid_tier();").await | ||
}; | ||
} | ||
|
||
set_license_key!(""); | ||
let error = test_paid_tier!().unwrap_err().to_report_string(); | ||
assert!(error.contains("feature TestPaid is only available for tier Paid and above, while the current tier is Free"), "{error}"); | ||
|
||
set_license_key!(KEY_100); | ||
test_paid_tier!().unwrap().assert_result_eq("true"); | ||
|
||
set_license_key!(KEY_20); | ||
let error = test_paid_tier!().unwrap_err().to_report_string(); | ||
assert!( | ||
error.contains("the license key is currently not effective"), | ||
"{error}" | ||
); | ||
|
||
cluster.simple_kill_nodes(["compute-2"]).await; | ||
tokio::time::sleep(std::time::Duration::from_secs(100)).await; | ||
test_paid_tier!().unwrap().assert_result_eq("true"); | ||
|
||
Ok(()) | ||
} |
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