@@ -27,6 +27,8 @@ import (
27
27
var _ = Describe ("Reconfiguration Performance Testing" , Ordered , Label ("reconfiguration" , "nfr" ), func () {
28
28
// used for cleaning up resources
29
29
const maxResourceCount = 150
30
+ const metricExistTimeout = 2 * time .Minute
31
+ const metricExistPolling = 1 * time .Second
30
32
31
33
var (
32
34
scrapeInterval = 15 * time .Second
@@ -63,6 +65,9 @@ var _ = Describe("Reconfiguration Performance Testing", Ordered, Label("reconfig
63
65
})
64
66
65
67
BeforeEach (func () {
68
+ output , err := framework .InstallGatewayAPI (getDefaultSetupCfg ().gwAPIVersion )
69
+ Expect (err ).ToNot (HaveOccurred (), string (output ))
70
+
66
71
// need to redeclare this variable to reset its resource version. The framework has some bugs where
67
72
// if we set and declare this as a global variable, even after deleting the namespace, when we try to
68
73
// recreate it, it will error saying the resource version has already been set.
@@ -312,86 +317,47 @@ var _ = Describe("Reconfiguration Performance Testing", Ordered, Label("reconfig
312
317
return stringTimeToReadyTotal , nil
313
318
}
314
319
315
- runTestWithMetrics := func (
316
- testName string ,
317
- resourceCount int ,
318
- test func (resourceCount int ) error ,
319
- startWithNGFSetup bool ,
320
- timeToReadyStartingLogSubstring string ,
321
- ) {
322
- var (
323
- metricExistTimeout = 2 * time .Minute
324
- metricExistPolling = 1 * time .Second
325
- ngfPodName string
326
- startTime time.Time
327
- )
320
+ deployNGFReturnsNGFPodNameAndStartTime := func () (string , time.Time ) {
321
+ var startTime time.Time
328
322
329
323
getStartTime := func () time.Time { return startTime }
330
324
modifyStartTime := func () { startTime = startTime .Add (500 * time .Millisecond ) }
331
325
332
- output , err := framework .InstallGatewayAPI (getDefaultSetupCfg ().gwAPIVersion )
333
- Expect (err ).ToNot (HaveOccurred (), string (output ))
334
-
335
- if startWithNGFSetup {
336
- setup (getDefaultSetupCfg ())
337
-
338
- podNames , err := framework .GetReadyNGFPodNames (k8sClient , ngfNamespace , releaseName , timeoutConfig .GetTimeout )
339
- Expect (err ).ToNot (HaveOccurred ())
340
- Expect (podNames ).To (HaveLen (1 ))
341
- ngfPodName = podNames [0 ]
342
- startTime = time .Now ()
343
-
344
- queries := []string {
345
- fmt .Sprintf (`container_memory_usage_bytes{pod="%s",container="nginx-gateway"}` , ngfPodName ),
346
- fmt .Sprintf (`container_cpu_usage_seconds_total{pod="%s",container="nginx-gateway"}` , ngfPodName ),
347
- // We don't need to check all nginx_gateway_fabric_* metrics, as they are collected at the same time
348
- fmt .Sprintf (`nginx_gateway_fabric_nginx_reloads_total{pod="%s"}` , ngfPodName ),
349
- }
326
+ setup (getDefaultSetupCfg ())
327
+ podNames , err := framework .GetReadyNGFPodNames (k8sClient , ngfNamespace , releaseName , timeoutConfig .GetTimeout )
328
+ Expect (err ).ToNot (HaveOccurred ())
329
+ Expect (podNames ).To (HaveLen (1 ))
330
+ ngfPodName := podNames [0 ]
331
+ startTime = time .Now ()
350
332
351
- for _ , q := range queries {
352
- Eventually (
353
- framework .CreateMetricExistChecker (
354
- promInstance ,
355
- q ,
356
- getStartTime ,
357
- modifyStartTime ,
358
- ),
359
- ).WithTimeout (metricExistTimeout ).WithPolling (metricExistPolling ).Should (Succeed ())
360
- }
333
+ queries := []string {
334
+ fmt .Sprintf (`container_memory_usage_bytes{pod="%s",container="nginx-gateway"}` , ngfPodName ),
335
+ fmt .Sprintf (`container_cpu_usage_seconds_total{pod="%s",container="nginx-gateway"}` , ngfPodName ),
336
+ // We don't need to check all nginx_gateway_fabric_* metrics, as they are collected at the same time
337
+ fmt .Sprintf (`nginx_gateway_fabric_nginx_reloads_total{pod="%s"}` , ngfPodName ),
361
338
}
362
339
363
- Expect (test (resourceCount )).To (Succeed ())
364
- Expect (checkResourceCreation (resourceCount )).To (Succeed ())
365
-
366
- if ! startWithNGFSetup {
367
- setup (getDefaultSetupCfg ())
368
-
369
- podNames , err := framework .GetReadyNGFPodNames (k8sClient , ngfNamespace , releaseName , timeoutConfig .GetTimeout )
370
- Expect (err ).ToNot (HaveOccurred ())
371
- Expect (podNames ).To (HaveLen (1 ))
372
- ngfPodName = podNames [0 ]
373
- startTime = time .Now ()
374
-
375
- // if i do a new instance of NGF each time, I might not need start time and can just do the endtime.
376
- queries := []string {
377
- fmt .Sprintf (`container_memory_usage_bytes{pod="%s",container="nginx-gateway"}` , ngfPodName ),
378
- fmt .Sprintf (`container_cpu_usage_seconds_total{pod="%s",container="nginx-gateway"}` , ngfPodName ),
379
- // We don't need to check all nginx_gateway_fabric_* metrics, as they are collected at the same time
380
- fmt .Sprintf (`nginx_gateway_fabric_nginx_reloads_total{pod="%s"}` , ngfPodName ),
381
- }
382
-
383
- for _ , q := range queries {
384
- Eventually (
385
- framework .CreateMetricExistChecker (
386
- promInstance ,
387
- q ,
388
- getStartTime ,
389
- modifyStartTime ,
390
- ),
391
- ).WithTimeout (metricExistTimeout ).WithPolling (metricExistPolling ).Should (Succeed ())
392
- }
340
+ for _ , q := range queries {
341
+ Eventually (
342
+ framework .CreateMetricExistChecker (
343
+ promInstance ,
344
+ q ,
345
+ getStartTime ,
346
+ modifyStartTime ,
347
+ ),
348
+ ).WithTimeout (metricExistTimeout ).WithPolling (metricExistPolling ).Should (Succeed ())
393
349
}
394
350
351
+ return ngfPodName , startTime
352
+ }
353
+
354
+ collectMetrics := func (
355
+ testName string ,
356
+ resourceCount int ,
357
+ timeToReadyStartingLogSubstring string ,
358
+ ngfPodName string ,
359
+ startTime time.Time ,
360
+ ) {
395
361
time .Sleep (2 * scrapeInterval )
396
362
397
363
endTime := time .Now ()
@@ -476,70 +442,112 @@ var _ = Describe("Reconfiguration Performance Testing", Ordered, Label("reconfig
476
442
477
443
// Test 1 - Resources exist before start-up
478
444
It ("test 1 - 30 resources" , func () {
445
+ resourceCount := 30
479
446
timeToReadyStartingLogSubstring := "Starting NGINX Gateway Fabric"
447
+ test := createResourcesGWLast (resourceCount )
480
448
481
- runTestWithMetrics ("1" ,
482
- 30 ,
483
- createResourcesGWLast ,
484
- false ,
449
+ Expect (test ).To (Succeed ())
450
+ Expect (checkResourceCreation (resourceCount )).To (Succeed ())
451
+
452
+ ngfPodName , startTime := deployNGFReturnsNGFPodNameAndStartTime ()
453
+
454
+ collectMetrics ("1" ,
455
+ resourceCount ,
485
456
timeToReadyStartingLogSubstring ,
457
+ ngfPodName ,
458
+ startTime ,
486
459
)
487
460
})
488
461
489
462
It ("test 1 - 150 resources" , func () {
463
+ resourceCount := 150
490
464
timeToReadyStartingLogSubstring := "Starting NGINX Gateway Fabric"
465
+ test := createResourcesGWLast (resourceCount )
466
+
467
+ Expect (test ).To (Succeed ())
468
+ Expect (checkResourceCreation (resourceCount )).To (Succeed ())
469
+
470
+ ngfPodName , startTime := deployNGFReturnsNGFPodNameAndStartTime ()
491
471
492
- runTestWithMetrics ("1" ,
493
- 150 ,
494
- createResourcesGWLast ,
495
- false ,
472
+ collectMetrics ("1" ,
473
+ resourceCount ,
496
474
timeToReadyStartingLogSubstring ,
475
+ ngfPodName ,
476
+ startTime ,
497
477
)
498
478
})
499
479
500
480
// Test 2 - Start NGF, deploy Gateway, create many resources attached to GW
501
481
It ("test 2 - 30 resources" , func () {
482
+ resourceCount := 30
502
483
timeToReadyStartingLogSubstring := "Reconciling the resource\" ,\" controller\" :\" httproute\" "
484
+ test := createResourcesRoutesLast (resourceCount )
503
485
504
- runTestWithMetrics ("2" ,
505
- 30 ,
506
- createResourcesRoutesLast ,
507
- true ,
486
+ ngfPodName , startTime := deployNGFReturnsNGFPodNameAndStartTime ()
487
+
488
+ Expect (test ).To (Succeed ())
489
+ Expect (checkResourceCreation (resourceCount )).To (Succeed ())
490
+
491
+ collectMetrics ("2" ,
492
+ resourceCount ,
508
493
timeToReadyStartingLogSubstring ,
494
+ ngfPodName ,
495
+ startTime ,
509
496
)
510
497
})
511
498
512
499
It ("test 2 - 150 resources" , func () {
500
+ resourceCount := 150
513
501
timeToReadyStartingLogSubstring := "Reconciling the resource\" ,\" controller\" :\" httproute\" "
502
+ test := createResourcesRoutesLast (resourceCount )
503
+
504
+ ngfPodName , startTime := deployNGFReturnsNGFPodNameAndStartTime ()
505
+
506
+ Expect (test ).To (Succeed ())
507
+ Expect (checkResourceCreation (resourceCount )).To (Succeed ())
514
508
515
- runTestWithMetrics ("2" ,
516
- 150 ,
517
- createResourcesRoutesLast ,
518
- true ,
509
+ collectMetrics ("2" ,
510
+ resourceCount ,
519
511
timeToReadyStartingLogSubstring ,
512
+ ngfPodName ,
513
+ startTime ,
520
514
)
521
515
})
522
516
523
- // Test 3: Start NGF, create many resources attached to a Gateway, deploy the Gateway
517
+ // Test 3 - Start NGF, create many resources attached to a Gateway, deploy the Gateway
524
518
It ("test 3 - 30 resources" , func () {
519
+ resourceCount := 30
525
520
timeToReadyStartingLogSubstring := "Reconciling the resource\" ,\" controller\" :\" gateway\" "
521
+ test := createResourcesGWLast (resourceCount )
522
+
523
+ ngfPodName , startTime := deployNGFReturnsNGFPodNameAndStartTime ()
524
+
525
+ Expect (test ).To (Succeed ())
526
+ Expect (checkResourceCreation (resourceCount )).To (Succeed ())
526
527
527
- runTestWithMetrics ("3" ,
528
- 30 ,
529
- createResourcesGWLast ,
530
- true ,
528
+ collectMetrics ("3" ,
529
+ resourceCount ,
531
530
timeToReadyStartingLogSubstring ,
531
+ ngfPodName ,
532
+ startTime ,
532
533
)
533
534
})
534
535
535
536
It ("test 3 - 150 resources" , func () {
537
+ resourceCount := 30
536
538
timeToReadyStartingLogSubstring := "Reconciling the resource\" ,\" controller\" :\" gateway\" "
539
+ test := createResourcesGWLast (resourceCount )
540
+
541
+ ngfPodName , startTime := deployNGFReturnsNGFPodNameAndStartTime ()
542
+
543
+ Expect (test ).To (Succeed ())
544
+ Expect (checkResourceCreation (resourceCount )).To (Succeed ())
537
545
538
- runTestWithMetrics ("3" ,
539
- 150 ,
540
- createResourcesGWLast ,
541
- true ,
546
+ collectMetrics ("3" ,
547
+ resourceCount ,
542
548
timeToReadyStartingLogSubstring ,
549
+ ngfPodName ,
550
+ startTime ,
543
551
)
544
552
})
545
553
0 commit comments