Skip to content

Commit

Permalink
Merge 8f8795d into 803718a
Browse files Browse the repository at this point in the history
  • Loading branch information
valaparthvi authored Jun 16, 2023
2 parents 803718a + 8f8795d commit 9fe60bb
Show file tree
Hide file tree
Showing 14 changed files with 525 additions and 596 deletions.
40 changes: 20 additions & 20 deletions tests/documentation/user-guides/doc_user_guides_quickstart_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,13 @@ var _ = Describe("User guides: Quickstart test", func() {
Expect(diff).To(BeEmpty(), file)
})
By("running odo dev", func() {
session, out, _, cmdEndpointsMap, err := helper.StartDevMode(helper.DevSessionOpts{})
devSession, err := helper.StartDevMode(helper.DevSessionOpts{})
Expect(err).To(BeNil())
session.Stop()
session.WaitEnd()
devSession.Stop()
devSession.WaitEnd()
args := []string{"dev"}
got := strings.ReplaceAll(string(out), commonVar.Context, "/home/user/quickstart-demo")
got = helper.ReplaceAllForwardedPorts(got, cmdEndpointsMap, map[string]string{"3000": "127.0.0.1:20001", "5858": "127.0.0.1:20002"})
got := strings.ReplaceAll(devSession.StdOut, commonVar.Context, "/home/user/quickstart-demo")
got = helper.ReplaceAllForwardedPorts(got, devSession.Endpoints, map[string]string{"3000": "127.0.0.1:20001", "5858": "127.0.0.1:20002"})
got = strings.ReplaceAll(got, commonVar.Project, namespace)
got = fmt.Sprintf(outputStringFormat, strings.Join(args, " "), helper.StripSpinner(got))
file := filepath.Join(commonNodeJSPath, "nodejs_odo_dev_output.mdx")
Expand Down Expand Up @@ -137,13 +137,13 @@ var _ = Describe("User guides: Quickstart test", func() {
Expect(diff).To(BeEmpty(), file)
})
By("running odo dev", func() {
session, out, _, cmdEndpointsMap, err := helper.StartDevMode(helper.DevSessionOpts{})
devSession, err := helper.StartDevMode(helper.DevSessionOpts{})
Expect(err).To(BeNil())
session.Stop()
session.WaitEnd()
devSession.Stop()
devSession.WaitEnd()
args := []string{"dev"}
got := strings.ReplaceAll(string(out), commonVar.Context, "/home/user/quickstart-demo")
got = helper.ReplaceAllForwardedPorts(got, cmdEndpointsMap, map[string]string{"8080": "127.0.0.1:20001"})
got := strings.ReplaceAll(devSession.StdOut, commonVar.Context, "/home/user/quickstart-demo")
got = helper.ReplaceAllForwardedPorts(got, devSession.Endpoints, map[string]string{"8080": "127.0.0.1:20001"})
got = strings.ReplaceAll(got, commonVar.Project, namespace)
got = fmt.Sprintf(outputStringFormat, strings.Join(args, " "), helper.StripSpinner(got))
file := filepath.Join(commonGoPath, "go_odo_dev_output.mdx")
Expand Down Expand Up @@ -193,13 +193,13 @@ var _ = Describe("User guides: Quickstart test", func() {
Expect(diff).To(BeEmpty(), file)
})
By("running odo dev", func() {
session, out, _, cmdEndpointsMap, err := helper.StartDevMode(helper.DevSessionOpts{})
devSession, err := helper.StartDevMode(helper.DevSessionOpts{})
Expect(err).To(BeNil())
session.Stop()
session.WaitEnd()
devSession.Stop()
devSession.WaitEnd()
args := []string{"dev"}
got := strings.ReplaceAll(string(out), commonVar.Context, "/home/user/quickstart-demo")
got = helper.ReplaceAllForwardedPorts(got, cmdEndpointsMap, map[string]string{"8080": "127.0.0.1:20001"})
got := strings.ReplaceAll(devSession.StdOut, commonVar.Context, "/home/user/quickstart-demo")
got = helper.ReplaceAllForwardedPorts(got, devSession.Endpoints, map[string]string{"8080": "127.0.0.1:20001"})
got = strings.ReplaceAll(got, commonVar.Project, namespace)
got = fmt.Sprintf(outputStringFormat, strings.Join(args, " "), helper.StripSpinner(got))
file := filepath.Join(commondotnetPath, "dotnet_odo_dev_output.mdx")
Expand Down Expand Up @@ -241,13 +241,13 @@ var _ = Describe("User guides: Quickstart test", func() {
Expect(diff).To(BeEmpty(), file)
})
By("running odo dev", func() {
session, out, _, cmdEndpointsMap, err := helper.StartDevMode(helper.DevSessionOpts{TimeoutInSeconds: 420})
devSession, err := helper.StartDevMode(helper.DevSessionOpts{TimeoutInSeconds: 420})
Expect(err).To(BeNil())
session.Stop()
session.WaitEnd()
devSession.Stop()
devSession.WaitEnd()
args := []string{"dev"}
got := strings.ReplaceAll(string(out), commonVar.Context, "/home/user/quickstart-demo")
got = helper.ReplaceAllForwardedPorts(got, cmdEndpointsMap, map[string]string{"8080": "127.0.0.1:20001", "5858": "127.0.0.1:20002"})
got := strings.ReplaceAll(devSession.StdOut, commonVar.Context, "/home/user/quickstart-demo")
got = helper.ReplaceAllForwardedPorts(got, devSession.Endpoints, map[string]string{"8080": "127.0.0.1:20001", "5858": "127.0.0.1:20002"})
got = strings.ReplaceAll(got, commonVar.Project, namespace)
got = fmt.Sprintf(outputStringFormat, strings.Join(args, " "), helper.StripSpinner(got))
file := filepath.Join(commonGoPath, "java_odo_dev_output.mdx")
Expand Down
77 changes: 36 additions & 41 deletions tests/e2escenarios/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,27 +98,26 @@ var _ = Describe("E2E Test", func() {

// "execute odo dev and add changes to application"
var devSession helper.DevSession
var ports map[string]string

devSession, _, _, ports, err = helper.StartDevMode(helper.DevSessionOpts{})
devSession, err = helper.StartDevMode(helper.DevSessionOpts{})
Expect(err).ToNot(HaveOccurred())
waitRemoteApp("http://127.0.0.1:3000", "Hello from Node.js Starter Application!", "runtime")
checkIfDevEnvIsUp(ports["3000"], "Hello from Node.js Starter Application!")
checkIfDevEnvIsUp(devSession.Endpoints["3000"], "Hello from Node.js Starter Application!")

helper.ReplaceString(filepath.Join(commonVar.Context, "server.js"), "from Node.js", "from updated Node.js")
_, _, _, err = devSession.WaitSync()
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!", "runtime")
checkIfDevEnvIsUp(ports["3000"], "Hello from updated Node.js Starter Application!")
checkIfDevEnvIsUp(devSession.Endpoints["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()
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!", "runtime")
checkIfDevEnvIsUp(ports["3000"], "Hello from Node.js app v2 Starter Application!")
checkIfDevEnvIsUp(devSession.Endpoints["3000"], "Hello from Node.js app v2 Starter Application!")

// "running odo list"
stdout := helper.Cmd("odo", "list", "component").ShouldPass().Out()
Expand Down Expand Up @@ -150,16 +149,16 @@ var _ = Describe("E2E Test", func() {
helper.MatchAllInOutput(stdout, []string{componentName, "nodejs", "Deploy"})

// start dev mode again
devSession, _, _, ports, err = helper.StartDevMode(helper.DevSessionOpts{})
devSession, 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")
_, _, _, err = devSession.WaitSync()
err = devSession.WaitSync()
Expect(err).ToNot(HaveOccurred())
// "should update the changes"
waitRemoteApp("http://127.0.0.1:3000", "Hello from Node.js app v3 Starter Application!", "runtime")
checkIfDevEnvIsUp(ports["3000"], "Hello from Node.js app v3 Starter Application!")
checkIfDevEnvIsUp(devSession.Endpoints["3000"], "Hello from Node.js app v3 Starter Application!")

// should list both dev,deploy
stdout = helper.Cmd("odo", "list", "component").ShouldPass().Out()
Expand Down Expand Up @@ -226,28 +225,26 @@ var _ = Describe("E2E Test", func() {

// "execute odo dev and add changes to application"
var devSession helper.DevSession
var ports map[string]string
var out []byte
devSession, out, _, ports, err = helper.StartDevMode(helper.DevSessionOpts{})
devSession, err = helper.StartDevMode(helper.DevSessionOpts{})
Expect(err).ToNot(HaveOccurred())
Expect(out).ToNot(BeEmpty())
Expect(devSession.StdOut).ToNot(BeEmpty())
waitRemoteApp(AppLocalURL, "Hello World!", "tools")
checkIfDevEnvIsUp(ports[AppPort], "Hello World!")
checkIfDevEnvIsUp(devSession.Endpoints[AppPort], "Hello World!")

helper.ReplaceString(filepath.Join(commonVar.Context, "src", "main", "java", "com", "example", "demo", "DemoApplication.java"), "Hello World!", "Hello updated World!")
_, _, _, err = devSession.WaitSync()
err = devSession.WaitSync()
Expect(err).ToNot(HaveOccurred())
// "should update the changes"
waitRemoteApp(AppLocalURL, "Hello updated World!", "tools")
checkIfDevEnvIsUp(ports[AppPort], "Hello updated World!")
checkIfDevEnvIsUp(devSession.Endpoints[AppPort], "Hello updated World!")

// "changes are made to the applications"
helper.ReplaceString(filepath.Join(commonVar.Context, "src", "main", "java", "com", "example", "demo", "DemoApplication.java"), "Hello updated World!", "Hello from an updated World!")
_, _, _, err = devSession.WaitSync()
err = devSession.WaitSync()
Expect(err).ToNot(HaveOccurred())
// "should deploy new changes"
waitRemoteApp(AppLocalURL, "Hello from an updated World!", "tools")
checkIfDevEnvIsUp(ports[AppPort], "Hello from an updated World!")
checkIfDevEnvIsUp(devSession.Endpoints[AppPort], "Hello from an updated World!")

// "running odo list"
stdout := helper.Cmd("odo", "list", "component").ShouldPass().Out()
Expand Down Expand Up @@ -279,17 +276,17 @@ var _ = Describe("E2E Test", func() {
helper.MatchAllInOutput(stdout, []string{componentName, "springboot", "Deploy"})

// start dev mode again
devSession, _, _, ports, err = helper.StartDevMode(helper.DevSessionOpts{})
devSession, err = helper.StartDevMode(helper.DevSessionOpts{})
Expect(err).ToNot(HaveOccurred())

// making changes to the project again
helper.ReplaceString(filepath.Join(commonVar.Context, "src", "main", "java", "com", "example", "demo", "DemoApplication.java"), "Hello from an updated World!", "Hello from an updated v2 World!")
_, _, _, err = devSession.WaitSync()
err = devSession.WaitSync()
Expect(err).ToNot(HaveOccurred())

// "should update the changes"
waitRemoteApp(AppLocalURL, "Hello from an updated v2 World!", "tools")
checkIfDevEnvIsUp(ports[AppPort], "Hello from an updated v2 World!")
checkIfDevEnvIsUp(devSession.Endpoints[AppPort], "Hello from an updated v2 World!")

// should list both dev,deploy
stdout = helper.Cmd("odo", "list", "component").ShouldPass().Out()
Expand Down Expand Up @@ -371,34 +368,33 @@ var _ = Describe("E2E Test", func() {

// "execute odo dev and add changes to application"
var devSession helper.DevSession
var ports map[string]string
var out []byte
devSession, out, _, ports, err = helper.StartDevMode(helper.DevSessionOpts{

devSession, err = helper.StartDevMode(helper.DevSessionOpts{
CmdlineArgs: []string{"--debug"},
})
Expect(err).ToNot(HaveOccurred())
Expect(out).ToNot(BeEmpty())
Expect(devSession.StdOut).ToNot(BeEmpty())

waitRemoteApp(LocalAppURL, "Hello from Node.js Starter Application!", "runtime")
checkIfDevEnvIsUp(ports[AppPort], "Hello from Node.js Starter Application!")
checkIfDevEnvIsUp(ports[DebugPort], "WebSockets request was expected")
checkIfDevEnvIsUp(devSession.Endpoints[AppPort], "Hello from Node.js Starter Application!")
checkIfDevEnvIsUp(devSession.Endpoints[DebugPort], "WebSockets request was expected")

helper.ReplaceString(filepath.Join(commonVar.Context, "server.js"), "from Node.js", "from updated Node.js")
_, _, _, err = devSession.WaitSync()
err = devSession.WaitSync()
Expect(err).ToNot(HaveOccurred())
// "should update the changes"
waitRemoteApp(LocalAppURL, "Hello from updated Node.js Starter Application!", "runtime")
checkIfDevEnvIsUp(ports[AppPort], "Hello from updated Node.js Starter Application!")
checkIfDevEnvIsUp(ports[DebugPort], "WebSockets request was expected")
checkIfDevEnvIsUp(devSession.Endpoints[AppPort], "Hello from updated Node.js Starter Application!")
checkIfDevEnvIsUp(devSession.Endpoints[DebugPort], "WebSockets request was expected")

// "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()
err = devSession.WaitSync()
Expect(err).ToNot(HaveOccurred())
// "should deploy new changes"
waitRemoteApp(LocalAppURL, "Hello from Node.js app v2 Starter Application!", "runtime")
checkIfDevEnvIsUp(ports[AppPort], "Hello from Node.js app v2 Starter Application!")
checkIfDevEnvIsUp(ports[DebugPort], "WebSockets request was expected")
checkIfDevEnvIsUp(devSession.Endpoints[AppPort], "Hello from Node.js app v2 Starter Application!")
checkIfDevEnvIsUp(devSession.Endpoints[DebugPort], "WebSockets request was expected")

// "running odo list"
stdout := helper.Cmd("odo", "list", "component").ShouldPass().Out()
Expand Down Expand Up @@ -488,29 +484,28 @@ var _ = Describe("E2E Test", func() {

// // "execute odo dev and add changes to application"
var devSession helper.DevSession
var ports map[string]string

devSession, _, _, ports, err = helper.StartDevMode(helper.DevSessionOpts{})
devSession, err = helper.StartDevMode(helper.DevSessionOpts{})
Expect(err).ToNot(HaveOccurred())

// "send data"
_, err = receiveData(fmt.Sprintf(ports["8080"] + "/api/user"))
_, err = receiveData(fmt.Sprintf(devSession.Endpoints["8080"] + "/api/user"))
Expect(err).ToNot(BeNil()) // should fail as application is not connected to DB

//add binding information (binding as ENV)
helper.Cmd("odo", "add", "binding", "--name", bindingName, "--service", "cluster-example-initdb", "--bind-as-files=false").ShouldPass()

// Get new random port after restart
_, _, ports, err = devSession.WaitRestartPortforward()
err = devSession.WaitRestartPortforward()
Expect(err).ToNot(HaveOccurred())

// "send data"
waitRemoteApp("http://127.0.0.1:8080/ping", "pong", "runtime")
data := sendDataEntry(ports["8080"])
data := sendDataEntry(devSession.Endpoints["8080"])
Expect(data["message"]).To(Equal("User created successfully"))

// "get all data"
rec, err := receiveData(fmt.Sprintf(ports["8080"] + "/api/user"))
rec, err := receiveData(fmt.Sprintf(devSession.Endpoints["8080"] + "/api/user"))
Expect(err).To(BeNil())
helper.MatchAllInOutput(rec, []string{"id", "1", "name", "joe", "location", "tokyo", "age", "23"})

Expand All @@ -525,7 +520,7 @@ var _ = Describe("E2E Test", func() {
// remove bindings and check devfile to not contain binding info
helper.Cmd("odo", "remove", "binding", "--name", bindingName).ShouldPass()

_, _, _, err = devSession.WaitSync()
err = devSession.WaitSync()
Expect(err).To(BeNil())
Eventually(func() string { return helper.Cmd("odo", "describe", "binding").ShouldRun().Out() }).
WithTimeout(120 * time.Second).
Expand Down
Loading

0 comments on commit 9fe60bb

Please sign in to comment.