diff --git a/energy-tests/Dockerfile-mariadb b/energy-tests/Dockerfile-mariadb index ee69078469..9ff0e09aa9 100644 --- a/energy-tests/Dockerfile-mariadb +++ b/energy-tests/Dockerfile-mariadb @@ -1,3 +1,3 @@ -FROM mariadb:10.8.2-focal +FROM mariadb:latest COPY ./wordpress-dump.sql /docker-entrypoint-initdb.d/wordpress-dump.sql EXPOSE 3306 diff --git a/energy-tests/Dockerfile-wordpress b/energy-tests/Dockerfile-wordpress index f3c86bb00d..fe046d61a5 100644 --- a/energy-tests/Dockerfile-wordpress +++ b/energy-tests/Dockerfile-wordpress @@ -1,4 +1,4 @@ -FROM wordpress:7.0.4-php8.3-apache +FROM wordpress:latest EXPOSE 9875 COPY ./html /var/www/html COPY ./wordpress.conf /etc/apache2/sites-enabled/wordpress.conf diff --git a/energy-tests/compose.yml b/energy-tests/compose.yml index 87b139c3aa..35d9f4a9f7 100644 --- a/energy-tests/compose.yml +++ b/energy-tests/compose.yml @@ -16,7 +16,7 @@ services: - 3306 healthcheck: test: [ - "CMD", "bash", "-c", "mysqladmin ping -h localhost -u wordpress -pwordpress | grep \"mysqld is alive\"" + "CMD", "bash", "-c", "mariadb -h localhost -u wordpress -pwordpress -e 'SELECT 1' >/dev/null 2>&1" ] interval: "1h" # effectively turns repeated healthchecks during runtime off start_period: "60s" diff --git a/energy-tests/puppeteer-flow.js b/energy-tests/playwright-flow.js similarity index 81% rename from energy-tests/puppeteer-flow.js rename to energy-tests/playwright-flow.js index 9ce15d9ee1..1303d3c9ea 100644 --- a/energy-tests/puppeteer-flow.js +++ b/energy-tests/playwright-flow.js @@ -1,19 +1,19 @@ -const puppeteer = require("puppeteer"); +const { chromium } = require("playwright"); const microtime = require("microtime"); (async () => { console.log(microtime.now()," Launching Browser"); - const browser = await puppeteer.launch({ - defaultViewport: { - width: 1920, - height: 1080, - }, + const browser = await chromium.launch({ headless: true, - executablePath: "/usr/bin/chromium-browser", args: ["--no-sandbox", "--disable-setuid-sandbox"], // Otherwise it won't run on Docker }); - const page = await browser.newPage(); + const page = await browser.newPage({ + viewport: { + width: 1920, + height: 1080, + }, + }); const dimensions = await page.evaluate(() => { return { width: document.documentElement.clientWidth, @@ -25,7 +25,7 @@ const microtime = require("microtime"); console.log(microtime.now()," Home Page"); await page.goto("http://gcb-wordpress-apache:9875", { - waitUntil: "networkidle2", + waitUntil: "networkidle", }); console.log(microtime.now(),"GMT_SCI_R=1"); @@ -40,7 +40,7 @@ const microtime = require("microtime"); console.log(microtime.now()," Long Text Page"); await page.click("a[href='http://gcb-wordpress-apache:9875/?page_id=36']"); - await page.waitForXPath('//*[contains(text(), "Lorem ipsum dolor sit amet")]') + await page.waitForSelector('xpath=//*[contains(text(), "Lorem ipsum dolor sit amet")]'); console.log(microtime.now(),"GMT_SCI_R=1"); console.log(microtime.now()," Closing Browser"); diff --git a/energy-tests/usage_scenario.yml b/energy-tests/usage_scenario.yml index ec477ad433..91b07d850b 100644 --- a/energy-tests/usage_scenario.yml +++ b/energy-tests/usage_scenario.yml @@ -1,7 +1,7 @@ --- -name: Wordpress Data Puppeteer Scenario +name: Wordpress Data Playwright Scenario author: Arne Tarara -description: Wordpress sample with pre-populated DB (pages and plugins) where a simple Puppeteer flow is executed +description: Wordpress sample with pre-populated DB (pages and plugins) where a simple Playwright flow is executed compose-file: !include compose.yml @@ -25,10 +25,11 @@ services: networks: - gcb-wordpress-mariadb-network folder-destination: "/tmp/repo" - gcb-puppeteer: - image: greencoding/puppeteer-chrome + gcb-playwright: + image: mcr.microsoft.com/playwright:jammy setup-commands: - - command: cp /tmp/repo/energy-tests/puppeteer-flow.js /var/www/puppeteer-flow.js + - command: cp /tmp/repo/energy-tests/playwright-flow.js /var/www/playwright-flow.js + - command: npm install playwright microtime --prefix /var/www networks: - gcb-wordpress-mariadb-network depends_on: @@ -37,11 +38,11 @@ services: flow: - name: Check Website - container: gcb-puppeteer + container: gcb-playwright commands: - type: console - command: node /var/www/puppeteer-flow.js - note: Starting Puppeteer Flow + command: node /var/www/playwright-flow.js + note: Starting Playwright Flow log-stdout: true read-notes-stdout: true read-sci-stdout: true @@ -49,8 +50,8 @@ flow: command: sleep 30 note: Idling - type: console - command: node /var/www/puppeteer-flow.js - note: Starting Puppeteer Flow again + command: node /var/www/playwright-flow.js + note: Starting Playwright Flow again log-stdout: true read-notes-stdout: true read-sci-stdout: true