From 5dcc01b9a4babb847a91608666e5277a3cdef92a Mon Sep 17 00:00:00 2001 From: Alex Corcoles Date: Mon, 12 Sep 2022 13:31:28 +0200 Subject: [PATCH 1/9] Use Thorntail 2.4.0 This is more compatible with latest versions of OCP. --- quip/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quip/pom.xml b/quip/pom.xml index 452cf93ebb..701b67fae3 100644 --- a/quip/pom.xml +++ b/quip/pom.xml @@ -9,7 +9,7 @@ war - 2.1.0.Final + 2.4.0.Final 1.8 1.8 false From c355a003cdbe87d928d5b3b278e638242ef856e0 Mon Sep 17 00:00:00 2001 From: Jaime Ramirez Date: Wed, 14 Jun 2023 15:43:19 +0200 Subject: [PATCH 2/9] ge(ch03s02): apps and solutions --- images-ubi/apps/greetings/.containerignore | 4 ++ images-ubi/apps/greetings/Containerfile | 19 ++++++++ images-ubi/apps/greetings/index.js | 49 ++++++++++++++++++++ images-ubi/apps/greetings/package-lock.json | 12 +++++ images-ubi/apps/greetings/package.json | 10 ++++ images-ubi/solutions/greetings/Containerfile | 19 ++++++++ 6 files changed, 113 insertions(+) create mode 100644 images-ubi/apps/greetings/.containerignore create mode 100644 images-ubi/apps/greetings/Containerfile create mode 100644 images-ubi/apps/greetings/index.js create mode 100644 images-ubi/apps/greetings/package-lock.json create mode 100644 images-ubi/apps/greetings/package.json create mode 100644 images-ubi/solutions/greetings/Containerfile diff --git a/images-ubi/apps/greetings/.containerignore b/images-ubi/apps/greetings/.containerignore new file mode 100644 index 0000000000..182b2759dc --- /dev/null +++ b/images-ubi/apps/greetings/.containerignore @@ -0,0 +1,4 @@ +.git +.containerignore +node_modules +Containerfile \ No newline at end of file diff --git a/images-ubi/apps/greetings/Containerfile b/images-ubi/apps/greetings/Containerfile new file mode 100644 index 0000000000..6ad1576657 --- /dev/null +++ b/images-ubi/apps/greetings/Containerfile @@ -0,0 +1,19 @@ +FROM registry.access.redhat.com/ubi9/nodejs-18-minimal:1-51 + +# Use root user to listen on port 80 +USER root + + +# Application listens on this port +ENV PORT=80 +EXPOSE ${PORT} + +# Install application dependencies +COPY package*.json ./ +RUN npm ci --omit=dev + +# Copy the application source code +COPY . . + +# Run the server +CMD npm start diff --git a/images-ubi/apps/greetings/index.js b/images-ubi/apps/greetings/index.js new file mode 100644 index 0000000000..ffd4060088 --- /dev/null +++ b/images-ubi/apps/greetings/index.js @@ -0,0 +1,49 @@ +const os = require("os"); +const http = require("http"); + + +const hostname = "0.0.0.0"; +const userInfo = os.userInfo(); +const port = process.env.PORT || 80; +const greetings = [ + "Guten tag", + "Hi!", + "Hello, how are you?", + "Hola, ¿que tal?", + "Bonjour, ça va bien?", + "Ciao, come stai?", + "Bon dia", + "Salve", + "Olá, tudo bem?", + "Namaste", + "Hallo", + "Hei!", + "Yassou", + "Ahoj!", + "Cześć!", + "Hej", + "Hey", + "Privet", + "Annyeong", + "Selam" +]; + + +console.log(`User ID: ${userInfo.uid}, group ID: ${userInfo.gid}`); + + +http + .createServer(handleRequest) + .listen(port, hostname, () => { + console.log(`Server running as at http://${hostname}:${port}/`); + }); + + +function handleRequest(req, res) { + const randomGreetingIndex = Math.floor(Math.random() * greetings.length); + const message = greetings[randomGreetingIndex]; + + res.statusCode = 200; + res.setHeader("Content-Type", "application/json"); + res.end(JSON.stringify({ message })); +} diff --git a/images-ubi/apps/greetings/package-lock.json b/images-ubi/apps/greetings/package-lock.json new file mode 100644 index 0000000000..b3ee78cfd9 --- /dev/null +++ b/images-ubi/apps/greetings/package-lock.json @@ -0,0 +1,12 @@ +{ + "name": "nodejs-example", + "version": "1.0.0", + "lockfileVersion": 2, + "requires": true, + "packages": { + "": { + "name": "nodejs-example", + "version": "1.0.0" + } + } +} diff --git a/images-ubi/apps/greetings/package.json b/images-ubi/apps/greetings/package.json new file mode 100644 index 0000000000..eea36bbf46 --- /dev/null +++ b/images-ubi/apps/greetings/package.json @@ -0,0 +1,10 @@ +{ + "name": "greetings", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "start": "node index.js", + "test": "echo \"Error: no test specified\" && exit 1" + } +} diff --git a/images-ubi/solutions/greetings/Containerfile b/images-ubi/solutions/greetings/Containerfile new file mode 100644 index 0000000000..3351f0ef73 --- /dev/null +++ b/images-ubi/solutions/greetings/Containerfile @@ -0,0 +1,19 @@ +FROM registry.access.redhat.com/ubi9/nodejs-18-minimal:1-51 + +RUN mkdir /opt/app-root/src/.npm && \ + chgrp -R 0 /opt/app-root/src/.npm && \ + chmod -R g=u /opt/app-root/src/.npm + +# Application listens on this port +ENV PORT=8080 +EXPOSE ${PORT} + +# Install application dependencies +COPY package*.json ./ +RUN npm ci --omit=dev + +# Copy the application source code +COPY . . + +# Run the server +CMD npm start From 29ba924c23cede2fda66bc26bfb0a363cd030cdf Mon Sep 17 00:00:00 2001 From: Jaime Ramirez Date: Fri, 16 Jun 2023 11:54:11 +0200 Subject: [PATCH 3/9] Improve app --- images-ubi/apps/greetings/.containerignore | 1 + images-ubi/apps/greetings/Containerfile | 13 ++- .../apps/greetings/LocalizationService.js | 93 +++++++++++++++++++ images-ubi/apps/greetings/index.js | 68 ++++++-------- images-ubi/apps/greetings/package-lock.json | 4 +- 5 files changed, 132 insertions(+), 47 deletions(-) create mode 100644 images-ubi/apps/greetings/LocalizationService.js diff --git a/images-ubi/apps/greetings/.containerignore b/images-ubi/apps/greetings/.containerignore index 182b2759dc..8d5b76ac06 100644 --- a/images-ubi/apps/greetings/.containerignore +++ b/images-ubi/apps/greetings/.containerignore @@ -1,4 +1,5 @@ .git +.npm .containerignore node_modules Containerfile \ No newline at end of file diff --git a/images-ubi/apps/greetings/Containerfile b/images-ubi/apps/greetings/Containerfile index 6ad1576657..8594cee901 100644 --- a/images-ubi/apps/greetings/Containerfile +++ b/images-ubi/apps/greetings/Containerfile @@ -1,19 +1,18 @@ -FROM registry.access.redhat.com/ubi9/nodejs-18-minimal:1-51 +FROM registry.access.redhat.com/ubi9/nodejs-18-minimal # Use root user to listen on port 80 USER root - # Application listens on this port ENV PORT=80 EXPOSE ${PORT} -# Install application dependencies -COPY package*.json ./ -RUN npm ci --omit=dev +# Add application sources +ADD . $HOME -# Copy the application source code -COPY . . +# Install dependencies. +# Clean up cache when finished. +RUN npm ci --omit=dev && rm -rf .npm # Run the server CMD npm start diff --git a/images-ubi/apps/greetings/LocalizationService.js b/images-ubi/apps/greetings/LocalizationService.js new file mode 100644 index 0000000000..e0b10c72fc --- /dev/null +++ b/images-ubi/apps/greetings/LocalizationService.js @@ -0,0 +1,93 @@ +/** + * Simulate an external localization service + */ +const fs = require("fs").promises; + + +const TRANSLATIONS = { + "greeting": { + "de-de": "Guten tag", + "en-us": "Hi!", + "es-es": "Hola, ¿que tal?", + "fr-be": "Bonjour, ça va bien?", + "it-it": "Ciao, come stai?", + "ca": "Bon dia", + "pt-pt": "Olá, tudo bem?", + "hi": "Namaste", + "nl-nl": "Hallo", + "no-no": "Hei!", + "el": "Yassou", + "cs": "Ahoj!", + "pl": "Cześć!", + "sv-se": "Hej", + "ru": "Privet", + "tr": "Selam" + } +} + + +async function translate(key, locale) { + let translated; + + try { + translated = await readFromFileCache(key, locale); + console.info(`${locale} '${key}' found in cache`); + } catch (error) { + // Only handle the not found case (ENOENT) + if (error.code !== "ENOENT") { + throw err; + } + + translated = await getTranslationFromExternalService(key, locale); + + await writeToFileCache(key, locale, translated); + } + + return translated; +} + + +async function readFromFileCache(key, locale) { + const buffer = await fs.readFile(generateCacheFilename(key, locale)); + return buffer.toString(); +} + + +function writeToFileCache(key, locale, value) { + return fs.writeFile(generateCacheFilename(key, locale), value); +} + + +function generateCacheFilename(key, locale) { + return `/var/cache/translation_${key}_${locale}`; +} + + +function getTranslationFromExternalService(key, locale) { + // Simulate a network delay of 500 millis + return new Promise((resolve) => { + setTimeout(() => { + const translated = TRANSLATIONS[key][locale]; + resolve(translated); + }, 500); + }); +} + + +function getSupportedLocaleIDs() { + return Object.keys(TRANSLATIONS.greeting); +} + + +function getRandomLocaleID() { + const locales = getSupportedLocaleIDs(); + const localeIndex = Math.floor(Math.random() * locales.length); + return locales[localeIndex]; +} + + +module.exports = { + translate, + getRandomLocaleID, + getSupportedLocaleIDs +} diff --git a/images-ubi/apps/greetings/index.js b/images-ubi/apps/greetings/index.js index ffd4060088..c1df7af449 100644 --- a/images-ubi/apps/greetings/index.js +++ b/images-ubi/apps/greetings/index.js @@ -1,47 +1,39 @@ const os = require("os"); const http = require("http"); +const localization = require("./LocalizationService"); const hostname = "0.0.0.0"; const userInfo = os.userInfo(); -const port = process.env.PORT || 80; -const greetings = [ - "Guten tag", - "Hi!", - "Hello, how are you?", - "Hola, ¿que tal?", - "Bonjour, ça va bien?", - "Ciao, come stai?", - "Bon dia", - "Salve", - "Olá, tudo bem?", - "Namaste", - "Hallo", - "Hei!", - "Yassou", - "Ahoj!", - "Cześć!", - "Hej", - "Hey", - "Privet", - "Annyeong", - "Selam" -]; - - -console.log(`User ID: ${userInfo.uid}, group ID: ${userInfo.gid}`); - - -http - .createServer(handleRequest) - .listen(port, hostname, () => { - console.log(`Server running as at http://${hostname}:${port}/`); - }); - - -function handleRequest(req, res) { - const randomGreetingIndex = Math.floor(Math.random() * greetings.length); - const message = greetings[randomGreetingIndex]; +const port = process.env.PORT || 8080; + + +main(); + + +async function main() { + console.info(`Running with user ID: ${userInfo.uid}, group ID: ${userInfo.gid}`); + + console.info("Verifying file cache..."); + await localization + .translate("greeting", "en-us") + .catch((error) => { + console.error("File cache does not work due to", error); + }); + + console.info("Starting server..."); + http + .createServer(handleRequest) + .listen(port, hostname, () => { + console.log(`Server listening at http://${hostname}:${port}/`); + }); +} + + +async function handleRequest(req, res) { + // Return a greeting message in a random language + const locale = localization.getRandomLocaleID(); + const message = await localization.translate("greeting", locale); res.statusCode = 200; res.setHeader("Content-Type", "application/json"); diff --git a/images-ubi/apps/greetings/package-lock.json b/images-ubi/apps/greetings/package-lock.json index b3ee78cfd9..6bc64955bf 100644 --- a/images-ubi/apps/greetings/package-lock.json +++ b/images-ubi/apps/greetings/package-lock.json @@ -1,11 +1,11 @@ { - "name": "nodejs-example", + "name": "greetings", "version": "1.0.0", "lockfileVersion": 2, "requires": true, "packages": { "": { - "name": "nodejs-example", + "name": "greetings", "version": "1.0.0" } } From 5147569a6ae26d69a4990c4ee71a4299c750f4bb Mon Sep 17 00:00:00 2001 From: Jaime Ramirez Date: Fri, 16 Jun 2023 13:25:36 +0200 Subject: [PATCH 4/9] fix solution --- images-ubi/apps/greetings/Containerfile | 10 ++-------- images-ubi/apps/greetings/index.js | 10 +++++----- images-ubi/solutions/greetings/Containerfile | 21 ++++++++++---------- 3 files changed, 18 insertions(+), 23 deletions(-) diff --git a/images-ubi/apps/greetings/Containerfile b/images-ubi/apps/greetings/Containerfile index 8594cee901..25af270d23 100644 --- a/images-ubi/apps/greetings/Containerfile +++ b/images-ubi/apps/greetings/Containerfile @@ -1,18 +1,12 @@ FROM registry.access.redhat.com/ubi9/nodejs-18-minimal -# Use root user to listen on port 80 -USER root - -# Application listens on this port ENV PORT=80 EXPOSE ${PORT} -# Add application sources +USER root + ADD . $HOME -# Install dependencies. -# Clean up cache when finished. RUN npm ci --omit=dev && rm -rf .npm -# Run the server CMD npm start diff --git a/images-ubi/apps/greetings/index.js b/images-ubi/apps/greetings/index.js index c1df7af449..58e14a2f56 100644 --- a/images-ubi/apps/greetings/index.js +++ b/images-ubi/apps/greetings/index.js @@ -15,11 +15,11 @@ async function main() { console.info(`Running with user ID: ${userInfo.uid}, group ID: ${userInfo.gid}`); console.info("Verifying file cache..."); - await localization - .translate("greeting", "en-us") - .catch((error) => { - console.error("File cache does not work due to", error); - }); + try { + await localization.translate("greeting", "en-us"); + } catch(error) { + console.error("File cache does not work due to", error); + } console.info("Starting server..."); http diff --git a/images-ubi/solutions/greetings/Containerfile b/images-ubi/solutions/greetings/Containerfile index 3351f0ef73..6815135c97 100644 --- a/images-ubi/solutions/greetings/Containerfile +++ b/images-ubi/solutions/greetings/Containerfile @@ -1,19 +1,20 @@ -FROM registry.access.redhat.com/ubi9/nodejs-18-minimal:1-51 - -RUN mkdir /opt/app-root/src/.npm && \ - chgrp -R 0 /opt/app-root/src/.npm && \ - chmod -R g=u /opt/app-root/src/.npm +FROM registry.access.redhat.com/ubi9/nodejs-18-minimal # Application listens on this port ENV PORT=8080 EXPOSE ${PORT} -# Install application dependencies -COPY package*.json ./ -RUN npm ci --omit=dev - # Copy the application source code -COPY . . +ADD . $HOME + +# Install application dependencies and clean up +RUN npm ci --omit=dev && rm -rf .npm + +# Fix permissions to write to /var/cache +USER root +RUN chgrp -R 0 /var/cache && \ + chmod -R g=u /var/cache +USER 1001 # Run the server CMD npm start From 6158dec1e29645b6e18fff2ebbef5a14f8d638b0 Mon Sep 17 00:00:00 2001 From: Jaime Ramirez Date: Fri, 16 Jun 2023 14:04:25 +0200 Subject: [PATCH 5/9] freeze base image --- images-ubi/apps/greetings/Containerfile | 2 +- images-ubi/solutions/greetings/Containerfile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/images-ubi/apps/greetings/Containerfile b/images-ubi/apps/greetings/Containerfile index 25af270d23..7c7fd953fd 100644 --- a/images-ubi/apps/greetings/Containerfile +++ b/images-ubi/apps/greetings/Containerfile @@ -1,4 +1,4 @@ -FROM registry.access.redhat.com/ubi9/nodejs-18-minimal +FROM registry.access.redhat.com/ubi9/nodejs-18-minimal:1-51 ENV PORT=80 EXPOSE ${PORT} diff --git a/images-ubi/solutions/greetings/Containerfile b/images-ubi/solutions/greetings/Containerfile index 6815135c97..56ef438b9d 100644 --- a/images-ubi/solutions/greetings/Containerfile +++ b/images-ubi/solutions/greetings/Containerfile @@ -1,4 +1,4 @@ -FROM registry.access.redhat.com/ubi9/nodejs-18-minimal +FROM registry.access.redhat.com/ubi9/nodejs-18-minimal:1-51 # Application listens on this port ENV PORT=8080 From 4a3b2ffeb9402b111f4fda8542fd26fef1624cea Mon Sep 17 00:00:00 2001 From: Jaime Ramirez Date: Fri, 16 Jun 2023 17:06:32 +0200 Subject: [PATCH 6/9] fix base image to point to internal registry --- images-ubi/apps/greetings/Containerfile | 2 +- images-ubi/solutions/greetings/Containerfile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/images-ubi/apps/greetings/Containerfile b/images-ubi/apps/greetings/Containerfile index 7c7fd953fd..7cec2e323f 100644 --- a/images-ubi/apps/greetings/Containerfile +++ b/images-ubi/apps/greetings/Containerfile @@ -1,4 +1,4 @@ -FROM registry.access.redhat.com/ubi9/nodejs-18-minimal:1-51 +FROM registry.ocp4.example.com:8443/ubi9/nodejs-18-minimal:1-51 ENV PORT=80 EXPOSE ${PORT} diff --git a/images-ubi/solutions/greetings/Containerfile b/images-ubi/solutions/greetings/Containerfile index 56ef438b9d..4c5b2e0c2d 100644 --- a/images-ubi/solutions/greetings/Containerfile +++ b/images-ubi/solutions/greetings/Containerfile @@ -1,4 +1,4 @@ -FROM registry.access.redhat.com/ubi9/nodejs-18-minimal:1-51 +FROM registry.ocp4.example.com:8443/ubi9/nodejs-18-minimal:1-51 # Application listens on this port ENV PORT=8080 From 13a9febcb5f7480681329d596e1e3b9b15692745 Mon Sep 17 00:00:00 2001 From: Marek Czernek Date: Thu, 13 Jul 2023 14:07:36 +0200 Subject: [PATCH 7/9] feat(ch04s04): Provide GE application (#335) --- .../apps/vertx-site/README.adoc | 32 +++++ .../apps/vertx-site/oc-new-app.sh | 7 ++ builds-applications/apps/vertx-site/pom.xml | 116 ++++++++++++++++++ .../com/redhat/vertx_site/MainVerticle.java | 41 +++++++ .../java/com/redhat/tests/VertxSiteTest.java | 43 +++++++ builds-applications/solutions/oc-new-app.sh | 8 ++ 6 files changed, 247 insertions(+) create mode 100644 builds-applications/apps/vertx-site/README.adoc create mode 100755 builds-applications/apps/vertx-site/oc-new-app.sh create mode 100644 builds-applications/apps/vertx-site/pom.xml create mode 100644 builds-applications/apps/vertx-site/src/main/java/com/redhat/vertx_site/MainVerticle.java create mode 100644 builds-applications/apps/vertx-site/src/test/java/com/redhat/tests/VertxSiteTest.java create mode 100755 builds-applications/solutions/oc-new-app.sh diff --git a/builds-applications/apps/vertx-site/README.adoc b/builds-applications/apps/vertx-site/README.adoc new file mode 100644 index 0000000000..a7fd350329 --- /dev/null +++ b/builds-applications/apps/vertx-site/README.adoc @@ -0,0 +1,32 @@ += Vertx-helloworld + +image:https://img.shields.io/badge/vert.x-4.4.4-purple.svg[link="https://vertx.io"] + +This application was generated using http://start.vertx.io + +== Building + +To launch your tests: +``` +./mvnw clean test +``` + +To package your application: +``` +./mvnw clean package +``` + +To run your application: +``` +./mvnw clean compile exec:java +``` + +== Help + +* https://vertx.io/docs/[Vert.x Documentation] +* https://stackoverflow.com/questions/tagged/vert.x?sort=newest&pageSize=15[Vert.x Stack Overflow] +* https://groups.google.com/forum/?fromgroups#!forum/vertx[Vert.x User Group] +* https://discord.gg/6ry7aqPWXy[Vert.x Discord] +* https://gitter.im/eclipse-vertx/vertx-users[Vert.x Gitter] + + diff --git a/builds-applications/apps/vertx-site/oc-new-app.sh b/builds-applications/apps/vertx-site/oc-new-app.sh new file mode 100755 index 0000000000..9403e5bbc9 --- /dev/null +++ b/builds-applications/apps/vertx-site/oc-new-app.sh @@ -0,0 +1,7 @@ +#!/bin/env bash + +oc new-app --name vertx-site \ + --build-env MAVEN_MIRROR_URL=http://nexus-infra.apps.ocp4.example.com/repository/java \ + -i redhat-openjdk18-openshift:1.8 \ + --context-dir builds-applications/apps/vertx-site \ + https://git.ocp4.example.com/developer/DO288-apps diff --git a/builds-applications/apps/vertx-site/pom.xml b/builds-applications/apps/vertx-site/pom.xml new file mode 100644 index 0000000000..0a540f91d1 --- /dev/null +++ b/builds-applications/apps/vertx-site/pom.xml @@ -0,0 +1,116 @@ + + + 4.0.0 + + com.redhat + vertx-site + 1.0.0-SNAPSHOT + + + UTF-8 + + 3.8.1 + 3.2.4 + 3.0.0-M5 + 3.0.0 + + 4.4.4 + 5.9.1 + + com.redhat.vertx_site.MainVerticle + io.vertx.core.Launcher + + + + + + io.vertx + vertx-stack-depchain + ${vertx.version} + pom + import + + + + + + + io.vertx + vertx-core + + + io.vertx + vertx-web + + + + junit + junit + 4.12 + test + + + io.vertx + vertx-unit + test + + + + + + + maven-compiler-plugin + ${maven-compiler-plugin.version} + + 1.8 + 1.8 + true + + + + maven-shade-plugin + ${maven-shade-plugin.version} + + + package + + shade + + + + + + ${launcher.class} + ${main.verticle} + + + + + ${project.build.directory}/${project.artifactId}-${project.version}-fat.jar + + + + + + + maven-surefire-plugin + ${maven-surefire-plugin.version} + + + org.codehaus.mojo + exec-maven-plugin + ${exec-maven-plugin.version} + + io.vertx.core.Launcher + + run + ${main.verticle} + + + + + + diff --git a/builds-applications/apps/vertx-site/src/main/java/com/redhat/vertx_site/MainVerticle.java b/builds-applications/apps/vertx-site/src/main/java/com/redhat/vertx_site/MainVerticle.java new file mode 100644 index 0000000000..96c271c612 --- /dev/null +++ b/builds-applications/apps/vertx-site/src/main/java/com/redhat/vertx_site/MainVerticle.java @@ -0,0 +1,41 @@ +package com.redhat.vertx_site; + +import io.vertx.core.AbstractVerticle; +import io.vertx.core.Vertx; +import io.vertx.core.http.HttpServer; +import io.vertx.core.http.HttpServerResponse; +import io.vertx.ext.web.Router; +import io.vertx.ext.web.RoutingContext; + +public class MainVerticle extends AbstractVerticle { + + @Override + public void start() { + // Create an HTTP server + HttpServer server = vertx.createHttpServer(); + + // Create a router to handle the HTTP requests + Router router = Router.router(vertx); + + // Define the route for the root path + router.get("/").handler(this::handleRoot); + + // Start the server and listen on port 8080 + server.requestHandler(router).listen(8080); + } + + private void handleRoot(RoutingContext routingContext) { + HttpServerResponse response = routingContext.response(); + + // Set the content type header + response.putHeader("Content-Type", "text/html"); + + // Send HTML content as the response + response.end("

