phpunit&;副测试及;Laravel-创建测试存储目录时发生随机故障
我正在为phpunit、paratest使用并行测试插件,并使用一个Laravel应用程序来加速测试套件的执行。 这在大多数情况下都有效,但偶尔会出现以下故障phpunit&;副测试及;Laravel-创建测试存储目录时发生随机故障,php,laravel,phpunit,flysystem,Php,Laravel,Phpunit,Flysystem,我正在为phpunit、paratest使用并行测试插件,并使用一个Laravel应用程序来加速测试套件的执行。 这在大多数情况下都有效,但偶尔会出现以下故障 League\Flysystem\Exception: Impossible to create the root directory "/codebuild/output/src0123456/src/github.com/org/repo/storage/framework/testing/disks/local". file_get
League\Flysystem\Exception: Impossible to create the root directory "/codebuild/output/src0123456/src/github.com/org/repo/storage/framework/testing/disks/local". file_get_contents(/codebuild/output/src0123456/src/github.com/org/repo/.env): failed to open stream: No such file or directory
/codebuild/output/src0123456/src/github.com/org/repo/vendor/league/flysystem/src/Adapter/Local.php:112
/codebuild/output/src0123456/src/github.com/org/repo/vendor/league/flysystem/src/Adapter/Local.php:78
/codebuild/output/src0123456/src/github.com/org/repo/vendor/laravel/framework/src/Illuminate/Filesystem/FilesystemManager.php:167
/codebuild/output/src0123456/src/github.com/org/repo/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:261
/codebuild/output/src0123456/src/github.com/org/repo/vendor/laravel/framework/src/Illuminate/Support/Facades/Storage.php:70
/codebuild/output/src0123456/src/github.com/org/repo/tests/TestCase.php:42
第42行的故障与正在创建本地存储文件夹进行测试的这一行有关
Storage::persistentFake();
我认为提到.env文件的错误的后半部分是不相关的,因为异常选择了最后记录的错误,而不是与故障相关的错误
这只会偶尔发生,所以这一定是一系列操作或时间问题
这些测试在针对PHP7.3和7.4的AWS代码构建环境中运行并失败
有人有什么想法吗?如果其他人遇到这个问题,可以通过在执行测试之前创建测试存储目录来解决
mkdir -p storage/framework/testing/disks/local
vendor/bin/paratest
它有点脆弱,但到目前为止,它对我们来说非常有效。根据我的经验,这通常不是文件系统的问题。大多数时候,我的测试没有正确地清理 根据文件系统和Paratest,您的测试以不同的顺序执行,然后会发生此错误 您可以做一些事情来追踪这一点:
--debug
模式,并检查之前执行的所有测试--order by=random
以不同的顺序执行测试,然后在从文件系统读取时显示测试。执行几次,也许你可以在本地模拟一下Testcase::setUp()
)之前创建文件系统布局,并在关闭(Testcase::teatDown()
)时对其进行清理,否则一个测试可能会影响另一个测试我看到你在用飞行系统。你不能只使用内存适配器而不是真正的文件系统吗?re:dates-laravel/Carbon可以设置“now()”-另请参见