Skip to content

Commit f1b3127

Browse files
..
1 parent 18e3821 commit f1b3127

File tree

1 file changed

+73
-108
lines changed
  • dpd-client/tests/integration_tests

1 file changed

+73
-108
lines changed

dpd-client/tests/integration_tests/mcast.rs

Lines changed: 73 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -3842,52 +3842,46 @@ async fn test_multicast_reset_all_tables() -> TestResult {
38423842
async fn test_multicast_group_id_recycling() -> TestResult {
38433843
let switch = &*get_switch().await;
38443844

3845-
let egress = PhysPort(28);
3846-
let internal_multicast_ip = IpAddr::V6(MULTICAST_NAT_IP);
3847-
let underlay_group = create_test_multicast_group(
3848-
switch,
3849-
internal_multicast_ip,
3850-
Some("recycling_test_underlay"),
3851-
&[(egress, types::Direction::Underlay)],
3852-
None,
3853-
false,
3854-
None,
3855-
)
3856-
.await;
3845+
let (port_id, link_id) = switch.link_id(PhysPort(28)).unwrap();
38573846

3858-
let group_ip1 = IpAddr::V4(MULTICAST_TEST_IPV4);
3859-
let nat_target = create_nat_target_ipv4();
3860-
let external_create1 = types::MulticastGroupCreateExternalEntry {
3847+
let group_ip1: Ipv6Addr = "ff04::100".parse().unwrap();
3848+
let internal_create1 = types::MulticastGroupCreateEntry {
38613849
group_ip: group_ip1,
38623850
tag: Some("recycling_test_1".to_string()),
3863-
nat_target: nat_target.clone(),
3864-
vlan_id: Some(10),
38653851
sources: None,
3852+
members: vec![types::MulticastGroupMember {
3853+
port_id,
3854+
link_id,
3855+
direction: types::Direction::External,
3856+
}],
38663857
};
38673858

38683859
let created_group1 = switch
38693860
.client
3870-
.multicast_group_create_external(&external_create1)
3861+
.multicast_group_create(&internal_create1)
38713862
.await?
38723863
.into_inner();
38733864

38743865
let first_external_id = created_group1.external_group_id;
38753866
let first_underlay_id = created_group1.underlay_group_id;
38763867

3877-
switch.client.multicast_group_delete(&group_ip1).await?;
3868+
switch.client.multicast_group_delete(&group_ip1.into()).await?;
38783869

3879-
let group_ip2 = IpAddr::V4(Ipv4Addr::new(224, 0, 1, 100));
3880-
let external_create2 = types::MulticastGroupCreateExternalEntry {
3870+
let group_ip2: Ipv6Addr = "ff04::101".parse().unwrap();
3871+
let internal_create2 = types::MulticastGroupCreateEntry {
38813872
group_ip: group_ip2,
38823873
tag: Some("recycling_test_2".to_string()),
3883-
nat_target: nat_target.clone(),
3884-
vlan_id: Some(10),
38853874
sources: None,
3875+
members: vec![types::MulticastGroupMember {
3876+
port_id,
3877+
link_id,
3878+
direction: types::Direction::External,
3879+
}],
38863880
};
38873881

38883882
let created_group2 = switch
38893883
.client
3890-
.multicast_group_create_external(&external_create2)
3884+
.multicast_group_create(&internal_create2)
38913885
.await?
38923886
.into_inner();
38933887

@@ -3896,22 +3890,25 @@ async fn test_multicast_group_id_recycling() -> TestResult {
38963890
"Second group should have external group ID"
38973891
);
38983892
assert!(
3899-
created_group2.underlay_group_id.is_some(),
3900-
"Second group should have underlay group ID"
3893+
created_group2.underlay_group_id.is_none(),
3894+
"Second group should not have underlay group ID"
39013895
);
39023896

3903-
let group_ip3 = IpAddr::V4(Ipv4Addr::new(224, 0, 1, 101));
3904-
let external_create3 = types::MulticastGroupCreateExternalEntry {
3897+
let group_ip3: Ipv6Addr = "ff04::102".parse().unwrap();
3898+
let internal_create3 = types::MulticastGroupCreateEntry {
39053899
group_ip: group_ip3,
39063900
tag: Some("recycling_test_3".to_string()),
3907-
nat_target: nat_target.clone(),
3908-
vlan_id: Some(10),
39093901
sources: None,
3902+
members: vec![types::MulticastGroupMember {
3903+
port_id,
3904+
link_id,
3905+
direction: types::Direction::External,
3906+
}],
39103907
};
39113908

39123909
let created_group3 = switch
39133910
.client
3914-
.multicast_group_create_external(&external_create3)
3911+
.multicast_group_create(&internal_create3)
39153912
.await?
39163913
.into_inner();
39173914

@@ -3920,13 +3917,12 @@ async fn test_multicast_group_id_recycling() -> TestResult {
39203917
"Third group should have external group ID"
39213918
);
39223919
assert!(
3923-
created_group3.underlay_group_id.is_some(),
3924-
"Third group should have underlay group ID"
3920+
created_group3.underlay_group_id.is_none(),
3921+
"Third group should not have underlay group ID"
39253922
);
39263923

3927-
cleanup_test_group(switch, group_ip2).await;
3928-
cleanup_test_group(switch, group_ip3).await;
3929-
cleanup_test_group(switch, internal_multicast_ip).await;
3924+
cleanup_test_group(switch, group_ip2.into()).await;
3925+
cleanup_test_group(switch, group_ip3.into()).await;
39303926

39313927
Ok(())
39323928
}
@@ -3936,62 +3932,51 @@ async fn test_multicast_group_id_recycling() -> TestResult {
39363932
async fn test_multicast_group_id_reuse() -> TestResult {
39373933
let switch = &*get_switch().await;
39383934

3939-
let egress = PhysPort(29);
3940-
let internal_multicast_ip = IpAddr::V6(MULTICAST_NAT_IP);
3941-
let underlay_group = create_test_multicast_group(
3942-
switch,
3943-
internal_multicast_ip,
3944-
Some("id_reuse_test_underlay"),
3945-
&[(egress, types::Direction::Underlay)],
3946-
None,
3947-
false,
3948-
None,
3949-
)
3950-
.await;
3935+
let (port_id, link_id) = switch.link_id(PhysPort(29)).unwrap();
39513936

39523937
let mut deleted_external_ids = Vec::new();
3953-
let mut deleted_underlay_ids = Vec::new();
39543938

39553939
for i in 0..5 {
3956-
let group_ip = IpAddr::V4(Ipv4Addr::new(224, 0, 1, 50 + i));
3957-
let nat_target = create_nat_target_ipv4();
3958-
let external_create = types::MulticastGroupCreateExternalEntry {
3940+
let group_ip: Ipv6Addr = format!("ff04::{}", 200 + i).parse().unwrap();
3941+
let internal_create = types::MulticastGroupCreateEntry {
39593942
group_ip,
39603943
tag: Some(format!("id_reuse_test_{}", i)),
3961-
nat_target,
3962-
vlan_id: Some(10),
39633944
sources: None,
3945+
members: vec![types::MulticastGroupMember {
3946+
port_id,
3947+
link_id,
3948+
direction: types::Direction::External,
3949+
}],
39643950
};
39653951

39663952
let created_group = switch
39673953
.client
3968-
.multicast_group_create_external(&external_create)
3954+
.multicast_group_create(&internal_create)
39693955
.await?
39703956
.into_inner();
39713957

39723958
if let Some(external_id) = created_group.external_group_id {
39733959
deleted_external_ids.push(external_id);
39743960
}
3975-
if let Some(underlay_id) = created_group.underlay_group_id {
3976-
deleted_underlay_ids.push(underlay_id);
3977-
}
39783961

3979-
switch.client.multicast_group_delete(&group_ip).await?;
3962+
switch.client.multicast_group_delete(&group_ip.into()).await?;
39803963
}
39813964

3982-
let new_group_ip = IpAddr::V4(Ipv4Addr::new(224, 0, 1, 200));
3983-
let nat_target = create_nat_target_ipv4();
3984-
let new_external_create = types::MulticastGroupCreateExternalEntry {
3965+
let new_group_ip: Ipv6Addr = "ff04::300".parse().unwrap();
3966+
let new_internal_create = types::MulticastGroupCreateEntry {
39853967
group_ip: new_group_ip,
39863968
tag: Some("id_reuse_verification".to_string()),
3987-
nat_target,
3988-
vlan_id: Some(10),
39893969
sources: None,
3970+
members: vec![types::MulticastGroupMember {
3971+
port_id,
3972+
link_id,
3973+
direction: types::Direction::External,
3974+
}],
39903975
};
39913976

39923977
let new_created_group = switch
39933978
.client
3994-
.multicast_group_create_external(&new_external_create)
3979+
.multicast_group_create(&new_internal_create)
39953980
.await?
39963981
.into_inner();
39973982

@@ -4006,19 +3991,7 @@ async fn test_multicast_group_id_reuse() -> TestResult {
40063991
panic!("New group should have an external group ID");
40073992
}
40083993

4009-
if let Some(new_underlay_id) = new_created_group.underlay_group_id {
4010-
assert!(
4011-
deleted_underlay_ids.contains(&new_underlay_id),
4012-
"New group should reuse a deleted underlay group ID, got {}, expected one of {:?}",
4013-
new_underlay_id,
4014-
deleted_underlay_ids
4015-
);
4016-
} else {
4017-
panic!("New group should have an underlay group ID");
4018-
}
4019-
4020-
cleanup_test_group(switch, new_group_ip).await;
4021-
cleanup_test_group(switch, internal_multicast_ip).await;
3994+
cleanup_test_group(switch, new_group_ip.into()).await;
40223995

40233996
Ok(())
40243997
}
@@ -4028,36 +4001,27 @@ async fn test_multicast_group_id_reuse() -> TestResult {
40284001
async fn test_multicast_group_id_pool_exhaustion_recovery() -> TestResult {
40294002
let switch = &*get_switch().await;
40304003

4031-
let egress = PhysPort(30);
4032-
let internal_multicast_ip = IpAddr::V6(MULTICAST_NAT_IP);
4033-
let underlay_group = create_test_multicast_group(
4034-
switch,
4035-
internal_multicast_ip,
4036-
Some("pool_exhaustion_test_underlay"),
4037-
&[(egress, types::Direction::Underlay)],
4038-
None,
4039-
false,
4040-
None,
4041-
)
4042-
.await;
4004+
let (port_id, link_id) = switch.link_id(PhysPort(30)).unwrap();
40434005

40444006
let mut created_groups = Vec::new();
40454007
let num_groups = 10;
40464008

40474009
for i in 0..num_groups {
4048-
let group_ip = IpAddr::V4(Ipv4Addr::new(224, 0, 2, 10 + i as u8));
4049-
let nat_target = create_nat_target_ipv4();
4050-
let external_create = types::MulticastGroupCreateExternalEntry {
4010+
let group_ip: Ipv6Addr = format!("ff04::{}", 400 + i).parse().unwrap();
4011+
let internal_create = types::MulticastGroupCreateEntry {
40514012
group_ip,
40524013
tag: Some(format!("pool_test_{}", i)),
4053-
nat_target,
4054-
vlan_id: Some(10),
40554014
sources: None,
4015+
members: vec![types::MulticastGroupMember {
4016+
port_id,
4017+
link_id,
4018+
direction: types::Direction::External,
4019+
}],
40564020
};
40574021

40584022
let created_group = switch
40594023
.client
4060-
.multicast_group_create_external(&external_create)
4024+
.multicast_group_create(&internal_create)
40614025
.await?
40624026
.into_inner();
40634027

@@ -4073,24 +4037,26 @@ async fn test_multicast_group_id_pool_exhaustion_recovery() -> TestResult {
40734037

40744038
let groups_to_delete = &created_groups[0..num_groups / 2];
40754039
for (group_ip, _) in groups_to_delete {
4076-
switch.client.multicast_group_delete(group_ip).await?;
4040+
switch.client.multicast_group_delete(&(*group_ip).into()).await?;
40774041
}
40784042

40794043
let mut new_groups = Vec::new();
40804044
for i in 0..num_groups / 2 {
4081-
let group_ip = IpAddr::V4(Ipv4Addr::new(224, 0, 3, 10 + i as u8));
4082-
let nat_target = create_nat_target_ipv4();
4083-
let external_create = types::MulticastGroupCreateExternalEntry {
4045+
let group_ip: Ipv6Addr = format!("ff04::{}", 500 + i).parse().unwrap();
4046+
let internal_create = types::MulticastGroupCreateEntry {
40844047
group_ip,
40854048
tag: Some(format!("pool_recovery_test_{}", i)),
4086-
nat_target,
4087-
vlan_id: Some(10),
40884049
sources: None,
4050+
members: vec![types::MulticastGroupMember {
4051+
port_id,
4052+
link_id,
4053+
direction: types::Direction::External,
4054+
}],
40894055
};
40904056

40914057
let created_group = switch
40924058
.client
4093-
.multicast_group_create_external(&external_create)
4059+
.multicast_group_create(&internal_create)
40944060
.await?
40954061
.into_inner();
40964062

@@ -4110,18 +4076,17 @@ async fn test_multicast_group_id_pool_exhaustion_recovery() -> TestResult {
41104076
"New group should have external group ID"
41114077
);
41124078
assert!(
4113-
group.underlay_group_id.is_some(),
4114-
"New group should have underlay group ID"
4079+
group.underlay_group_id.is_none(),
4080+
"New group should not have underlay group ID"
41154081
);
41164082
}
41174083

41184084
for (group_ip, _) in &created_groups[num_groups / 2..] {
4119-
cleanup_test_group(switch, *group_ip).await;
4085+
cleanup_test_group(switch, (*group_ip).into()).await;
41204086
}
41214087
for (group_ip, _) in &new_groups {
4122-
cleanup_test_group(switch, *group_ip).await;
4088+
cleanup_test_group(switch, (*group_ip).into()).await;
41234089
}
4124-
cleanup_test_group(switch, internal_multicast_ip).await;
41254090

41264091
Ok(())
41274092
}

0 commit comments

Comments
 (0)