Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: automate profiling test #15

Merged
merged 3 commits into from
Nov 10, 2023
Merged
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
37 changes: 37 additions & 0 deletions tests/test.bats
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,20 @@ health_checks() {
ddev exec "curl -s xhgui:80" | grep "XHGui - Run list"
}

# This tests the collector function works.
collector_checks() {
# Turn on the collector
ddev xhprof
# Ensure there's no profiling data link
ddev exec "curl -s xhgui:80" | grep -v '<a href="/?server_name=web">'

# Profile site
ddev exec "curl -s web:80" | grep "Demo website"
sleep 5
# Ensure there a profiling data link
ddev exec "curl -s xhgui:80" | grep '<a href="/?server_name=web">'
}

@test "install from directory" {
set -eu -o pipefail
cd ${TESTDIR}
Expand All @@ -45,3 +59,26 @@ health_checks() {
# Check service works
health_checks
}

@test "a site can be profiled" {
set -eu -o pipefail
cd ${TESTDIR}

# Create test site
echo "# Create a demo website at ${TESTDIR}" >&3
ddev composer require perftools/php-profiler
ddev composer install
ddev config --docroot=public --create-docroot
echo "<?php
require_once __DIR__ . '/../vendor/autoload.php';
require_once '/mnt/ddev_config/xhgui/collector/xhgui.collector.php';
echo 'Demo website';" >${TESTDIR}/public/index.php

echo "# ddev get ${DIR} with project ${PROJNAME} in ${TESTDIR} ($(pwd))" >&3
ddev get ${DIR}
ddev restart

# Check service works
health_checks
collector_checks
}