@@ -2794,6 +2794,106 @@ func TestRecoverMigrationMonitorsFromLabels_VolumeAttributeFiltering(t *testing.
27942794 expectRecover : false ,
27952795 note : "storageAccountType mismatch blocks recovery" ,
27962796 },
2797+ // NEW: Case-insensitive key tests
2798+ {
2799+ name : "pv-case-insensitive-storageaccounttype-uppercase-key" ,
2800+ attrs : map [string ]string {"STORAGEACCOUNTTYPE" : string (toSKU )},
2801+ expectRecover : true ,
2802+ note : "uppercase storageAccountType key should match case-insensitively" ,
2803+ },
2804+ {
2805+ name : "pv-case-insensitive-storageaccounttype-mixed-key" ,
2806+ attrs : map [string ]string {"StorageAccountType" : string (toSKU )},
2807+ expectRecover : true ,
2808+ note : "mixed case storageAccountType key should match case-insensitively" ,
2809+ },
2810+ {
2811+ name : "pv-case-insensitive-skuname-uppercase-key" ,
2812+ attrs : map [string ]string {"SKUNAME" : string (toSKU )},
2813+ expectRecover : true ,
2814+ note : "uppercase skuName key should match case-insensitively" ,
2815+ },
2816+ {
2817+ name : "pv-case-insensitive-skuname-lowercase-key" ,
2818+ attrs : map [string ]string {"skuname" : string (toSKU )},
2819+ expectRecover : true ,
2820+ note : "lowercase skuName key should match case-insensitively" ,
2821+ },
2822+ {
2823+ name : "pv-case-insensitive-skuname-mixed-key" ,
2824+ attrs : map [string ]string {"SkuName" : string (toSKU )},
2825+ expectRecover : true ,
2826+ note : "mixed case skuName key should match case-insensitively" ,
2827+ },
2828+ // NEW: Case-insensitive value tests
2829+ {
2830+ name : "pv-case-insensitive-value-lowercase-premiumv2" ,
2831+ attrs : map [string ]string {"skuName" : strings .ToLower (string (toSKU ))},
2832+ expectRecover : true ,
2833+ note : "lowercase PremiumV2_LRS value should match case-insensitively" ,
2834+ },
2835+ {
2836+ name : "pv-case-insensitive-value-uppercase-premiumv2" ,
2837+ attrs : map [string ]string {"skuName" : strings .ToUpper (string (toSKU ))},
2838+ expectRecover : true ,
2839+ note : "uppercase PREMIUMV2_LRS value should match case-insensitively" ,
2840+ },
2841+ {
2842+ name : "pv-case-insensitive-value-mixed-premiumv2" ,
2843+ attrs : map [string ]string {"skuName" : "PremiumV2_lrs" },
2844+ expectRecover : true ,
2845+ note : "mixed case PremiumV2_lrs value should match case-insensitively" ,
2846+ },
2847+ {
2848+ name : "pv-case-insensitive-value-mismatch-premium" ,
2849+ attrs : map [string ]string {"skuName" : strings .ToLower (string (armcompute .DiskStorageAccountTypesPremiumLRS ))},
2850+ expectRecover : false ,
2851+ note : "lowercase premium_lrs value should not match PremiumV2_LRS" ,
2852+ },
2853+ // NEW: Combined case-insensitive key and value tests
2854+ {
2855+ name : "pv-case-insensitive-both-key-value-uppercase" ,
2856+ attrs : map [string ]string {"SKUNAME" : strings .ToUpper (string (toSKU ))},
2857+ expectRecover : true ,
2858+ note : "uppercase key and value should both match case-insensitively" ,
2859+ },
2860+ {
2861+ name : "pv-case-insensitive-both-key-value-mixed" ,
2862+ attrs : map [string ]string {"SkuName" : "premiumv2_LRS" },
2863+ expectRecover : true ,
2864+ note : "mixed case key and value should both match case-insensitively" ,
2865+ },
2866+ {
2867+ name : "pv-case-insensitive-multiple-keys-match" ,
2868+ attrs : map [string ]string {
2869+ "STORAGEACCOUNTTYPE" : strings .ToUpper (string (toSKU )),
2870+ "skuname" : strings .ToLower (string (toSKU )),
2871+ },
2872+ expectRecover : true ,
2873+ note : "multiple case-insensitive keys with matching values should recover" ,
2874+ },
2875+ {
2876+ name : "pv-case-insensitive-multiple-keys-mismatch" ,
2877+ attrs : map [string ]string {
2878+ "STORAGEACCOUNTTYPE" : strings .ToUpper (string (toSKU )),
2879+ "skuname" : strings .ToLower (string (armcompute .DiskStorageAccountTypesPremiumLRS )),
2880+ },
2881+ expectRecover : false ,
2882+ note : "case-insensitive keys with one mismatched value should not recover" ,
2883+ },
2884+ // Edge cases for case sensitivity
2885+ {
2886+ name : "pv-case-insensitive-extra-spaces-key" ,
2887+ attrs : map [string ]string {"storageaccounttype" : string (toSKU )}, // Note: spaces in keys would be unusual but testing lowercase
2888+ expectRecover : true ,
2889+ note : "key case variations should work" ,
2890+ },
2891+ {
2892+ name : "pv-case-insensitive-underscore-variations" ,
2893+ attrs : map [string ]string {"skuName" : "PremiumV2_LRS" },
2894+ expectRecover : true ,
2895+ note : "exact match should still work with case-insensitive implementation" ,
2896+ },
27972897 }
27982898
27992899 var pvListItems []corev1.PersistentVolume
@@ -2924,13 +3024,13 @@ func TestRecoverMigrationMonitorsFromLabels_VolumeAttributeFiltering(t *testing.
29243024 if task .PVName == c .name {
29253025 found = true
29263026 if ! c .expectRecover {
2927- t .Errorf ("PV %s was recovered but should have been skipped (attributes %+v)" , c .name , c .attrs )
3027+ t .Errorf ("PV %s was recovered but should have been skipped (attributes %+v, note: %s )" , c .name , c .attrs , c . note )
29283028 }
29293029 break
29303030 }
29313031 }
29323032 if c .expectRecover && ! found {
2933- t .Errorf ("PV %s should have been recovered but was not (attributes %+v)" , c .name , c .attrs )
3033+ t .Errorf ("PV %s should have been recovered but was not (attributes %+v, note: %s )" , c .name , c .attrs , c . note )
29343034 }
29353035 }
29363036
0 commit comments