From c72e75bce320ef488281196fda717b1cfec86c80 Mon Sep 17 00:00:00 2001 From: anandrkskd Date: Fri, 27 May 2022 00:10:50 +0530 Subject: [PATCH 1/7] add e2e tests, add G107 in gosec as exception Signed-off-by: anandrkskd --- Makefile | 2 +- tests/e2escenarios/e2e-test.go | 258 +++++++++++++++++++++++++++++++++ 2 files changed, 259 insertions(+), 1 deletion(-) create mode 100644 tests/e2escenarios/e2e-test.go diff --git a/Makefile b/Makefile index 52b7c053720..8aff77218b8 100644 --- a/Makefile +++ b/Makefile @@ -102,7 +102,7 @@ vet: .PHONY: sec sec: - go run $(COMMON_GOFLAGS) github.com/securego/gosec/v2/cmd/gosec -severity medium -confidence medium -exclude G304,G204 -quiet ./... + go run $(COMMON_GOFLAGS) github.com/securego/gosec/v2/cmd/gosec -severity medium -confidence medium -exclude G304,G204,G107 -quiet ./... .PHONY: clean clean: diff --git a/tests/e2escenarios/e2e-test.go b/tests/e2escenarios/e2e-test.go new file mode 100644 index 00000000000..7ca12fd32c0 --- /dev/null +++ b/tests/e2escenarios/e2e-test.go @@ -0,0 +1,258 @@ +//go:build linux || darwin || dragonfly || solaris || openbsd || netbsd || freebsd +// +build linux darwin dragonfly solaris openbsd netbsd freebsd + +package e2escenarios + +import ( + "fmt" + "io" + "net/http" + "path" + "path/filepath" + "time" + + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" + "github.com/redhat-developer/odo/tests/helper" +) + +var _ = Describe("E2E Test", func() { + var commonVar helper.CommonVar + var _ = BeforeEach(func() { + commonVar = helper.CommonBeforeEach() + }) + var _ = AfterEach(func() { + helper.CommonAfterEach(commonVar) + }) + + checkIfDevEnvIsUp := func(url, assertString string) { + Eventually(func() string { + url := fmt.Sprintf("http://%s", url) + resp, err := http.Get(url) + Expect(err).ToNot(HaveOccurred()) + defer resp.Body.Close() + + body, _ := io.ReadAll(resp.Body) + return string(body) + }, 60*time.Second, 10*time.Second).Should(Equal(assertString)) + } + + Context("starting with empty Directory", func() { + componentName := helper.RandString(6) + var _ = BeforeEach(func() { + helper.Chdir(commonVar.Context) + Expect(helper.ListFilesInDir(commonVar.Context)).To(BeEmpty()) + }) + + It("should verify developer workflow from 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"} + output, err := helper.RunInteractive(command, nil, func(ctx helper.InteractiveContext) { + + helper.ExpectString(ctx, "Select language") + helper.SendLine(ctx, "javascript") + + helper.ExpectString(ctx, "Select project type") + helper.SendLine(ctx, "Node.js\n") + + helper.ExpectString(ctx, "Which starter project do you want to use") + helper.SendLine(ctx, "nodejs-starter\n") + + helper.ExpectString(ctx, "Enter component name") + helper.SendLine(ctx, componentName) + + helper.ExpectString(ctx, "Your new component '"+componentName+"' is ready in the current directory") + + }) + Expect(err).To(BeNil()) + Expect(output).To(ContainSubstring("Your new component '" + componentName + "' is ready in the current directory")) + Expect(helper.ListFilesInDir(commonVar.Context)).To(ContainElement("devfile.yaml")) + Expect(helper.ListFilesInDir(commonVar.Context)).To(ContainElement("server.js")) + + // "execute odo dev and add changes to application" + var devSession helper.DevSession + var outContents []byte + var ports map[string]string + + devSession, outContents, _, ports, err = helper.StartDevMode() + helper.ReplaceString(filepath.Join(commonVar.Context, "server.js"), "from Node.js", "from updated Node.js") + Expect(err).ToNot(HaveOccurred()) + helper.MatchAllInOutput(string(outContents), []string{"Watching for changes in the current directory"}) + + // "should update the changes" + checkIfDevEnvIsUp(ports["3000"], "Hello from updated Node.js Starter Application!") + + // "changes are made made to the applications" + helper.ReplaceString(filepath.Join(commonVar.Context, "server.js"), "from updated Node.js", "from Node.js app v2") + helper.MatchAllInOutput(string(outContents), []string{"Watching for changes in the current directory"}) + + // "should deploy new changes" + checkIfDevEnvIsUp(ports["3000"], "Hello from Node.js app v2 Starter Application!") + + // "running odo list" + stdout := helper.Cmd("odo", "list").ShouldPass().Out() + helper.MatchAllInOutput(stdout, []string{componentName, "nodejs", "Dev"}) + + // "exit dev mode and run odo deploy" + devSession.Stop() + devSession.WaitEnd() + + // "run odo deploy" + helper.CopyExampleDevFile(filepath.Join("source", "devfiles", "nodejs", "devfile-deploy.yaml"), path.Join(commonVar.Context, "devfile.yaml")) + helper.ReplaceString(filepath.Join(commonVar.Context, "devfile.yaml"), "nodejs-prj1-api-abhz", componentName) + + //helper.ReplaceString(filepath.Join(commonVar.Context, "devfile.yaml"), "quay.io/unknown-account/myimage", "quay.io/repository/libpod/alpine") + 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").ShouldPass().Out() + helper.MatchAllInOutput(stdout, []string{componentName, "nodejs", "Deploy"}) + + // start dev mode again + devSession, outContents, _, ports, err = helper.StartDevMode() + 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") + helper.MatchAllInOutput(string(outContents), []string{"Watching for changes in the current directory"}) + + // "should update the changes" + checkIfDevEnvIsUp(ports["3000"], "Hello from Node.js app v3 Starter Application!") + + // should list both dev,deploy + stdout = helper.Cmd("odo", "list").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")) + + // "run odo delete and check if the component is deleted" + command = []string{"odo", "delete", "component"} + 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") + }) + 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", func() { + componentName := helper.RandString(6) + 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"} + output, 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: nodejs") + helper.ExpectString(ctx, "Is this correct") + + helper.SendLine(ctx, "\n") + + helper.ExpectString(ctx, "Select container for which you want to change configuration?") + + helper.SendLine(ctx, "\n") + + helper.ExpectString(ctx, "Enter component name") + + helper.SendLine(ctx, componentName) + + helper.ExpectString(ctx, "Your new component '"+componentName+"' is ready in the current directory") + + }) + Expect(err).To(BeNil()) + Expect(output).To(ContainSubstring("Your new component '" + componentName + "' is ready in the current directory")) + Expect(helper.ListFilesInDir(commonVar.Context)).To(ContainElement("devfile.yaml")) + + // "execute odo dev and add changes to application" + var devSession helper.DevSession + var outContents []byte + var ports map[string]string + + devSession, outContents, _, ports, err = helper.StartDevMode() + helper.ReplaceString(filepath.Join(commonVar.Context, "server.js"), "from Node.js", "from updated Node.js") + Expect(err).ToNot(HaveOccurred()) + + helper.MatchAllInOutput(string(outContents), []string{"Watching for changes in the current directory"}) + // "should update the changes" + + checkIfDevEnvIsUp(ports["3000"], "Hello from updated Node.js Starter Application!") + + // "changes are made made to the applications" + + helper.ReplaceString(filepath.Join(commonVar.Context, "server.js"), "from updated Node.js", "from Node.js app v2") + helper.MatchAllInOutput(string(outContents), []string{"Watching for changes in the current directory"}) + + // "should deploy new changes" + checkIfDevEnvIsUp(ports["3000"], "Hello from Node.js app v2 Starter Application!") + + // "running odo list" + stdout := helper.Cmd("odo", "list").ShouldPass().Out() + helper.MatchAllInOutput(stdout, []string{componentName, "nodejs", "Dev"}) + + // "exit dev mode and run odo deploy" + devSession.Stop() + devSession.WaitEnd() + + // // "run odo deploy" + helper.CopyExampleDevFile(filepath.Join("source", "devfiles", "nodejs", "devfile-deploy.yaml"), path.Join(commonVar.Context, "devfile.yaml")) + 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").ShouldPass().Out() + helper.MatchAllInOutput(stdout, []string{componentName, "nodejs", "Deploy"}) + + // start dev mode again + devSession, _, _, ports, err = helper.StartDevMode() + 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" + checkIfDevEnvIsUp(ports["3000"], "Hello from Node.js app v3 Starter Application!") + + // should list both dev,deploy + stdout = helper.Cmd("odo", "list").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"} + 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") + }) + 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)) + }) + }) +}) From 0a3805f8c5880a587810ef0e45792024b2a92b87 Mon Sep 17 00:00:00 2001 From: anandrkskd Date: Thu, 2 Jun 2022 18:14:43 +0530 Subject: [PATCH 2/7] add error handling Signed-off-by: anandrkskd --- tests/e2escenarios/e2e-test.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tests/e2escenarios/e2e-test.go b/tests/e2escenarios/e2e-test.go index 7ca12fd32c0..be8e335eb09 100644 --- a/tests/e2escenarios/e2e-test.go +++ b/tests/e2escenarios/e2e-test.go @@ -27,8 +27,7 @@ var _ = Describe("E2E Test", func() { checkIfDevEnvIsUp := func(url, assertString string) { Eventually(func() string { - url := fmt.Sprintf("http://%s", url) - resp, err := http.Get(url) + resp, err := http.Get(fmt.Sprintf("http://%s", url)) Expect(err).ToNot(HaveOccurred()) defer resp.Body.Close() @@ -137,11 +136,12 @@ var _ = Describe("E2E Test", func() { // "run odo delete and check if the component is deleted" command = []string{"odo", "delete", "component"} - helper.RunInteractive(command, nil, func(ctx helper.InteractiveContext) { + _, 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)) }) @@ -246,11 +246,12 @@ var _ = Describe("E2E Test", func() { Expect(stdout).To(ContainSubstring("Your Devfile has been successfully deployed")) command = []string{"odo", "delete", "component"} - helper.RunInteractive(command, nil, func(ctx helper.InteractiveContext) { + _, 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)) }) From c763809268facc24778bd942c4c30e1abb101c64 Mon Sep 17 00:00:00 2001 From: anandrkskd Date: Sat, 4 Jun 2022 20:26:24 +0530 Subject: [PATCH 3/7] incorporate reviews Signed-off-by: anandrkskd --- tests/e2escenarios/e2e-test.go | 36 +++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/tests/e2escenarios/e2e-test.go b/tests/e2escenarios/e2e-test.go index be8e335eb09..c1ed5f71ec4 100644 --- a/tests/e2escenarios/e2e-test.go +++ b/tests/e2escenarios/e2e-test.go @@ -74,20 +74,19 @@ var _ = Describe("E2E Test", func() { // "execute odo dev and add changes to application" var devSession helper.DevSession - var outContents []byte var ports map[string]string - devSession, outContents, _, ports, err = helper.StartDevMode() + devSession, _, _, ports, err = helper.StartDevMode() helper.ReplaceString(filepath.Join(commonVar.Context, "server.js"), "from Node.js", "from updated Node.js") Expect(err).ToNot(HaveOccurred()) - helper.MatchAllInOutput(string(outContents), []string{"Watching for changes in the current directory"}) + devSession.WaitSync() // "should update the changes" checkIfDevEnvIsUp(ports["3000"], "Hello from updated Node.js Starter Application!") // "changes are made made to the applications" helper.ReplaceString(filepath.Join(commonVar.Context, "server.js"), "from updated Node.js", "from Node.js app v2") - helper.MatchAllInOutput(string(outContents), []string{"Watching for changes in the current directory"}) + devSession.WaitSync() // "should deploy new changes" checkIfDevEnvIsUp(ports["3000"], "Hello from Node.js app v2 Starter Application!") @@ -100,6 +99,14 @@ var _ = Describe("E2E Test", func() { 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.ReplaceString(filepath.Join(commonVar.Context, "devfile.yaml"), "nodejs-prj1-api-abhz", componentName) @@ -113,12 +120,12 @@ var _ = Describe("E2E Test", func() { helper.MatchAllInOutput(stdout, []string{componentName, "nodejs", "Deploy"}) // start dev mode again - devSession, outContents, _, ports, err = helper.StartDevMode() + devSession, _, _, ports, err = helper.StartDevMode() 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") - helper.MatchAllInOutput(string(outContents), []string{"Watching for changes in the current directory"}) + devSession.WaitSync() // "should update the changes" checkIfDevEnvIsUp(ports["3000"], "Hello from Node.js app v3 Starter Application!") @@ -186,14 +193,13 @@ var _ = Describe("E2E Test", func() { // "execute odo dev and add changes to application" var devSession helper.DevSession - var outContents []byte var ports map[string]string - devSession, outContents, _, ports, err = helper.StartDevMode() + devSession, _, _, ports, err = helper.StartDevMode() helper.ReplaceString(filepath.Join(commonVar.Context, "server.js"), "from Node.js", "from updated Node.js") Expect(err).ToNot(HaveOccurred()) - helper.MatchAllInOutput(string(outContents), []string{"Watching for changes in the current directory"}) + devSession.WaitSync() // "should update the changes" checkIfDevEnvIsUp(ports["3000"], "Hello from updated Node.js Starter Application!") @@ -201,7 +207,7 @@ var _ = Describe("E2E Test", func() { // "changes are made made to the applications" helper.ReplaceString(filepath.Join(commonVar.Context, "server.js"), "from updated Node.js", "from Node.js app v2") - helper.MatchAllInOutput(string(outContents), []string{"Watching for changes in the current directory"}) + devSession.WaitSync() // "should deploy new changes" checkIfDevEnvIsUp(ports["3000"], "Hello from Node.js app v2 Starter Application!") @@ -214,7 +220,15 @@ var _ = Describe("E2E Test", func() { devSession.Stop() devSession.WaitEnd() - // // "run odo deploy" + // 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.ReplaceString(filepath.Join(commonVar.Context, "devfile.yaml"), "nodejs-prj1-api-abhz", componentName) stdout = helper.Cmd("odo", "deploy").AddEnv("PODMAN_CMD=echo").ShouldPass().Out() From a5f2141ae626e7a2ba7c8a9a80a977bb361584c2 Mon Sep 17 00:00:00 2001 From: anandrkskd Date: Mon, 6 Jun 2022 10:47:54 +0530 Subject: [PATCH 4/7] error handling Signed-off-by: anandrkskd --- tests/e2escenarios/e2e-test.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/e2escenarios/e2e-test.go b/tests/e2escenarios/e2e-test.go index c1ed5f71ec4..669ce46911a 100644 --- a/tests/e2escenarios/e2e-test.go +++ b/tests/e2escenarios/e2e-test.go @@ -80,14 +80,14 @@ var _ = Describe("E2E Test", func() { helper.ReplaceString(filepath.Join(commonVar.Context, "server.js"), "from Node.js", "from updated Node.js") Expect(err).ToNot(HaveOccurred()) devSession.WaitSync() - + Expect(err).ToNot(HaveOccurred()) // "should update the changes" checkIfDevEnvIsUp(ports["3000"], "Hello from updated Node.js Starter Application!") // "changes are made made to the applications" helper.ReplaceString(filepath.Join(commonVar.Context, "server.js"), "from updated Node.js", "from Node.js app v2") devSession.WaitSync() - + Expect(err).ToNot(HaveOccurred()) // "should deploy new changes" checkIfDevEnvIsUp(ports["3000"], "Hello from Node.js app v2 Starter Application!") @@ -126,7 +126,7 @@ var _ = Describe("E2E Test", func() { // making changes to the project again helper.ReplaceString(filepath.Join(commonVar.Context, "server.js"), "from Node.js app v2", "from Node.js app v3") devSession.WaitSync() - + Expect(err).ToNot(HaveOccurred()) // "should update the changes" checkIfDevEnvIsUp(ports["3000"], "Hello from Node.js app v3 Starter Application!") @@ -200,14 +200,16 @@ var _ = Describe("E2E Test", func() { Expect(err).ToNot(HaveOccurred()) devSession.WaitSync() - // "should update the changes" + Expect(err).ToNot(HaveOccurred()) + // "should update the changes" checkIfDevEnvIsUp(ports["3000"], "Hello from updated Node.js Starter Application!") // "changes are made made to the applications" helper.ReplaceString(filepath.Join(commonVar.Context, "server.js"), "from updated Node.js", "from Node.js app v2") devSession.WaitSync() + Expect(err).ToNot(HaveOccurred()) // "should deploy new changes" checkIfDevEnvIsUp(ports["3000"], "Hello from Node.js app v2 Starter Application!") From 37c715ccbefdb359127989017126a0cee3c8ca49 Mon Sep 17 00:00:00 2001 From: anandrkskd Date: Mon, 6 Jun 2022 10:48:29 +0530 Subject: [PATCH 5/7] error handling Signed-off-by: anandrkskd --- tests/e2escenarios/e2e-test.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/e2escenarios/e2e-test.go b/tests/e2escenarios/e2e-test.go index 669ce46911a..24a7c71faf9 100644 --- a/tests/e2escenarios/e2e-test.go +++ b/tests/e2escenarios/e2e-test.go @@ -79,14 +79,14 @@ var _ = Describe("E2E Test", func() { devSession, _, _, ports, err = helper.StartDevMode() helper.ReplaceString(filepath.Join(commonVar.Context, "server.js"), "from Node.js", "from updated Node.js") Expect(err).ToNot(HaveOccurred()) - devSession.WaitSync() + _, _, err = devSession.WaitSync() Expect(err).ToNot(HaveOccurred()) // "should update the changes" checkIfDevEnvIsUp(ports["3000"], "Hello from updated Node.js Starter Application!") // "changes are made made to the applications" helper.ReplaceString(filepath.Join(commonVar.Context, "server.js"), "from updated Node.js", "from Node.js app v2") - devSession.WaitSync() + _, _, err = devSession.WaitSync() Expect(err).ToNot(HaveOccurred()) // "should deploy new changes" checkIfDevEnvIsUp(ports["3000"], "Hello from Node.js app v2 Starter Application!") @@ -125,7 +125,7 @@ var _ = Describe("E2E Test", func() { // making changes to the project again helper.ReplaceString(filepath.Join(commonVar.Context, "server.js"), "from Node.js app v2", "from Node.js app v3") - devSession.WaitSync() + _, _, err = devSession.WaitSync() Expect(err).ToNot(HaveOccurred()) // "should update the changes" checkIfDevEnvIsUp(ports["3000"], "Hello from Node.js app v3 Starter Application!") @@ -199,7 +199,7 @@ var _ = Describe("E2E Test", func() { helper.ReplaceString(filepath.Join(commonVar.Context, "server.js"), "from Node.js", "from updated Node.js") Expect(err).ToNot(HaveOccurred()) - devSession.WaitSync() + _, _, err = devSession.WaitSync() Expect(err).ToNot(HaveOccurred()) // "should update the changes" @@ -208,7 +208,7 @@ var _ = Describe("E2E Test", func() { // "changes are made made to the applications" helper.ReplaceString(filepath.Join(commonVar.Context, "server.js"), "from updated Node.js", "from Node.js app v2") - devSession.WaitSync() + _, _, err = devSession.WaitSync() Expect(err).ToNot(HaveOccurred()) // "should deploy new changes" From 49300758a864f3fc6f63c53ad35baf3675eb5fd2 Mon Sep 17 00:00:00 2001 From: anandrkskd Date: Tue, 7 Jun 2022 13:22:21 +0530 Subject: [PATCH 6/7] disable G107 for tests only Signed-off-by: anandrkskd --- Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 8aff77218b8..a8b8f33670e 100644 --- a/Makefile +++ b/Makefile @@ -102,7 +102,8 @@ vet: .PHONY: sec sec: - go run $(COMMON_GOFLAGS) github.com/securego/gosec/v2/cmd/gosec -severity medium -confidence medium -exclude G304,G204,G107 -quiet ./... + go run $(COMMON_GOFLAGS) github.com/securego/gosec/v2/cmd/gosec -severity medium -confidence medium -exclude G304,G204,G107 -quiet ./tests/... + go run $(COMMON_GOFLAGS) github.com/securego/gosec/v2/cmd/gosec -severity medium -confidence medium -exclude G304,G204 -quiet ./cmd/... ./pkg/... .PHONY: clean clean: From 50b57b8413a3e405cc263d47a9c594be59a92cd7 Mon Sep 17 00:00:00 2001 From: anandrkskd Date: Tue, 7 Jun 2022 14:37:02 +0530 Subject: [PATCH 7/7] remove commented code Signed-off-by: anandrkskd --- tests/e2escenarios/e2e-test.go | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/e2escenarios/e2e-test.go b/tests/e2escenarios/e2e-test.go index 24a7c71faf9..28cf43d97f3 100644 --- a/tests/e2escenarios/e2e-test.go +++ b/tests/e2escenarios/e2e-test.go @@ -111,7 +111,6 @@ var _ = Describe("E2E Test", func() { helper.CopyExampleDevFile(filepath.Join("source", "devfiles", "nodejs", "devfile-deploy.yaml"), path.Join(commonVar.Context, "devfile.yaml")) helper.ReplaceString(filepath.Join(commonVar.Context, "devfile.yaml"), "nodejs-prj1-api-abhz", componentName) - //helper.ReplaceString(filepath.Join(commonVar.Context, "devfile.yaml"), "quay.io/unknown-account/myimage", "quay.io/repository/libpod/alpine") stdout = helper.Cmd("odo", "deploy").AddEnv("PODMAN_CMD=echo").ShouldPass().Out() Expect(stdout).To(ContainSubstring("Your Devfile has been successfully deployed"))