@@ -66,9 +66,10 @@ var _ = ginkgo.Describe("Reconcile Test", ginkgo.Ordered, func() {
66
66
})
67
67
68
68
ginkgo .It ("should push config items first to satisfy foreign keys for changes & analyses" , func () {
69
- count , err := upstream .ReconcileSome (DefaultContext , upstreamConf , 100 , "config_items" )
69
+ count , fkFailed , err := upstream .ReconcileSome (DefaultContext , upstreamConf , 100 , "config_items" )
70
70
Expect (err ).To (BeNil ())
71
71
Expect (count ).To (Not (BeZero ()))
72
+ Expect (fkFailed ).To (BeZero ())
72
73
})
73
74
74
75
ginkgo .It ("should sync config_changes to upstream" , func () {
@@ -84,8 +85,9 @@ var _ = ginkgo.Describe("Reconcile Test", ginkgo.Ordered, func() {
84
85
Expect (err ).ToNot (HaveOccurred ())
85
86
Expect (changes ).To (BeZero ())
86
87
87
- count , err := upstream .ReconcileSome (DefaultContext , upstreamConf , 10 , "config_changes" )
88
+ count , fkFailed , err := upstream .ReconcileSome (DefaultContext , upstreamConf , 10 , "config_changes" )
88
89
Expect (err ).ToNot (HaveOccurred ())
90
+ Expect (fkFailed ).To (BeZero ())
89
91
90
92
err = upstreamCtx .DB ().Select ("COUNT(*)" ).Model (& models.ConfigChange {}).Scan (& changes ).Error
91
93
Expect (err ).ToNot (HaveOccurred ())
@@ -112,8 +114,9 @@ var _ = ginkgo.Describe("Reconcile Test", ginkgo.Ordered, func() {
112
114
Expect (err ).ToNot (HaveOccurred ())
113
115
Expect (analyses ).To (BeZero ())
114
116
115
- count , err := upstream .ReconcileSome (DefaultContext , upstreamConf , 10 , "config_analysis" )
117
+ count , fkFailed , err := upstream .ReconcileSome (DefaultContext , upstreamConf , 10 , "config_analysis" )
116
118
Expect (err ).ToNot (HaveOccurred ())
119
+ Expect (fkFailed ).To (BeZero ())
117
120
118
121
err = upstreamCtx .DB ().Select ("COUNT(*)" ).Model (& models.ConfigAnalysis {}).Scan (& analyses ).Error
119
122
Expect (err ).ToNot (HaveOccurred ())
@@ -138,8 +141,9 @@ var _ = ginkgo.Describe("Reconcile Test", ginkgo.Ordered, func() {
138
141
Expect (err ).ToNot (HaveOccurred ())
139
142
Expect (artifacts ).To (BeZero ())
140
143
141
- count , err := upstream .ReconcileSome (DefaultContext , upstreamConf , 10 , "artifacts" )
144
+ count , fkFailed , err := upstream .ReconcileSome (DefaultContext , upstreamConf , 10 , "artifacts" )
142
145
Expect (err ).ToNot (HaveOccurred ())
146
+ Expect (fkFailed ).To (BeZero ())
143
147
144
148
err = upstreamCtx .DB ().Select ("COUNT(*)" ).Model (& models.Artifact {}).Scan (& artifacts ).Error
145
149
Expect (err ).ToNot (HaveOccurred ())
@@ -162,8 +166,9 @@ var _ = ginkgo.Describe("Reconcile Test", ginkgo.Ordered, func() {
162
166
Expect (err ).ToNot (HaveOccurred ())
163
167
Expect (upstreamCount ).To (BeZero ())
164
168
165
- count , err := upstream .ReconcileSome (DefaultContext , upstreamConf , 10 , "job_history" )
169
+ count , fkFailed , err := upstream .ReconcileSome (DefaultContext , upstreamConf , 10 , "job_history" )
166
170
Expect (err ).ToNot (HaveOccurred ())
171
+ Expect (fkFailed ).To (BeZero ())
167
172
168
173
err = upstreamCtx .DB ().Select ("COUNT(*)" ).Model (& models.JobHistory {}).Scan (& upstreamCount ).Error
169
174
Expect (err ).ToNot (HaveOccurred ())
@@ -257,9 +262,9 @@ var _ = ginkgo.Describe("Reconcile Test", ginkgo.Ordered, func() {
257
262
Where ("id IN ?" , []uuid.UUID {deployment .ID , pod .ID }).UpdateColumn ("is_pushed" , true ).Error
258
263
Expect (err ).To (BeNil ())
259
264
260
- count , err := upstream .ReconcileSome (DefaultContext , upstreamConf , 10 , t )
265
+ _ , fkFailed , err := upstream .ReconcileSome (DefaultContext , upstreamConf , 10 , t )
261
266
Expect (err ).To (HaveOccurred ())
262
- Expect (count ).To (Equal ( 0 ))
267
+ Expect (fkFailed ).To (BeNumerically ( ">" , 0 ))
263
268
264
269
// After reconciliation, those config items should have been marked as unpushed.
265
270
var unpushed int
@@ -317,8 +322,9 @@ var _ = ginkgo.Describe("Reconcile Test", ginkgo.Ordered, func() {
317
322
})
318
323
319
324
ginkgo .It ("should reconcile the above canary & checks" , func () {
320
- _ , err := upstream .ReconcileSome (DefaultContext , upstreamConf , 10 , "canaries" , "checks" )
325
+ _ , fkFailed , err := upstream .ReconcileSome (DefaultContext , upstreamConf , 10 , "canaries" , "checks" )
321
326
Expect (err ).To (BeNil ())
327
+ Expect (fkFailed ).To (BeZero ())
322
328
323
329
var canaryCount int
324
330
err = DefaultContext .DB ().Model (& models.Canary {}).Select ("Count(*)" ).Where ("id IN ?" , []uuid.UUID {httpCanary .ID , tcpCanary .ID }).Where ("is_pushed = ?" , true ).Scan (& canaryCount ).Error
@@ -339,8 +345,9 @@ var _ = ginkgo.Describe("Reconcile Test", ginkgo.Ordered, func() {
339
345
err = DefaultContext .DB ().Model (& models.Check {}).Where ("id IN ?" , []uuid.UUID {httpChecks .ID , tcpCheck .ID }).Update ("is_pushed" , false ).Error
340
346
Expect (err ).To (BeNil ())
341
347
342
- _ , err = upstream .ReconcileSome (DefaultContext , upstreamConf , 100 , "checks" )
348
+ _ , fkFailed , err : = upstream .ReconcileSome (DefaultContext , upstreamConf , 100 , "checks" )
343
349
Expect (err ).To (Not (BeNil ()))
350
+ Expect (fkFailed ).To (BeNumerically (">" , 0 ))
344
351
345
352
// We expect the http check to have been marked as pushed
346
353
// while the tcp check & its canary to have been marked as unpushed
@@ -361,17 +368,19 @@ var _ = ginkgo.Describe("Reconcile Test", ginkgo.Ordered, func() {
361
368
})
362
369
363
370
ginkgo .It ("The next round of reconciliation should have no error" , func () {
364
- _ , err := upstream .ReconcileAll (DefaultContext , upstreamConf , 100 )
371
+ _ , fkFailed , err := upstream .ReconcileAll (DefaultContext , upstreamConf , 100 )
365
372
Expect (err ).To (BeNil ())
373
+ Expect (fkFailed ).To (BeZero ())
366
374
})
367
375
})
368
376
})
369
377
})
370
378
371
379
ginkgo .Context ("should handle updates" , func () {
372
380
ginkgo .It ("ensure all the topologies & canaries have been pushed" , func () {
373
- _ , err := upstream .ReconcileSome (DefaultContext , upstreamConf , 100 , "topologies" , "canaries" )
381
+ _ , fkFailed , err := upstream .ReconcileSome (DefaultContext , upstreamConf , 100 , "topologies" , "canaries" )
374
382
Expect (err ).To (BeNil ())
383
+ Expect (fkFailed ).To (BeZero ())
375
384
376
385
var unpushedCanaries int
377
386
err = DefaultContext .DB ().Select ("COUNT(*)" ).Where ("is_pushed = false" ).Model (& models.Canary {}).Scan (& unpushedCanaries ).Error
@@ -392,9 +401,10 @@ var _ = ginkgo.Describe("Reconcile Test", ginkgo.Ordered, func() {
392
401
err = DefaultContext .DB ().Model (& models.Canary {}).Where ("is_pushed = ?" , true ).Update ("is_pushed" , false ).Error
393
402
Expect (err ).To (BeNil ())
394
403
395
- count , err := upstream .ReconcileSome (DefaultContext , upstreamConf , 100 , "topologies" , "canaries" )
404
+ count , fkFailed , err := upstream .ReconcileSome (DefaultContext , upstreamConf , 100 , "topologies" , "canaries" )
396
405
Expect (err ).To (BeNil ())
397
406
Expect (count ).To (Not (BeZero ()))
407
+ Expect (fkFailed ).To (BeZero ())
398
408
399
409
var unpushedCanaries int
400
410
err = DefaultContext .DB ().Select ("COUNT(*)" ).Where ("is_pushed = false" ).Model (& models.Canary {}).Scan (& unpushedCanaries ).Error
0 commit comments