@@ -45,7 +45,7 @@ func (suite *ResyncTestSuite) TearDownTest() {
45
45
}
46
46
47
47
// Ensure that all the components are running after runnings the tests
48
- if ! fixture .IsProcessRunning ("process " ) {
48
+ if ! fixture .IsProcessRunning ("principal " ) {
49
49
err := fixture .StartProcess ("principal" )
50
50
requires .NoError (err )
51
51
}
@@ -94,9 +94,7 @@ func (suite *ResyncTestSuite) Test_ResyncDeletionOnPrincipalStartupManaged() {
94
94
err = fixture .StartProcess ("principal" )
95
95
requires .NoError (err )
96
96
97
- requires .Eventually (func () bool {
98
- return fixture .IsProcessRunning ("principal" )
99
- }, 30 * time .Second , 1 * time .Second )
97
+ fixture .CheckReadiness (suite .T (), "principal" )
100
98
101
99
requires .Eventually (func () bool {
102
100
app := argoapp.Application {}
@@ -137,9 +135,7 @@ func (suite *ResyncTestSuite) Test_ResyncUpdatesOnPrincipalStartupManaged() {
137
135
err = fixture .StartProcess ("principal" )
138
136
requires .NoError (err )
139
137
140
- requires .Eventually (func () bool {
141
- return fixture .IsProcessRunning ("principal" )
142
- }, 30 * time .Second , 1 * time .Second )
138
+ fixture .CheckReadiness (suite .T (), "principal" )
143
139
144
140
requires .Eventually (func () bool {
145
141
app := argoapp.Application {}
@@ -177,9 +173,7 @@ func (suite *ResyncTestSuite) Test_ResyncDeletionOnAgentStartupManaged() {
177
173
err = fixture .StartProcess ("agent-managed" )
178
174
requires .NoError (err )
179
175
180
- requires .Eventually (func () bool {
181
- return fixture .IsProcessRunning ("agent-managed" )
182
- }, 30 * time .Second , 1 * time .Second )
176
+ fixture .CheckReadiness (suite .T (), "agent-managed" )
183
177
184
178
requires .Eventually (func () bool {
185
179
app := argoapp.Application {}
@@ -214,9 +208,7 @@ func (suite *ResyncTestSuite) Test_ResyncUpdatesOnAgentStartupManaged() {
214
208
err = fixture .StartProcess ("agent-managed" )
215
209
requires .NoError (err )
216
210
217
- requires .Eventually (func () bool {
218
- return fixture .IsProcessRunning ("agent-managed" )
219
- }, 30 * time .Second , 1 * time .Second )
211
+ fixture .CheckReadiness (suite .T (), "agent-managed" )
220
212
221
213
// updates to the app on the agent side should be reverted since principal is the source of truth
222
214
requires .Eventually (func () bool {
@@ -253,9 +245,7 @@ func (suite *ResyncTestSuite) Test_ResyncDeletionOnAgentStartupAutonomous() {
253
245
err = fixture .StartProcess ("agent-autonomous" )
254
246
requires .NoError (err )
255
247
256
- requires .Eventually (func () bool {
257
- return fixture .IsProcessRunning ("agent-autonomous" )
258
- }, 30 * time .Second , 1 * time .Second )
248
+ fixture .CheckReadiness (suite .T (), "agent-autonomous" )
259
249
260
250
requires .Eventually (func () bool {
261
251
app := argoapp.Application {}
@@ -336,9 +326,7 @@ func (suite *ResyncTestSuite) Test_ResyncDeletionOnPrincipalStartupAutonomous()
336
326
err = fixture .StartProcess ("principal" )
337
327
requires .NoError (err )
338
328
339
- requires .Eventually (func () bool {
340
- return fixture .IsProcessRunning ("principal" )
341
- }, 30 * time .Second , 1 * time .Second )
329
+ fixture .CheckReadiness (suite .T (), "principal" )
342
330
343
331
requires .Eventually (func () bool {
344
332
err := suite .PrincipalClient .Get (suite .Ctx , principalKey , principalApp , metav1.GetOptions {})
@@ -375,9 +363,7 @@ func (suite *ResyncTestSuite) Test_ResyncUpdatesOnPrincipalStartupAutonomous() {
375
363
err = fixture .StartProcess ("principal" )
376
364
requires .NoError (err )
377
365
378
- requires .Eventually (func () bool {
379
- return fixture .IsProcessRunning ("principal" )
380
- }, 30 * time .Second , 1 * time .Second )
366
+ fixture .CheckReadiness (suite .T (), "principal" )
381
367
382
368
// updates to the app on the principal side should be reverted since agent is the source of truth in autonomous mode
383
369
requires .Eventually (func () bool {
@@ -398,6 +384,8 @@ func (suite *ResyncTestSuite) Test_ResyncOnConnectionLostManagedMode() {
398
384
// Restart the agent process so that the agent talks to the principal via Toxiproxy
399
385
fixture .RestartAgent (suite .T (), "agent-managed" )
400
386
387
+ fixture .CheckReadiness (suite .T (), "agent-managed" )
388
+
401
389
// Create a managed app
402
390
app := suite .createManagedApp ()
403
391
requires .NotNil (app )
@@ -435,6 +423,8 @@ func (suite *ResyncTestSuite) Test_ResyncOnConnectionLostAutonomousMode() {
435
423
// Restart the agent process so that the agent talks to the principal via Toxiproxy
436
424
fixture .RestartAgent (suite .T (), "agent-autonomous" )
437
425
426
+ fixture .CheckReadiness (suite .T (), "agent-autonomous" )
427
+
438
428
// Create an autonomous app
439
429
app := suite .createAutonomousApp ()
440
430
requires .NotNil (app )
@@ -493,9 +483,7 @@ func (suite *ResyncTestSuite) Test_RepositoryResync_OnAppProjectUpdate() {
493
483
err = fixture .StartProcess ("principal" )
494
484
requires .NoError (err )
495
485
496
- requires .Eventually (func () bool {
497
- return fixture .IsProcessRunning ("principal" )
498
- }, 30 * time .Second , 1 * time .Second )
486
+ fixture .CheckReadiness (suite .T (), "principal" )
499
487
500
488
requires .Eventually (func () bool {
501
489
appProject := argoapp.AppProject {}
@@ -542,9 +530,7 @@ func (suite *ResyncTestSuite) Test_RepositoryResync_OnCreation() {
542
530
err = fixture .StartProcess ("principal" )
543
531
requires .NoError (err )
544
532
545
- requires .Eventually (func () bool {
546
- return fixture .IsProcessRunning ("principal" )
547
- }, 30 * time .Second , 1 * time .Second )
533
+ fixture .CheckReadiness (suite .T (), "principal" )
548
534
549
535
// Ensure the appProject has been created on the workload cluster
550
536
requires .Eventually (func () bool {
@@ -649,6 +635,8 @@ func (suite *ResyncTestSuite) Test_RepositoryResync_OnDeletion() {
649
635
err = fixture .StartProcess ("principal" )
650
636
requires .NoError (err )
651
637
638
+ fixture .CheckReadiness (suite .T (), "principal" )
639
+
652
640
// Ensure the appProject is still present on the workload cluster
653
641
requires .Eventually (func () bool {
654
642
appProject := argoapp.AppProject {}
@@ -680,9 +668,7 @@ func (suite *ResyncTestSuite) Test_AppProjectResync_OnCreate() {
680
668
err = fixture .StartProcess ("principal" )
681
669
requires .NoError (err )
682
670
683
- requires .Eventually (func () bool {
684
- return fixture .IsProcessRunning ("principal" )
685
- }, 30 * time .Second , 1 * time .Second )
671
+ fixture .CheckReadiness (suite .T (), "principal" )
686
672
687
673
projKey := fixture .ToNamespacedName (appProject )
688
674
@@ -724,6 +710,8 @@ func (suite *ResyncTestSuite) Test_AppProjectResync_OnUpdate() {
724
710
err = fixture .StartProcess ("principal" )
725
711
requires .NoError (err )
726
712
713
+ fixture .CheckReadiness (suite .T (), "principal" )
714
+
727
715
// Ensure the appProject is updated on the workload cluster
728
716
requires .Eventually (func () bool {
729
717
appProject := argoapp.AppProject {}
@@ -757,6 +745,8 @@ func (suite *ResyncTestSuite) Test_AppProjectResync_OnDeletion() {
757
745
err = fixture .StartProcess ("principal" )
758
746
requires .NoError (err )
759
747
748
+ fixture .CheckReadiness (suite .T (), "principal" )
749
+
760
750
// Ensure the appProject is deleted from the workload cluster
761
751
requires .Eventually (func () bool {
762
752
appProject := argoapp.AppProject {}
@@ -766,7 +756,7 @@ func (suite *ResyncTestSuite) Test_AppProjectResync_OnDeletion() {
766
756
}
767
757
768
758
// Delete the AppProject from the control plane when the agent is down
769
- // and ensure that the AppProject is created again when the agent is restarted
759
+ // and ensure that the AppProject is deleted from the workload cluster when the agent is restarted
770
760
func (suite * ResyncTestSuite ) Test_AppProjectResync_DeleteOnAgentDelete () {
771
761
requires := suite .Require ()
772
762
@@ -785,19 +775,21 @@ func (suite *ResyncTestSuite) Test_AppProjectResync_DeleteOnAgentDelete() {
785
775
err = suite .PrincipalClient .Delete (suite .Ctx , appProject , metav1.DeleteOptions {})
786
776
requires .NoError (err )
787
777
788
- // Start the agent and ensure that the appProject is created on the workload cluster
778
+ // AppProject should still exist on the workload cluster
779
+ err = suite .ManagedAgentClient .Get (suite .Ctx , projKey , appProject , metav1.GetOptions {})
780
+ requires .NoError (err )
781
+
782
+ // Start the agent and ensure that the appProject is deleted from the workload cluster
789
783
err = fixture .StartProcess ("agent-managed" )
790
784
requires .NoError (err )
791
785
792
- requires .Eventually (func () bool {
793
- return fixture .IsProcessRunning ("agent-managed" )
794
- }, 30 * time .Second , 1 * time .Second )
786
+ fixture .CheckReadiness (suite .T (), "agent-managed" )
795
787
796
788
// Ensure the appProject has been created on the workload cluster
797
789
requires .Eventually (func () bool {
798
790
appProject := argoapp.AppProject {}
799
791
err := suite .ManagedAgentClient .Get (suite .Ctx , projKey , & appProject , metav1.GetOptions {})
800
- return err == nil
792
+ return errors . IsNotFound ( err )
801
793
}, 30 * time .Second , 1 * time .Second )
802
794
}
803
795
@@ -825,9 +817,7 @@ func (suite *ResyncTestSuite) Test_AppProjectResync_CreateOnAgentDelete() {
825
817
err = fixture .StartProcess ("agent-managed" )
826
818
requires .NoError (err )
827
819
828
- requires .Eventually (func () bool {
829
- return fixture .IsProcessRunning ("agent-managed" )
830
- }, 30 * time .Second , 1 * time .Second )
820
+ fixture .CheckReadiness (suite .T (), "agent-managed" )
831
821
832
822
// Ensure the appProject has been created on the workload cluster
833
823
requires .Eventually (func () bool {
0 commit comments