Integration tests for odo dev running on podman (#6332)

* Change signature of StartDevMode to use options structure

* Add tests for odo dev on podman

* Uncomment commented code

* Update Makefile

Co-authored-by: Armel Soro <armel@rm3l.org>

Co-authored-by: Armel Soro <armel@rm3l.org>
This commit is contained in:
Philippe Martin
2022-11-24 14:24:00 +01:00
committed by GitHub
parent 5660093167
commit 120920f868
15 changed files with 307 additions and 222 deletions

View File

@@ -53,6 +53,8 @@ GINKGO_FLAGS_ALL = $(GINKGO_TEST_ARGS) --randomize-all --slow-spec-threshold=$(S
GINKGO_FLAGS_AUTO = $(GINKGO_FLAGS_ALL) -p GINKGO_FLAGS_AUTO = $(GINKGO_FLAGS_ALL) -p
# Flags for tests that may be run in parallel # Flags for tests that may be run in parallel
GINKGO_FLAGS=$(GINKGO_FLAGS_ALL) -nodes=$(TEST_EXEC_NODES) GINKGO_FLAGS=$(GINKGO_FLAGS_ALL) -nodes=$(TEST_EXEC_NODES)
# Flags for tests that must not be run in parallel
GINKGO_FLAGS_ONE=$(GINKGO_FLAGS_ALL) -nodes=1
# GolangCi version for unit-validate test # GolangCi version for unit-validate test
GOLANGCI_LINT_VERSION=1.49.0 GOLANGCI_LINT_VERSION=1.49.0
@@ -190,12 +192,16 @@ openshiftci-presubmit-unittests:
.PHONY: test-integration-cluster .PHONY: test-integration-cluster
test-integration-cluster: test-integration-cluster:
$(RUN_GINKGO) $(GINKGO_FLAGS) --junit-report="test-integration.xml" --label-filter="!nocluster" tests/integration $(RUN_GINKGO) $(GINKGO_FLAGS) --junit-report="test-integration.xml" --label-filter="!nocluster && !podman" tests/integration
.PHONY: test-integration-no-cluster .PHONY: test-integration-no-cluster
test-integration-no-cluster: test-integration-no-cluster:
$(RUN_GINKGO) $(GINKGO_FLAGS_AUTO) --junit-report="test-integration-nc.xml" --label-filter=nocluster tests/integration $(RUN_GINKGO) $(GINKGO_FLAGS_AUTO) --junit-report="test-integration-nc.xml" --label-filter=nocluster tests/integration
.PHONY: test-integration-podman
test-integration-podman:
$(RUN_GINKGO) $(GINKGO_FLAGS_ONE) --junit-report="test-integration-podman.xml" --label-filter=podman tests/integration
.PHONY: test-integration .PHONY: test-integration
test-integration: test-integration-no-cluster test-integration-cluster test-integration: test-integration-no-cluster test-integration-cluster

View File

@@ -42,7 +42,7 @@ var _ = Describe("odo devfile supported tests", func() {
defer helper.Chdir(workingDir) defer helper.Chdir(workingDir)
helper.Chdir(projectDirPath) helper.Chdir(projectDirPath)
helper.Cmd("odo", "init", "--name", componentName, "--devfile", component, "--starter", starter).ShouldPass() helper.Cmd("odo", "init", "--name", componentName, "--devfile", component, "--starter", starter).ShouldPass()
session, _, _, _, err := helper.StartDevMode(nil) session, _, _, _, err := helper.StartDevMode(helper.DevSessionOpts{})
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
session.Stop() session.Stop()
session.WaitEnd() session.WaitEnd()

View File

@@ -76,7 +76,7 @@ var _ = Describe("E2E Test", func() {
var devSession helper.DevSession var devSession helper.DevSession
var ports map[string]string var ports map[string]string
devSession, _, _, ports, err = helper.StartDevMode(nil) devSession, _, _, ports, err = helper.StartDevMode(helper.DevSessionOpts{})
helper.ReplaceString(filepath.Join(commonVar.Context, "server.js"), "from Node.js", "from updated Node.js") helper.ReplaceString(filepath.Join(commonVar.Context, "server.js"), "from Node.js", "from updated Node.js")
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
_, _, _, err = devSession.WaitSync() _, _, _, err = devSession.WaitSync()
@@ -119,7 +119,7 @@ var _ = Describe("E2E Test", func() {
helper.MatchAllInOutput(stdout, []string{componentName, "nodejs", "Deploy"}) helper.MatchAllInOutput(stdout, []string{componentName, "nodejs", "Deploy"})
// start dev mode again // start dev mode again
devSession, _, _, ports, err = helper.StartDevMode(nil) devSession, _, _, ports, err = helper.StartDevMode(helper.DevSessionOpts{})
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
// making changes to the project again // making changes to the project again
@@ -193,7 +193,7 @@ var _ = Describe("E2E Test", func() {
var devSession helper.DevSession var devSession helper.DevSession
var ports map[string]string var ports map[string]string
devSession, _, _, ports, err = helper.StartDevMode(nil) devSession, _, _, ports, err = helper.StartDevMode(helper.DevSessionOpts{})
helper.ReplaceString(filepath.Join(commonVar.Context, "server.js"), "from Node.js", "from updated Node.js") helper.ReplaceString(filepath.Join(commonVar.Context, "server.js"), "from Node.js", "from updated Node.js")
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
@@ -239,7 +239,7 @@ var _ = Describe("E2E Test", func() {
helper.MatchAllInOutput(stdout, []string{componentName, "nodejs", "Deploy"}) helper.MatchAllInOutput(stdout, []string{componentName, "nodejs", "Deploy"})
// start dev mode again // start dev mode again
devSession, _, _, ports, err = helper.StartDevMode(nil) devSession, _, _, ports, err = helper.StartDevMode(helper.DevSessionOpts{})
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
// making changes to the project again // making changes to the project again

View File

@@ -114,25 +114,34 @@ type DevSession struct {
console *expect.Console console *expect.Console
} }
type DevSessionOpts struct {
EnvVars []string
CmdlineArgs []string
RunOnPodman bool
}
// StartDevMode starts a dev session with `odo dev` // StartDevMode starts a dev session with `odo dev`
// It returns a session structure, the contents of the standard and error outputs // It returns a session structure, the contents of the standard and error outputs
// and the redirections endpoints to access ports opened by component // and the redirections endpoints to access ports opened by component
// when the dev mode is completely started // when the dev mode is completely started
func StartDevMode(envvars []string, opts ...string) (DevSession, []byte, []byte, map[string]string, error) { func StartDevMode(options DevSessionOpts) (DevSession, []byte, []byte, map[string]string, error) {
if options.RunOnPodman {
options.CmdlineArgs = append(options.CmdlineArgs, "--run-on", "podman")
options.EnvVars = append(options.EnvVars, "ODO_EXPERIMENTAL_MODE=true")
}
c, err := expect.NewConsole(expect.WithStdout(os.Stdout)) c, err := expect.NewConsole(expect.WithStdout(os.Stdout))
if err != nil { if err != nil {
return DevSession{}, nil, nil, nil, err return DevSession{}, nil, nil, nil, err
} }
args := []string{"dev", "--random-ports"} args := []string{"dev", "--random-ports"}
args = append(args, opts...) args = append(args, options.CmdlineArgs...)
cmd := Cmd("odo", args...) cmd := Cmd("odo", args...)
cmd.Cmd.Stdin = c.Tty() cmd.Cmd.Stdin = c.Tty()
cmd.Cmd.Stdout = c.Tty() cmd.Cmd.Stdout = c.Tty()
cmd.Cmd.Stderr = c.Tty() cmd.Cmd.Stderr = c.Tty()
session := cmd.AddEnv(envvars...).Runner().session session := cmd.AddEnv(options.EnvVars...).Runner().session
WaitForOutputToContain("[Ctrl+c] - Exit", 360, 10, session) WaitForOutputToContain("[Ctrl+c] - Exit", 360, 10, session)
result := DevSession{ result := DevSession{
session: session, session: session,
@@ -229,7 +238,10 @@ func (o DevSession) CheckNotSynced(timeout time.Duration) {
// The inside handler is passed the internal session pointer, the contents of the standard and error outputs, // The inside handler is passed the internal session pointer, the contents of the standard and error outputs,
// and a slice of strings - ports - giving the redirections in the form localhost:<port_number> to access ports opened by component // and a slice of strings - ports - giving the redirections in the form localhost:<port_number> to access ports opened by component
func RunDevMode(additionalOpts []string, envvars []string, inside func(session *gexec.Session, outContents []byte, errContents []byte, ports map[string]string)) error { func RunDevMode(additionalOpts []string, envvars []string, inside func(session *gexec.Session, outContents []byte, errContents []byte, ports map[string]string)) error {
session, outContents, errContents, urls, err := StartDevMode(envvars, additionalOpts...) session, outContents, errContents, urls, err := StartDevMode(DevSessionOpts{
EnvVars: envvars,
CmdlineArgs: additionalOpts,
})
if err != nil { if err != nil {
return err return err
} }

View File

@@ -1,7 +1,12 @@
package helper package helper
import (
"github.com/onsi/ginkgo/v2"
)
const ( const (
LabelNoCluster = "nocluster" LabelNoCluster = "nocluster"
LabelPodman = "podman"
) )
func NeedsCluster(labels []string) bool { func NeedsCluster(labels []string) bool {
@@ -9,6 +14,18 @@ func NeedsCluster(labels []string) bool {
if label == LabelNoCluster { if label == LabelNoCluster {
return false return false
} }
if label == LabelPodman {
return false
}
} }
return true return true
} }
func LabelPodmanIf(value bool, args ...interface{}) []interface{} {
res := []interface{}{}
if value {
res = append(res, ginkgo.Label(LabelPodman))
}
res = append(res, args...)
return res
}

View File

@@ -249,7 +249,7 @@ status:
When("odo dev is run", func() { When("odo dev is run", func() {
BeforeEach(func() { BeforeEach(func() {
devSession, _, _, _, err = helper.StartDevMode(nil) devSession, _, _, _, err = helper.StartDevMode(helper.DevSessionOpts{})
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
}) })
AfterEach(func() { AfterEach(func() {
@@ -265,7 +265,7 @@ status:
When("odo dev is run", func() { When("odo dev is run", func() {
BeforeEach(func() { BeforeEach(func() {
devSession, _, _, _, err = helper.StartDevMode(nil) devSession, _, _, _, err = helper.StartDevMode(helper.DevSessionOpts{})
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
}) })

View File

@@ -177,7 +177,7 @@ var _ = Describe("odo delete command tests", func() {
var devSession helper.DevSession var devSession helper.DevSession
BeforeEach(func() { BeforeEach(func() {
var err error var err error
devSession, _, _, _, err = helper.StartDevMode(nil) devSession, _, _, _, err = helper.StartDevMode(helper.DevSessionOpts{})
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
defer func() { defer func() {
devSession.Kill() devSession.Kill()

View File

@@ -176,7 +176,7 @@ var _ = Describe("odo describe component command tests", func() {
BeforeEach(func() { BeforeEach(func() {
var err error var err error
devSession, _, _, ports, err = helper.StartDevMode(nil) devSession, _, _, ports, err = helper.StartDevMode(helper.DevSessionOpts{})
Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())
}) })

View File

@@ -537,7 +537,7 @@ var _ = Describe("odo describe/list binding command tests", func() {
var session helper.DevSession var session helper.DevSession
BeforeEach(func() { BeforeEach(func() {
var err error var err error
session, _, _, _, err = helper.StartDevMode(nil) session, _, _, _, err = helper.StartDevMode(helper.DevSessionOpts{})
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
}) })

View File

@@ -40,7 +40,9 @@ var _ = Describe("odo dev debug command tests", func() {
var ports map[string]string var ports map[string]string
BeforeEach(func() { BeforeEach(func() {
var err error var err error
devSession, _, _, ports, err = helper.StartDevMode(nil, "--debug") devSession, _, _, ports, err = helper.StartDevMode(helper.DevSessionOpts{
CmdlineArgs: []string{"--debug"},
})
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
}) })
@@ -97,7 +99,9 @@ var _ = Describe("odo dev debug command tests", func() {
devfileHandlerCtx.devfileHandler(filepath.Join(commonVar.Context, "devfile.yaml")) devfileHandlerCtx.devfileHandler(filepath.Join(commonVar.Context, "devfile.yaml"))
} }
var err error var err error
session, stdout, stderr, ports, err = helper.StartDevMode(nil, "--debug") session, stdout, stderr, ports, err = helper.StartDevMode(helper.DevSessionOpts{
CmdlineArgs: []string{"--debug"},
})
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
}) })
@@ -168,7 +172,10 @@ var _ = Describe("odo dev debug command tests", func() {
BeforeEach(func() { BeforeEach(func() {
helper.CopyExample(filepath.Join("source", "devfiles", "nodejs", "project"), commonVar.Context) helper.CopyExample(filepath.Join("source", "devfiles", "nodejs", "project"), commonVar.Context)
helper.CopyExampleDevFile(filepath.Join("source", "devfiles", "nodejs", "devfile-composite-apply-commands.yaml"), filepath.Join(commonVar.Context, "devfile.yaml")) helper.CopyExampleDevFile(filepath.Join("source", "devfiles", "nodejs", "devfile-composite-apply-commands.yaml"), filepath.Join(commonVar.Context, "devfile.yaml"))
session, sessionOut, _, ports, err = helper.StartDevMode([]string{"PODMAN_CMD=echo"}, "--debug") session, sessionOut, _, ports, err = helper.StartDevMode(helper.DevSessionOpts{
EnvVars: []string{"PODMAN_CMD=echo"},
CmdlineArgs: []string{"--debug"},
})
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
}) })
It("should execute the composite apply commands successfully", func() { It("should execute the composite apply commands successfully", func() {
@@ -254,7 +261,9 @@ var _ = Describe("odo dev debug command tests", func() {
devfileHandlerCtx.devfileHandler(filepath.Join(commonVar.Context, "devfile.yaml")) devfileHandlerCtx.devfileHandler(filepath.Join(commonVar.Context, "devfile.yaml"))
} }
var err error var err error
session, stdout, stderr, ports, err = helper.StartDevMode(nil, "--debug") session, stdout, stderr, ports, err = helper.StartDevMode(helper.DevSessionOpts{
CmdlineArgs: []string{"--debug"},
})
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
}) })

View File

@@ -189,28 +189,36 @@ var _ = Describe("odo dev command tests", func() {
}) })
}) })
When("recording telemetry data", func() { for _, podman := range []bool{true, false} {
BeforeEach(func() { podman := podman
helper.EnableTelemetryDebug() When("recording telemetry data", helper.LabelPodmanIf(podman, func() {
session, _, _, _, _ := helper.StartDevMode(nil) BeforeEach(func() {
session.Stop() helper.EnableTelemetryDebug()
session.WaitEnd() session, _, _, _, _ := helper.StartDevMode(helper.DevSessionOpts{
}) RunOnPodman: podman,
AfterEach(func() { })
helper.ResetTelemetry() session.Stop()
}) session.WaitEnd()
It("should record the telemetry data correctly", func() { })
td := helper.GetTelemetryDebugData() AfterEach(func() {
Expect(td.Event).To(ContainSubstring("odo dev")) helper.ResetTelemetry()
Expect(td.Properties.Success).To(BeFalse()) })
Expect(td.Properties.Error).ToNot(ContainSubstring("user interrupted")) It("should record the telemetry data correctly", func() {
Expect(td.Properties.CmdProperties[segment.ComponentType]).To(ContainSubstring("nodejs")) td := helper.GetTelemetryDebugData()
Expect(td.Properties.CmdProperties[segment.Language]).To(ContainSubstring("nodejs")) Expect(td.Event).To(ContainSubstring("odo dev"))
Expect(td.Properties.CmdProperties[segment.ProjectType]).To(ContainSubstring("nodejs")) if !podman {
Expect(td.Properties.CmdProperties).Should(HaveKey(segment.Caller)) // TODO(feloy) what should be the correct exit code for odo dev after pressing ctrl-c?
Expect(td.Properties.CmdProperties[segment.Caller]).To(BeEmpty()) Expect(td.Properties.Success).To(BeFalse())
}) }
}) Expect(td.Properties.Error).ToNot(ContainSubstring("user interrupted"))
Expect(td.Properties.CmdProperties[segment.ComponentType]).To(ContainSubstring("nodejs"))
Expect(td.Properties.CmdProperties[segment.Language]).To(ContainSubstring("nodejs"))
Expect(td.Properties.CmdProperties[segment.ProjectType]).To(ContainSubstring("nodejs"))
Expect(td.Properties.CmdProperties).Should(HaveKey(segment.Caller))
Expect(td.Properties.CmdProperties[segment.Caller]).To(BeEmpty())
})
}))
}
When("an env.yaml file contains a non-current Project", func() { When("an env.yaml file contains a non-current Project", func() {
BeforeEach(func() { BeforeEach(func() {
@@ -230,7 +238,7 @@ ComponentSettings:
BeforeEach(func() { BeforeEach(func() {
var err error var err error
devSession, _, _, _, err = helper.StartDevMode(nil) devSession, _, _, _, err = helper.StartDevMode(helper.DevSessionOpts{})
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
}) })
@@ -255,7 +263,7 @@ ComponentSettings:
BeforeEach(func() { BeforeEach(func() {
var err error var err error
devSession, _, _, _, err = helper.StartDevMode(nil) devSession, _, _, _, err = helper.StartDevMode(helper.DevSessionOpts{})
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
}) })
@@ -279,7 +287,7 @@ ComponentSettings:
BeforeEach(func() { BeforeEach(func() {
helper.Cmd("odo", "preference", "set", "-f", "Ephemeral", "false").ShouldPass() helper.Cmd("odo", "preference", "set", "-f", "Ephemeral", "false").ShouldPass()
var err error var err error
devSession, _, _, _, err = helper.StartDevMode(nil) devSession, _, _, _, err = helper.StartDevMode(helper.DevSessionOpts{})
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
}) })
@@ -335,7 +343,7 @@ ComponentSettings:
BeforeEach(func() { BeforeEach(func() {
helper.Cmd("odo", "preference", "set", "-f", "Ephemeral", "false").ShouldPass() helper.Cmd("odo", "preference", "set", "-f", "Ephemeral", "false").ShouldPass()
var err error var err error
devSession, _, _, _, err = helper.StartDevMode(nil) devSession, _, _, _, err = helper.StartDevMode(helper.DevSessionOpts{})
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
}) })
@@ -382,7 +390,9 @@ ComponentSettings:
BeforeEach(func() { BeforeEach(func() {
var err error var err error
devSession, _, _, _, err = helper.StartDevMode(nil, "--no-watch") devSession, _, _, _, err = helper.StartDevMode(helper.DevSessionOpts{
CmdlineArgs: []string{"--no-watch"},
})
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
}) })
@@ -435,7 +445,7 @@ ComponentSettings:
helper.ReplaceString(filepath.Join(commonVar.Context, "devfile.yaml"), "npm start", "sleep 20 ; npm start") helper.ReplaceString(filepath.Join(commonVar.Context, "devfile.yaml"), "npm start", "sleep 20 ; npm start")
var err error var err error
devSession, _, _, ports, err = helper.StartDevMode(nil) devSession, _, _, ports, err = helper.StartDevMode(helper.DevSessionOpts{})
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
}) })
@@ -493,7 +503,9 @@ ComponentSettings:
func() { func() {
helper.CopyExample(filepath.Join("source", "devfiles", "nodejs", "project"), commonVar.Context) helper.CopyExample(filepath.Join("source", "devfiles", "nodejs", "project"), commonVar.Context)
helper.CopyExampleDevFile(filepath.Join("source", "devfiles", "nodejs", devfile.devfileName), filepath.Join(commonVar.Context, "devfile.yaml")) helper.CopyExampleDevFile(filepath.Join("source", "devfiles", "nodejs", devfile.devfileName), filepath.Join(commonVar.Context, "devfile.yaml"))
devSession, _, _, _, err = helper.StartDevMode(devfile.envvars) devSession, _, _, _, err = helper.StartDevMode(helper.DevSessionOpts{
EnvVars: devfile.envvars,
})
Expect(err).To(BeNil()) Expect(err).To(BeNil())
// ensure the deployment is created by `odo dev` // ensure the deployment is created by `odo dev`
@@ -534,7 +546,7 @@ ComponentSettings:
func() { func() {
helper.CopyExample(filepath.Join("source", "devfiles", "nodejs", "project"), commonVar.Context) helper.CopyExample(filepath.Join("source", "devfiles", "nodejs", "project"), commonVar.Context)
helper.CopyExampleDevFile(filepath.Join("source", "devfiles", "nodejs", "devfile-with-k8s-resource.yaml"), filepath.Join(commonVar.Context, "devfile.yaml")) helper.CopyExampleDevFile(filepath.Join("source", "devfiles", "nodejs", "devfile-with-k8s-resource.yaml"), filepath.Join(commonVar.Context, "devfile.yaml"))
devSession, _, _, _, err = helper.StartDevMode(nil) devSession, _, _, _, err = helper.StartDevMode(helper.DevSessionOpts{})
Expect(err).To(BeNil()) Expect(err).To(BeNil())
}) })
AfterEach(func() { AfterEach(func() {
@@ -548,153 +560,170 @@ ComponentSettings:
}) })
for _, manual := range []bool{false, true} { for _, manual := range []bool{false, true} {
manual := manual for _, podman := range []bool{false, true} {
Context("port-forwarding for the component", func() { manual := manual
When("devfile has single endpoint", func() { podman := podman
BeforeEach(func() { Context("port-forwarding for the component", helper.LabelPodmanIf(podman, func() {
helper.CopyExample(filepath.Join("source", "devfiles", "nodejs", "project"), commonVar.Context) When("devfile has single endpoint", func() {
helper.Cmd("odo", "set", "project", commonVar.Project).ShouldPass()
helper.Cmd("odo", "init", "--name", cmpName, "--devfile-path", helper.GetExamplePath("source", "devfiles", "nodejs", "devfile.yaml")).ShouldPass()
})
When("running odo dev", func() {
var devSession helper.DevSession
var ports map[string]string
BeforeEach(func() { BeforeEach(func() {
var err error if !podman {
opts := []string{} helper.Cmd("odo", "set", "project", commonVar.Project).ShouldPass()
if manual {
opts = append(opts, "--no-watch")
} }
devSession, _, _, ports, err = helper.StartDevMode(nil, opts...) helper.CopyExample(filepath.Join("source", "devfiles", "nodejs", "project"), commonVar.Context)
Expect(err).ToNot(HaveOccurred()) helper.Cmd("odo", "init", "--name", cmpName, "--devfile-path", helper.GetExamplePath("source", "devfiles", "nodejs", "devfile.yaml")).ShouldPass()
}) })
AfterEach(func() { When("running odo dev", func() {
devSession.Stop() var devSession helper.DevSession
devSession.WaitEnd() var ports map[string]string
})
It("should expose the endpoint on localhost", func() {
url := fmt.Sprintf("http://%s", ports["3000"])
resp, err := http.Get(url)
Expect(err).ToNot(HaveOccurred())
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
helper.MatchAllInOutput(string(body), []string{"Hello from Node.js Starter Application!"})
Expect(err).ToNot(HaveOccurred())
})
When("modifying memoryLimit for container in Devfile", func() {
BeforeEach(func() { BeforeEach(func() {
src := "memoryLimit: 1024Mi"
dst := "memoryLimit: 1023Mi"
helper.ReplaceString("devfile.yaml", src, dst)
if manual {
if os.Getenv("SKIP_KEY_PRESS") == "true" {
Skip("This is a unix-terminal specific scenario, skipping")
}
devSession.PressKey('p')
}
var err error var err error
_, _, ports, err = devSession.WaitSync() opts := []string{}
Expect(err).Should(Succeed()) if manual {
opts = append(opts, "--no-watch")
}
devSession, _, _, ports, err = helper.StartDevMode(helper.DevSessionOpts{
CmdlineArgs: opts,
RunOnPodman: podman,
})
Expect(err).ToNot(HaveOccurred())
})
AfterEach(func() {
devSession.Stop()
devSession.WaitEnd()
}) })
It("should expose the endpoint on localhost", func() { It("should expose the endpoint on localhost", func() {
By("updating the pod", func() { url := fmt.Sprintf("http://%s", ports["3000"])
podName := commonVar.CliRunner.GetRunningPodNameByComponent(cmpName, commonVar.Project) resp, err := http.Get(url)
bufferOutput := commonVar.CliRunner.Run("get", "pods", podName, "-o", "jsonpath='{.spec.containers[0].resources.requests.memory}'").Out.Contents()
output := string(bufferOutput)
Expect(output).To(ContainSubstring("1023Mi"))
})
By("exposing the endpoint", func() {
url := fmt.Sprintf("http://%s", ports["3000"])
resp, err := http.Get(url)
Expect(err).ToNot(HaveOccurred())
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
helper.MatchAllInOutput(string(body), []string{"Hello from Node.js Starter Application!"})
Expect(err).ToNot(HaveOccurred())
})
})
})
})
})
When("devfile has multiple endpoints", func() {
BeforeEach(func() {
helper.CopyExample(filepath.Join("source", "devfiles", "nodejs", "project-with-multiple-endpoints"), commonVar.Context)
helper.Cmd("odo", "set", "project", commonVar.Project).ShouldPass()
helper.Cmd("odo", "init", "--name", cmpName, "--devfile-path", helper.GetExamplePath("source", "devfiles", "nodejs", "devfile-with-multiple-endpoints.yaml")).ShouldPass()
})
When("running odo dev", func() {
var devSession helper.DevSession
var ports map[string]string
BeforeEach(func() {
opts := []string{}
if manual {
opts = append(opts, "--no-watch")
}
var err error
devSession, _, _, ports, err = helper.StartDevMode(nil, opts...)
Expect(err).ToNot(HaveOccurred())
})
AfterEach(func() {
devSession.Stop()
devSession.WaitEnd()
})
It("should expose all endpoints on localhost regardless of exposure", func() {
getServerResponse := func(p int) string {
resp, err := http.Get(fmt.Sprintf("http://%s", ports[strconv.Itoa(p)]))
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
defer resp.Body.Close() defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body) body, _ := io.ReadAll(resp.Body)
return string(body) helper.MatchAllInOutput(string(body), []string{"Hello from Node.js Starter Application!"})
} Expect(err).ToNot(HaveOccurred())
containerPorts := []int{3000, 4567, 7890} })
for _, p := range containerPorts { if !podman {
By(fmt.Sprintf("exposing a port targeting container port %d", p), func() { When("modifying memoryLimit for container in Devfile", func() {
r := getServerResponse(p) BeforeEach(func() {
helper.MatchAllInOutput(r, []string{"Hello from Node.js Starter Application!"}) src := "memoryLimit: 1024Mi"
}) dst := "memoryLimit: 1023Mi"
} helper.ReplaceString("devfile.yaml", src, dst)
if manual {
if os.Getenv("SKIP_KEY_PRESS") == "true" {
Skip("This is a unix-terminal specific scenario, skipping")
}
helper.ReplaceString("server.js", "Hello from Node.js", "H3110 from Node.js") devSession.PressKey('p')
}
if manual { var err error
if os.Getenv("SKIP_KEY_PRESS") == "true" { _, _, ports, err = devSession.WaitSync()
Skip("This is a unix-terminal specific scenario, skipping") Expect(err).Should(Succeed())
}
devSession.PressKey('p')
}
_, _, _, err := devSession.WaitSync()
Expect(err).Should(Succeed())
for _, p := range containerPorts {
By(fmt.Sprintf("returning the right response when querying port forwarded for container port %d", p),
func() {
Eventually(func() string {
return getServerResponse(p)
}, 180, 10).Should(Equal("H3110 from Node.js Starter Application!"))
}) })
It("should expose the endpoint on localhost", func() {
By("updating the pod", func() {
podName := commonVar.CliRunner.GetRunningPodNameByComponent(cmpName, commonVar.Project)
bufferOutput := commonVar.CliRunner.Run("get", "pods", podName, "-o", "jsonpath='{.spec.containers[0].resources.requests.memory}'").Out.Contents()
output := string(bufferOutput)
Expect(output).To(ContainSubstring("1023Mi"))
})
By("exposing the endpoint", func() {
url := fmt.Sprintf("http://%s", ports["3000"])
resp, err := http.Get(url)
Expect(err).ToNot(HaveOccurred())
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
helper.MatchAllInOutput(string(body), []string{"Hello from Node.js Starter Application!"})
Expect(err).ToNot(HaveOccurred())
})
})
})
} }
}) })
}) })
}) When("devfile has multiple endpoints", func() {
}) BeforeEach(func() {
if !podman {
helper.Cmd("odo", "set", "project", commonVar.Project).ShouldPass()
}
helper.CopyExample(filepath.Join("source", "devfiles", "nodejs", "project-with-multiple-endpoints"), commonVar.Context)
helper.Cmd("odo", "init", "--name", cmpName, "--devfile-path", helper.GetExamplePath("source", "devfiles", "nodejs", "devfile-with-multiple-endpoints.yaml")).ShouldPass()
})
When("running odo dev", func() {
var devSession helper.DevSession
var ports map[string]string
BeforeEach(func() {
opts := []string{}
if manual {
opts = append(opts, "--no-watch")
}
var err error
devSession, _, _, ports, err = helper.StartDevMode(helper.DevSessionOpts{
CmdlineArgs: opts,
RunOnPodman: podman,
})
Expect(err).ToNot(HaveOccurred())
})
AfterEach(func() {
devSession.Stop()
devSession.WaitEnd()
})
It("should expose all endpoints on localhost regardless of exposure", func() {
getServerResponse := func(p int) string {
resp, err := http.Get(fmt.Sprintf("http://%s", ports[strconv.Itoa(p)]))
Expect(err).ToNot(HaveOccurred())
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
return string(body)
}
containerPorts := []int{3000, 4567, 7890}
for _, p := range containerPorts {
By(fmt.Sprintf("exposing a port targeting container port %d", p), func() {
r := getServerResponse(p)
helper.MatchAllInOutput(r, []string{"Hello from Node.js Starter Application!"})
})
}
if !podman {
helper.ReplaceString("server.js", "Hello from Node.js", "H3110 from Node.js")
if manual {
if os.Getenv("SKIP_KEY_PRESS") == "true" {
Skip("This is a unix-terminal specific scenario, skipping")
}
devSession.PressKey('p')
}
_, _, _, err := devSession.WaitSync()
Expect(err).Should(Succeed())
for _, p := range containerPorts {
By(fmt.Sprintf("returning the right response when querying port forwarded for container port %d", p),
func() {
Eventually(func() string {
return getServerResponse(p)
}, 180, 10).Should(Equal("H3110 from Node.js Starter Application!"))
})
}
}
})
})
})
})...)
}
} }
for _, devfileHandlerCtx := range []struct { for _, devfileHandlerCtx := range []struct {
@@ -732,7 +761,7 @@ ComponentSettings:
var session helper.DevSession var session helper.DevSession
BeforeEach(func() { BeforeEach(func() {
var err error var err error
session, _, _, _, err = helper.StartDevMode(nil) session, _, _, _, err = helper.StartDevMode(helper.DevSessionOpts{})
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
}) })
AfterEach(func() { AfterEach(func() {
@@ -740,7 +769,7 @@ ComponentSettings:
session.WaitEnd() session.WaitEnd()
}) })
It("should check if the env variable has a correct value", func() { It("3. should check if the env variable has a correct value", func() {
envVars := commonVar.CliRunner.GetEnvsDevFileDeployment(devfileCmpName, "app", commonVar.Project) envVars := commonVar.CliRunner.GetEnvsDevFileDeployment(devfileCmpName, "app", commonVar.Project)
// check if the env variable has a correct value. This value was substituted from in devfile from variable // check if the env variable has a correct value. This value was substituted from in devfile from variable
Expect(envVars["FOO"]).To(Equal("bar")) Expect(envVars["FOO"]).To(Equal("bar"))
@@ -751,7 +780,9 @@ ComponentSettings:
var session helper.DevSession var session helper.DevSession
BeforeEach(func() { BeforeEach(func() {
var err error var err error
session, _, _, _, err = helper.StartDevMode(nil, "--var", "VALUE_TEST=baz") session, _, _, _, err = helper.StartDevMode(helper.DevSessionOpts{
CmdlineArgs: []string{"--var", "VALUE_TEST=baz"},
})
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
}) })
AfterEach(func() { AfterEach(func() {
@@ -773,7 +804,9 @@ ComponentSettings:
var err error var err error
err = helper.CreateFileWithContent(varfilename, "VALUE_TEST=baz") err = helper.CreateFileWithContent(varfilename, "VALUE_TEST=baz")
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
session, _, _, _, err = helper.StartDevMode(nil, "--var-file", "vars.txt") session, _, _, _, err = helper.StartDevMode(helper.DevSessionOpts{
CmdlineArgs: []string{"--var-file", "vars.txt"},
})
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
}) })
AfterEach(func() { AfterEach(func() {
@@ -797,7 +830,9 @@ ComponentSettings:
_ = os.Setenv("VALUE_TEST", "baz") _ = os.Setenv("VALUE_TEST", "baz")
err = helper.CreateFileWithContent(varfilename, "VALUE_TEST") err = helper.CreateFileWithContent(varfilename, "VALUE_TEST")
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
session, _, _, _, err = helper.StartDevMode(nil, "--var-file", "vars.txt") session, _, _, _, err = helper.StartDevMode(helper.DevSessionOpts{
CmdlineArgs: []string{"--var-file", "vars.txt"},
})
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
}) })
AfterEach(func() { AfterEach(func() {
@@ -898,7 +933,7 @@ ComponentSettings:
// Create a new directory // Create a new directory
helper.MakeDir(newDirPath) helper.MakeDir(newDirPath)
var err error var err error
session, _, _, _, err = helper.StartDevMode(nil) session, _, _, _, err = helper.StartDevMode(helper.DevSessionOpts{})
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
}) })
@@ -967,7 +1002,7 @@ ComponentSettings:
// Create a new directory // Create a new directory
helper.MakeDir(newDirPath) helper.MakeDir(newDirPath)
var err error var err error
session, _, _, _, err = helper.StartDevMode(nil) session, _, _, _, err = helper.StartDevMode(helper.DevSessionOpts{})
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
}) })
@@ -1034,7 +1069,7 @@ ComponentSettings:
fmt.Printf("the .gitignore file was not created, reason %v", err.Error()) fmt.Printf("the .gitignore file was not created, reason %v", err.Error())
} }
var err error var err error
session, _, _, _, err = helper.StartDevMode(nil) session, _, _, _, err = helper.StartDevMode(helper.DevSessionOpts{})
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
}) })
AfterEach(func() { AfterEach(func() {
@@ -1100,7 +1135,7 @@ ComponentSettings:
devfileHandlerCtx.devfileHandler(filepath.Join(commonVar.Context, "devfile.yaml")) devfileHandlerCtx.devfileHandler(filepath.Join(commonVar.Context, "devfile.yaml"))
} }
var err error var err error
session, _, _, _, err = helper.StartDevMode(nil) session, _, _, _, err = helper.StartDevMode(helper.DevSessionOpts{})
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
}) })
@@ -1140,7 +1175,7 @@ ComponentSettings:
} }
var err error var err error
session, _, _, _, err = helper.StartDevMode(nil) session, _, _, _, err = helper.StartDevMode(helper.DevSessionOpts{})
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
}) })
AfterEach(func() { AfterEach(func() {
@@ -1176,7 +1211,7 @@ ComponentSettings:
// reset clonePath and change the workdir accordingly, it should sync to project name // reset clonePath and change the workdir accordingly, it should sync to project name
helper.ReplaceString(filepath.Join(commonVar.Context, "devfile.yaml"), "clonePath: webapp/", "# clonePath: webapp/") helper.ReplaceString(filepath.Join(commonVar.Context, "devfile.yaml"), "clonePath: webapp/", "# clonePath: webapp/")
var err error var err error
session, _, _, _, err = helper.StartDevMode(nil) session, _, _, _, err = helper.StartDevMode(helper.DevSessionOpts{})
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
}) })
AfterEach(func() { AfterEach(func() {
@@ -1207,7 +1242,7 @@ ComponentSettings:
} }
var err error var err error
session, _, _, _, err = helper.StartDevMode(nil) session, _, _, _, err = helper.StartDevMode(helper.DevSessionOpts{})
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
}) })
AfterEach(func() { AfterEach(func() {
@@ -1238,7 +1273,7 @@ ComponentSettings:
devfileHandlerCtx.devfileHandler(filepath.Join(commonVar.Context, "devfile.yaml")) devfileHandlerCtx.devfileHandler(filepath.Join(commonVar.Context, "devfile.yaml"))
} }
var err error var err error
session, _, _, _, err = helper.StartDevMode(nil) session, _, _, _, err = helper.StartDevMode(helper.DevSessionOpts{})
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
}) })
AfterEach(func() { AfterEach(func() {
@@ -1268,7 +1303,7 @@ ComponentSettings:
devfileHandlerCtx.devfileHandler(filepath.Join(commonVar.Context, "devfile.yaml")) devfileHandlerCtx.devfileHandler(filepath.Join(commonVar.Context, "devfile.yaml"))
} }
var err error var err error
session, _, _, _, err = helper.StartDevMode(nil) session, _, _, _, err = helper.StartDevMode(helper.DevSessionOpts{})
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
}) })
AfterEach(func() { AfterEach(func() {
@@ -1340,7 +1375,7 @@ ComponentSettings:
devfileHandlerCtx.devfileHandler(filepath.Join(commonVar.Context, "devfile.yaml")) devfileHandlerCtx.devfileHandler(filepath.Join(commonVar.Context, "devfile.yaml"))
} }
var err error var err error
session, _, _, _, err = helper.StartDevMode(nil) session, _, _, _, err = helper.StartDevMode(helper.DevSessionOpts{})
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
}) })
AfterEach(func() { AfterEach(func() {
@@ -1378,7 +1413,9 @@ ComponentSettings:
When("odo dev is running", func() { When("odo dev is running", func() {
BeforeEach(func() { BeforeEach(func() {
helper.CopyExample(filepath.Join("source", "devfiles", "nodejs", "project"), commonVar.Context) helper.CopyExample(filepath.Join("source", "devfiles", "nodejs", "project"), commonVar.Context)
session, sessionOut, sessionErr, ports, err = helper.StartDevMode([]string{"PODMAN_CMD=echo"}) session, sessionOut, sessionErr, ports, err = helper.StartDevMode(helper.DevSessionOpts{
EnvVars: []string{"PODMAN_CMD=echo"},
})
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
}) })
It("should execute the composite apply commands successfully", func() { It("should execute the composite apply commands successfully", func() {
@@ -1464,7 +1501,9 @@ CMD ["npm", "start"]
url = server.URL url = server.URL
helper.ReplaceString(filepath.Join(commonVar.Context, "devfile.yaml"), "./Dockerfile", url) helper.ReplaceString(filepath.Join(commonVar.Context, "devfile.yaml"), "./Dockerfile", url)
session, sessionOut, _, ports, err = helper.StartDevMode(env) session, sessionOut, _, ports, err = helper.StartDevMode(helper.DevSessionOpts{
EnvVars: env,
})
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
}) })
@@ -1539,7 +1578,7 @@ CMD ["npm", "start"]
devfileHandlerCtx.devfileHandler(filepath.Join(commonVar.Context, "devfile.yaml")) devfileHandlerCtx.devfileHandler(filepath.Join(commonVar.Context, "devfile.yaml"))
} }
var err error var err error
session, _, _, _, err = helper.StartDevMode(nil) session, _, _, _, err = helper.StartDevMode(helper.DevSessionOpts{})
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
}) })
AfterEach(func() { AfterEach(func() {
@@ -1576,7 +1615,7 @@ CMD ["npm", "start"]
devfileHandlerCtx.devfileHandler(filepath.Join(commonVar.Context, "devfile.yaml")) devfileHandlerCtx.devfileHandler(filepath.Join(commonVar.Context, "devfile.yaml"))
} }
var err error var err error
session, _, _, _, err = helper.StartDevMode(nil) session, _, _, _, err = helper.StartDevMode(helper.DevSessionOpts{})
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
}) })
AfterEach(func() { AfterEach(func() {
@@ -1613,7 +1652,7 @@ CMD ["npm", "start"]
devfileHandlerCtx.devfileHandler(filepath.Join(commonVar.Context, "devfile.yaml")) devfileHandlerCtx.devfileHandler(filepath.Join(commonVar.Context, "devfile.yaml"))
} }
var err error var err error
session, _, _, _, err = helper.StartDevMode(nil) session, _, _, _, err = helper.StartDevMode(helper.DevSessionOpts{})
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
}) })
AfterEach(func() { AfterEach(func() {
@@ -1652,7 +1691,7 @@ CMD ["npm", "start"]
devfileHandlerCtx.devfileHandler(filepath.Join(commonVar.Context, "devfile.yaml")) devfileHandlerCtx.devfileHandler(filepath.Join(commonVar.Context, "devfile.yaml"))
} }
var err error var err error
session, stdout, stderr, _, err = helper.StartDevMode(nil) session, stdout, stderr, _, err = helper.StartDevMode(helper.DevSessionOpts{})
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
}) })
@@ -1717,7 +1756,7 @@ CMD ["npm", "start"]
devfileHandlerCtx.devfileHandler(filepath.Join(commonVar.Context, "devfile.yaml")) devfileHandlerCtx.devfileHandler(filepath.Join(commonVar.Context, "devfile.yaml"))
} }
var err error var err error
session, stdout, stderr, _, err = helper.StartDevMode(nil) session, stdout, stderr, _, err = helper.StartDevMode(helper.DevSessionOpts{})
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
}) })
@@ -1793,7 +1832,7 @@ CMD ["npm", "start"]
helper.CopyExampleDevFile(filepath.Join("source", "devfiles", "nodejs", "devfile.yaml"), filepath.Join(commonVar.Context, "devfile.yaml")) helper.CopyExampleDevFile(filepath.Join("source", "devfiles", "nodejs", "devfile.yaml"), filepath.Join(commonVar.Context, "devfile.yaml"))
helper.ReplaceString(filepath.Join(commonVar.Context, "devfile.yaml"), "npm start", "npm starts") helper.ReplaceString(filepath.Join(commonVar.Context, "devfile.yaml"), "npm start", "npm starts")
var err error var err error
session, _, initErr, _, err = helper.StartDevMode(nil) session, _, initErr, _, err = helper.StartDevMode(helper.DevSessionOpts{})
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
}) })
AfterEach(func() { AfterEach(func() {
@@ -1833,7 +1872,7 @@ CMD ["npm", "start"]
helper.Cmd("odo", "init", "--name", devfileCmpName, "--devfile-path", helper.GetExamplePath("source", "devfiles", "springboot", "devfile.yaml")).ShouldPass() helper.Cmd("odo", "init", "--name", devfileCmpName, "--devfile-path", helper.GetExamplePath("source", "devfiles", "springboot", "devfile.yaml")).ShouldPass()
helper.CopyExample(filepath.Join("source", "devfiles", "springboot", "project"), commonVar.Context) helper.CopyExample(filepath.Join("source", "devfiles", "springboot", "project"), commonVar.Context)
var err error var err error
session, _, _, _, err = helper.StartDevMode(nil) session, _, _, _, err = helper.StartDevMode(helper.DevSessionOpts{})
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
}) })
AfterEach(func() { AfterEach(func() {
@@ -2107,7 +2146,9 @@ CMD ["npm", "start"]
helper.Cmd("odo", "init", "--name", cmpName, "--devfile-path", helper.GetExamplePath("source", "devfiles", "springboot", "devfile-registry.yaml")).ShouldPass() helper.Cmd("odo", "init", "--name", cmpName, "--devfile-path", helper.GetExamplePath("source", "devfiles", "springboot", "devfile-registry.yaml")).ShouldPass()
helper.CopyExample(filepath.Join("source", "devfiles", "springboot", "project"), commonVar.Context) helper.CopyExample(filepath.Join("source", "devfiles", "springboot", "project"), commonVar.Context)
var err error var err error
session, _, _, _, err = helper.StartDevMode(nil, "-v", "4") session, _, _, _, err = helper.StartDevMode(helper.DevSessionOpts{
CmdlineArgs: []string{"-v", "4"},
})
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
}) })
AfterEach(func() { AfterEach(func() {
@@ -2214,7 +2255,7 @@ CMD ["npm", "start"]
helper.Cmd("odo", "init", "--name", cmpName, "--devfile-path", helper.GetExamplePath("source", "devfiles", "nodejs", "devfile-with-MR-CL-CR.yaml")).ShouldPass() helper.Cmd("odo", "init", "--name", cmpName, "--devfile-path", helper.GetExamplePath("source", "devfiles", "nodejs", "devfile-with-MR-CL-CR.yaml")).ShouldPass()
helper.CopyExample(filepath.Join("source", "devfiles", "nodejs", "project"), commonVar.Context) helper.CopyExample(filepath.Join("source", "devfiles", "nodejs", "project"), commonVar.Context)
var err error var err error
session, _, _, _, err = helper.StartDevMode(nil) session, _, _, _, err = helper.StartDevMode(helper.DevSessionOpts{})
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
}) })
AfterEach(func() { AfterEach(func() {
@@ -2253,7 +2294,7 @@ CMD ["npm", "start"]
helper.ReplaceString("package.json", "node server.js", "node server/server.js") helper.ReplaceString("package.json", "node server.js", "node server/server.js")
var err error var err error
session, _, _, _, err = helper.StartDevMode(nil) session, _, _, _, err = helper.StartDevMode(helper.DevSessionOpts{})
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
}) })
AfterEach(func() { AfterEach(func() {
@@ -2284,7 +2325,7 @@ CMD ["npm", "start"]
helper.Cmd("odo", "init", "--name", cmpName, "--devfile-path", helper.GetExamplePath("source", "devfiles", "nodejs", "devfile.yaml")).ShouldPass() helper.Cmd("odo", "init", "--name", cmpName, "--devfile-path", helper.GetExamplePath("source", "devfiles", "nodejs", "devfile.yaml")).ShouldPass()
helper.CopyExample(filepath.Join("source", "devfiles", "nodejs", "project"), commonVar.Context) helper.CopyExample(filepath.Join("source", "devfiles", "nodejs", "project"), commonVar.Context)
session, _, errContents, _, err := helper.StartDevMode(nil) session, _, errContents, _, err := helper.StartDevMode(helper.DevSessionOpts{})
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
defer func() { defer func() {
session.Stop() session.Stop()
@@ -2306,7 +2347,7 @@ CMD ["npm", "start"]
helper.Cmd("odo", "init", "--name", cmpName, "--devfile-path", helper.GetExamplePath("source", "devfiles", "nodejs", "devfile.yaml")).ShouldPass() helper.Cmd("odo", "init", "--name", cmpName, "--devfile-path", helper.GetExamplePath("source", "devfiles", "nodejs", "devfile.yaml")).ShouldPass()
helper.CopyExample(filepath.Join("source", "devfiles", "nodejs", "project"), commonVar.Context) helper.CopyExample(filepath.Join("source", "devfiles", "nodejs", "project"), commonVar.Context)
session, _, errContents, err := helper.StartDevMode(nil) session, _, errContents, err := helper.StartDevMode(helper.DevSessionOpts{})
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
defer session.Stop() defer session.Stop()
helper.MatchAllInOutput(string(errContents), []string{"odo may not work as expected in the default project"}) helper.MatchAllInOutput(string(errContents), []string{"odo may not work as expected in the default project"})
@@ -2327,7 +2368,7 @@ CMD ["npm", "start"]
helper.GetExamplePath("source", "devfiles", "nodejs", "devfile-with-multiple-endpoints.yaml")).ShouldPass() helper.GetExamplePath("source", "devfiles", "nodejs", "devfile-with-multiple-endpoints.yaml")).ShouldPass()
var err error var err error
devSession, _, _, _, err = helper.StartDevMode(nil) devSession, _, _, _, err = helper.StartDevMode(helper.DevSessionOpts{})
Expect(err).ShouldNot(HaveOccurred()) Expect(err).ShouldNot(HaveOccurred())
}) })
@@ -2400,7 +2441,7 @@ CMD ["npm", "start"]
}) })
It("should run odo dev successfully (#5620)", func() { It("should run odo dev successfully (#5620)", func() {
devSession, stdoutBytes, stderrBytes, _, err := helper.StartDevMode(nil) devSession, stdoutBytes, stderrBytes, _, err := helper.StartDevMode(helper.DevSessionOpts{})
Expect(err).ShouldNot(HaveOccurred()) Expect(err).ShouldNot(HaveOccurred())
defer devSession.Stop() defer devSession.Stop()
const errorMessage = "Failed to create the component:" const errorMessage = "Failed to create the component:"
@@ -2435,7 +2476,7 @@ CMD ["npm", "start"]
helper.Cmd("odo", "init", "--name", cmpName, "--devfile-path", helper.GetExamplePath("source", "devfiles", "nodejs", "devfile-with-multiple-endpoints.yaml")).ShouldPass() helper.Cmd("odo", "init", "--name", cmpName, "--devfile-path", helper.GetExamplePath("source", "devfiles", "nodejs", "devfile-with-multiple-endpoints.yaml")).ShouldPass()
Expect(helper.VerifyFileExists(".odo/devstate.json")).To(BeFalse()) Expect(helper.VerifyFileExists(".odo/devstate.json")).To(BeFalse())
var err error var err error
devSession, _, _, _, err = helper.StartDevMode(nil) devSession, _, _, _, err = helper.StartDevMode(helper.DevSessionOpts{})
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
}) })
@@ -2463,7 +2504,7 @@ CMD ["npm", "start"]
helper.Cmd("odo", "init", "--name", cmpName, "--devfile-path", helper.GetExamplePath("source", "devfiles", "nodejs", "devfile-with-multiple-endpoints.yaml")).ShouldPass() helper.Cmd("odo", "init", "--name", cmpName, "--devfile-path", helper.GetExamplePath("source", "devfiles", "nodejs", "devfile-with-multiple-endpoints.yaml")).ShouldPass()
Expect(helper.VerifyFileExists(".odo/devstate.json")).To(BeFalse()) Expect(helper.VerifyFileExists(".odo/devstate.json")).To(BeFalse())
var err error var err error
devSession, _, _, _, err = helper.StartDevMode(nil) devSession, _, _, _, err = helper.StartDevMode(helper.DevSessionOpts{})
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
}) })
@@ -2495,7 +2536,7 @@ CMD ["npm", "start"]
helper.CopyExampleDevFile(filepath.Join("source", "devfiles", "nodejs", "devfile-parent.yaml"), filepath.Join(commonVar.Context, "devfile-parent.yaml")) helper.CopyExampleDevFile(filepath.Join("source", "devfiles", "nodejs", "devfile-parent.yaml"), filepath.Join(commonVar.Context, "devfile-parent.yaml"))
helper.CopyExample(filepath.Join("source", "nodejs"), commonVar.Context) helper.CopyExample(filepath.Join("source", "nodejs"), commonVar.Context)
var err error var err error
devSession, _, _, _, err = helper.StartDevMode(nil) devSession, _, _, _, err = helper.StartDevMode(helper.DevSessionOpts{})
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
gitignorePath := filepath.Join(commonVar.Context, ".gitignore") gitignorePath := filepath.Join(commonVar.Context, ".gitignore")
@@ -2531,7 +2572,7 @@ CMD ["npm", "start"]
BeforeEach(func() { BeforeEach(func() {
helper.CopyExample(filepath.Join("source", "java-quarkus"), commonVar.Context) helper.CopyExample(filepath.Join("source", "java-quarkus"), commonVar.Context)
var err error var err error
devSession, stdout, _, _, err = helper.StartDevMode(nil) devSession, stdout, _, _, err = helper.StartDevMode(helper.DevSessionOpts{})
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
}) })
@@ -2570,7 +2611,7 @@ CMD ["npm", "start"]
var devSession helper.DevSession var devSession helper.DevSession
BeforeEach(func() { BeforeEach(func() {
var err error var err error
devSession, _, _, _, err = helper.StartDevMode(nil) devSession, _, _, _, err = helper.StartDevMode(helper.DevSessionOpts{})
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
}) })
@@ -2796,7 +2837,7 @@ CMD ["npm", "start"]
var devSession helper.DevSession var devSession helper.DevSession
BeforeEach(func() { BeforeEach(func() {
var err error var err error
devSession, _, _, _, err = helper.StartDevMode(nil) devSession, _, _, _, err = helper.StartDevMode(helper.DevSessionOpts{})
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
}) })

