@@ -379,30 +379,50 @@ describe('Test gitrepos with cabundle', { tags: '@p0' }, () => {
379
379
} ) ;
380
380
381
381
if ( ! / \/ 2 \. 7 / . test ( Cypress . env ( 'rancher_version' ) ) && ! / \/ 2 \. 8 / . test ( Cypress . env ( 'rancher_version' ) ) ) {
382
+
382
383
describe ( 'Test Fleet with Webhook' , { tags : '@p0' } , ( ) => {
384
+
385
+ const gh_private_pwd = Cypress . env ( 'gh_private_pwd' ) ;
386
+
387
+ before ( 'Preparing Github Webhook' , ( ) => {
388
+
389
+ // Prepare webhook in Github
390
+ cy . exec ( 'bash assets/webhook-tests/webhook_setup.sh' , { env : { gh_private_pwd } } ) . then ( ( result ) => {
391
+ cy . log ( result . stdout , result . stderr ) ;
392
+ } )
393
+
394
+ cy . login ( ) ;
395
+
396
+ // Open local terminal in Rancher UI
397
+ cy . accesMenuSelection ( 'local' ) ;
398
+ cy . get ( '#btn-kubectl' ) . click ( ) ;
399
+ cy . contains ( 'Connected' ) . should ( 'be.visible' ) ;
400
+
401
+ // Add yaml file to the terminal to create ad-hoc ingress
402
+ cy . get ( 'button > i.icon.icon-upload.icon-lg' ) . click ( ) ;
403
+ cy . addYamlFile ( 'assets/webhook-tests/webhook_ingress.yaml' ) ;
404
+ cy . clickButton ( 'Import' ) ;
405
+ cy . clickButton ( 'Close' ) ;
406
+
407
+ } ) ;
408
+
383
409
qase ( 152 ,
410
+
384
411
it ( 'Fleet-152: Test Fleet with Webhook and disable polling ' , { tags : '@fleet-152' } , ( ) => {
385
412
386
413
const repoName = 'webhook-test-disable-polling' ;
387
- const gh_private_pwd = Cypress . env ( 'gh_private_pwd' ) ;
388
414
389
- // Prepare webhook in Github
390
- cy . exec ( 'bash assets/webhook-tests/webhook_setup.sh' , { env : { gh_private_pwd } } ) . then ( ( result ) => {
391
- cy . log ( result . stdout , result . stderr ) ;
392
- } )
415
+ cy . exec ( 'bash assets/webhook-tests/webhook_test_2_replicas.sh' ) . then ( ( result ) => {
416
+ cy . log ( result . stdout , result . stderr ) ;
417
+ } ) ;
393
418
394
419
// Open local terminal in Rancher UI
395
420
cy . accesMenuSelection ( 'local' ) ;
396
421
cy . get ( '#btn-kubectl' ) . click ( ) ;
397
422
cy . contains ( 'Connected' ) . should ( 'be.visible' ) ;
398
423
399
- // Add yaml file to the terminal to create ad-hoc ingress
400
- cy . get ( 'button > i.icon.icon-upload.icon-lg' ) . click ( ) ;
401
- cy . addYamlFile ( 'assets/webhook-tests/webhook_ingress.yaml' ) ;
402
- cy . clickButton ( 'Import' ) ;
403
- cy . clickButton ( 'Close' ) ;
404
-
405
424
cy . typeIntoCanvasTermnal ( '\
425
+ kubectl delete secrets -n cattle-fleet-system gitjob-webhook{enter} \
406
426
kubectl create secret generic gitjob-webhook -n cattle-fleet-system --from-literal=github=webhooksecretvalue{enter}' ) ;
407
427
408
428
// Ensure webhook repo starts with 2 replicas
@@ -428,11 +448,6 @@ if (!/\/2\.7/.test(Cypress.env('rancher_version')) && !/\/2\.8/.test(Cypress.env
428
448
cy . contains ( 'tr.main-row' , repoName , { timeout : 20000 } ) . should ( 'be.visible' ) ;
429
449
cy . verifyTableRow ( 0 , 'Active' , '2/2' ) ;
430
450
431
- // Give extra time for job to finsih.
432
- // TODO: remove this wait once https://github.com/rancher/fleet/issues/3067 is fixed
433
- // or find a way to wait for the job to finish
434
- cy . wait ( 10000 ) ;
435
-
436
451
// Change replicas to 5
437
452
cy . exec ( 'bash assets/webhook-tests/webhook_test_5_replicas.sh' ) . then ( ( result ) => {
438
453
cy . log ( result . stdout , result . stderr ) ;
@@ -442,6 +457,120 @@ if (!/\/2\.7/.test(Cypress.env('rancher_version')) && !/\/2\.8/.test(Cypress.env
442
457
cy . verifyTableRow ( 0 , 'Active' , '5/5' ) ;
443
458
} )
444
459
) ;
460
+
461
+ if ( ! / \/ 2 \. 9 / . test ( Cypress . env ( 'rancher_version' ) ) && ! / \/ 2 \. 1 0 / . test ( Cypress . env ( 'rancher_version' ) ) && ! / \/ 2 \. 1 1 / . test ( Cypress . env ( 'rancher_version' ) ) ) {
462
+
463
+ qase ( 178 ,
464
+
465
+ it ( 'Fleet-178: Test Fleet with Webhook and secret on gitrepo directly ' , { tags : '@fleet-178' } , ( ) => {
466
+
467
+ const repoName = 'test-disable-polling' ;
468
+
469
+ // Reset test to 2 replicas in case is not reset
470
+ cy . exec ( 'bash assets/webhook-tests/webhook_test_2_replicas.sh' ) . then ( ( result ) => {
471
+ cy . log ( result . stdout , result . stderr ) ;
472
+ } ) ;
473
+
474
+ // Open local terminal in Rancher UI
475
+ cy . accesMenuSelection ( 'local' ) ;
476
+ cy . get ( '#btn-kubectl' ) . click ( ) ;
477
+ cy . contains ( 'Connected' ) . should ( 'be.visible' ) ;
478
+
479
+ // CHANGE TO REMOVE EXISTING SECRET
480
+ cy . typeIntoCanvasTermnal ( '\
481
+ kubectl delete secrets -n cattle-fleet-system gitjob-webhook{enter}' ) ;
482
+
483
+ // Gitrepo creation via YAML
484
+ cy . accesMenuSelection ( 'Continuous Delivery' , 'Git Repos' ) ;
485
+ cy . fleetNamespaceToggle ( 'fleet-local' ) ;
486
+ cy . clickButton ( 'Add Repository' ) ;
487
+ cy . clickButton ( 'Edit as YAML' ) ;
488
+
489
+ cy . addYamlFile ( 'assets/webhook-tests/webhook_test_webhook_secret_in_repo.yaml' ) ;
490
+ cy . clickButton ( 'Create' ) ;
491
+ cy . verifyTableRow ( 0 , 'Active' , '1/1' ) ;
492
+ cy . checkGitRepoStatus ( repoName , '1 / 1' , '1 / 1' ) ;
493
+
494
+ cy . verifyJobDeleted ( repoName , false ) ;
495
+
496
+ // Verify deployments have 2 replicas only
497
+ cy . accesMenuSelection ( 'local' , 'Workloads' , 'Deployments' ) ;
498
+ cy . filterInSearchBox ( repoName ) ;
499
+ cy . wait ( 500 ) ;
500
+ cy . contains ( 'tr.main-row' , repoName , { timeout : 20000 } ) . should ( 'be.visible' ) ;
501
+ cy . verifyTableRow ( 0 , 'Active' , '2/2' ) ;
502
+
503
+ // Change replicas to 5 in Github Webhook
504
+ cy . exec ( 'bash assets/webhook-tests/webhook_test_5_replicas.sh' ) . then ( ( result ) => {
505
+ cy . log ( result . stdout , result . stderr ) ;
506
+ } ) ;
507
+
508
+ // Verify deployments STILL HAVE 2 replicas and NOT 5
509
+ cy . verifyTableRow ( 0 , 'Active' , '2/2' ) ;
510
+
511
+ // Verify error on log
512
+ cy . accesMenuSelection ( 'local' , 'Workloads' , 'Pods' ) ;
513
+ cy . filterInSearchBox ( 'gitjob' )
514
+ cy . open3dotsMenu ( 'gitjob' , 'View Logs' )
515
+ cy . contains ( '"Webhook processing failed"' ) . should ( 'exist' ) ;
516
+ } )
517
+ )
518
+
519
+ qase ( 177 ,
520
+
521
+ it ( 'Fleet-177: Test Fleet with Webhook and secret using "gitjob-webhhook" on "cattle-fleet-system" ' , { tags : '@fleet-177' } , ( ) => {
522
+
523
+ const repoName = 'test-disable-polling' ;
524
+
525
+ // Reset test to 2 replicas in case is not reset
526
+ cy . exec ( 'bash assets/webhook-tests/webhook_test_2_replicas.sh' ) . then ( ( result ) => {
527
+ cy . log ( result . stdout , result . stderr ) ;
528
+ } ) ;
529
+
530
+ // Open local terminal in Rancher UI
531
+ cy . accesMenuSelection ( 'local' ) ;
532
+ cy . get ( '#btn-kubectl' ) . click ( ) ;
533
+ cy . contains ( 'Connected' ) . should ( 'be.visible' ) ;
534
+
535
+ // Adding wrong generic secret
536
+ cy . typeIntoCanvasTermnal ( '\
537
+ kubectl create secret generic gitjob-webhook -n cattle-fleet-system --from-literal=github=wrong-webhook-secret{enter}' ) ;
538
+
539
+ // Gitrepo creation via YAML
540
+ cy . accesMenuSelection ( 'Continuous Delivery' , 'Git Repos' ) ;
541
+ cy . fleetNamespaceToggle ( 'fleet-local' ) ;
542
+ cy . clickButton ( 'Add Repository' ) ;
543
+ cy . clickButton ( 'Edit as YAML' ) ;
544
+
545
+ cy . addYamlFile ( 'assets/webhook-tests/webhook_test_disable_polling.yaml' ) ;
546
+ cy . clickButton ( 'Create' ) ;
547
+ cy . verifyTableRow ( 0 , 'Active' , '1/1' ) ;
548
+ cy . checkGitRepoStatus ( repoName , '1 / 1' , '1 / 1' ) ;
549
+
550
+ cy . verifyJobDeleted ( repoName , false ) ;
551
+
552
+ // Verify deployments has 2 replicas only
553
+ cy . accesMenuSelection ( 'local' , 'Workloads' , 'Deployments' ) ;
554
+ cy . filterInSearchBox ( repoName ) ;
555
+ cy . wait ( 500 ) ;
556
+ cy . contains ( 'tr.main-row' , repoName , { timeout : 20000 } ) . should ( 'be.visible' ) ;
557
+ cy . verifyTableRow ( 0 , 'Active' , '2/2' ) ;
558
+
559
+ // Change replicas to 5 in Github Webhook
560
+ cy . exec ( 'bash assets/webhook-tests/webhook_test_5_replicas.sh' ) . then ( ( result ) => {
561
+ cy . log ( result . stdout , result . stderr ) ;
562
+ } ) ;
563
+
564
+ // Verify deployments STILL HAVE 2 replicas and NOT 5
565
+ cy . verifyTableRow ( 0 , 'Active' , '2/2' ) ;
566
+
567
+ // Verify error on log
568
+ cy . accesMenuSelection ( 'local' , 'Workloads' , 'Pods' ) ;
569
+ cy . filterInSearchBox ( 'gitjob' )
570
+ cy . open3dotsMenu ( 'gitjob' , 'View Logs' )
571
+ cy . contains ( 'HMAC verification failed' ) . should ( 'exist' ) ;
572
+ } )
573
+ ) }
445
574
} )
446
575
} ;
447
576
@@ -552,6 +681,7 @@ if (!/\/2\.7/.test(Cypress.env('rancher_version')) && !/\/2\.8/.test(Cypress.env
552
681
cy . get ( 'table > tbody > tr' ) . contains ( repoName ) . should ( 'be.visible' ) ;
553
682
} )
554
683
) } ) ;
684
+
555
685
} ;
556
686
557
687
if ( ! / \/ 2 \. 8 / . test ( Cypress . env ( 'rancher_version' ) ) && ! / \/ 2 \. 9 / . test ( Cypress . env ( 'rancher_version' ) ) ) {
0 commit comments