Skip to content

Commit 7801be3

Browse files
authored
Fix Helm tests failing with latest version (#8179)
fix helm test
1 parent 78bf7cd commit 7801be3

File tree

2 files changed

+160
-154
lines changed

2 files changed

+160
-154
lines changed

charts/tests/helmunit_test.go

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -167,16 +167,16 @@ func TestHelmNICTemplateNegative(t *testing.T) {
167167
t.Parallel()
168168

169169
negativeTests := map[string]struct {
170-
valuesFile string
171-
releaseName string
172-
namespace string
173-
expectedErrorMsg string
170+
valuesFile string
171+
releaseName string
172+
namespace string
173+
expectedErrorMsgs []string
174174
}{
175175
"startupStatusInvalid": {
176-
valuesFile: "testdata/startupstatus-invalid.yaml",
177-
releaseName: "startupstatus-invalid",
178-
namespace: "default",
179-
expectedErrorMsg: "port is required",
176+
valuesFile: "testdata/startupstatus-invalid.yaml",
177+
releaseName: "startupstatus-invalid",
178+
namespace: "default",
179+
expectedErrorMsgs: []string{"missing properties 'port', 'path'", "port is required"},
180180
},
181181
}
182182

@@ -201,11 +201,17 @@ func TestHelmNICTemplateNegative(t *testing.T) {
201201
t.Fatalf("Expected helm template to fail for invalid configuration, but it succeeded")
202202
}
203203

204-
if tc.expectedErrorMsg != "" && !strings.Contains(err.Error(), tc.expectedErrorMsg) {
205-
t.Fatalf("Expected error to contain '%s', but got: %s", tc.expectedErrorMsg, err.Error())
204+
errMsg := err.Error()
205+
for _, expected := range tc.expectedErrorMsgs {
206+
if strings.Contains(errMsg, expected) {
207+
t.Logf("Expected failure occurred: %s", errMsg)
208+
return
209+
}
206210
}
207211

208-
t.Logf("Expected failure occurred: %s", err.Error())
212+
t.Fatalf("Expected error to contain '%s', but got: %s", tc.expectedErrorMsgs[0], errMsg)
213+
214+
t.Logf("Expected failure occurred: %s", errMsg)
209215
})
210216
}
211217
}

internal/configs/version2/__snapshots__/templates_test.snap