Welcome to your Vert.x v1.0 application!

"); + } + + public static void main(String[] args) { + Vertx vertx = Vertx.vertx(); + vertx.deployVerticle(new MainVerticle()); + } +} diff --git a/builds-applications/apps/vertx-site/src/test/java/com/redhat/tests/VertxSiteTest.java b/builds-applications/apps/vertx-site/src/test/java/com/redhat/tests/VertxSiteTest.java new file mode 100644 index 0000000000..5c801044ed --- /dev/null +++ b/builds-applications/apps/vertx-site/src/test/java/com/redhat/tests/VertxSiteTest.java @@ -0,0 +1,43 @@ +package com.redhat.tests; + +import com.redhat.vertx_site.MainVerticle; +import io.vertx.core.Vertx; +import io.vertx.core.http.HttpClient; +import io.vertx.core.http.HttpClientResponse; +import io.vertx.core.http.HttpMethod; +import io.vertx.ext.unit.TestContext; +import io.vertx.ext.unit.junit.VertxUnitRunner; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; + + +@RunWith(VertxUnitRunner.class) +public class VertxSiteTest { + private Vertx vertx; + + @Before + public void setUp(TestContext context) { + vertx = Vertx.vertx(); + vertx.deployVerticle(new MainVerticle(), context.asyncAssertSuccess()); + } + + @After + public void tearDown(TestContext context) { + vertx.close(context.asyncAssertSuccess()); + } + + @Test + public void testHomePage(TestContext context) { + final HttpClient client = vertx.createHttpClient(); + + client.request(HttpMethod.GET, 8080, "localhost", "/") + .compose(request -> request.send().compose(HttpClientResponse::body)) + .onComplete(context.asyncAssertSuccess(buffer -> { + context.assertTrue(buffer.toString().contains("Welcome to your Vert.x")); + client.close(); + })); + } + +} diff --git a/builds-applications/solutions/oc-new-app.sh b/builds-applications/solutions/oc-new-app.sh new file mode 100755 index 0000000000..42d8f0ac9e --- /dev/null +++ b/builds-applications/solutions/oc-new-app.sh @@ -0,0 +1,8 @@ +#!/bin/env bash + +oc new-app --name vertx-site \ + --build-env MAVEN_MIRROR_URL=http://nexus-infra.apps.ocp4.example.com/repository/java \ + --env JAVA_APP_JAR=vertx-site-1.0.0-SNAPSHOT-fat.jar \ + -i redhat-openjdk18-openshift:1.8 \ + --context-dir builds-applications/apps/vertx-site \ + https://git.ocp4.example.com/developer/DO288-apps From b266560d048fcfa848ab7094e4bab9aab3c402be Mon Sep 17 00:00:00 2001 From: Student User Date: Mon, 17 Jul 2023 02:54:46 -0400 Subject: [PATCH 8/9] changed --- ubi-echo/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ubi-echo/Dockerfile b/ubi-echo/Dockerfile index 176078e5f5..0b28fb3c8b 100644 --- a/ubi-echo/Dockerfile +++ b/ubi-echo/Dockerfile @@ -1,3 +1,3 @@ FROM registry.access.redhat.com/ubi8/ubi:8.0 USER 1001 -CMD bash -c "while true; do echo test; sleep 5; done" +CMD bash -c "while true; do (( i++ )); echo test \$i; sleep 5; done" From c4b4ff412d0b73401dd8a9e774fa93aacd0a24a4 Mon Sep 17 00:00:00 2001 From: Student User Date: Mon, 17 Jul 2023 12:55:55 -0400 Subject: [PATCH 9/9] validations --- nodejs-helloworld/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nodejs-helloworld/package.json b/nodejs-helloworld/package.json index 338e1f7ead..29b13f406d 100644 --- a/nodejs-helloworld/package.json +++ b/nodejs-helloworld/package.json @@ -9,6 +9,6 @@ "author": "Red Hat Training", "license": "ASL", "dependencies": { - "express" "4.14.x" + "express": "4.14.x" } }