Skip to content

Commit eae746e

Browse files
committed
validator: adjust services IPs to support multiple VS nodes
Move ScyllaDB nodes IP last octets from 2-254 to 1-127. Move Vector Store node IP last octets from 1 to 128-254. This setup supports adding more ScyllaDB and Vector Store nodes in testing if needed. Changed `VS_NAME` to a list of available DNS names for Vector Store nodes. Now the names are `vs1`, `vs2`, `vs3`, and more if needed. Renamed `get_default_vs_url` function to `get_default_vs_urls` and adjusted it to return URLs of three default Vector Store nodes. Added `get_default_vs_ips` function to return vector of three default Vector Store node IPs (not to confuse with DNS names). Adjusted `get_default_node_configs` so that now the default nodes does support one primary Vector Store node and two secondary ones.
1 parent 8afbf54 commit eae746e

File tree

3 files changed

+56
-31
lines changed

3 files changed

+56
-31
lines changed

crates/validator-tests/src/common.rs

Lines changed: 40 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -26,23 +26,32 @@ pub use vector_store::httproutes::IndexStatus;
2626

2727
pub const DEFAULT_TEST_TIMEOUT: Duration = Duration::from_secs(120);
2828

29-
pub const VS_NAME: &str = "vs";
29+
pub const VS_NAMES: [&str; 3] = ["vs1", "vs2", "vs3"];
3030

3131
pub const VS_PORT: u16 = 6080;
3232
pub const DB_PORT: u16 = 9042;
3333