View File

@@ -97,7 +97,7 @@ var _ = Describe("odo devfile deploy command tests", func() {
}) })
It("should run odo dev successfully", func() { It("should run odo dev successfully", func() {
session, _, _, _, err := helper.StartDevMode(nil) session, _, _, _, err := helper.StartDevMode(helper.DevSessionOpts{})
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
session.Kill() session.Kill()
session.WaitEnd() session.WaitEnd()
@@ -105,7 +105,7 @@ var _ = Describe("odo devfile deploy command tests", func() {
When("running and stopping odo dev", func() { When("running and stopping odo dev", func() {
BeforeEach(func() { BeforeEach(func() {
session, _, _, _, err := helper.StartDevMode(nil) session, _, _, _, err := helper.StartDevMode(helper.DevSessionOpts{})
Expect(err).ShouldNot(HaveOccurred()) Expect(err).ShouldNot(HaveOccurred())
session.Stop() session.Stop()
session.WaitEnd() session.WaitEnd()

View File

@@ -101,7 +101,7 @@ var _ = Describe("odo list with devfile", func() {
helper.CopyExampleDevFile(filepath.Join("source", "devfiles", "nodejs", "devfile-deploy.yaml"), path.Join(commonVar.Context, "devfile.yaml")) helper.CopyExampleDevFile(filepath.Join("source", "devfiles", "nodejs", "devfile-deploy.yaml"), path.Join(commonVar.Context, "devfile.yaml"))
helper.Chdir(commonVar.Context) helper.Chdir(commonVar.Context)
var err error var err error
devSession, _, _, _, err = helper.StartDevMode(nil) devSession, _, _, _, err = helper.StartDevMode(helper.DevSessionOpts{})
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
}) })
AfterEach(func() { AfterEach(func() {
@@ -214,7 +214,7 @@ var _ = Describe("odo list with devfile", func() {
var devSession helper.DevSession var devSession helper.DevSession
BeforeEach(func() { BeforeEach(func() {
var err error var err error
devSession, _, _, _, err = helper.StartDevMode(nil) devSession, _, _, _, err = helper.StartDevMode(helper.DevSessionOpts{})
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
}) })
AfterEach(func() { AfterEach(func() {
@@ -241,7 +241,7 @@ var _ = Describe("odo list with devfile", func() {
var devSession helper.DevSession var devSession helper.DevSession
BeforeEach(func() { BeforeEach(func() {
var err error var err error
devSession, _, _, _, err = helper.StartDevMode(nil) devSession, _, _, _, err = helper.StartDevMode(helper.DevSessionOpts{})
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
}) })
AfterEach(func() { AfterEach(func() {

View File

@@ -77,7 +77,7 @@ var _ = Describe("odo logs command tests", func() {
var err error var err error
BeforeEach(func() { BeforeEach(func() {
devSession, _, _, _, err = helper.StartDevMode(nil) devSession, _, _, _, err = helper.StartDevMode(helper.DevSessionOpts{})
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
// We need to wait for the pod deployed as a Kubernetes component // We need to wait for the pod deployed as a Kubernetes component
Eventually(func() bool { Eventually(func() bool {
@@ -175,7 +175,7 @@ var _ = Describe("odo logs command tests", func() {
var devSession helper.DevSession var devSession helper.DevSession
var err error var err error
BeforeEach(func() { BeforeEach(func() {
devSession, _, _, _, err = helper.StartDevMode(nil) devSession, _, _, _, err = helper.StartDevMode(helper.DevSessionOpts{})
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
helper.Cmd("odo", "deploy").AddEnv("PODMAN_CMD=echo").ShouldPass() helper.Cmd("odo", "deploy").AddEnv("PODMAN_CMD=echo").ShouldPass()
Eventually(func() bool { Eventually(func() bool {

View File

@@ -45,7 +45,7 @@ var _ = Describe("odo remove binding command tests", func() {
var session helper.DevSession var session helper.DevSession
BeforeEach(func() { BeforeEach(func() {
var err error var err error
session, _, _, _, err = helper.StartDevMode(nil) session, _, _, _, err = helper.StartDevMode(helper.DevSessionOpts{})
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
}) })
AfterEach(func() { AfterEach(func() {