Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Test] Rework NodeJS MongoDB devfile API test #23307

Merged
merged 2 commits into from
Jan 8, 2025
Merged

Conversation

SkorikSergey
Copy link
Contributor

@SkorikSergey SkorikSergey commented Jan 8, 2025

What does this PR do?

Rework the NodeJS MongoDB devfile API test regarding our previous strategy which was implemented in the PHP devfile API test

Screenshot/screencast of this PR

Devfile is valid with schema version 2.2.2
DevWorkspace che-code-nodejs-mongodb was generated
          ▼ DevWorkspaceConfigurationHelper.getDevWorkspaceConfigurationYamlAsString
          ▼ KubernetesCommandLineToolsExecutor.applyAndWaitDevWorkspace - oc
          ▼ KubernetesCommandLineToolsExecutor.applyYamlConfigurationAsStringOutput - oc
          ▼ ShellExecutor.executeCommand - cat <<EOF | oc apply -n admin-devspaces -f - 
          apiVersion: workspace.devfile.io/v1alpha2
          kind: DevWorkspaceTemplate
          metadata:
            name: che-code-nodejs-mongodb
          spec:
            commands:
              - apply:
                  component: che-code-injector
                id: init-container-command
              - exec:
                  commandLine: nohup /checode/entrypoint-volume.sh > /checode/entrypoint-logs.txt
                    2>&1 &
                  component: che-code-runtime-description
                id: init-che-code-command
            components:
              - container:
                  command:
                    - /entrypoint-init-container.sh
                  cpuLimit: 500m
                  cpuRequest: 30m
                  image: registry.redhat.io/devspaces/code-rhel8@sha256:02c8f907dc2e18c61fa643accbf8378f385d3368af49794a78b9529cc63eb636
                  memoryLimit: 256Mi
                  memoryRequest: 32Mi
                  volumeMounts:
                    - name: checode
                      path: /checode
                name: che-code-injector
              - attributes:
                  app.kubernetes.io/component: che-code-runtime
                  app.kubernetes.io/part-of: che-code.eclipse.org
                  controller.devfile.io/container-contribution: true
                container:
                  cpuLimit: 500m
                  cpuRequest: 30m
                  endpoints:
                    - attributes:
                        cookiesAuthEnabled: true
                        discoverable: false
                        type: main
                        urlRewriteSupported: true
                      exposure: public
                      name: che-code
                      protocol: https
                      secure: true
                      targetPort: 3100
                    - attributes:
                        discoverable: false
                        urlRewriteSupported: false
                      exposure: public
                      name: code-redirect-1
                      protocol: https
                      targetPort: 13131
                    - attributes:
                        discoverable: false
                        urlRewriteSupported: false
                      exposure: public
                      name: code-redirect-2
                      protocol: https
                      targetPort: 13132
                    - attributes:
                        discoverable: false
                        urlRewriteSupported: false
                      exposure: public
                      name: code-redirect-3
                      protocol: https
                      targetPort: 13133
                  image: registry.redhat.io/devspaces/udi-rhel8@sha256:d147892c643a0127cfcf868daee0ff416a8df922fe2a7c716ebfc457ff526fa2
                  memoryLimit: 1024Mi
                  memoryRequest: 256Mi
                  volumeMounts:
                    - name: checode
                      path: /checode
                name: che-code-runtime-description
              - name: checode
                volume: {}
            events:
              postStart:
                - init-che-code-command
              preStart:
                - init-container-command
          ---
          apiVersion: workspace.devfile.io/v1alpha2
          kind: DevWorkspace
          metadata:
            name: nodejs-mongodbb8822bf6
            annotations:
              che.eclipse.org/devfile: >
                schemaVersion: 2.2.2
          
                metadata:
                  name: nodejs-mongodb
                components:
                  - name: nodejs
                    container:
                      image: >-
                        registry.redhat.io/devspaces/udi-rhel8@sha256:d147892c643a0127cfcf868daee0ff416a8df922fe2a7c716ebfc457ff526fa2
                      env:
                        - name: SECRET
                          value: 220fd770-c028-480d-8f95-f84353c7d55a
                        - name: NODE_ENV
                          value: production
                      endpoints:
                        - exposure: public
                          name: nodejs
                          targetPort: 8080
                          protocol: https
                      memoryLimit: 1Gi
                      memoryRequest: 512Mi
                      cpuLimit: '2'
                      cpuRequest: '1'
                      mountSources: true
                      volumeMounts:
                        - name: npm
                          path: /home/user/.npm
                  - name: npm
                    volume:
                      size: 1G
                  - name: mongo
                    container:
                      image: >-
                        registry.redhat.io/rhscl/mongodb-36-rhel7@sha256:9f799d356d7d2e442bde9d401b720600fd9059a3d8eefea6f3b2ffa721c0dc73
                      env:
                        - name: MONGODB_USER
                          value: user
                        - name: MONGODB_PASSWORD
                          value: password
                        - name: MONGODB_DATABASE
                          value: guestbook
                        - name: MONGODB_ADMIN_PASSWORD
                          value: password
                      endpoints:
                        - name: mongodb
                          exposure: internal
                          targetPort: 27017
                      memoryLimit: 512Mi
                      memoryRequest: 256Mi
                      cpuLimit: '1'
                      cpuRequest: '0.25'
                      mountSources: false
                      volumeMounts:
                        - name: mongo-storage
                          path: /var/lib/mongodb/data
                  - name: mongo-storage
                    volume:
                      size: 1G
                commands:
                  - id: 1-run
                    exec:
                      label: Run the application
                      component: nodejs
                      workingDir: ${PROJECTS_ROOT}/nodejs-mongodb-sample
                      commandLine: npm install && node --inspect=9229 app.js
                      group:
                        kind: run
                projects:
                  - name: nodejs-mongodb-sample
                    zip:
                      location: >-
                        http://devspaces-dashboard.openshift-devspaces.svc:8080/dashboard/api/airgap-sample/project/download?id=nodejs-mongodb
          spec:
            started: true
            routingClass: che
            template:
              components:
                - name: nodejs
                  container:
                    image: registry.redhat.io/devspaces/udi-rhel8@sha256:d147892c643a0127cfcf868daee0ff416a8df922fe2a7c716ebfc457ff526fa2
                    env:
                      - name: SECRET
                        value: 220fd770-c028-480d-8f95-f84353c7d55a
                      - name: NODE_ENV
                        value: production
                    endpoints:
                      - exposure: public
                        name: nodejs
                        targetPort: 8080
                        protocol: https
                    memoryLimit: 1Gi
                    memoryRequest: 512Mi
                    cpuLimit: "2"
                    cpuRequest: "1"
                    mountSources: true
                    volumeMounts:
                      - name: npm
                        path: /home/user/.npm
                - name: npm
                  volume:
                    size: 1G
                - name: mongo
                  container:
                    image: registry.redhat.io/rhscl/mongodb-36-rhel7@sha256:9f799d356d7d2e442bde9d401b720600fd9059a3d8eefea6f3b2ffa721c0dc73
                    env:
                      - name: MONGODB_USER
                        value: user
                      - name: MONGODB_PASSWORD
                        value: password
                      - name: MONGODB_DATABASE
                        value: guestbook
                      - name: MONGODB_ADMIN_PASSWORD
                        value: password
                    endpoints:
                      - name: mongodb
                        exposure: internal
                        targetPort: 27017
                    memoryLimit: 512Mi
                    memoryRequest: 256Mi
                    cpuLimit: "1"
                    cpuRequest: "0.25"
                    mountSources: false
                    volumeMounts:
                      - name: mongo-storage
                        path: /var/lib/mongodb/data
                - name: mongo-storage
                  volume:
                    size: 1G
              commands:
                - id: 1-run
                  exec:
                    label: Run the application
                    component: nodejs
                    workingDir: ${PROJECTS_ROOT}/nodejs-mongodb-sample
                    commandLine: npm install && node --inspect=9229 app.js
                    group:
                      kind: run
              projects:
                - name: nodejs-mongodb-sample
                  zip:
                    location: http://devspaces-dashboard.openshift-devspaces.svc:8080/dashboard/api/airgap-sample/project/download?id=nodejs-mongodb
            contributions:
              - name: editor
                kubernetes:
                  name: che-code-nodejs-mongodb
          
          EOF
