@@ -2205,6 +2205,7 @@ mod tests {
2205
2205
description : String :: from ( "description" ) ,
2206
2206
} ,
2207
2207
Some ( requested_ip) ,
2208
+ vec ! [ ] ,
2208
2209
)
2209
2210
. unwrap ( ) ;
2210
2211
let err = context. datastore ( )
@@ -2234,6 +2235,7 @@ mod tests {
2234
2235
description : String :: from ( "description" ) ,
2235
2236
} ,
2236
2237
Some ( requested_ip) ,
2238
+ vec ! [ ] ,
2237
2239
)
2238
2240
. unwrap ( ) ;
2239
2241
let inserted_interface = context
@@ -2266,6 +2268,7 @@ mod tests {
2266
2268
description : String :: from ( "description" ) ,
2267
2269
} ,
2268
2270
None ,
2271
+ vec ! [ ] ,
2269
2272
)
2270
2273
. unwrap ( ) ;
2271
2274
let err = context. datastore ( )
@@ -2304,6 +2307,7 @@ mod tests {
2304
2307
description : String :: from ( "description" ) ,
2305
2308
} ,
2306
2309
None ,
2310
+ vec ! [ ] ,
2307
2311
)
2308
2312
. unwrap ( ) ;
2309
2313
let inserted_interface = context
@@ -2348,6 +2352,7 @@ mod tests {
2348
2352
description : String :: from ( "description" ) ,
2349
2353
} ,
2350
2354
None ,
2355
+ vec ! [ ] ,
2351
2356
)
2352
2357
. unwrap ( ) ;
2353
2358
let inserted_interface = context
@@ -2367,6 +2372,7 @@ mod tests {
2367
2372
description : String :: from ( "description" ) ,
2368
2373
} ,
2369
2374
Some ( inserted_interface. ip . ip ( ) ) ,
2375
+ vec ! [ ] ,
2370
2376
)
2371
2377
. unwrap ( ) ;
2372
2378
let result = context
@@ -2615,6 +2621,7 @@ mod tests {
2615
2621
description : String :: from ( "description" ) ,
2616
2622
} ,
2617
2623
None ,
2624
+ vec ! [ ] ,
2618
2625
)
2619
2626
. unwrap ( ) ;
2620
2627
let _ = context
@@ -2634,6 +2641,7 @@ mod tests {
2634
2641
description : String :: from ( "description" ) ,
2635
2642
} ,
2636
2643
None ,
2644
+ vec ! [ ] ,
2637
2645
)
2638
2646
. unwrap ( ) ;
2639
2647
let result = context
@@ -2665,6 +2673,7 @@ mod tests {
2665
2673
description : String :: from ( "description" ) ,
2666
2674
} ,
2667
2675
None ,
2676
+ vec ! [ ] ,
2668
2677
)
2669
2678
. unwrap ( ) ;
2670
2679
let _ = context
@@ -2681,6 +2690,7 @@ mod tests {
2681
2690
description : String :: from ( "description" ) ,
2682
2691
} ,
2683
2692
None ,
2693
+ vec ! [ ] ,
2684
2694
)
2685
2695
. unwrap ( ) ;
2686
2696
let result = context
@@ -2709,6 +2719,7 @@ mod tests {
2709
2719
description : String :: from ( "description" ) ,
2710
2720
} ,
2711
2721
None ,
2722
+ vec ! [ ] ,
2712
2723
)
2713
2724
. unwrap ( ) ;
2714
2725
let _ = context
@@ -2751,6 +2762,7 @@ mod tests {
2751
2762
description : String :: from ( "description" ) ,
2752
2763
} ,
2753
2764
None ,
2765
+ vec ! [ ] ,
2754
2766
)
2755
2767
. unwrap ( ) ;
2756
2768
let _ = context
@@ -2769,6 +2781,7 @@ mod tests {
2769
2781
description : String :: from ( "description" ) ,
2770
2782
} ,
2771
2783
addr,
2784
+ vec ! [ ] ,
2772
2785
)
2773
2786
. unwrap ( ) ;
2774
2787
let result = context
@@ -2808,6 +2821,7 @@ mod tests {
2808
2821
description : String :: from ( "description" ) ,
2809
2822
} ,
2810
2823
None ,
2824
+ vec ! [ ] ,
2811
2825
)
2812
2826
. unwrap ( ) ;
2813
2827
let _ = context
@@ -2837,6 +2851,7 @@ mod tests {
2837
2851
description : String :: from ( "description" ) ,
2838
2852
} ,
2839
2853
None ,
2854
+ vec ! [ ] ,
2840
2855
)
2841
2856
. unwrap ( ) ;
2842
2857
let result = context
@@ -2870,6 +2885,7 @@ mod tests {
2870
2885
description : String :: from ( "description" ) ,
2871
2886
} ,
2872
2887
None ,
2888
+ vec ! [ ] ,
2873
2889
)
2874
2890
. unwrap ( ) ;
2875
2891
let result = context
@@ -2914,6 +2930,7 @@ mod tests {
2914
2930
"The random MAC address {:?} is not a valid {} address" ,
2915
2931
inserted. mac, kind,
2916
2932
) ;
2933
+ assert_eq ! ( inserted. transit_ips, incomplete. transit_ips) ;
2917
2934
}
2918
2935
2919
2936
// Test that we fail to insert an interface if there are no available slots
@@ -2938,6 +2955,7 @@ mod tests {
2938
2955
description : String :: from ( "description" ) ,
2939
2956
} ,
2940
2957
None ,
2958
+ vec ! [ ] ,
2941
2959
)
2942
2960
. unwrap ( ) ;
2943
2961
let inserted_interface = context
@@ -2973,6 +2991,7 @@ mod tests {
2973
2991
description : String :: from ( "description" ) ,
2974
2992
} ,
2975
2993
None ,
2994
+ vec ! [ ] ,
2976
2995
)
2977
2996
. unwrap ( ) ;
2978
2997
let result = context
@@ -3012,6 +3031,7 @@ mod tests {
3012
3031
description : String :: from ( "description" ) ,
3013
3032
} ,
3014
3033
None ,
3034
+ vec ! [ ] ,
3015
3035
)
3016
3036
. unwrap ( ) ;
3017
3037
let intf = context
@@ -3039,6 +3059,7 @@ mod tests {
3039
3059
description : String :: from ( "description" ) ,
3040
3060
} ,
3041
3061
None ,
3062
+ vec ! [ ] ,
3042
3063
)
3043
3064
. unwrap ( ) ;
3044
3065
let intf = context
@@ -3070,6 +3091,7 @@ mod tests {
3070
3091
description : String :: from ( "description" ) ,
3071
3092
} ,
3072
3093
None ,
3094
+ vec ! [ ] ,
3073
3095
)
3074
3096
. unwrap ( ) ;
3075
3097
let intf = context
@@ -3113,6 +3135,7 @@ mod tests {
3113
3135
description : String :: from ( "description" ) ,
3114
3136
} ,
3115
3137
Some ( IpAddr :: V4 ( addr) ) ,
3138
+ vec ! [ ] ,
3116
3139
)
3117
3140
. unwrap ( ) ;
3118
3141
let _ = context
@@ -3133,6 +3156,7 @@ mod tests {
3133
3156
description : String :: from ( "description" ) ,
3134
3157
} ,
3135
3158
None ,
3159
+ vec ! [ ] ,
3136
3160
)
3137
3161
. unwrap ( ) ;
3138
3162
@@ -3187,4 +3211,62 @@ mod tests {
3187
3211
"fd00::ffff:ffff:ffff:fffe" . parse:: <IpAddr >( ) . unwrap( ) ,
3188
3212
) ;
3189
3213
}
3214
+
3215
+ #[ tokio:: test]
3216
+ async fn test_insert_with_transit_ips ( ) {
3217
+ let context = TestContext :: new ( "test_insert_with_transit_ips" , 2 ) . await ;
3218
+ let instance = context. create_stopped_instance ( ) . await ;
3219
+ let instance_id = InstanceUuid :: from_untyped_uuid ( instance. id ( ) ) ;
3220
+
3221
+ // Create transit IPs to test with
3222
+ let transit_ips = vec ! [
3223
+ "10.0.0.0/24" . parse( ) . unwrap( ) ,
3224
+ "192.168.1.0/24" . parse( ) . unwrap( ) ,
3225
+ "172.16.0.0/16" . parse( ) . unwrap( ) ,
3226
+ ] ;
3227
+
3228
+ let interface = IncompleteNetworkInterface :: new_instance (
3229
+ Uuid :: new_v4 ( ) ,
3230
+ instance_id,
3231
+ context. net1 . subnets [ 0 ] . clone ( ) ,
3232
+ IdentityMetadataCreateParams {
3233
+ name : "interface-with-transit" . parse ( ) . unwrap ( ) ,
3234
+ description : String :: from ( "Test interface with transit IPs" ) ,
3235
+ } ,
3236
+ None , // Auto-assign IP
3237
+ transit_ips. clone ( ) ,
3238
+ )
3239
+ . unwrap ( ) ;
3240
+
3241
+ let inserted_interface = context
3242
+ . datastore ( )
3243
+ . instance_create_network_interface_raw (
3244
+ context. opctx ( ) ,
3245
+ interface. clone ( ) ,
3246
+ )
3247
+ . await
3248
+ . expect ( "Failed to insert interface with transit IPs" ) ;
3249
+
3250
+ // Verify the basic interface properties
3251
+ assert_interfaces_eq ( & interface, & inserted_interface. clone ( ) . into ( ) ) ;
3252
+
3253
+ // Verify transit IPs are correctly persisted
3254
+ assert_eq ! (
3255
+ inserted_interface. transit_ips. len( ) ,
3256
+ transit_ips. len( ) ,
3257
+ "Transit IPs count should match"
3258
+ ) ;
3259
+
3260
+ for ( actual, expected) in
3261
+ inserted_interface. transit_ips . iter ( ) . zip ( transit_ips. iter ( ) )
3262
+ {
3263
+ assert_eq ! (
3264
+ actual, expected,
3265
+ "Transit IP {} should match expected {}" ,
3266
+ actual, expected
3267
+ ) ;
3268
+ }
3269
+
3270
+ context. success ( ) . await ;
3271
+ }
3190
3272
}
0 commit comments