Skip to content

Commit

Permalink
chore: add timeout to dnf commands and print test errors
Browse files Browse the repository at this point in the history
  • Loading branch information
ricardomaraschini committed Oct 5, 2023
1 parent 4bb7cbf commit 2b9a24c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion e2e/install_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ func TestHostPreflight(t *testing.T) {
defer tc.Destroy()
t.Log("installing ssh and binutils on node 0")
commands := [][]string{
{"dnf", "install", "-y", "openssh-server", "binutils", "tar"},
{"dnf", "--setopt=metadata_expire=120", "install", "-y", "openssh-server", "binutils", "tar"},
{"systemctl", "enable", "sshd"},
{"systemctl", "start", "sshd"},
}
Expand Down
7 changes: 6 additions & 1 deletion e2e/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,22 @@ func (b *buffer) Close() error {
return nil
}

// RunCommandsOnNode runs a series of commands on a node.
func RunCommandsOnNode(t *testing.T, cl *cluster.Output, node int, cmds [][]string) error {
for _, cmd := range cmds {
cmdstr := strings.Join(cmd, " ")
t.Logf("running `%s` node %d", cmdstr, node)
if _, _, err := RunCommandOnNode(t, cl, node, cmd); err != nil {
stdout, stderr, err := RunCommandOnNode(t, cl, node, cmd)
if err != nil {
t.Logf("stdout:\n%s", stdout)
t.Logf("stderr:\n%s", stderr)
return err
}
}
return nil
}

// RunCommandOnNode runs a command on a node with a timeout.
func RunCommandOnNode(t *testing.T, cl *cluster.Output, node int, line []string) (string, string, error) {
stdout := &buffer{bytes.NewBuffer(nil)}
stderr := &buffer{bytes.NewBuffer(nil)}
Expand Down

0 comments on commit 2b9a24c

Please sign in to comment.