devworkspacetemplate.workspace.devfile.io/che-code-nodejs-mongodb created
devworkspace.workspace.devfile.io/nodejs-mongodbb8822bf6 created
          ▼ KubernetesCommandLineToolsExecutor.waitDevWorkspace - oc - wait till workspace ready.
          ▼ ShellExecutor.executeCommand - oc wait -n admin-devspaces --for=condition=Ready dw nodejs-mongodbb8822bf6 --timeout=360s
devworkspace.workspace.devfile.io/nodejs-mongodbb8822bf6 condition met
          ▼ KubernetesCommandLineToolsExecutor.getPodAndContainerNames - oc
          ▼ KubernetesCommandLineToolsExecutor.getWorkspacePodName - oc - get workspace pod name.
          ▼ ShellExecutor.executeCommand - oc get pod -l controller.devfile.io/devworkspace_name=nodejs-mongodbb8822bf6 -n admin-devspaces -o name
pod/workspace23baa31d444643fc-585899956-778hn
          ▼ KubernetesCommandLineToolsExecutor.getContainerName - oc - get container name.
          ▼ ShellExecutor.executeCommand - oc get pod/workspace23baa31d444643fc-585899956-778hn -o jsonpath='{.spec.containers[*].name}' -n admin-devspaces
nodejs mongo che-gateway

    ✔ Create nodejs-mongodb workspace (52708ms)
      • workdir from exec section of DevWorkspace file: ${PROJECTS_ROOT}/nodejs-mongodb-sample
      • commandLine from exec section of DevWorkspace file: npm install && node --inspect=9229 app.js
          ▼ ContainerTerminal.execInContainerCommandWithTimeout - oc
          ▼ ShellExecutor.executeCommand -  timeout 20 oc exec -i pod/workspace23baa31d444643fc-585899956-778hn -n admin-devspaces -c nodejs -- sh -c 'cd ${PROJECTS_ROOT}/nodejs-mongodb-sample && npm install && node --inspect=9229 app.js'
