Skip to content
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

system-test: refactor KernelCrashKdump function #155

Merged
merged 1 commit into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 2 additions & 15 deletions tests/system-tests/internal/reboot/reboot.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,16 +100,10 @@ func HardRebootNode(nodeName string, nsName string) error {

// KernelCrashKdump triggers a kernel crash dump which generates a vmcore dump.
func KernelCrashKdump(nodeName string) error {
// pull openshift apiserver deployment object to wait for after the node reboot.
openshiftAPIDeploy, err := deployment.Pull(APIClient, "apiserver", "openshift-apiserver")

if err != nil {
return err
}

cmdToExec := []string{"chroot", "/rootfs", "/bin/sh", "-c", "rm -rf /var/crash/*"}

glog.V(90).Infof("Remove any existing crash dumps. Exec cmd %v", cmdToExec)
_, err = remote.ExecuteOnNodeWithDebugPod(cmdToExec, nodeName)
_, err := remote.ExecuteOnNodeWithDebugPod(cmdToExec, nodeName)

if err != nil {
return err
Expand All @@ -124,13 +118,6 @@ func KernelCrashKdump(nodeName string) error {
return err
}

// wait for the openshift apiserver deployment to be available
err = openshiftAPIDeploy.WaitUntilCondition("Available", 5*time.Minute)

if err != nil {
return err
}

return nil
}

Expand Down
12 changes: 12 additions & 0 deletions tests/system-tests/ran-du/tests/kernel-crash-kdump.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/openshift-kni/eco-goinfra/pkg/deployment"
"github.com/openshift-kni/eco-goinfra/pkg/nodes"
"github.com/openshift-kni/eco-goinfra/pkg/reportxml"
"github.com/openshift-kni/eco-gotests/tests/system-tests/internal/reboot"
Expand All @@ -22,6 +23,12 @@ var _ = Describe(
ContinueOnFailure,
Label("KernelCrashKdump"), func() {
It("Trigger kernel crash to generate kdump vmcore", reportxml.ID("56216"), Label("KernelCrashKdump"), func() {
By("Pulling in OpenshiftAPI deployment")

// pull openshift apiserver deployment object to wait for after the node reboot.
openshiftAPIDeploy, err := deployment.Pull(APIClient, "apiserver", "openshift-apiserver")

Expect(err).ToNot(HaveOccurred(), "Failed to pull in Openshift API deployment")

By("Retrieve nodes list")
nodeList, err := nodes.List(
Expand All @@ -35,6 +42,11 @@ var _ = Describe(
err = reboot.KernelCrashKdump(node.Definition.Name)
Expect(err).ToNot(HaveOccurred(), "Error triggering a kernel crash on the node.")

By("Waiting for the openshift apiserver deployment to be available")
err = openshiftAPIDeploy.WaitUntilCondition("Available", 5*time.Minute)

Expect(err).ToNot(HaveOccurred(), "OpenShift API server deployment not Availalble")

By(fmt.Sprintf("Wait for %d minutes for the cluster resources to reconciliate their state",
RanDuTestConfig.RebootRecoveryTime))
time.Sleep(time.Duration(RanDuTestConfig.RebootRecoveryTime) * time.Minute)
Expand Down
Loading