From 3bdcc5a8b8893061000c51684f536684905d9203 Mon Sep 17 00:00:00 2001 From: Rodolfo Napoles Date: Fri, 30 Oct 2020 15:43:58 -0400 Subject: [PATCH 1/6] #3377 adding odo devfile support test --- Makefile | 5 + tests/e2escenarios/e2e_devfile_test.go | 174 +++++++++++++++++++++++++ 2 files changed, 179 insertions(+) create mode 100644 tests/e2escenarios/e2e_devfile_test.go diff --git a/Makefile b/Makefile index 860f1a17f31..b7f115baab0 100644 --- a/Makefile +++ b/Makefile @@ -397,6 +397,11 @@ test-e2e-source: test-e2e-images: ginkgo $(GINKGO_FLAGS) -focus="odo supported images e2e tests" tests/e2escenarios/ +# Run devfile e2e tests: odo devfile supported tests +.PHONY: test-e2e-devfile +test-e2e-devfile: + ginkgo $(GINKGO_FLAGS) -focus="odo devfile support tests" tests/e2escenarios/ + # Run all e2e test scenarios .PHONY: test-e2e-all test-e2e-all: diff --git a/tests/e2escenarios/e2e_devfile_test.go b/tests/e2escenarios/e2e_devfile_test.go new file mode 100644 index 00000000000..f43aeee4471 --- /dev/null +++ b/tests/e2escenarios/e2e_devfile_test.go @@ -0,0 +1,174 @@ +package e2escenarios + +import ( + "fmt" + "strings" + "time" + + "github.com/openshift/odo/tests/helper" + + . "github.com/onsi/ginkgo" +) + +// 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-openliberty +// - java-maven, no starter project available at the time this script was developed, so skiping this component for now + +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 + }) + + preSetup := func() { + helper.MakeDir(projectDirPath) + helper.Chdir(projectDirPath) + } + + // This is run after every Spec (It) + var _ = AfterEach(func() { + helper.CommonAfterEach(commonVar) + }) + + Context("odo debug on a nodeJS starterProject component", func() { + JustBeforeEach(func() { + preSetup() + }) + + It("Verify output debug information for nodeJS debug works", func() { + fmt.Println("********************************************************") + fmt.Println("* Test devfile debug support for nodeJS component *") + fmt.Println("********************************************************") + helper.CmdShouldPass("odo", "create", "nodejs", "--starter", "--project", commonVar.Project, componentName, "--context", projectDirPath) + helper.CmdShouldPass("odo", "push", "--debug", "--context", projectDirPath) + + stopChannel := make(chan bool) + go func() { + helper.CmdShouldRunAndTerminate(60*time.Second, stopChannel, "odo", "debug", "port-forward", "--local-port", "5858", "--context", projectDirPath) + }() + + // 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, `"localPort": 5858`) { + return true + } + return false + }) + + stopChannel <- true + }) + + }) + Context("odo debug on a java-springboot starterProject component", func() { + JustBeforeEach(func() { + preSetup() + }) + + It("Verify output debug information for nodeJS java-springboot works", func() { + fmt.Println("*****************************************************************") + fmt.Println("* Test devfile debug support for java-springboot component *") + fmt.Println("*****************************************************************") + helper.CmdShouldPass("odo", "create", "java-springboot", "--starter", "--project", commonVar.Project, componentName, "--context", projectDirPath) + helper.CmdShouldPass("odo", "push", "--debug", "--context", projectDirPath) + + stopChannel := make(chan bool) + go func() { + helper.CmdShouldRunAndTerminate(60*time.Second, stopChannel, "odo", "debug", "port-forward", "--local-port", "5858", "--context", projectDirPath) + }() + + // 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, `"localPort": 5858`) { + return true + } + return false + }) + + stopChannel <- true + }) + + }) + + Context("odo debug on a java-openliberty starterProject component", func() { + JustBeforeEach(func() { + preSetup() + }) + + It("Verify output debug information for java-openliberty debug works", func() { + fmt.Println("******************************************************************") + fmt.Println("* Test devfile debug support for java-openliberty component *") + fmt.Println("******************************************************************") + helper.CmdShouldPass("odo", "create", "java-openliberty", "--starter", "--project", commonVar.Project, componentName, "--context", projectDirPath) + helper.CmdShouldPass("odo", "push", "--debug", "--context", projectDirPath) + + stopChannel := make(chan bool) + go func() { + helper.CmdShouldRunAndTerminate(60*time.Second, stopChannel, "odo", "debug", "port-forward", "--local-port", "5858", "--context", projectDirPath) + }() + + // 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, `"localPort": 5858`) { + return true + } + return false + }) + + stopChannel <- true + }) + + }) + + Context("odo debug on a java-quarkus starterProject component", func() { + JustBeforeEach(func() { + preSetup() + }) + + It("Verify output debug information for java-quarkus debug works", func() { + fmt.Println("**************************************************************") + fmt.Println("* Test devfile debug support for java-quarkus component *") + fmt.Println("**************************************************************") + helper.CmdShouldPass("odo", "create", "java-quarkus", "--starter", "--project", commonVar.Project, componentName, "--context", projectDirPath) + helper.CmdShouldPass("odo", "push", "--debug", "--context", projectDirPath) + + stopChannel := make(chan bool) + go func() { + helper.CmdShouldRunAndTerminate(60*time.Second, stopChannel, "odo", "debug", "port-forward", "--local-port", "5858", "--context", projectDirPath) + }() + + // 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, `"localPort": 5858`) { + return true + } + return false + }) + + stopChannel <- true + }) + + }) + +}) From d60146940f829a1467d72bd9ad1f62858779c297 Mon Sep 17 00:00:00 2001 From: Rodolfo Napoles Date: Mon, 2 Nov 2020 14:01:35 -0500 Subject: [PATCH 2/6] #3377 replaced spaces with a Tab --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index b7f115baab0..9036f608186 100644 --- a/Makefile +++ b/Makefile @@ -400,7 +400,7 @@ test-e2e-images: # Run devfile e2e tests: odo devfile supported tests .PHONY: test-e2e-devfile test-e2e-devfile: - ginkgo $(GINKGO_FLAGS) -focus="odo devfile support tests" tests/e2escenarios/ + ginkgo $(GINKGO_FLAGS) -focus="odo devfile support tests" tests/e2escenarios/ # Run all e2e test scenarios .PHONY: test-e2e-all From e040dbe6b3ff7c8d4f4e45685e0de7be170732d7 Mon Sep 17 00:00:00 2001 From: Rodolfo Napoles Date: Mon, 2 Nov 2020 17:12:37 -0500 Subject: [PATCH 3/6] #3377 updated focus value --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 9036f608186..4263026ee0c 100644 --- a/Makefile +++ b/Makefile @@ -400,7 +400,7 @@ test-e2e-images: # Run devfile e2e tests: odo devfile supported tests .PHONY: test-e2e-devfile test-e2e-devfile: - ginkgo $(GINKGO_FLAGS) -focus="odo devfile support tests" tests/e2escenarios/ + ginkgo $(GINKGO_FLAGS) -focus="odo devfile supported tests" tests/e2escenarios/ # Run all e2e test scenarios .PHONY: test-e2e-all From e9b56d5a14514da2f189fe0f99e03a85a5b8abae Mon Sep 17 00:00:00 2001 From: Rodolfo Napoles Date: Wed, 4 Nov 2020 12:00:15 -0500 Subject: [PATCH 4/6] #3377 addressed all Priti's comments in PR --- tests/e2escenarios/e2e_devfile_test.go | 152 ++++++------------------- 1 file changed, 32 insertions(+), 120 deletions(-) diff --git a/tests/e2escenarios/e2e_devfile_test.go b/tests/e2escenarios/e2e_devfile_test.go index f43aeee4471..09146adb689 100644 --- a/tests/e2escenarios/e2e_devfile_test.go +++ b/tests/e2escenarios/e2e_devfile_test.go @@ -1,7 +1,6 @@ package e2escenarios import ( - "fmt" "strings" "time" @@ -34,141 +33,54 @@ var _ = Describe("odo devfile supported tests", func() { projectDirPath = commonVar.Context + projectDir }) - preSetup := func() { - helper.MakeDir(projectDirPath) - helper.Chdir(projectDirPath) - } + // preSetup := func() { + // helper.MakeDir(projectDirPath) + // helper.Chdir(projectDirPath) + // } // This is run after every Spec (It) var _ = AfterEach(func() { helper.CommonAfterEach(commonVar) }) - Context("odo debug on a nodeJS starterProject component", func() { - JustBeforeEach(func() { - preSetup() - }) - - It("Verify output debug information for nodeJS debug works", func() { - fmt.Println("********************************************************") - fmt.Println("* Test devfile debug support for nodeJS component *") - fmt.Println("********************************************************") - helper.CmdShouldPass("odo", "create", "nodejs", "--starter", "--project", commonVar.Project, componentName, "--context", projectDirPath) - helper.CmdShouldPass("odo", "push", "--debug", "--context", projectDirPath) - - stopChannel := make(chan bool) - go func() { - helper.CmdShouldRunAndTerminate(60*time.Second, stopChannel, "odo", "debug", "port-forward", "--local-port", "5858", "--context", projectDirPath) - }() - - // 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, `"localPort": 5858`) { - return true - } - return false - }) - - stopChannel <- true + createStarterProjAndSetDebug := func(component string) { + helper.CmdShouldPass("odo", "create", component, "--starter", "--project", commonVar.Project, componentName, "--context", projectDirPath) + helper.CmdShouldPass("odo", "push", "--debug", "--context", projectDirPath) + + stopChannel := make(chan bool) + go func() { + helper.CmdShouldRunAndTerminate(60*time.Second, stopChannel, "odo", "debug", "port-forward", "--local-port", "5858", "--context", projectDirPath) + }() + + // 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, `"localPort": 5858`) { + return true + } + return false }) + stopChannel <- true + } - }) - Context("odo debug on a java-springboot starterProject component", func() { + Context("odo debug support for devfile components", func() { JustBeforeEach(func() { - preSetup() + helper.MakeDir(projectDirPath) + helper.Chdir(projectDirPath) }) - - It("Verify output debug information for nodeJS java-springboot works", func() { - fmt.Println("*****************************************************************") - fmt.Println("* Test devfile debug support for java-springboot component *") - fmt.Println("*****************************************************************") - helper.CmdShouldPass("odo", "create", "java-springboot", "--starter", "--project", commonVar.Project, componentName, "--context", projectDirPath) - helper.CmdShouldPass("odo", "push", "--debug", "--context", projectDirPath) - - stopChannel := make(chan bool) - go func() { - helper.CmdShouldRunAndTerminate(60*time.Second, stopChannel, "odo", "debug", "port-forward", "--local-port", "5858", "--context", projectDirPath) - }() - - // 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, `"localPort": 5858`) { - return true - } - return false - }) - - stopChannel <- true + It("Verify output debug information for nodeJS debug works", func() { + createStarterProjAndSetDebug("nodejs") }) - - }) - - Context("odo debug on a java-openliberty starterProject component", func() { - JustBeforeEach(func() { - preSetup() + It("Verify output debug information for java-springboot works", func() { + createStarterProjAndSetDebug("java-springboot") }) - It("Verify output debug information for java-openliberty debug works", func() { - fmt.Println("******************************************************************") - fmt.Println("* Test devfile debug support for java-openliberty component *") - fmt.Println("******************************************************************") - helper.CmdShouldPass("odo", "create", "java-openliberty", "--starter", "--project", commonVar.Project, componentName, "--context", projectDirPath) - helper.CmdShouldPass("odo", "push", "--debug", "--context", projectDirPath) - - stopChannel := make(chan bool) - go func() { - helper.CmdShouldRunAndTerminate(60*time.Second, stopChannel, "odo", "debug", "port-forward", "--local-port", "5858", "--context", projectDirPath) - }() - - // 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, `"localPort": 5858`) { - return true - } - return false - }) - - stopChannel <- true - }) - - }) - - Context("odo debug on a java-quarkus starterProject component", func() { - JustBeforeEach(func() { - preSetup() + createStarterProjAndSetDebug("java-openliberty") }) - It("Verify output debug information for java-quarkus debug works", func() { - fmt.Println("**************************************************************") - fmt.Println("* Test devfile debug support for java-quarkus component *") - fmt.Println("**************************************************************") - helper.CmdShouldPass("odo", "create", "java-quarkus", "--starter", "--project", commonVar.Project, componentName, "--context", projectDirPath) - helper.CmdShouldPass("odo", "push", "--debug", "--context", projectDirPath) - - stopChannel := make(chan bool) - go func() { - helper.CmdShouldRunAndTerminate(60*time.Second, stopChannel, "odo", "debug", "port-forward", "--local-port", "5858", "--context", projectDirPath) - }() - - // 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, `"localPort": 5858`) { - return true - } - return false - }) - - stopChannel <- true + createStarterProjAndSetDebug("java-quarkus") }) - }) }) From 7a460750918f098207000fa29fee6c8314f965db Mon Sep 17 00:00:00 2001 From: Rodolfo Napoles Date: Mon, 9 Nov 2020 11:08:01 -0500 Subject: [PATCH 5/6] #3377 addressed additional comments from Priti's comments in PR --- tests/e2escenarios/e2e_devfile_test.go | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/tests/e2escenarios/e2e_devfile_test.go b/tests/e2escenarios/e2e_devfile_test.go index 09146adb689..ccb75a89bea 100644 --- a/tests/e2escenarios/e2e_devfile_test.go +++ b/tests/e2escenarios/e2e_devfile_test.go @@ -31,13 +31,10 @@ var _ = Describe("odo devfile supported tests", func() { componentName = helper.RandString(6) helper.Chdir(commonVar.Context) projectDirPath = commonVar.Context + projectDir + helper.MakeDir(projectDirPath) + helper.Chdir(projectDirPath) }) - // preSetup := func() { - // helper.MakeDir(projectDirPath) - // helper.Chdir(projectDirPath) - // } - // This is run after every Spec (It) var _ = AfterEach(func() { helper.CommonAfterEach(commonVar) @@ -45,6 +42,7 @@ var _ = Describe("odo devfile supported tests", func() { createStarterProjAndSetDebug := func(component string) { helper.CmdShouldPass("odo", "create", component, "--starter", "--project", commonVar.Project, componentName, "--context", projectDirPath) + helper.CmdShouldPass("odo", "push", "--context", projectDirPath) helper.CmdShouldPass("odo", "push", "--debug", "--context", projectDirPath) stopChannel := make(chan bool) @@ -65,10 +63,6 @@ var _ = Describe("odo devfile supported tests", func() { } Context("odo debug support for devfile components", func() { - JustBeforeEach(func() { - helper.MakeDir(projectDirPath) - helper.Chdir(projectDirPath) - }) It("Verify output debug information for nodeJS debug works", func() { createStarterProjAndSetDebug("nodejs") }) From 97efaf0b6f6b0349a2fae8f8a50b8e538fc78b46 Mon Sep 17 00:00:00 2001 From: Rodolfo Napoles Date: Tue, 10 Nov 2020 11:07:22 -0500 Subject: [PATCH 6/6] #3377 adding make test-e2e-devfile --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index a8802b9c2a3..b26acd4870d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -158,6 +158,7 @@ jobs: - travis_wait make test-e2e-java - travis_wait make test-e2e-source - travis_wait make test-e2e-images + - travis_wait make test-e2e-devfile - odo logout # Fix https://github.com/openshift/odo/issues/3714 to uncomment tests