diff --git a/tests/e2escenarios/e2e_devfile_test.go b/tests/e2escenarios/e2e_devfile_test.go deleted file mode 100644 index 3e204a99c25..00000000000 --- a/tests/e2escenarios/e2e_devfile_test.go +++ /dev/null @@ -1,82 +0,0 @@ -package e2escenarios - -import ( - "github.com/redhat-developer/odo/tests/helper" - - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" -) - -// Test Objective: -// Test ODO devfile support features - -// Scope: -// Test debug support for the following components, making use of starter projects define in the corresponding devfile: -// - nodejs -// - java-springboot -// - java-quarkus -// - java-maven - -var _ = Describe("odo devfile supported tests", func() { - var componentName, projectDirPath string - var projectDir = "/projectDir" - var commonVar helper.CommonVar - - // This is run before every Spec (It) - var _ = BeforeEach(func() { - commonVar = helper.CommonBeforeEach() - componentName = helper.RandString(6) - helper.Chdir(commonVar.Context) - projectDirPath = commonVar.Context + projectDir - helper.MakeDir(projectDirPath) - helper.Chdir(projectDirPath) - }) - - // This is run after every Spec (It) - var _ = AfterEach(func() { - helper.CommonAfterEach(commonVar) - }) - - createStarterProjAndSetDebug := func(component, starter string) { - workingDir := helper.Getwd() - defer helper.Chdir(workingDir) - helper.Chdir(projectDirPath) - helper.Cmd("odo", "init", "--name", componentName, "--devfile", component, "--starter", starter).ShouldPass() - session, _, _, _, err := helper.StartDevMode(helper.DevSessionOpts{}) - Expect(err).ToNot(HaveOccurred()) - session.Stop() - session.WaitEnd() - - // stopChannel := make(chan bool) - // go func() { - // helper.Cmd("odo", "debug", "port-forward", "--local-port", debugLocalPort, "--context", projectDirPath).WithTerminate(60*time.Second, stopChannel).ShouldRun() - // }() - // - // // Make sure that the debug information output, outputs correctly. - // // We do *not* check the json output since the debugProcessID will be different each time. - // helper.WaitForCmdOut("odo", []string{"debug", "info", "-o", "json", "--context", projectDirPath}, 1, false, func(output string) bool { - // if strings.Contains(output, `"kind": "OdoDebugInfo"`) && - // strings.Contains(output, fmt.Sprintf(`"localPort": %s`, debugLocalPort)) { - // return true - // } - // return false - // }) - // stopChannel <- true - } - - Context("odo debug support for devfile components", func() { - It("Verify output debug information for nodeJS debug works", func() { - createStarterProjAndSetDebug("nodejs", "nodejs-starter") - }) - It("Verify output debug information for java-springboot works", func() { - createStarterProjAndSetDebug("java-springboot", "springbootproject") - }) - It("Verify output debug information for java-quarkus debug works", func() { - createStarterProjAndSetDebug("java-quarkus", "community") - }) - It("Verify output debug information for java-maven debug works", func() { - createStarterProjAndSetDebug("java-maven", "springbootproject") - }) - }) - -}) diff --git a/tests/e2escenarios/e2e_test.go b/tests/e2escenarios/e2e_test.go index 1505447f80d..f11a776e5be 100644 --- a/tests/e2escenarios/e2e_test.go +++ b/tests/e2escenarios/e2e_test.go @@ -185,127 +185,149 @@ var _ = Describe("E2E Test", func() { }) }) - Context("starting with non-empty Directory", func() { - var _ = BeforeEach(func() { - helper.Chdir(commonVar.Context) - helper.CopyExample(filepath.Join("source", "devfiles", "nodejs", "project"), commonVar.Context) - }) - It("should verify developer workflow from non-empty Directory", func() { - deploymentName := "my-component" - serviceName := "my-cs" - getDeployArgs := []string{"get", "deployment", "-n", commonVar.Project} - getSVCArgs := []string{"get", "svc", "-n", commonVar.Project} - - command := []string{"odo", "init"} - _, err := helper.RunInteractive(command, nil, func(ctx helper.InteractiveContext) { - - // helper.ExpectString(ctx, "Based on the files in the current directory odo detected") - helper.ExpectString(ctx, "Language: JavaScript") - helper.ExpectString(ctx, "Project type: Node.js") - helper.ExpectString(ctx, "Is this correct") - - helper.SendLine(ctx, "") - - helper.ExpectString(ctx, "Select container for which you want to change configuration?") - - helper.SendLine(ctx, "") - - helper.ExpectString(ctx, "Enter component name") - - helper.SendLine(ctx, componentName) - - helper.ExpectString(ctx, "Your new component '"+componentName+"' is ready in the current directory") - + for _, debug := range []bool{true, false} { + debug := debug + const ( + AppPort = "3000" + DebugPort = "5858" + RemoteAppURL = "http://127.0.0.1:3000" + ) + Context("starting with non-empty Directory", func() { + var _ = BeforeEach(func() { + helper.Chdir(commonVar.Context) + helper.CopyExample(filepath.Join("source", "devfiles", "nodejs", "project"), commonVar.Context) }) - Expect(err).To(BeNil()) - Expect(helper.ListFilesInDir(commonVar.Context)).To(ContainElement("devfile.yaml")) + It(fmt.Sprintf("should verify developer workflow from non-empty Directory (debug=%v)", debug), func() { + deploymentName := "my-component" + serviceName := "my-cs" + getDeployArgs := []string{"get", "deployment", "-n", commonVar.Project} + getSVCArgs := []string{"get", "svc", "-n", commonVar.Project} - // "execute odo dev and add changes to application" - var devSession helper.DevSession - var ports map[string]string - - devSession, _, _, ports, err = helper.StartDevMode(helper.DevSessionOpts{}) - Expect(err).ToNot(HaveOccurred()) - waitRemoteApp("http://127.0.0.1:3000", "Hello from Node.js Starter Application!") - checkIfDevEnvIsUp(ports["3000"], "Hello from Node.js Starter Application!") + command := []string{"odo", "init"} + _, err := helper.RunInteractive(command, nil, func(ctx helper.InteractiveContext) { - helper.ReplaceString(filepath.Join(commonVar.Context, "server.js"), "from Node.js", "from updated Node.js") - _, _, _, err = devSession.WaitSync() - Expect(err).ToNot(HaveOccurred()) - // "should update the changes" - waitRemoteApp("http://127.0.0.1:3000", "Hello from updated Node.js Starter Application!") - checkIfDevEnvIsUp(ports["3000"], "Hello from updated Node.js Starter Application!") - - // "changes are made to the applications" - helper.ReplaceString(filepath.Join(commonVar.Context, "server.js"), "from updated Node.js", "from Node.js app v2") - _, _, _, err = devSession.WaitSync() - Expect(err).ToNot(HaveOccurred()) - // "should deploy new changes" - waitRemoteApp("http://127.0.0.1:3000", "Hello from Node.js app v2 Starter Application!") - checkIfDevEnvIsUp(ports["3000"], "Hello from Node.js app v2 Starter Application!") - - // "running odo list" - stdout := helper.Cmd("odo", "list", "component").ShouldPass().Out() - helper.MatchAllInOutput(stdout, []string{componentName, "Node.js", "Dev"}) + // helper.ExpectString(ctx, "Based on the files in the current directory odo detected") + helper.ExpectString(ctx, "Language: JavaScript") + helper.ExpectString(ctx, "Project type: Node.js") + helper.ExpectString(ctx, "Is this correct") - // "exit dev mode and run odo deploy" - devSession.Stop() - devSession.WaitEnd() + helper.SendLine(ctx, "") - // all resources should be deleted from the namespace - services := commonVar.CliRunner.GetServices(commonVar.Project) - Expect(services).To(BeEmpty()) - pvcs := commonVar.CliRunner.GetAllPVCNames(commonVar.Project) - Expect(pvcs).To(BeEmpty()) - pods := commonVar.CliRunner.GetAllPodNames(commonVar.Project) - Expect(pods).To(BeEmpty()) + helper.ExpectString(ctx, "Select container for which you want to change configuration?") - // "run odo deploy" - helper.CopyExampleDevFile( - filepath.Join("source", "devfiles", "nodejs", "devfile-deploy.yaml"), - path.Join(commonVar.Context, "devfile.yaml"), - helper.DevfileMetadataNameSetter(componentName)) - helper.ReplaceString(filepath.Join(commonVar.Context, "devfile.yaml"), "nodejs-prj1-api-abhz", componentName) - stdout = helper.Cmd("odo", "deploy").AddEnv("PODMAN_CMD=echo").ShouldPass().Out() - Expect(stdout).To(ContainSubstring("Your Devfile has been successfully deployed")) + helper.SendLine(ctx, "") - // should deploy new changes - stdout = helper.Cmd("odo", "list", "component").ShouldPass().Out() - helper.MatchAllInOutput(stdout, []string{componentName, "nodejs", "Deploy"}) + helper.ExpectString(ctx, "Enter component name") - // start dev mode again - devSession, _, _, ports, err = helper.StartDevMode(helper.DevSessionOpts{}) - Expect(err).ToNot(HaveOccurred()) + helper.SendLine(ctx, componentName) - // making changes to the project again - helper.ReplaceString(filepath.Join(commonVar.Context, "server.js"), "from Node.js app v2", "from Node.js app v3") + helper.ExpectString(ctx, "Your new component '"+componentName+"' is ready in the current directory") - // "should update the changes" - waitRemoteApp("http://127.0.0.1:3000", "Hello from Node.js app v3 Starter Application!") - checkIfDevEnvIsUp(ports["3000"], "Hello from Node.js app v3 Starter Application!") + }) + Expect(err).To(BeNil()) + Expect(helper.ListFilesInDir(commonVar.Context)).To(ContainElement("devfile.yaml")) - // should list both dev,deploy - stdout = helper.Cmd("odo", "list", "component").ShouldPass().Out() - helper.MatchAllInOutput(stdout, []string{componentName, "nodejs", "Dev", "Deploy"}) + // "execute odo dev and add changes to application" + var devSession helper.DevSession + var ports map[string]string + args := []string{} + if debug { + args = append(args, "--debug") + } + devSession, _, _, ports, err = helper.StartDevMode(helper.DevSessionOpts{CmdlineArgs: args}) + Expect(err).ToNot(HaveOccurred()) + waitRemoteApp(RemoteAppURL, "Hello from Node.js Starter Application!") + checkIfDevEnvIsUp(ports[AppPort], "Hello from Node.js Starter Application!") + if debug { + checkIfDevEnvIsUp(ports[DebugPort], "WebSockets request was expected") + } + helper.ReplaceString(filepath.Join(commonVar.Context, "server.js"), "from Node.js", "from updated Node.js") + _, _, _, err = devSession.WaitSync() + Expect(err).ToNot(HaveOccurred()) + // "should update the changes" + waitRemoteApp(RemoteAppURL, "Hello from updated Node.js Starter Application!") + checkIfDevEnvIsUp(ports[AppPort], "Hello from updated Node.js Starter Application!") + if debug { + checkIfDevEnvIsUp(ports[DebugPort], "WebSockets request was expected") + } - // "exit dev mode and run odo deploy" - devSession.Stop() + // "changes are made to the applications" + helper.ReplaceString(filepath.Join(commonVar.Context, "server.js"), "from updated Node.js", "from Node.js app v2") + _, _, _, err = devSession.WaitSync() + Expect(err).ToNot(HaveOccurred()) + // "should deploy new changes" + waitRemoteApp(RemoteAppURL, "Hello from Node.js app v2 Starter Application!") + checkIfDevEnvIsUp(ports[AppPort], "Hello from Node.js app v2 Starter Application!") + if debug { + checkIfDevEnvIsUp(ports[DebugPort], "WebSockets request was expected") + } - // "run odo deploy" - stdout = helper.Cmd("odo", "deploy").AddEnv("PODMAN_CMD=echo").ShouldPass().Out() - Expect(stdout).To(ContainSubstring("Your Devfile has been successfully deployed")) + // "running odo list" + stdout := helper.Cmd("odo", "list", "component").ShouldPass().Out() + helper.MatchAllInOutput(stdout, []string{componentName, "Node.js", "Dev"}) + + // "exit dev mode and run odo deploy" + devSession.Stop() + devSession.WaitEnd() + + // all resources should be deleted from the namespace + services := commonVar.CliRunner.GetServices(commonVar.Project) + Expect(services).To(BeEmpty()) + pvcs := commonVar.CliRunner.GetAllPVCNames(commonVar.Project) + Expect(pvcs).To(BeEmpty()) + pods := commonVar.CliRunner.GetAllPodNames(commonVar.Project) + Expect(pods).To(BeEmpty()) + + // "run odo deploy" + helper.CopyExampleDevFile( + filepath.Join("source", "devfiles", "nodejs", "devfile-deploy.yaml"), + path.Join(commonVar.Context, "devfile.yaml"), + helper.DevfileMetadataNameSetter(componentName)) + helper.ReplaceString(filepath.Join(commonVar.Context, "devfile.yaml"), "nodejs-prj1-api-abhz", componentName) + stdout = helper.Cmd("odo", "deploy").AddEnv("PODMAN_CMD=echo").ShouldPass().Out() + Expect(stdout).To(ContainSubstring("Your Devfile has been successfully deployed")) + + // should deploy new changes + stdout = helper.Cmd("odo", "list", "component").ShouldPass().Out() + helper.MatchAllInOutput(stdout, []string{componentName, "nodejs", "Deploy"}) + + // start dev mode again + devSession, _, _, ports, err = helper.StartDevMode(helper.DevSessionOpts{}) + Expect(err).ToNot(HaveOccurred()) + + // making changes to the project again + helper.ReplaceString(filepath.Join(commonVar.Context, "server.js"), "from Node.js app v2", "from Node.js app v3") + + // "should update the changes" + waitRemoteApp(RemoteAppURL, "Hello from Node.js app v3 Starter Application!") + checkIfDevEnvIsUp(ports[AppPort], "Hello from Node.js app v3 Starter Application!") + if debug { + checkIfDevEnvIsUp(ports[DebugPort], "WebSockets request was expected") + } - command = []string{"odo", "delete", "component"} - _, err = helper.RunInteractive(command, nil, func(ctx helper.InteractiveContext) { - helper.ExpectString(ctx, "Are you sure you want to delete \""+componentName+"\" and all its resources?") - helper.SendLine(ctx, "y") - helper.ExpectString(ctx, "successfully deleted") + // should list both dev,deploy + stdout = helper.Cmd("odo", "list", "component").ShouldPass().Out() + helper.MatchAllInOutput(stdout, []string{componentName, "nodejs", "Dev", "Deploy"}) + + // "exit dev mode and run odo deploy" + devSession.Stop() + + // "run odo deploy" + stdout = helper.Cmd("odo", "deploy").AddEnv("PODMAN_CMD=echo").ShouldPass().Out() + Expect(stdout).To(ContainSubstring("Your Devfile has been successfully deployed")) + + command = []string{"odo", "delete", "component"} + _, err = helper.RunInteractive(command, nil, func(ctx helper.InteractiveContext) { + helper.ExpectString(ctx, "Are you sure you want to delete \""+componentName+"\" and all its resources?") + helper.SendLine(ctx, "y") + helper.ExpectString(ctx, "successfully deleted") + }) + Expect(err).To(BeNil()) + Eventually(string(commonVar.CliRunner.Run(getDeployArgs...).Out.Contents()), 60, 3).ShouldNot(ContainSubstring(deploymentName)) + Eventually(string(commonVar.CliRunner.Run(getSVCArgs...).Out.Contents()), 60, 3).ShouldNot(ContainSubstring(serviceName)) }) - Expect(err).To(BeNil()) - Eventually(string(commonVar.CliRunner.Run(getDeployArgs...).Out.Contents()), 60, 3).ShouldNot(ContainSubstring(deploymentName)) - Eventually(string(commonVar.CliRunner.Run(getSVCArgs...).Out.Contents()), 60, 3).ShouldNot(ContainSubstring(serviceName)) }) - }) + } Context("starting with non-empty Directory add Binding", func() { sendDataEntry := func(url string) map[string]interface{} {