Symfony(4.4) Panther Test case doesn't work on GitlabCI - php

I use Panther Tests Case and PHPUnit on my symfony project for functional testing.
When I run my tests on my computer (php bin/phpunit), everything works fine. When i'm connected on my server and I run my tests, everything works fine.Chrome-driver is correctly installed on th server and i can run it with command lines.
BUT, when i push on gitlab and my CI starts, i always have the same error :
That is a screenshot from gitlab interface
My script begins with a connection to my server using SSH.So the beahviour should be the same as when i connect to my server using Putty and SSH...
The command i use on my .gitlab.ci script is 'php bin/phpunit'. The same that i use locally.
I've found some posts speaking about this problem but all on Selenium and nothing for panther... Please help ! :)

don't know if the problem is still existing, but I've been struggling with the same issue since yesterday and I fixed it by evenutally reading the doc ;-) : https://github.com/symfony/panther#chrome-specific-environment-variables
Due the Chrome's sandboxing, there is the need to specify a specific ENV variable to ensure the correct running in a container.
I update my .gitlacb-ci.yml with this on my test step:
before_script:
- ... {HERE : ensure your chromedriver is existing in the container}
- export PANTHER_NO_SANDBOX=1
So... lesson learned/remembered : 5 min of doc reading is worth 2 days of google searching... ;-)

Related

Impossible to access OVH API from Symfony command online