Lines changed: 143 additions & 143 deletions
Original file line numberDiff line numberDiff line change
@@ -1077,6 +1077,149 @@ server {
10771077

10781078
---
10791079

1080+
[TestExecuteVirtualServerTemplateWithCachePolicyNGINXPlus - 1]
1081+
1082+
upstream test-upstream {
1083+
zone test-upstream ;
1084+
server 10.0.0.20:8001 max_fails=0 fail_timeout= max_conns=0;
1085+
}
1086+
1087+
proxy_cache_path /var/cache/nginx/test_cache_full_advanced levels=2:2 keys_zone=test_cache_full_advanced:50m;
1088+
proxy_cache_path /var/cache/nginx/test_cache_location_location_cache keys_zone=test_cache_location_location_cache:20m;
1089+
geo $purge_allowed_test_cache_full_advanced {
1090+
default 0;
1091+
127.0.0.1 1;
1092+
10.0.0.0/8 1;
1093+
192.168.1.0/24 1;
1094+
}
1095+
1096+
map $request_method $cache_purge_test_cache_full_advanced {
1097+
PURGE $purge_allowed_test_cache_full_advanced;
1098+
default 0;
1099+
}
1100+
1101+
server {
1102+
listen 80;
1103+
listen [::]:80;
1104+
1105+
1106+
server_name example.com;
1107+
status_zone example.com;
1108+
set $resource_type "virtualserver";
1109+
set $resource_name "";
1110+
set $resource_namespace "";
1111+
1112+
server_tokens "off";
1113+
# Server-level cache configuration
1114+
proxy_cache test_cache_full_advanced;
1115+
proxy_cache_key $scheme$proxy_host$request_uri;
1116+
proxy_ignore_headers Cache-Control Expires Set-Cookie Vary X-Accel-Expires;
1117+
proxy_cache_valid 200 2h;
1118+
proxy_cache_valid 301 2h;
1119+
proxy_cache_valid 404 2h;
1120+
proxy_cache_methods GET HEAD POST;
1121+
proxy_cache_purge $cache_purge_test_cache_full_advanced;
1122+
1123+
1124+
1125+
1126+
location / {
1127+
set $service "";
1128+
status_zone "";
1129+
1130+
1131+
set $default_connection_header close;
1132+
proxy_connect_timeout ;
1133+
proxy_read_timeout ;
1134+
proxy_send_timeout ;
1135+
client_max_body_size ;
1136+
1137+
proxy_buffering off;
1138+
proxy_http_version 1.1;
1139+
proxy_set_header Upgrade $http_upgrade;
1140+
proxy_set_header Connection $vs_connection_header;
1141+
proxy_pass_request_headers off;
1142+
proxy_set_header X-Real-IP $remote_addr;
1143+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
1144+
proxy_set_header X-Forwarded-Host $host;
1145+
proxy_set_header X-Forwarded-Port $server_port;
1146+
proxy_set_header X-Forwarded-Proto $scheme;
1147+
proxy_cache test_cache_location_location_cache;
1148+
proxy_cache_key $scheme$proxy_host$request_uri;
1149+
proxy_cache_valid any 1h;
1150+
proxy_cache_methods GET HEAD;
1151+
proxy_pass http://test-upstream;
1152+
proxy_next_upstream ;
1153+
proxy_next_upstream_timeout ;
1154+
proxy_next_upstream_tries 0;
1155+
}
1156+
}
1157+
1158+
---
1159+
1160+
[TestExecuteVirtualServerTemplateWithCachePolicyOSS - 1]
1161+
1162+
upstream test-upstream {zone test-upstream ;
1163+
server 10.0.0.20:8001 max_fails=0 fail_timeout= max_conns=0;
1164+
}
1165+
1166+
proxy_cache_path /var/cache/nginx/test_cache_basic_cache levels=1:2 keys_zone=test_cache_basic_cache:10m;
1167+
proxy_cache_path /var/cache/nginx/test_cache_location_simple_cache keys_zone=test_cache_location_simple_cache:5m;
1168+
server {
1169+
listen 80;
1170+
listen [::]:80;
1171+
1172+
1173+
server_name example.com;
1174+
1175+
set $resource_type "virtualserver";
1176+
set $resource_name "";
1177+
set $resource_namespace "";
1178+
1179+
server_tokens "off";
1180+
# Server-level cache configuration
1181+
proxy_cache test_cache_basic_cache;
1182+
proxy_cache_key $scheme$proxy_host$request_uri;
1183+
proxy_ignore_headers Cache-Control Expires Set-Cookie Vary X-Accel-Expires;
1184+
proxy_cache_valid any 1h;
1185+
proxy_cache_methods GET HEAD;
1186+
1187+
1188+
1189+
1190+
location / {
1191+
set $service "";
1192+
1193+
1194+
set $default_connection_header close;
1195+
proxy_connect_timeout ;
1196+
proxy_read_timeout ;
1197+
proxy_send_timeout ;
1198+
client_max_body_size ;
1199+
1200+
proxy_buffering off;
1201+
proxy_http_version 1.1;
1202+
proxy_set_header Upgrade $http_upgrade;
1203+
proxy_set_header Connection $vs_connection_header;
1204+
proxy_pass_request_headers off;
1205+
proxy_set_header X-Real-IP $remote_addr;
1206+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
1207+
proxy_set_header X-Forwarded-Host $host;
1208+
proxy_set_header X-Forwarded-Port $server_port;
1209+
proxy_set_header X-Forwarded-Proto $scheme;
1210+
proxy_cache test_cache_location_simple_cache;
1211+
proxy_cache_key $scheme$proxy_host$request_uri;
1212+
proxy_cache_valid 200 30m;
1213+
proxy_cache_valid 404 30m;
1214+
proxy_pass http://test-upstream;
1215+
proxy_next_upstream ;
1216+
proxy_next_upstream_timeout ;
1217+
proxy_next_upstream_tries 0;
1218+
}
1219+
}
1220+
1221+
---
1222+
10801223
[TestExecuteVirtualServerTemplateWithJWKSWithToken - 1]
10811224

10821225
upstream vs_default_cafe_tea {
@@ -3493,146 +3636,3 @@ server {
34933636
}
34943637

34953638
---
3496-
3497-
[TestExecuteVirtualServerTemplateWithCachePolicyOSS - 1]
3498-
3499-
upstream test-upstream {zone test-upstream ;
3500-
server 10.0.0.20:8001 max_fails=0 fail_timeout= max_conns=0;
3501-
}
3502-
3503-
proxy_cache_path /var/cache/nginx/test_cache_basic_cache levels=1:2 keys_zone=test_cache_basic_cache:10m;
3504-
proxy_cache_path /var/cache/nginx/test_cache_location_simple_cache keys_zone=test_cache_location_simple_cache:5m;
3505-
server {
3506-
listen 80;
3507-
listen [::]:80;
3508-
3509-
3510-
server_name example.com;
3511-
3512-
set $resource_type "virtualserver";
3513-
set $resource_name "";
3514-
set $resource_namespace "";
3515-
3516-
server_tokens "off";
3517-
# Server-level cache configuration
3518-
proxy_cache test_cache_basic_cache;
3519-
proxy_cache_key $scheme$proxy_host$request_uri;
3520-
proxy_ignore_headers Cache-Control Expires Set-Cookie Vary X-Accel-Expires;
3521-
proxy_cache_valid any 1h;
3522-
proxy_cache_methods GET HEAD;
3523-
3524-
3525-
3526-
3527-
location / {
3528-
set $service "";
3529-
3530-
3531-
set $default_connection_header close;
3532-
proxy_connect_timeout ;
3533-
proxy_read_timeout ;
3534-
proxy_send_timeout ;
3535-
client_max_body_size ;
3536-
3537-
proxy_buffering off;
3538-
proxy_http_version 1.1;
3539-
proxy_set_header Upgrade $http_upgrade;
3540-
proxy_set_header Connection $vs_connection_header;
3541-
proxy_pass_request_headers off;
3542-
proxy_set_header X-Real-IP $remote_addr;
3543-
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
3544-
proxy_set_header X-Forwarded-Host $host;
3545-
proxy_set_header X-Forwarded-Port $server_port;
3546-
proxy_set_header X-Forwarded-Proto $scheme;
3547-
proxy_cache test_cache_location_simple_cache;
3548-
proxy_cache_key $scheme$proxy_host$request_uri;
3549-
proxy_cache_valid 200 30m;
3550-
proxy_cache_valid 404 30m;
3551-
proxy_pass http://test-upstream;
3552-
proxy_next_upstream ;
3553-
proxy_next_upstream_timeout ;
3554-
proxy_next_upstream_tries 0;
3555-
}
3556-
}
3557-
3558-
---
3559-
3560-
[TestExecuteVirtualServerTemplateWithCachePolicyNGINXPlus - 1]
3561-
3562-
upstream test-upstream {
3563-
zone test-upstream ;
3564-
server 10.0.0.20:8001 max_fails=0 fail_timeout= max_conns=0;
3565-
}
3566-
3567-
proxy_cache_path /var/cache/nginx/test_cache_full_advanced levels=2:2 keys_zone=test_cache_full_advanced:50m;
3568-
proxy_cache_path /var/cache/nginx/test_cache_location_location_cache keys_zone=test_cache_location_location_cache:20m;
3569-
geo $purge_allowed_test_cache_full_advanced {
3570-
default 0;
3571-
127.0.0.1 1;
3572-
10.0.0.0/8 1;
3573-
192.168.1.0/24 1;
3574-
}
3575-
3576-
map $request_method $cache_purge_test_cache_full_advanced {
3577-
PURGE $purge_allowed_test_cache_full_advanced;
3578-
default 0;
3579-
}
3580-
3581-
server {
3582-
listen 80;
3583-
listen [::]:80;
3584-
3585-
3586-
server_name example.com;
3587-
status_zone example.com;
3588-
set $resource_type "virtualserver";
3589-
set $resource_name "";
3590-
set $resource_namespace "";
3591-
3592-
server_tokens "off";
3593-
# Server-level cache configuration
3594-
proxy_cache test_cache_full_advanced;
3595-
proxy_cache_key $scheme$proxy_host$request_uri;
3596-
proxy_ignore_headers Cache-Control Expires Set-Cookie Vary X-Accel-Expires;
3597-
proxy_cache_valid 200 2h;
3598-
proxy_cache_valid 301 2h;
3599-
proxy_cache_valid 404 2h;
3600-
proxy_cache_methods GET HEAD POST;
3601-
proxy_cache_purge $cache_purge_test_cache_full_advanced;
3602-
3603-
3604-
3605-
3606-
location / {
3607-
set $service "";
3608-
status_zone "";
3609-
3610-
3611-
set $default_connection_header close;
3612-
proxy_connect_timeout ;
3613-
proxy_read_timeout ;
3614-
proxy_send_timeout ;
3615-
client_max_body_size ;
3616-
3617-
proxy_buffering off;
3618-
proxy_http_version 1.1;
3619-
proxy_set_header Upgrade $http_upgrade;
3620-
proxy_set_header Connection $vs_connection_header;
3621-
proxy_pass_request_headers off;
3622-
proxy_set_header X-Real-IP $remote_addr;
3623-
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
3624-
proxy_set_header X-Forwarded-Host $host;
3625-
proxy_set_header X-Forwarded-Port $server_port;
3626-
proxy_set_header X-Forwarded-Proto $scheme;
3627-
proxy_cache test_cache_location_location_cache;
3628-
proxy_cache_key $scheme$proxy_host$request_uri;
3629-
proxy_cache_valid any 1h;
3630-
proxy_cache_methods GET HEAD;
3631-
proxy_pass http://test-upstream;
3632-
proxy_next_upstream ;
3633-
proxy_next_upstream_timeout ;
3634-
proxy_next_upstream_tries 0;
3635-
}
3636-
}
3637-
3638-
---

0 commit comments

Comments
 (0)