Skip to content

Commit

Permalink
trying to set the wwwroot
Browse files Browse the repository at this point in the history
  • Loading branch information
lameze committed Dec 18, 2024
1 parent 9b11d72 commit 6e0d799
Show file tree
Hide file tree
Showing 5 changed files with 87 additions and 45 deletions.
36 changes: 2 additions & 34 deletions exports
Original file line number Diff line number Diff line change
Expand Up @@ -3,45 +3,13 @@ export WORKSPACE=/home/simey/moodlehq/moodle-ci-runner/workspace
export CODEDIR=/home/simey/www/docker_integration_main

# The test to run
#export TESTTORUN=phpunit
#export TESTTORUN=install
export JOBTYPE=performance

# The browser to use for Behat tests
#export BROWSER=firefox
#export BROWSER=chrome
#export BROWSER_HEADLESS=0
#export BEHAT_TOTAL_RUNS=3

# The build id - this is used to generated the chash
export BUILD_ID="1"

# The Database to use
#export DBTYPE=mysqli
#export DBTYPE=mariadb
#export DBTYPE=oci
export DBTYPE=pgsql
#export DBTYPE=sqlsrv

# Database slaces
export DBREPLICAS=0
#export DBTAG=latest

# Any Behat Tags to run
#export TAGS='@javascript&&@mod_workshop&&@arn'
#export TAGS=core_notes
#export TAGS=arn
#export TAGS=filter
#export TAGS="@install"
#export BEHAT_NAME="We can use calculated grade totals"

export DBTAG=14
# PHP Version
export PHP_VERSION=8.1

# Install the moodle mobile app plugin.
#export PLUGINSTOINSTALL="https://github.com/moodlehq/moodle-local_moodlemobileapp.git|local/moodlemobileapp|"
#export MOBILE_VERSION="latest"


#export GOOD_COMMIT="7f450dcea36d752e62ab169cbeaf830ecb54c70f"
#export BAD_COMMIT="29ab56c4d28ccdc82722595fac1a1d739e6f2a0d"
export PHP_VERSION=8.3
70 changes: 61 additions & 9 deletions runner/main/jobtypes/performance/performance.sh
Original file line number Diff line number Diff line change
Expand Up @@ -107,23 +107,18 @@ function performance_setup_normal() {
# Create an empty timing file.
touch "${SHAREDDIR}"/timing.json

# Clone the moodle-performance-comparison repository.
git clone https://github.com/moodlehq/moodle-performance-comparison.git

# Set up the environment.
cd moodle-performance-comparison
composer install

# Init the Performance site.
echo
echo ">>> startsection Initialising Performance environment at $(date)<<<"
echo "============================================================================"
local initcmd
performance_initcmd initcmd # By nameref.

echo "Running: ${initcmd[*]}"

docker exec -t -u www-data "${WEBSERVER}" "${initcmd[@]}"

echo "Creating test data"
performance_generate_test_data

echo "============================================================================"
echo ">>> stopsection <<<"
}
Expand All @@ -141,6 +136,63 @@ function performance_initcmd() {
)
}

function performance_generate_test_data() {
local phpcmd="php"

# Generate courses.
docker exec -t -u www-data "${WEBSERVER}" ${phpcmd} admin/tool/generator/cli/maketestsite.php \
--size="XS" \
--fixeddataset \
--bypasscheck \
--filesizelimit="1000"
echo "NETWORK: ${NETWORK}"

# Variables
# WEBSERVER="your_webserver_container"
# phpcmd="php"
# SHAREDDIR="/path/to/shared/dir" # Replace with actual shared directory
SIZE="XS"
SHORTNAME="testcourse_3"

# Generate the test plan files and capture the output
testplanfiles=$(docker exec -t -u www-data "${WEBSERVER}" ${phpcmd} admin/tool/generator/cli/maketestplan.php \
--size='XS' \
--shortname='testcourse_3' \
--bypasscheck)

# Display the captured output
echo "Captured Output:"
echo "${testplanfiles}"

# Extract URLs and download files to ${SHAREDDIR}
urls=$(echo "${testplanfiles}" | grep -oP 'http://[^ ]+')
for url in ${urls}; do
# Extract the filename from the URL
filename=$(basename "${url}")
echo "Downloading: ${url} to ${SHAREDDIR}/${filename}"
curl -o "${SHAREDDIR}/${filename}" "${url}"
done

echo "All files downloaded to ${SHAREDDIR}."
# Uncomment and handle the test plan files if needed.
# local testplanfiles="$(${testplancommand})"
# if [[ "$testplanfiles" == *"testplan"* ]]; then
# local files=( $testplanfiles )
# if [ "${#files[*]}" -ne 2 ]; then
# echo "Error: There was a problem generating the test plan." >&2
# exit 1
# fi
# ${curlcmd} \
# -o $FILE_NAME_TEST_PLAN ${files[0]} \
# -o $FILE_NAME_USERS ${files[1]} \
# --silent || \
# throw_error "There was a problem getting the test plan files. Check your wwwroot setting."
# else
# echo "Error: There was a problem generating the test plan." >&2
# exit 1
# fi
}

