Skip to content

Commit

Permalink
Fix to startup test
Browse files Browse the repository at this point in the history
Signed-off-by: Derek Nola <derek.nola@suse.com>
  • Loading branch information
dereknola committed May 4, 2023
1 parent a4a478a commit 202b41c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
8 changes: 5 additions & 3 deletions tests/e2e/startup/startup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ func KillK3sCluster(nodes []string) error {
if _, err := e2e.RunCmdOnNode("sudo k3s-killall.sh", node); err != nil {
return err
}
if strings.Contains(node, "server") {
if _, err := e2e.RunCmdOnNode("sudo rm -rf /var/lib/rancher/k3s/server/db", node); err != nil {
return err
}
}
}
return nil
}
Expand Down Expand Up @@ -243,9 +248,6 @@ var _ = Describe("Various Startup Configurations", Ordered, func() {
cmd := "kubectl logs -n kube-system -l app.kubernetes.io/name=traefik -c traefik"
Eventually(func() error {
_, err := e2e.RunCommand(cmd)
if err != nil {
_, _ = e2e.ParsePods(kubeConfigFile, true)
}
return err
}, "360s", "5s").Should(Succeed())
})
Expand Down
8 changes: 4 additions & 4 deletions tests/e2e/testutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -443,20 +443,20 @@ func RestartClusterAgent(nodeNames []string) error {

// RunCmdOnNode executes a command from within the given node
func RunCmdOnNode(cmd string, nodename string) (string, error) {
runcmd := "vagrant ssh -c \"" + cmd + "\" " + nodename
runcmd := "vagrant ssh " + nodename + " -c \"" + cmd + "\""
out, err := RunCommand(runcmd)
if err != nil {
return out, fmt.Errorf("failed to run command: %s on node %s: %s, %v", cmd, nodename, out, err)
}
return out, nil
}

// RunCommand executes a command on the host
func RunCommand(cmd string) (string, error) {
c := exec.Command("bash", "-c", cmd)
// we don't use c.env because we embed the command inside a bash shell
if k, b := os.LookupEnv("E2E_KUBECONFIG"); b {
c.Env = append(c.Env, "KUBECONFIG="+k)
cmd = "KUBECONFIG=" + k + " " + cmd
}
c := exec.Command("bash", "-c", cmd)
out, err := c.CombinedOutput()
return string(out), err
}
Expand Down

0 comments on commit 202b41c

Please sign in to comment.