Skip to content

Commit

Permalink
Add test highlighting the issue and setting the expectations
Browse files Browse the repository at this point in the history
  • Loading branch information
rm3l committed May 10, 2023
1 parent da28e7d commit 397745f
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 1 deletion.
9 changes: 8 additions & 1 deletion tests/helper/helper_filesystem.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,15 @@ func copyDir(src string, dst string, info os.FileInfo) error {
// path is the path to the required file
// fileContent is the content to be written to the given file
func CreateFileWithContent(path string, fileContent string) error {
return CreateFileWithContentAndPerm(path, fileContent, 0600)
}

// CreateFileWithContentAndPerm creates a file at the given path using the given file permissions, and writes the given content.
// path is the path to the required file
// fileContent is the content to be written to the given file
func CreateFileWithContentAndPerm(path string, fileContent string, perm os.FileMode) error {
// create and open file if not exists
var file, err = os.OpenFile(path, os.O_RDWR|os.O_CREATE, 0600)
var file, err = os.OpenFile(path, os.O_RDWR|os.O_CREATE, perm)
if err != nil {
return err
}
Expand Down
37 changes: 37 additions & 0 deletions tests/integration/cmd_dev_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ package integration
import (
"bufio"
"encoding/json"
"errors"
"fmt"
"io"
"io/fs"
"net/http"
"net/http/httptest"
"os"
Expand Down Expand Up @@ -80,6 +82,41 @@ var _ = Describe("odo dev command tests", func() {
errOut := helper.Cmd("odo", "dev", "--platform", "podman").WithEnv("PODMAN_CMD=echo").ShouldFail().Err()
Expect(errOut).To(ContainSubstring("unable to access podman"))
})

It("should start on cluster even if Podman client takes long to initialize", func() {
if runtime.GOOS == "windows" {
Skip("skipped on Windows as it requires Unix permissions")
}
_, err := os.Stat("/bin/bash")
if errors.Is(err, fs.ErrNotExist) {
Skip("skipped because bash executable not found")
}

// odo dev on cluster should not wait for the Podman client to initialize properly, if this client takes very long.
// See https://github.com/redhat-developer/odo/issues/6575.
// StartDevMode will time out if Podman client takes too long to initialize.
delayer := filepath.Join(commonVar.Context, "podman-cmd-delayer")
err = helper.CreateFileWithContentAndPerm(delayer, `#!/bin/bash
echo Delaying command execution... >&2
sleep 7200
echo "$@"
`, 0755)
Expect(err).ShouldNot(HaveOccurred())

var devSession helper.DevSession
var stderrBytes []byte
devSession, _, stderrBytes, _, err = helper.StartDevMode(helper.DevSessionOpts{
RunOnPodman: false,
CmdlineArgs: []string{"-v", "3"},
EnvVars: []string{"PODMAN_CMD=" + delayer},
})
Expect(err).ShouldNot(HaveOccurred())
defer devSession.Kill()

Expect(string(stderrBytes)).Should(ContainSubstring("timeout while waiting for Podman version"))
})

When("using a default namespace", func() {
BeforeEach(func() {
commonVar.CliRunner.SetProject("default")
Expand Down

0 comments on commit 397745f

Please sign in to comment.