forked from jbartus/fastly-magento2-demo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Jim Bartus
committed
Aug 7, 2023
1 parent
ea99903
commit 7ec66a6
Showing
5 changed files
with
104 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
resource "google_compute_instance" "puppeteer" { | ||
name = "${var.site_name}-puppeteer" | ||
machine_type = "c3-standard-4" | ||
depends_on = [fastly_service_vcl.demo_service] | ||
allow_stopping_for_update = true | ||
boot_disk { | ||
initialize_params { | ||
image = "ubuntu-os-cloud/ubuntu-2304-amd64" | ||
} | ||
} | ||
network_interface { | ||
network = "default" | ||
access_config {} | ||
} | ||
metadata = { | ||
ssh-keys = "ubuntu:${file("${var.ssh_pub_key}")}" | ||
} | ||
metadata_startup_script = "apt install -y libnss3 libatk1.0-0 libatk-bridge2.0-0 libx11-xcb1 libxcb-dri3-0 libxcomposite1 libxdamage1 libxfixes3 libcups2 libdrm2 libxrandr2 libgbm1 libasound2 libpangocairo-1.0-0 libgtk-3-0" | ||
connection { | ||
type = "ssh" | ||
user = "ubuntu" | ||
private_key = file("${var.ssh_priv_key}") | ||
host = self.network_interface.0.access_config.0.nat_ip | ||
} | ||
provisioner "file" { | ||
source = "puppets/" | ||
destination = "/home/ubuntu" | ||
} | ||
provisioner "remote-exec" { | ||
inline = [ | ||
"curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.4/install.sh | bash", | ||
"export NVM_DIR=\"$HOME/.nvm\"", | ||
"[ -s \"$NVM_DIR/nvm.sh\" ] && \\. \"$NVM_DIR/nvm.sh\"", | ||
"nvm install node", | ||
"npm install puppeteer", | ||
"export SITE_URL=https://${var.site_name}.freetls.fastly.net", | ||
"nohup bash -c 'while true; do node homepage.js && sleep `shuf -i 2-10 -n1`; done &'", | ||
"sleep 5 && nohup bash -c 'while true; do node promobutton.js && sleep `shuf -i 2-10 -n1`; done &'", | ||
"sleep 10 && nohup bash -c 'while true; do node shopper.js && sleep `shuf -i 2-10 -n1`; done &'", | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
const puppeteer = require('puppeteer'); | ||
|
||
(async () => { | ||
const browser = await puppeteer.launch({headless: "new"}); | ||
const page = await browser.newPage(); | ||
await page.setViewport({width: 1600, height: 900}); | ||
await page.goto(process.env.SITE_URL); | ||
await page.mouse.wheel({deltaY: 1000}); | ||
await page.waitForTimeout(100); | ||
await page.mouse.wheel({deltaY: 1000}); | ||
await page.waitForTimeout(100); | ||
//await page.screenshot({ path: 'homepage.png' }); | ||
await browser.close(); | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
const puppeteer = require('puppeteer'); | ||
|
||
(async () => { | ||
const browser = await puppeteer.launch({headless: "new"}); | ||
const page = await browser.newPage(); | ||
await page.setViewport({width: 1600, height: 900}); | ||
await page.goto(process.env.SITE_URL); | ||
await page.waitForTimeout(2000); | ||
await page.waitForSelector('.action.more.button') | ||
await page.click('.action.more.button'); | ||
await page.waitForTimeout(2000); | ||
await page.mouse.wheel({deltaY: 1000}); | ||
await page.waitForTimeout(100); | ||
await page.mouse.wheel({deltaY: 1000}); | ||
await page.waitForTimeout(100); | ||
//await page.screenshot({ path: 'promobutton.png' }); | ||
await browser.close(); | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
const puppeteer = require('puppeteer'); | ||
|
||
(async () => { | ||
const browser = await puppeteer.launch({headless: "new"}); | ||
const page = await browser.newPage(); | ||
await page.setViewport({width: 1600, height: 900}); | ||
await page.goto(process.env.SITE_URL); | ||
await page.waitForTimeout(2000); | ||
await page.click('a[href$="sale.html"]'); | ||
await page.waitForTimeout(2000); | ||
await page.click('#maincontent > div.columns > div.sidebar.sidebar-main > div > div > ul:nth-child(2) > li:nth-child(2) > a'); | ||
await page.waitForTimeout(2000); | ||
await page.mouse.wheel({deltaY: 500}); | ||
await page.waitForTimeout(100); | ||
await page.click('#product-item-info_1316 > a > span > span > img'); | ||
await page.waitForTimeout(2000); | ||
await page.click('#option-label-size-144-item-168'); | ||
await page.waitForTimeout(500); | ||
await page.click('#option-label-color-93-item-56'); | ||
await page.waitForTimeout(500); | ||
await page.click('#product-addtocart-button > span'); | ||
await page.waitForTimeout(2000); | ||
await page.click('#maincontent > div.page.messages > div:nth-child(2) > div > div > div > a'); | ||
await page.waitForTimeout(2000); | ||
//await page.screenshot({ path: 'shopper.png' }); | ||
await browser.close(); | ||
})(); |