#function performance_datacmd() {
#
#}
Expand Down
5 changes: 3 additions & 2 deletions runner/main/modules/docker-php/config.template.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
if (empty($CFG->skiplangupgrade)) {
define('TOOL_LANGIMPORT_REMOTE_TESTS', true);
}

echo "WWWROOT: " . getenv('MOODLE_WWWROOT') . "\n";
$CFG->wwwroot = getenv('MOODLE_WWWROOT') ?: 'http://host.name';
$CFG->dataroot = '/var/www/moodledata';
$CFG->admin = 'admin';
Expand All @@ -74,7 +74,8 @@

$CFG->phpunit_dataroot = '/var/www/phpunitdata';
$CFG->phpunit_prefix = 't_';

// Set the generated users password to avoid the default non-loggeable one.
$CFG->tool_generator_users_password = '%%toolgeneratorpassword%%';
// Configure behat.
\moodlehq_ci_runner::set_behat_configuration(
getenv('WEBSERVER'),
Expand Down
3 changes: 3 additions & 0 deletions runner/main/modules/docker-php/docker-php.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ function docker-php_setup() {
docker run \
--network "${NETWORK}" \
--name "${WEBSERVER}" \
-e MOODLE_WWWROOT="http://$ip_address"
--detach \
--env-file "${ENVIROPATH}" \
-v "${COMPOSERCACHE}:/var/www/.composer:rw" \
Expand All @@ -61,6 +62,8 @@ function docker-php_setup() {
# Ensure that the whole .composer directory is writable to all (www-data needs to write there).
docker exec "${WEBSERVER}" chmod -R go+rw /var/www/.composer



echo
echo "Webserver logs:"
docker logs "${WEBSERVER}"
Expand Down
18 changes: 18 additions & 0 deletions runner/main/modules/moodle-core-copy/moodle-core-copy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,24 @@ function moodle-core-copy_setup() {

# Copy the config.php in place
echo "== Copying configuration in place."
ip_address=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' "${WEBSERVER}")
echo "IP Address: ${ip_address}"
# Set the MOODLE_WWWROOT environment variable
# export MOODLE_WWWROOT="http://$ip_address"
# Verify that the environment variable is set
# echo "MOODLE_WWWROOT is set to $MOODLE_WWWROOT"
# Set the MOODLE_WWWROOT environment variable in the running container

# Set the MOODLE_WWWROOT environment variable
export MOODLE_WWWROOT="http://$ip_address"

# Verify that the environment variable is set
echo "MOODLE_WWWROOT is set to $MOODLE_WWWROOT"

# Set the MOODLE_WWWROOT environment variable in the running container
docker exec "${WEBSERVER}" /bin/bash -c "export MOODLE_WWWROOT='http://$ip_address' && echo 'MOODLE_WWWROOT is set to $MOODLE_WWWROOT'"


docker cp "${BASEDIR}/modules/docker-php/config.template.php" "${WEBSERVER}":/var/www/html/config.php
docker exec "${WEBSERVER}" chown -R www-data:www-data /var/www/html/config.php

Expand Down

0 comments on commit 6e0d799

Please sign in to comment.