npm warn old lockfile
npm warn old lockfile The package-lock.json file was created with an old version of npm,
npm warn old lockfile so supplemental metadata must be fetched from the registry.
npm warn old lockfile
npm warn old lockfile This is a one-time fix-up, please be patient...
npm warn old lockfile
npm warn deprecated rimraf@2.6.3: Rimraf versions prior to v4 are no longer supported
npm warn deprecated inflight@1.0.6: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.
npm warn deprecated glob@7.1.4: Glob versions prior to v9 are no longer supported
npm warn deprecated mkdirp@0.5.1: Legacy versions of mkdirp are no longer supported. Please update to mkdirp 1.x. (Note that the API surface has changed to use Promises in 1.x.)
npm warn deprecated debug@4.1.1: Debug versions >=3.2.0 <3.2.7 || >=4 <4.3.1 have a low-severity ReDos regression when used in a Node.js environment. It is recommended you upgrade to 3.2.7 or 4.3.1. (https://github.com/visionmedia/debug/issues/797)
npm warn deprecated axios@0.18.1: Critical security vulnerability fixed in v0.21.1. For more information, see https://github.com/axios/axios/pull/3410
npm warn deprecated bson@1.1.1: Fixed a critical issue with BSON serialization documented in CVE-2019-2391, see https://bit.ly/2KcpXdo for more details
npm warn deprecated eslint@5.16.0: This version is no longer supported. Please see https://eslint.org/version-support for other options.
npm warn deprecated core-js@2.6.9: core-js@<3.23.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Some versions have web compatibility issues. Please, upgrade your dependencies to the actual version of core-js.
npm notice
npm notice New major version of npm available! 10.8.1 -> 11.0.0
npm notice Changelog: https://github.com/npm/cli/releases/tag/v11.0.0
npm notice To update run: npm install -g npm@11.0.0
npm notice
Debugger listening on ws://127.0.0.1:9229/d490f966-1495-48de-a0d0-af1209227511
For help, see: https://nodejs.org/en/docs/inspector

added 248 packages, and audited 249 packages in 6s

28 vulnerabilities (4 low, 4 moderate, 16 high, 4 critical)

To address issues that do not require attention, run:
  npm audit fix

To address all issues (including breaking changes), run:
  npm audit fix --force

Run `npm audit` for details.
(node:144) Warning: Accessing non-existent property 'count' of module exports inside circular dependency
(Use `node --trace-warnings ...` to show where the warning was created)
(node:144) Warning: Accessing non-existent property 'findOne' of module exports inside circular dependency
(node:144) Warning: Accessing non-existent property 'remove' of module exports inside circular dependency
(node:144) Warning: Accessing non-existent property 'updateOne' of module exports inside circular dependency
(node:144) DeprecationWarning: current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to the MongoClient constructor.
App listening on port 8080
Press Ctrl+C to quit.
connected to mongodb://user:password@localhost:27017/guestbook
    ✔ Check "Run the application" command
          ▼ KubernetesCommandLineToolsExecutor.deleteDevWorkspace - oc - delete 'nodejs-mongodbb8822bf6' devWorkspace
          ▼ ShellExecutor.executeCommand - oc patch dw nodejs-mongodbb8822bf6 -n admin-devspaces -p '{ "metadata": { "finalizers": null }}' --type merge || true
devworkspace.workspace.devfile.io/nodejs-mongodbb8822bf6 patched
          ▼ ShellExecutor.executeCommand - oc delete dw nodejs-mongodbb8822bf6 -n admin-devspaces || true
devworkspace.workspace.devfile.io "nodejs-mongodbb8822bf6" deleted
          ▼ KubernetesCommandLineToolsExecutor.deleteDevWorkspace - oc - delete 'che-code-nodejs-mongodb' devWorkspaceTemplate
          ▼ ShellExecutor.executeCommand - oc delete dwt che-code-nodejs-mongodb -n admin-devspaces || true
devworkspacetemplate.workspace.devfile.io "che-code-nodejs-mongodb" deleted


  2 passing (1m)

What issues does this PR fix or reference?

https://issues.redhat.com/browse/CRW-7878

How to test this PR?

PR Checklist

As the author of this Pull Request I made sure that:

Reviewers

Reviewers, please comment how you tested the PR when approving it.

@SkorikSergey SkorikSergey added status/code-review This issue has a pull request posted for it and is awaiting code review completion by the community. kind/task Internal things, technical debt, and to-do tasks to be performed. area/qe labels Jan 8, 2025
@SkorikSergey SkorikSergey self-assigned this Jan 8, 2025
Copy link
Contributor

@dmytro-ndp dmytro-ndp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test run against Dev Spaces 3.17 was successful.

PR looks good to merge.

@SkorikSergey SkorikSergey merged commit 7ba4b8c into main Jan 8, 2025
5 checks passed
@SkorikSergey SkorikSergey deleted the nodejsmongodb branch January 8, 2025 14:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/qe kind/task Internal things, technical debt, and to-do tasks to be performed. status/code-review This issue has a pull request posted for it and is awaiting code review completion by the community.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants