Skip to content

Commit 2c48341

Browse files
committed
Added usage_scenario and benchmarks
1 parent 85a43c1 commit 2c48341

15 files changed

+1932
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
baseURL: http://localhost:8001/
2+
scenarios:
3+
- path: homepage-landing.js
4+
name: homepage-landing
5+
# - path: search.js
6+
# name: search
7+
- path: blog-filtering.js
8+
name: blog-filtering
9+
# - path: contact-us.js
10+
# name: contact-us
11+
# - path: admin.js
12+
# name: admin
13+
projectName: gold-bakerydemo-static
14+
samples: 3
15+
distant: false
16+
useAdblock: false
17+
ignoreHTTPSErrors: true
18+
containers:
19+
- "bakerydemo-static_app-1"

benchmark/greenframe/.greenframe.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
baseURL: http://localhost:8000/
2+
scenarios:
3+
- path: homepage-landing.js
4+
name: homepage-landing
5+
- path: search.js
6+
name: search
7+
- path: blog-filtering.js
8+
name: blog-filtering
9+
- path: contact-us.js
10+
name: contact-us
11+
- path: admin.js
12+
name: admin
13+
projectName: gold-bakerydemo
14+
samples: 3
15+
distant: false
16+
useAdblock: false
17+
ignoreHTTPSErrors: true
18+
containers:
19+
- "bakerydemo-gold-benchmark-app-1"
20+
databaseContainers:
21+
- "bakerydemo-gold-benchmark-db-1"
22+
- "bakerydemo-gold-benchmark-redis-1"

benchmark/greenframe/admin.js

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
async (page) => {
2+
await page.goto("admin/login/", { waitUntil: "networkidle" });
3+
console.log(await page.title());
4+
5+
const id_username = await page.locator('#id_username');
6+
await id_username.type('admin');
7+
const id_password = await page.locator('#id_password');
8+
await id_password.type('changeme');
9+
const submit = await page.locator('[type="submit"]');
10+
11+
await Promise.all([
12+
page.waitForNavigation({ waitUntil: 'networkidle' }),
13+
submit.press('Enter')
14+
]);
15+
16+
console.log(await page.title());
17+
18+
await Promise.all([
19+
page.waitForNavigation({ waitUntil: 'networkidle' }),
20+
page.locator('[href="/admin/pages/60/"]').first().click()
21+
])
22+
console.log(await page.title());
23+
24+
await Promise.all([
25+
page.waitForNavigation({ waitUntil: 'networkidle' }),
26+
page.locator('[href="/admin/pages/61/"]').first().click()
27+
])
28+
console.log(await page.title());
29+
30+
await Promise.all([
31+
// Very heavy page that takes forever to load.
32+
page.waitForNavigation({ waitUntil: 'load', timeout: 15000 }),
33+
page.locator('[href="/admin/pages/77/edit/"]').first().click()
34+
])
35+
console.log(await page.title());
36+
37+
const id_title = await page.locator('#id_title');
38+
await id_title.type('(new) ');
39+
40+
const previewToggle = await page.waitForSelector('[aria-label="Toggle preview"]', { timeout: 10000 });
41+
42+
await previewToggle.click();
43+
44+
await page.waitForSelector('iframe[title="Preview"]', { visible: true });
45+
await page.waitForFunction(() => document.querySelector('iframe[title="Preview"]').contentDocument.querySelector('h1').innerText === '(new) Desserts with Benefits');
46+
47+
// Un-comment to visually confirm the live preview panel’s appearance.
48+
// await page.screenshot({ path: 'admin.png' });
49+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
async (page) => {
2+
await page.goto("blog/", { waitUntil: "networkidle" });
3+
console.log(await page.title());
4+
5+
await page.waitForTimeout(3000);
6+
await page.scrollToElement('footer');
7+
await page.waitForLoadState('networkidle');
8+
9+
await Promise.all([
10+
page.waitForNavigation({ waitUntil: 'networkidle' }),
11+
page.locator('[aria-label="Filter by tag name dessert"]').click()
12+
])
13+
console.log(await page.title());
14+
15+
await page.waitForTimeout(3000);
16+
await page.scrollToElement('footer');
17+
await page.waitForLoadState('networkidle');
18+
19+
await Promise.all([
20+
page.waitForNavigation({ waitUntil: 'networkidle' }),
21+
page.locator('[href="/blog/desserts-benefits/"]').click()
22+
])
23+
console.log(await page.title());
24+
25+
await page.waitForTimeout(3000);
26+
await page.scrollToElement('footer');
27+
await page.waitForLoadState('networkidle');
28+
}

benchmark/greenframe/contact-us.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
async (page) => {
2+
await page.goto("contact-us/", { waitUntil: "networkidle" });
3+
console.log(await page.title());
4+
5+
await page.waitForTimeout(3000);
6+
await page.scrollToElement('footer');
7+
await page.waitForLoadState('networkidle');
8+
9+
const id_subject = await page.locator('#id_subject');
10+
await id_subject.type('Enquiring about bread');
11+
const id_your_name = await page.locator('#id_your_name');
12+
await id_your_name.type('Testing tester');
13+
const id_purpose = await page.locator('#id_purpose');
14+
await id_purpose.selectOption('Question');
15+
const id_body = await page.locator('#id_body');
16+
await id_body.type('Is this is for demo purposes only?');
17+
const submit = await page.locator('[type="submit"]');
18+
19+
await Promise.all([
20+
page.waitForNavigation({ waitUntil: 'networkidle' }),
21+
submit.press('Enter')
22+
]);
23+
24+
await page.waitForTimeout(3000);
25+
await page.scrollToElement('footer');
26+
await page.waitForLoadState('networkidle');
27+
28+
console.log(await page.title());
29+
const intro = await page.locator('.index-header__body-introduction');
30+
console.log(await intro.evaluate((node) => node.innerText));
31+
32+
await page.waitForTimeout(3000);
33+
await page.scrollToElement('footer');
34+
await page.waitForLoadState('networkidle');
35+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
async (page) => {
2+
await page.goto("", { waitUntil: "networkidle" });
3+
console.log(await page.title());
4+
5+
await page.waitForTimeout(3000);
6+
await page.scrollToElement('footer');
7+
await page.waitForLoadState('networkidle');
8+
9+
await Promise.all([
10+
page.waitForNavigation({ waitUntil: 'networkidle' }),
11+
page.locator('[href="/breads"]').click()
12+
])
13+
console.log(await page.title());
14+
15+
await page.waitForTimeout(3000);
16+
await page.scrollToElement('footer');
17+
await page.waitForLoadState('networkidle');
18+
19+
await Promise.all([
20+
page.waitForNavigation({ waitUntil: 'networkidle' }),
21+
page.locator('[href="/breads/bolani/"]').click()
22+
])
23+
console.log(await page.title());
24+
25+
await page.waitForTimeout(3000);
26+
await page.scrollToElement('footer');
27+
await page.waitForLoadState('networkidle');
28+
}

benchmark/greenframe/search.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
async (page) => {
2+
await page.goto("", { waitUntil: "networkidle" });
3+
console.log(await page.title());
4+
5+
await page.waitForTimeout(10000);
6+
await page.scrollToElement('footer');
7+
await page.waitForLoadState('networkidle');
8+
9+
const search = await page.locator('#search-input');
10+
await search.type('bread');
11+
await Promise.all([
12+
page.waitForNavigation({ waitUntil: 'networkidle' }),
13+
search.press('Enter')
14+
]);
15+
16+
console.log(await page.title());
17+
18+
await page.waitForTimeout(10000);
19+
await page.scrollToElement('footer');
20+
await page.waitForLoadState('networkidle');
21+
22+
await Promise.all([
23+
page.waitForNavigation({ waitUntil: 'networkidle' }),
24+
page.locator('[href="/blog/icelandic-baking/"]').click()
25+
])
26+
27+
await page.waitForTimeout(30000);
28+
29+
console.log(await page.title());
30+
}

benchmark/puppeteer/admin.js

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
import puppeteer from 'puppeteer';
2+
import microtime from 'microtime';
3+
4+
(async () => {
5+
const browser = await puppeteer.launch({
6+
headless: true,
7+
executablePath: "/usr/bin/chromium-browser",
8+
args: ['--no-sandbox', '--disable-setuid-sandbox'],
9+
});
10+
const page = await browser.newPage();
11+
page.setDefaultTimeout(5000);
12+
await page.setViewport({"width":1280,"height":1600});
13+
14+
await page.goto(process.env.USAGE_SCENARIO_DOMAIN+"/admin/login/", { waitUntil: "networkidle0" });
15+
console.log(microtime.now(), await page.title());
16+
console.log("GMT_SCI_R=1");
17+
18+
const id_username = await page.$('#id_username');
19+
await id_username.type('admin');
20+
const id_password = await page.$('#id_password');
21+
await id_password.type('changeme');
22+
const submit = await page.$('[type="submit"]');
23+
24+
await Promise.all([
25+
page.waitForNavigation({ waitUntil: 'networkidle0' }),
26+
submit.press('Enter')
27+
]);
28+
29+
console.log(microtime.now(), await page.title());
30+
console.log("GMT_SCI_R=1");
31+
32+
await Promise.all([
33+
page.waitForNavigation({ waitUntil: 'networkidle0' }),
34+
page.click('[href="/admin/pages/60/"]')
35+
])
36+
console.log(microtime.now(), await page.title());
37+
38+
await Promise.all([
39+
page.waitForNavigation({ waitUntil: 'networkidle0' }),
40+
page.click('[href="/admin/pages/61/"]')
41+
])
42+
console.log(microtime.now(), await page.title());
43+
console.log("GMT_SCI_R=1");
44+
45+
await Promise.all([
46+
// Very heavy page that takes forever to load.
47+
page.waitForNavigation({ waitUntil: 'load', timeout: 15000 }),
48+
page.click('[href="/admin/pages/77/edit/"]')
49+
])
50+
console.log(microtime.now(), await page.title());
51+
52+
const id_title = await page.$('#id_title');
53+
await id_title.type('(new) ');
54+
55+
const previewToggle = await page.waitForSelector('[aria-label="Toggle preview"]', { timeout: 10000 });
56+
57+
await previewToggle.click();
58+
59+
await page.waitForSelector('iframe[title="Preview"]', { visible: true });
60+
61+
// I keep getting the error "Preview not available."
62+
// https://ibb.co/3CpLYZF
63+
//await page.waitForFunction(() => document.querySelector('iframe[title="Preview"]').contentDocument.querySelector('h1').innerText === '(new) Desserts with Benefits');
64+
65+
// Un-comment to visually confirm the live preview panel’s appearance.
66+
// await page.screenshot({ path: 'admin.png' });
67+
68+
await browser.close();
69+
})().catch(err => {
70+
console.error(err);
71+
process.exit(1);
72+
});

benchmark/puppeteer/blog-filtering.js

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import puppeteer from 'puppeteer';
2+
import microtime from 'microtime';
3+
4+
(async () => {
5+
const browser = await puppeteer.launch({
6+
headless: true,
7+
executablePath: "/usr/bin/chromium-browser",
8+
args: ['--no-sandbox', '--disable-setuid-sandbox'],
9+
});
10+
const page = await browser.newPage();
11+
page.setDefaultTimeout(5000);
12+
await page.setViewport({"width":1280,"height":800});
13+
14+
await page.goto(process.env.USAGE_SCENARIO_DOMAIN+"/blog/", { waitUntil: "networkidle0" });
15+
console.log(microtime.now(), await page.title());
16+
console.log("GMT_SCI_R=1");
17+
18+
await page.waitForTimeout(3000);
19+
await page.evaluate(() => document.querySelector('footer').scrollIntoView());
20+
await page.waitForNetworkIdle();
21+
22+
await Promise.all([
23+
page.waitForNavigation({ waitUntil: 'networkidle0' }),
24+
page.click('[href="/blog/tags/dessert/"]')
25+
])
26+
console.log(microtime.now(), await page.title());
27+
console.log("GMT_SCI_R=1");
28+
29+
await page.waitForTimeout(3000);
30+
await page.evaluate(() => document.querySelector('footer').scrollIntoView());
31+
await page.waitForNetworkIdle();
32+
33+
await Promise.all([
34+
page.waitForNavigation({ waitUntil: 'networkidle0' }),
35+
page.click('[href="/blog/desserts-benefits/"]')
36+
])
37+
console.log(microtime.now(), await page.title());
38+
console.log("GMT_SCI_R=1");
39+
40+
await page.waitForTimeout(3000);
41+
await page.evaluate(() => document.querySelector('footer').scrollIntoView());
42+
await page.waitForNetworkIdle();
43+
44+
await browser.close();
45+
})().catch(err => {
46+
console.error(err);
47+
process.exit(1);
48+
});

benchmark/puppeteer/contact-us.js

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import puppeteer from 'puppeteer';
2+
import microtime from 'microtime';
3+
4+
(async () => {
5+
const browser = await puppeteer.launch({
6+
headless: true,
7+
executablePath: "/usr/bin/chromium-browser",
8+
args: ['--no-sandbox', '--disable-setuid-sandbox'],
9+
});
10+
const page = await browser.newPage();
11+
page.setDefaultTimeout(5000);
12+
await page.setViewport({"width":1280,"height":1600});
13+
14+
await page.goto(process.env.USAGE_SCENARIO_DOMAIN+"/contact-us/", { waitUntil: "networkidle0" });
15+
console.log(microtime.now(), await page.title());
16+
console.log("GMT_SCI_R=1");
17+
18+
await page.waitForTimeout(3000);
19+
await page.evaluate(() => document.querySelector('footer').scrollIntoView());
20+
await page.waitForNetworkIdle();
21+
22+
const id_subject = await page.$('#id_subject');
23+
await id_subject.type('Enquiring about bread');
24+
const id_your_name = await page.$('#id_your_name');
25+
await id_your_name.type('Testing tester');
26+
const id_purpose = await page.$('#id_purpose');
27+
await id_purpose.select('Question');
28+
const id_body = await page.$('#id_body');
29+
await id_body.type('Is this is for demo purposes only?');
30+
const submit = await page.$('[type="submit"]');
31+
32+
await Promise.all([
33+
page.waitForNavigation({ waitUntil: 'networkidle0' }),
34+
submit.press('Enter')
35+
]);
36+
console.log("GMT_SCI_R=1");
37+
38+
39+
await page.waitForTimeout(3000);
40+
await page.evaluate(() => document.querySelector('footer').scrollIntoView());
41+
await page.waitForNetworkIdle();
42+
43+
console.log(microtime.now(), await page.title());
44+
const intro = await page.$('.index-header__body-introduction');
45+
console.log(microtime.now(), (await intro.evaluate((node) => node.innerText)).replaceAll("\n", "--"));
46+
47+
await page.waitForTimeout(3000);
48+
await page.evaluate(() => document.querySelector('footer').scrollIntoView());
49+
await page.waitForNetworkIdle();
50+
51+
await browser.close();
52+
})().catch(err => {
53+
console.error(err);
54+
process.exit(1);
55+
});

0 commit comments

Comments
 (0)