Comments (20)
I just improved my life a lot by altering the DB_USERNAME
in .env.testing to be root....
DB_USERNAME=root
from sail.
@driesvints Thanks for your reply. Here is the repo https://github.com/nat-mystudiosessions/sail-issue-112
I get the error running the command sail test --parallel --recreate-databases
.
However, if I update the default .env variable from DB_USERNAME=sail
to DB_USERNAME=root
as @powellblyth suggested the error does not occur.
Since this is a new empty project it needs the --recreate-databases
flag to show the error. In the project I am working on I have written database tests, so I get the error even without the flag. Thanks for checking this out. Please let me know if I can help further.
from sail.
Here's a proposed solution for parallel testing in Sail, now that we can leave my unfortunate typos 😄 above behind us:
Setting env DB_USERNAME
to root
directly in the sail test
command proxy enables creating/dropping databases during parallel testing.
This is where the proxy is defined:
Lines 126 to 129 in c54ad51
...and this is the line to add:
-e DB_USERNAME=root \
After that change, you can run sail test --parallel --recreate-databases
successfully!
As Sail is meant to be a local dev environment I don't think it hurts running the tests with another db user than what's actually specified in .env
. Unless you have some test that explicitly tests db user permissions... which I believe is extremely unlikely 😆
And here's the repo with reproduction of the problem we're solving: https://github.com/bjuppa/sail-issue-112
from sail.
Oo I'm investigating this exact same issue on my end.
I've altered my .env.testing environment so i can run the test from my host, but I get the exact same error. The issue may not be inside Sail
from sail.
Cool @powellblyth! I didn't see reference to a root user even being created while I was digging around the docker files, so I was a bit lost. It's nice to know it's created in the background, though I'm sure someone else will run into the same problem and maybe they can find this post and save them a day of head scratching. Thanks for the help.
from sail.
Heya, thanks for reporting.
I'll need more info and/or code to debug this further. Can you please create a repository with the command below, commit the code that reproduces the issue and share the repository here? Please make sure that you have the latest version of the Laravel installer in order to run this command. Please also make sure you have both Git & the GitHub CLI tool properly set up.
laravel new sail-issue-112 --github="--public"
After you've posted the repository, I'll try to reproduce the issue.
Thanks!
from sail.
@nat-mystudiosessions you did not create the repo with the command I posted above. Please recreate the repo with the exact command from above.
from sail.
@driesvints Ok. I tried the command first and got an error (I'm developing via WSL). I will read up on the GitHub CLI tool and try again (haven't used it before).
from sail.
@nat-mystudiosessions actually just committing the skeleton separate from your specific changes is the most important thing.
from sail.
@driesvints Ok, I was a little confused because I actually didn't change anything. The error occurs with a fresh Laravel install, that is all that is in the repo. Changing the DB_USERNAME
env value from sail
to root
makes the problem go away, but since sail
is the default DB_USERNAME it will likely throw people off the first time they try parallel testing. I'm not sure if answer is a bug fix or just a note in the docs, something like If you're using parallel testing, be sure your testing env file DB_USERNAME is set to root or else the testing process won't have the proper permissions to drop or create the necessary testing tables.
🙂
from sail.
I can run parallel testing just fine with the env values set by sail (including the sail username). Please post a way for me to reproduce the issue, otherwise I can't help out sorry.
from sail.
Hi, I ran into the same issue and created a repo with a reproduction according to instructions ☝️ and documented steps to reproduce in the readme:
https://github.com/bjuppa/sail-issue-112
I guess the problem is that tests are run with the DB_USERNAME
from .env
... and in Sail's MySQL this user has no permission to drop or create databases. Only the root
db user has this permission.
So, while you can indeed get the tests to run in parallel by setting DB_USERNAME
to root
, anyone cloning a Laravel project where DB_USERNAME
is set to something other than root
in .env.example
will run into problems.
@driesvints, what if Sail could give create+drop database permissions to the DB_USERNAME
user after creating the MySQL instance?
from sail.
@bjuppa parallel testing isn't supported for Dusk.
from sail.
@bjuppa parallel testing isn't supported for Dusk.
Ah, that's a shame! It seems to be such a small change to get it working, and it saves so much time to run tests in parallel while developing 😄
If I can get parallel testing working again with Sail, will you consider a PR?
I've been using parallel testing with Sail since I started work on my app in September and it's been working fine up until I rebuilt the docker images.
from sail.
Hey @driesvints , you asked for an example. sorry I didn't see that.
https://github.com/powellblyth/sail-issue-112
The failing test is the example test. I didn't bother actually writing a test in it because it happens when the user factory is triggered.
If we are all doing something wrong, I'd welcome a PR ;o)
from sail.
If I can get parallel testing working again with Sail, will you consider a PR?
It's literally impossible due to chrome not supporting it.
from sail.
for my example above, this is my .env (It's an out-of-the-box copy of example)
This is running on Intel Mac on Big Sur in case that's relevant. Latest version of docker
APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:yg3jwRpCiRo3D0MwrZDkpuXJ5dyLgZWLqv7DiawS134=
APP_DEBUG=true
APP_URL=http://sail-issue-112.test
LOG_CHANNEL=stack
LOG_LEVEL=debug
DB_CONNECTION=mysql
DB_HOST=mariadb
DB_PORT=3306
DB_DATABASE=sail_issue_112
DB_USERNAME=sail
DB_PASSWORD=password
BROADCAST_DRIVER=log
CACHE_DRIVER=file
FILESYSTEM_DRIVER=local
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120
MEMCACHED_HOST=memcached
REDIS_HOST=redis
REDIS_PASSWORD=null
REDIS_PORT=6379
MAIL_MAILER=smtp
MAIL_HOST=mailhog
MAIL_PORT=1025
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS=null
MAIL_FROM_NAME="${APP_NAME}"
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=
AWS_USE_PATH_STYLE_ENDPOINT=false
PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
from sail.
If I can get parallel testing working again with Sail, will you consider a PR?
It's literally impossible due to chrome not supporting it.
Would that be parallel testing with Sail + Dusk?
What I'm trying to do is just get sail test --parallel
working. And it already does in my app, as long as I do sail up
with a DB_USERNAME
other than root
, and then switch it to root
in .env
before running sail test --parallel
from sail.
Sorry! I realize I confused everyone! I meant to write Sail
above in my first comment, not Dusk
😬 This issue has nothing to do with Dusk, I'm sorry!
from sail.
I've updated my first comment above ☝️ to be correct, will you please read it again in this new light? 🙏
from sail.
Related Issues (20)
- Segmentation fault with last docker version HOT 62
- laravel.build script doesn't create new Laravel Sail application HOT 4
- Problems with mysql container HOT 2
- The stream or file "/var/www/html/storage/logs/laravel.log" could not be opened in append mode: Failed to open stream: Permission denied HOT 1
- Overwriting of images with multiple projects HOT 7
- phpunit.xml breaks sail if not present HOT 1
- laravelsail/php83-composer:latest missing PDO HOT 3
- Possible issue with latest docker compose 2.24 HOT 11
- HTTP tests are not included in test coverage by pcov HOT 7
- Sail does not read changes in .env file HOT 4
- MacOs Dockerfile failed on NO_PUBKEY 4F4EA0AAE5267A6C HOT 2
- Sail + Dusk not picking up Dusk specific .env file (.env.dusk.local) HOT 9
- Unable to pull PHP packages from ondrej repo HOT 1
- Hi, I have a problem with base_path HOT 1
- E: Unable to locate package postgresql-client-15 HOT 2
- Don't create DB after use command "sail up". HOT 1
- fresh install laravel 11 using bash don't remove comment from dotenv DB_DATABASE HOT 4
- Error on build: failed to solve: process "/bin/sh -c apt-get update ..." HOT 3
- SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo for mysql failed: Temporary failure in name resolution HOT 1
- docker-compose: command not found HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sail.