Running out of memory PHPUnit CI/CD Pipelines

Posted 2 months ago by BillRiess

I'm getting this error in Bitbuckets Pipelines when running PHPUnit but not when I run PHPUnit locally...

PHPUnit 7.5.7 by Sebastian Bergmann and contributors.
EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE  63 / 153 ( 41%)
EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE 126 / 153 ( 82%)
EEE

Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 32768 bytes) in /opt/atlassian/pipelines/agent/build/vendor/laravel/telescope/config/telescope.php on line 1

Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 32768 bytes) in /opt/atlassian/pipelines/agent/build/vendor/symfony/debug/Exception/FatalErrorException.php on line 1

Running locally, everything works.

Here is my phpunit.xml

<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
         backupStaticAttributes="false"
         bootstrap="vendor/autoload.php"
         colors="true"
         convertErrorsToExceptions="true"
         convertNoticesToExceptions="true"
         convertWarningsToExceptions="true"
         processIsolation="false"
         stopOnFailure="false">
    <testsuites>
        <testsuite name="Unit">
            <directory suffix="Test.php">./tests/Unit</directory>
        </testsuite>

        <testsuite name="Feature">
            <directory suffix="Test.php">./tests/Feature</directory>
        </testsuite>
    </testsuites>
    <filter>
        <whitelist processUncoveredFilesFromWhitelist="true">
            <directory suffix=".php">./app</directory>
        </whitelist>
    </filter>
    <php>
        <env name="APP_ENV" value="testing"/>
        <env name="BCRYPT_ROUNDS" value="4"/>
        <env name="CACHE_DRIVER" value="array"/>
        <env name="MAIL_DRIVER" value="array"/>
        <env name="QUEUE_CONNECTION" value="sync"/>
        <env name="SESSION_DRIVER" value="array"/>
        <env name="TELESCOPE_ENABLED" value="false"/>
        <env name="DB_CONNECTION" value="sqlite_memory"/>
    </php>
</phpunit>

The sqlite_memory connection just points to :memory: based driver.

The TestCase.php:

<?php

namespace Tests;

use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;

abstract class TestCase extends BaseTestCase
{
    use CreatesApplication, RefreshDatabase;

    public function tearDown(): void
    {
        parent::tearDown();
        app()->forgetInstances();
    }
}

Pipelines gives 4gb of ram which should be plenty for the tests that are running. Again, locally there are no issues but on the Pipeline server there is. I'm wondering if maybe there is a config option or something I'm missing.

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.