diff --git a/tests/examples/source/devfiles/nodejs/devfile-child.yaml b/tests/examples/source/devfiles/nodejs/devfile-child.yaml new file mode 100644 index 00000000000..0c6562533b1 --- /dev/null +++ b/tests/examples/source/devfiles/nodejs/devfile-child.yaml @@ -0,0 +1,5 @@ +schemaVersion: 2.1.0 +metadata: + name: child +parent: + uri: devfile-parent.yaml diff --git a/tests/examples/source/devfiles/nodejs/devfile-parent.yaml b/tests/examples/source/devfiles/nodejs/devfile-parent.yaml new file mode 100644 index 00000000000..cd58a029ed3 --- /dev/null +++ b/tests/examples/source/devfiles/nodejs/devfile-parent.yaml @@ -0,0 +1,61 @@ +commands: +- exec: + commandLine: npm install + component: runtime + group: + isDefault: true + kind: build + workingDir: /project + id: install +- exec: + commandLine: npm start + component: runtime + group: + isDefault: true + kind: run + workingDir: /project + id: run +- exec: + commandLine: npm run debug + component: runtime + group: + isDefault: true + kind: debug + workingDir: /project + id: debug +- exec: + commandLine: npm test + component: runtime + group: + isDefault: true + kind: test + workingDir: /project + id: test +components: +- container: + endpoints: + - name: http-3000 + targetPort: 3000 + image: registry.access.redhat.com/ubi8/nodejs-14:latest + memoryLimit: 1024Mi + mountSources: true + sourceMapping: /project + name: runtime +metadata: + description: Stack with Node.js 14 + displayName: Node.js Runtime + icon: https://nodejs.org/static/images/logos/nodejs-new-pantone-black.svg + language: javascript + name: nodejs-prj1-api-abhz + projectType: nodejs + tags: + - NodeJS + - Express + - ubi8 + version: 1.0.1 +schemaVersion: 2.0.0 +starterProjects: +- git: + remotes: + origin: https://github.com/odo-devfiles/nodejs-ex.git + name: nodejs-starter diff --git a/tests/helper/helper_filesystem.go b/tests/helper/helper_filesystem.go index 09fb34df2ac..f5772c4ed74 100644 --- a/tests/helper/helper_filesystem.go +++ b/tests/helper/helper_filesystem.go @@ -273,3 +273,15 @@ func CreateSimpleFile(context, filePrefix, fileExtension string) (string, string return FilePath, string(content) } + +func AppendToFile(filepath string, s string) error { + f, err := os.OpenFile(filepath, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0600) + if err != nil { + return err + } + defer f.Close() // #nosec G307 + if _, err := f.WriteString(s); err != nil { + return err + } + return nil +} diff --git a/tests/integration/cmd_dev_test.go b/tests/integration/cmd_dev_test.go index c8580cda59c..437714bf6e3 100644 --- a/tests/integration/cmd_dev_test.go +++ b/tests/integration/cmd_dev_test.go @@ -2215,4 +2215,40 @@ CMD ["npm", "start"] }) }) }) + + When("a devfile with a local parent is used for odo dev and the parent is not synced", func() { + var devSession helper.DevSession + BeforeEach(func() { + helper.CopyExampleDevFile(filepath.Join("source", "devfiles", "nodejs", "devfile-child.yaml"), filepath.Join(commonVar.Context, "devfile.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) + var err error + devSession, _, _, _, err = helper.StartDevMode(nil) + Expect(err).ToNot(HaveOccurred()) + + gitignorePath := filepath.Join(commonVar.Context, ".gitignore") + err = helper.AppendToFile(gitignorePath, "\n/devfile-parent.yaml\n") + Expect(err).ToNot(HaveOccurred()) + }) + + AfterEach(func() { + // We stop the process so the process does not remain after the end of the tests + devSession.Kill() + devSession.WaitEnd() + }) + + When("updating the parent", func() { + BeforeEach(func() { + helper.ReplaceString("devfile-parent.yaml", "1024Mi", "1023Mi") + }) + + It("should update the component", func() { + Eventually(func() string { + stdout, _, _, err := devSession.GetInfo() + Expect(err).ToNot(HaveOccurred()) + return string(stdout) + }, 180, 10).Should(ContainSubstring("Updating Component")) + }) + }) + }) })