-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Configurable minimum worker nodecount #238
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ bin | |
|
||
# editor and IDE paraphernalia | ||
.idea | ||
*.iml | ||
*.swp | ||
*.swo | ||
*~ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -445,22 +445,88 @@ var _ = Describe("SNR Controller", func() { | |
remediationStrategy = v1alpha1.ResourceDeletionRemediationStrategy | ||
}) | ||
|
||
It("Verify that watchdog is not receiving food after some time", func() { | ||
lastFoodTime := dummyDog.LastFoodTime() | ||
timeout := dummyDog.GetTimeout() | ||
Eventually(func() bool { | ||
newTime := dummyDog.LastFoodTime() | ||
// ensure the timeout passed | ||
timeoutPassed := time.Now().After(lastFoodTime.Add(3 * timeout)) | ||
// ensure wd wasn't feeded | ||
missedFeed := newTime.Before(lastFoodTime.Add(timeout)) | ||
if timeoutPassed && missedFeed { | ||
return true | ||
} | ||
lastFoodTime = newTime | ||
return false | ||
}, 10*shared.PeerUpdateInterval, timeout).Should(BeTrue()) | ||
AfterEach(func() { | ||
By("Restore default settings") | ||
apiConnectivityCheckConfig.MinPeersForRemediation = 1 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: I think this makes more sense in the general After Each block |
||
|
||
// sleep so config can update | ||
time.Sleep(time.Second * 2) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think this is needed, IIUC config isn't being updated async here There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I verified that if I didn't put the sleep often times the config was not updated when the other routines ran. It took me quite some time to track this particular problem down 😭 It's even worse if I disable some tests so things run in different orders |
||
}) | ||
|
||
Context("no peer found, and using default setting for MinPeersForRemediation", func() { | ||
BeforeEach(func() { | ||
apiConnectivityCheckConfig.MinPeersForRemediation = 1 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this is redundant because was already updated in the AfterEach block |
||
snrConfig.Spec.MinPeersForRemediation = 1 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IIUC this is the default value, so I think it would make more sense to add it in |
||
}) | ||
|
||
It("Does not receive peer communication and has MinPeersForRemediation set to 1 so no reboot "+ | ||
"will occur", func() { | ||
lastFoodTime := dummyDog.LastFoodTime() | ||
timeout := dummyDog.GetTimeout() | ||
fmt.Printf("timeout: %s", timeout.String()) | ||
Eventually(func() bool { | ||
fmt.Println("YYYY") | ||
newTime := dummyDog.LastFoodTime() | ||
fmt.Printf("newTime: %s\n", newTime.Format(time.StampMilli)) | ||
// ensure the timeout passed | ||
timeoutPassed := time.Now().After(lastFoodTime.Add(3 * timeout)) | ||
// ensure wd wasn't feeded | ||
fmt.Printf("missedFeed time: %s\n", lastFoodTime.Add(timeout).Format(time.StampMilli)) | ||
missedFeed := newTime.Before(lastFoodTime.Add(timeout)) | ||
if timeoutPassed && missedFeed { | ||
fmt.Println("timeout passed and missed feed") | ||
return true | ||
} | ||
lastFoodTime = newTime | ||
fmt.Println("timeout didn't pass and/or didn't miss feed") | ||
return false | ||
}, 10*shared.PeerUpdateInterval, timeout).Should(BeTrue()) | ||
}) | ||
}) | ||
|
||
Context("no peer found and MinPeersForRemediation is configured to 0", func() { | ||
JustBeforeEach(func() { | ||
apiConnectivityCheckConfig.MinPeersForRemediation = 0 | ||
|
||
// sleep so config can update | ||
time.Sleep(time.Second * 2) | ||
}) | ||
|
||
It("Does not receive peer communication and since configured to need zero peers, initiates a reboot", | ||
func() { | ||
fmt.Println("test 0") | ||
lastFoodTime := dummyDog.LastFoodTime() | ||
fmt.Printf("original lastFoodTime: %s\n", lastFoodTime.Format(time.StampMilli)) | ||
timeout := dummyDog.GetTimeout() | ||
fmt.Printf("timeout: %s\n", timeout.String()) | ||
|
||
Eventually(func() bool { | ||
fmt.Println("test 1") | ||
newTime := dummyDog.LastFoodTime() | ||
fmt.Printf("newTime: %s\n", newTime.Format(time.StampMilli)) | ||
// ensure the timeout passed | ||
n := time.Now() | ||
fmt.Printf("now (%s) should be past 3x past lastFoodTime(%s) which is %s\n", | ||
n.Format(time.StampMilli), lastFoodTime.Format(time.StampMilli), lastFoodTime.Add(3*timeout).Format(time.StampMilli)) | ||
//fmt.Printf("timeout: %s\n", lastFoodTime.Add(3*timeout).Format(time.StampMilli)) | ||
timeoutPassed := n.After(lastFoodTime.Add(3 * timeout)) | ||
// ensure wd wasn't feeded | ||
fmt.Printf("missedFeed time: %s\n", lastFoodTime.Add(timeout).Format(time.StampMilli)) | ||
fmt.Printf("newTime (%s) should be before lastFoodTime+%s (%s)\n", newTime.Format(time.StampMilli), timeout.String(), | ||
lastFoodTime.Add(timeout).Format(time.StampMilli)) | ||
missedFeed := newTime.Before(lastFoodTime.Add(timeout)) | ||
if timeoutPassed && missedFeed { | ||
fmt.Println("returning true") | ||
return true | ||
} | ||
lastFoodTime = newTime | ||
|
||
fmt.Println("returning false") | ||
return false | ||
}, "15s", timeout).Should(BeTrue()) | ||
}) | ||
}) | ||
|
||
}) | ||
|
||
Context("Configuration is missing", func() { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, any particular reason this test was removed ?