-
Notifications
You must be signed in to change notification settings - Fork 11
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
fix reboot_test.go and collectEntries #2663
Merged
Merged
Changes from 3 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
adabb94
fix reboot_test and collectEntries
YZ775 f352de2
fix reboot_test.go to use Expect() and fix kubectl command
YZ775 c05bb4c
fix reboot_test.go
YZ775 4c50cb7
fix reboot_test.go
YZ775 f20f197
fix reboot_test.go
YZ775 661ec7e
fix neco-reboter_test.go to use strimgs.TrimSpace
YZ775 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ package dctest | |
import ( | ||
"encoding/json" | ||
"fmt" | ||
"slices" | ||
"strings" | ||
"time" | ||
|
||
|
@@ -229,6 +230,24 @@ func testNecoRebooterRebootGracefully() { | |
return nil | ||
}).Should(Succeed()) | ||
|
||
By("getting available racks") | ||
stdout, _, err := execAt(bootServers[0], "kubectl", "get", "nodes", "-o", "json") | ||
Expect(err).NotTo(HaveOccurred()) | ||
nodes := corev1.NodeList{} | ||
err = json.Unmarshal(stdout, &nodes) | ||
Expect(err).NotTo(HaveOccurred()) | ||
racks := []string{} | ||
for _, node := range nodes.Items { | ||
rack := node.Labels["topology.kubernetes.io/zone"] | ||
if len(rack) == 0 { | ||
continue | ||
} | ||
racks = append(racks, rack) | ||
} | ||
slices.Sort(racks) | ||
racks = slices.Compact(racks) | ||
Expect(len(racks)).To(BeNumerically(">", 1)) | ||
|
||
By("changing neco-rebooter config") | ||
config := necorebooter.Config{ | ||
RebootTimes: []necorebooter.RebootTimes{ | ||
|
@@ -286,7 +305,7 @@ func testNecoRebooterRebootGracefully() { | |
}, | ||
}, | ||
NodeSelector: map[string]string{ | ||
"topology.kubernetes.io/zone": "rack1", | ||
"topology.kubernetes.io/zone": racks[0], | ||
}, | ||
}, | ||
} | ||
|
@@ -317,18 +336,14 @@ func testNecoRebooterRebootGracefully() { | |
Expect(err).NotTo(HaveOccurred()) | ||
|
||
By("creating a pod") | ||
stdout, stderr, err := execAtWithInput(bootServers[0], podYaml, "kubectl", "apply", "-f", "-") | ||
if err != nil { | ||
Fail(fmt.Sprintf("stdout: %s, stderr: %s, err: %v", stdout, stderr, err)) | ||
} | ||
_, _, err = execAtWithInput(bootServers[0], podYaml, "kubectl", "apply", "-f", "-") | ||
Expect(err).NotTo(HaveOccurred()) | ||
By("creating a pdb") | ||
stdout, stderr, err = execAtWithInput(bootServers[0], pdbYaml, "kubectl", "apply", "-f", "-") | ||
if err != nil { | ||
Fail(fmt.Sprintf("stdout: %s, stderr: %s, err: %v", stdout, stderr, err)) | ||
} | ||
_, _, err = execAtWithInput(bootServers[0], pdbYaml, "kubectl", "apply", "-f", "-") | ||
Expect(err).NotTo(HaveOccurred()) | ||
|
||
By("adding rack1 nodes to reboot-list") | ||
execSafeAt(bootServers[0], "sh", "-c", "yes | neco rebooter reboot-worker --rack=1") | ||
By(fmt.Sprintf("adding %s nodes to reboot-list", racks[0])) | ||
execSafeAt(bootServers[0], "sh", "-c", fmt.Sprintf("yes | neco rebooter reboot-worker --rack=%s", racks[0][4:])) | ||
|
||
By("enable rebooting") | ||
execSafeAt(bootServers[0], "ckecli", "rq", "enable") | ||
|
@@ -346,16 +361,16 @@ func testNecoRebooterRebootGracefully() { | |
return nil | ||
}).Should(Succeed()) | ||
|
||
By("adding rack2 nodes to reboot-list") | ||
execSafeAt(bootServers[0], "sh", "-c", "yes | neco rebooter reboot-worker --rack=2") | ||
By(fmt.Sprintf("adding %s nodes to reboot-list", racks[1])) | ||
execSafeAt(bootServers[0], "sh", "-c", fmt.Sprintf("yes | neco rebooter reboot-worker --rack=%s", racks[1][4:])) | ||
|
||
By("waiting for skipping rack1 and moving to rack2") | ||
By(fmt.Sprintf("waiting for skipping %s and moving to %s", racks[0], racks[1])) | ||
Eventually(func() error { | ||
stdout, stderr, err := execAt(bootServers[0], "neco", "rebooter", "show-processing-group") | ||
if err != nil { | ||
return fmt.Errorf("stdout: %s, stderr: %s, err: %v", stdout, stderr, err) | ||
} | ||
if string(stdout) != "rack2\n" { | ||
if strings.Contains(string(stdout), racks[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. How about use |
||
return fmt.Errorf("reboot-queue is not processed") | ||
} | ||
return nil | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Nice. But why don't you keep the
stdout
andstderr
?We can pass the optionalDescription, if we want.
https://github.com/onsi/gomega/blob/7cabed651e981da0c7d0219ad7208626cef58016/gomega_dsl.go#L524