Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion energy-tests/Dockerfile-mariadb
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion energy-tests/Dockerfile-wordpress
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion energy-tests/compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
20 changes: 10 additions & 10 deletions energy-tests/puppeteer-flow.js → energy-tests/playwright-flow.js
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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");

Expand All @@ -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");
Expand Down
21 changes: 11 additions & 10 deletions energy-tests/usage_scenario.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
name: Wordpress Data Puppeteer Scenario
name: Wordpress Data Playwright Scenario
author: Arne Tarara <arne@green-coding.berlin>
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

Expand All @@ -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:
Expand All @@ -37,20 +38,20 @@ 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
- type: console
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
Expand Down