34-
pub const VS_OCTET: u8 = 1;
35-
pub const DB_OCTET_1: u8 = 2;
36-
pub const DB_OCTET_2: u8 = 3;
37-
pub const DB_OCTET_3: u8 = 4;
38-
39-
pub async fn get_default_vs_url(actors: &TestActors) -> String {
40-
format!(
41-
"http://{}.{}:{}",
42-
VS_NAME,
43-
actors.dns.domain().await,
44-
VS_PORT
45-
)
34+
pub const DB_OCTET_1: u8 = 1;
35+
pub const DB_OCTET_2: u8 = 2;
36+
pub const DB_OCTET_3: u8 = 3;
37+
pub const VS_OCTET_1: u8 = 128;
38+
pub const VS_OCTET_2: u8 = 129;
39+
pub const VS_OCTET_3: u8 = 130;
40+
41+
pub async fn get_default_vs_urls(actors: &TestActors) -> Vec<String> {
42+
let domain = actors.dns.domain().await;
43+
VS_NAMES
44+
.iter()
45+
.map(|name| format!("http://{}.{}:{}", name, domain, VS_PORT))
46+
.collect()
47+
}
48+
49+
pub fn get_default_vs_ips(actors: &TestActors) -> Vec<Ipv4Addr> {
50+
vec![
51+
actors.services_subnet.ip(VS_OCTET_1),
52+
actors.services_subnet.ip(VS_OCTET_2),
53+
actors.services_subnet.ip(VS_OCTET_3),
54+
]
4655
}
4756

4857
pub fn get_default_db_ips(actors: &TestActors) -> Vec<Ipv4Addr> {
@@ -54,23 +63,28 @@ pub fn get_default_db_ips(actors: &TestActors) -> Vec<Ipv4Addr> {
5463
}
5564

5665
pub async fn get_default_node_configs(actors: &TestActors) -> Vec<ScyllaNodeConfig> {
57-
let vs_url = get_default_vs_url(actors).await;
66+
let vs_urls = get_default_vs_urls(actors).await;
5867
get_default_db_ips(actors)
5968
.iter()
60-
.map(|&ip| ScyllaNodeConfig {
61-
db_ip: ip,
62-
primary_vs_uris: vec![vs_url.clone()],
63-
secondary_vs_uris: vec![],
69+
.enumerate()
70+
.map(|(i, &ip)| {
71+
let mut vs_urls = vs_urls.clone();
72+
ScyllaNodeConfig {
73+
db_ip: ip,
74+
primary_vs_uris: vec![vs_urls.remove(i)],
75+
secondary_vs_uris: vs_urls,
76+
}
6477
})
6578
.collect()
6679
}
6780

6881
pub async fn init(actors: TestActors) {
6982
info!("started");
7083

71-
let vs_ip = actors.services_subnet.ip(VS_OCTET);
72-
73-
actors.dns.upsert(VS_NAME.to_string(), vs_ip).await;
84+
let vs_ips = get_default_vs_ips(&actors);
85+
for (name, ip) in VS_NAMES.iter().zip(vs_ips.iter()) {
86+
actors.dns.upsert(name.to_string(), *ip).await;
87+
}
7488

7589
let node_configs: Vec<ScyllaNodeConfig> = get_default_node_configs(&actors).await;
7690
let db_ip = node_configs.first().unwrap().db_ip; // Use the first DB node for vector store connection
@@ -80,7 +94,7 @@ pub async fn init(actors: TestActors) {
8094
actors
8195
.vs
8296
.start(
83-
(vs_ip, VS_PORT).into(),
97+
(vs_ips[0], VS_PORT).into(),
8498
(db_ip, DB_PORT).into(),
8599
HashMap::new(),
86100
)
@@ -92,7 +106,9 @@ pub async fn init(actors: TestActors) {
92106

93107
pub async fn cleanup(actors: TestActors) {
94108
info!("started");
95-
actors.dns.remove(VS_NAME.to_string()).await;
109+
for name in VS_NAMES.iter() {
110+
actors.dns.remove(name.to_string()).await;
111+
}
96112
actors.vs.stop().await;
97113
actors.db.stop().await;
98114
info!("finished");
@@ -106,7 +122,7 @@ pub async fn prepare_connection(actors: &TestActors) -> (Arc<Session>, HttpClien
106122
.await
107123
.expect("failed to create session"),
108124
);
109-
let client = HttpClient::new((actors.services_subnet.ip(VS_OCTET), VS_PORT).into());
125+
let client = HttpClient::new((actors.services_subnet.ip(VS_OCTET_1), VS_PORT).into());
110126
(session, client)
111127
}
112128

crates/validator-vector-store/src/high_availability.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,11 @@ pub(crate) async fn new() -> TestCase {
1919
}
2020

2121
async fn init_one_primary_two_secondary(actors: TestActors) {
22-
let vs_ip = actors.services_subnet.ip(VS_OCTET);
23-
actors.dns.upsert(VS_NAME.to_string(), vs_ip).await;
22+
let vs_ip = actors.services_subnet.ip(VS_OCTET_1);
23+
actors.dns.upsert(VS_NAMES[0].to_string(), vs_ip).await;
2424

25-
let vs_url = get_default_vs_url(&actors).await;
25+
let vs_urls = get_default_vs_urls(&actors).await;
26+
let vs_url = &vs_urls[0];
2627

2728
let node_configs: Vec<ScyllaNodeConfig> = vec![
2829
ScyllaNodeConfig {

crates/validator-vector-store/src/memory_limit.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,11 @@ async fn memory_limit_during_index_build(actors: TestActors) {
3535
info!("started");
3636

3737
// Start DB
38-
let vs_ip = actors.services_subnet.ip(common::VS_OCTET);
39-
actors.dns.upsert(common::VS_NAME.to_string(), vs_ip).await;
38+
let vs_ip = actors.services_subnet.ip(common::VS_OCTET_1);
39+
actors
40+
.dns
41+
.upsert(common::VS_NAMES[0].to_string(), vs_ip)
42+
.await;
4043
let node_configs = common::get_default_node_configs(&actors).await;
4144
let db_ip = node_configs.first().unwrap().db_ip;
4245
actors.db.start(node_configs.clone(), None).await;
@@ -104,8 +107,13 @@ async fn memory_limit_during_index_build(actors: TestActors) {
104107
assert!(actors.vs.wait_for_ready().await);
105108

106109
// Create index
107-
let client =
108-
HttpClient::new((actors.services_subnet.ip(common::VS_OCTET), common::VS_PORT).into());
110+
let client = HttpClient::new(
111+
(
112+
actors.services_subnet.ip(common::VS_OCTET_1),
113+
common::VS_PORT,
114+
)
115+
.into(),
116+
);
109117

110118
let index = common::create_index(&session, &client, &table, "v").await;
111119

0 commit comments

Comments
 (0)