Here is my problem: I'm developing a Symfony project which accesses telephony and email data from OVH API. Since I'm working in local, I've never met any problems, the API connection was working and I could recover all data.
Yesterday I deployed my project online on an OVH hosting, and when I launch a command from the SSH panel, I get cURL error 7.
The problem doesn't come from the API because I call it in my Controller and I don't get any errors.
My command is :
(php/5.6/production/) ~/www $ php bin/console converseo:updateTelephony
And the error I get :
[GuzzleHttp\Exception\ConnectException]
cURL error 7: Failed to connect to 213.186.33.117: Network is unreachable (
see http://curl.haxx.se/libcurl/c/libcurl-errors.html)
I don't know why this command works on localhost and in my controller, but doesn't work online.
I've got a similar problem in the past with SSH.
I resolved it by creating a CRON task in OVH admin menu. This CRON task call myfile.sh.
Myfile.sh:
#!/bin/bash
cd /home/yourpath
/usr/local/php5.6/bin/php bin/console converseo:updateTelephony
It was ok for me because I needed to execute the command only sometimes in the day. I hope it will helps you.
If you need to launch this command in a specific moment, I think you will need to upgrade your hosting account(vps for example) and type the command directly on the server.
I resolved my problem by putting a PHP file into my www folder, which contains :
<?php
shell_exec("sh myfile.sh");
?>
And myfile.sh :
#!/bin/bash
cd /homez.myNumber/MyNameSite/www
/usr/local/php5.6/bin/php bin/console converseo:MyCommand --env=prod

PhpStorm can not parse PHPUnit version output. Very strange error

I'm trying to set up PHPUnit in PhpStorm 2017.1 on Windows 10 using a Vagrant box for a Laravel project. I've set up a remote interpreter, and I've been using it for a couple of months now, everything working fine.
I've been asked to do some unit testing so I've set up PhpStorm with PHPUnit, following my coworkers' instructions (PhpStorm on Mac) but when I select autoload.php in my vendor folder I receive the error message
"Can not parse PHPUnit version output: Could not open input file: /vagrant/vendorphpunitphpunitphpunit" (no slashes).
If I run PHPUnit via vagrant ssh in the command line, my tests execute fine, and I can manually select the PHPUnit phar in PhpStorm, but then I'm missing the autoloaded classes, so everything fails.
WI-35806 -- seems the same. It was marked as fixed today.
If that's the right ticket then the fix should be available in 2017.1.2 -- you may try EAP build when it will become available if you cannot wait until 2017.1.2 final will be officially released.
If you get a similar bug when setting up PHPUnit with Docker, then it could also be because of bad volume bindings.
In the following preferences screen, click on the folder icon to Edit Docker Container Settings, then edit the Volume bindings.
In case you configure remote PHP cli interpreter by Docker Compose, if you get a similar bug of parsing PHPUnit version output like this, the reason may comes from using variables in docker-compose.yaml (e.g using $PWD in volume binding).
For instance, if you mount your current directory like this:
...
volumes:
- $PWD:/var/www/html
PHPStorm do not know what $PWD really is, therefore it cannot parse PHPUnit output due to volume binding. You should change the variables to a specific value (e.g to ./ in this case):
...
volumes:
- ./:/var/www/html

php exec SVN empty output, works fine in terminal under same user

I have an issue updating SVN from within PHP. It was working fine then suddenly stopped working a few days ago.
I am running PHP-FPM 5.5 through Nginx. SVN version is 1.8.8.
The code:
exec("svn cleanup $path");
exec("svn revert $path -R");
exec("svn update $path --accept theirs-full --non-interactive", $output, $return);
echo "Return: $return\nOutput: ".print_r($output, true)
Output:
Return: 1
Output: Array
(
)
When I run this in terminal (under the same user as PHP-FPM and Nginx), I get the expected output:
Updating '/path/to/app':
At revision 100
PHP CLI also works with the correct output (under same user as PHP-FPM and Nginx):
php5 /path/to/app/svnupdate.php
Based on this it seems to be specifically an issue with PHP5-FPM exec on svn. But how can I debug this and figure out what is wrong?
Thanks.
Updates from comments to keep everything together:
Tried the proc_open approach, running only "svn cleanup $path" via that failed and caused all files to lock. running same command under same user in terminal worked fine and unlocked all files again.
Tried full path to svn bin, no difference
Running "svn info $path" seems to work fine, no files were locked.
The following commands all fail in php exec/proc_open (without any error message or output) and lock the app files:
svn cleanup $path
svn revert $path -R
"svn update $path" returns "Updating '$path'" but stops there, previously the current build number would be returned on a second line.
I have a 2nd setup with a different app and svn server but running the same version OS and all software, this one is working fine. I think that rules out software.
i tried rolling the issue server back to a version from 2 months ago when it was working, the server automatically updates software and app on launch but should not have touched config files or cache. After it was available it was still showing the same issue. Fairly sure that rules out software config files/cache.
Which leaves only app codebase and svn server as a possible cause. I'll try resetting the svn server next and redoing the svn project.
Update 2:
Recreated the project on the SVN server, remove application from app server and all svn config directories, checked out the new project from SVN server (build 1). Still the same error. !_!
Update 3:
After doing all of the above i concluded that left only the file base that could be causing the issue. And it was, there was a "Can't convert string from native encoding to 'UTF-8':" error being thrown by SVN because of a few files with special characters in the filename. Interestingly the error only stopped the process when running from php-fpm and not in terminal. NO IDEA WHY. I added export LC_CTYPE=en_US.UTF-8; to the exec command and now it is working fine.
exec("export LC_CTYPE=en_US.UTF-8; svn update $path",$output);
The exit status (1) indicates that the command fails for some reason. To find out the reason, you need to capture the standard error with the help of proc_open function as shown in this answer. The exec function captures only the standard output.
There was a "Can't convert string from native encoding to 'UTF-8':" error being thrown by SVN because of a few files with special characters in the filename. Interestingly the error only stopped the process when running from php-fpm and not in terminal. NO IDEA WHY. I added export LC_CTYPE=en_US.UTF-8; to the exec command and now it is working fine.
exec("export LC_CTYPE=en_US.UTF-8; svn update $path",$output);
I used this code to actually discover the error in php:
$proc = proc_open('svn update', $desc, $pipes);
echo 'PIPE 1: '.stream_get_contents($pipes[1]); fclose($pipes[1]);
echo 'PIPE 2: '.stream_get_contents($pipes[2]); fclose($pipes[1]);
echo 'STATUS: '.proc_close($proc);
In my situation, I fixed the problem by following steps:
check which user php-fpm runs, in my case, it is nginx
cat /etc/passwd to check 'nginx' user, its home directory is '/var/cache/nginx'
cp /root/.subversion to /var/cache/nginx
reconfig /var/cache/nginx/.subversion/servers if you need
then is works well
Maybe the debug process is helpful:
I guess it is because of the permission problem
I change nginx from /sbin/nologin to /bin/bash
I run runuser -l nginx -c 'php myphpscript_which_exec_svn_command.php'
It will output some information you need
So I get the solution, for security reason, change nginx user property back(/bin/bash to /sbin/nologin)

OpenTok learning-open-tok issue

I've been following the steps at this link: https://github.com/opentok/learning-opentok-php, and I can't get past the first step because I don't understand what I have to do on this part:
The run-demo file starts the PHP CLI development server (requires PHP >= 5.4) on port 8080. If you want to run your server on another port, edit the file. Finally, start the server using the run-demo script.
And then when i actually run the run-demo script and follow the link: http://localhost:8080/session i get this message on screen "You must run composer install in the sample app directory", and if i try to run the composer it doesent run.

Google App Engine PHP Helloworld Example Does Nothing

I assume I'm making some simple mistake, but I just can't get the Google App Engine PHP SDK (GAE) "helloworld" example to work.
When I attempt to run the example on a Windows XP command line, I get no errors. The dev appserver is ever started on port 8080. I followed the GAE PHP SDK "Getting Started" page to the letter. If I mistype the path name, I get an error on that, but that’s it.
I have installed Python 2.7, PHP 5.4 and the GAE PHP SDK 1.8.3. All seem to work independently without error. Testing such…phpinfo() works, the Python interpreter works as well.
I’ve read all of the other questions/answers on this subject on the Stack(here) but nothing has helped. Here's some details:
My "helloworld" dir (the app.yawl file is there too):
C:\helloworld\helloworld.php
My Google GAE dir:
C:\google_appengine
My PHP dir:
C:\PHP
My Python dir:
C:\Python27
Here's the dev appserver startup command line I'm using in a Windows XP CMD window:
python C:\google_appengine\dev_appserver.py --php_executable_path=C:\PHP\php-cgi.exe C:\helloworld\helloworld
The dev web server does not start, can't see the listener on default port 8080 in netstat.
You said that the app.yawl file is present in the helloworld directory.
Its actually app.yaml . You may have saved that with incorrect extension. Check it.
The other thing I noticed is in the last command you are pointing to the .php file as C:\helloworld\helloworld.
You should actually point to the APPLICATION_DIRECTORY, which in your case is just C:/helloworld/

Categories