Laravel Dusk test for remote site not work - laravel-5.5

...
$this->browse(function (Browser $browser) {
$browser->visit(url()->route('login'))
->type('email', 'user.one#email.com')
->type('password', 'something')
->press('Login')
->pause(60*60*1000)
->assertRouteIs('dashboard')
...
It works on local which is use APP_URL something like 'https://project.dev' but not work for remote 'https://project.com' and 'http://123.123.12.12'.
Errors or Problems
login test on remote site not work
Different between local and remote
dusk installed in local
dusk not installed in remote
What i did to try solve it
I read that Chrome need HTTPS. I given https to it. Still not work. 😫
I pause the dusk longer. With the dusk browser open, i try type the username & password and submit it. Still not work. 😫
Reported on laravel dusk github as well

Without exact errors, it is difficult, to answer your question,
but from what you described I can provide some hints:
You should never use dusk in production or public site, even if it's configured as dev (security concerns).
I assume, that you are trying to run dusk on your dev, with remote APP_URL. This is wrong concept, cause your tests can manipulate data on db. In case your local and remote uses the same database it might work, but as said, bringing further problems.
Considering above, some of your tests could pass, if you make sure the following requirements are satisfied:
your .env APP_URL matches in both locations
you don't use migrations,factories etc in your dusk tests
you don't write any data to db (via testing register page for example) cause it would be a nightmare to handle these changes, when using the same db and running tests for local and remote
you modify DuskTestCase.php to add --no-sandbox option. This speeds tests up - so you shouldn't need to use pause
Final thoughts.
A good workflow for this would be:
Test your app locally
Commit changes to VCS (Version Control System) with CI (Continuous Integration) - for example gitlab - and run dusk test there.
Deploy to production, if tests are passing, either manually, or via deploy scripts - CD (Continuous Delivery)

Related

Django - Development server alternatives

Is there good alternatives to the django developement server (runserver) that are more performant,
especially in concurency and static serving, and that have the auto-reload function, without having to setup a full blown production environment ?
Im working on Windows so gunicorn cannot be used.
You can install and use the rungevent commant. It has auto-reload function and it's more performant than thread-based servers (it is greenlet-oriented). The only caveat is the static file serving: you must install a webserver or proxy like nginx for that.
Are you doing so high bulk tests in ur dev server so you suffer this -specially regarding static files-? If so, then you must emulate, as said, a productive environment (just have an nginx correctly configured pointing to the address:port you use for your rungevent command).
If static files is not your problem, install a rungevent command and try how it works.
No since dev sites are made to handle limited requests, runserver runs fine on a machine that can match the requirements of your app.
If you are dealing with a large scale dev project which your system cannot tolerate, then it's either time to reproduce a production environment or upgrade.
I find it difficult to believe that your application is that bad in terms of performance, again if you are trying to test the behavior of a full production site (in terms of DB entries etc) then its time to emulate the production environment.
If that is not the case, then I would start checking the underlying models / code of the project.
Well, if you don't want to use django dev server you will have to spend some time to setup anyway. But the good part is that you can do it only once. Sequential deploying will take very little time.
Not so much time ago I switched from fastcgi to uWSGI and it made my life much easier.
uWSGI is awesome! It has autoreload (which works both in daemon mode and when launched directly in terminal). When launched in terminal you can use debugger (e.g. pdb) during request just like you do in django dev-server. And of course you can debug with print in simple cases.
I'm using it with nginx which serves both static and uWSGI but it of course can be any server.
The most useful feature for me in this configuration is that you use the same thing both for dev and production. For simple projects after developing you just turn off autoreload and a few other options and it's ready.

Django web server -- where should I draw the line between production and development?

I know that it's bad to use the Django web server in production. There's been at least one Stackoveflow question on this already.
But I'm wondering about where to draw the line between development and production? If I'm only allowing HTTP access to one (or a few) IP addresses, then I know I'm in development. What if I open it to all IP addresses, but only e-mail a couple friends to see what they think of what I've built?
As far as I can tell, the problems with using the Django server are:
It's single-threaded
Security
I don't think (1) is likely to be an issue if I'm only sharing it with a few people. For (2)--what's the worst-case scenario? Does it make a difference that I'm running on an Amazon EC2 server that I could very easily restart from a backup if something bad happened?
Well, the answer is very simple actually, you've left development when you have something you must protect: real user personal information, real data in your database that you'd be afraid to lose, etc.
Security isn't a concern until these things are present. The rule about not using the dev server in "production" is guidance, not mandatory. You can fire up the dev server in your production environment any time you want. However, you'd be silly to do so and then open up universal access to it, once your site is truly live and in use by the world.
Setting up mod_wsgi (or some other WSGI container) on a development machine takes all of 5 minutes, and can help you sort out deployment issues before you actually reach deployment. So really, why ever use the development server if you don't have to?

CruiseControl.NET run as a windows service and as a standalone process behaves differently

I have a project that is being built using CruiseControl.NET. The project contains an 'MSBuild task' that runs the build for the project and also the unit tests. The unit test in turn is just a MSBuild 'exec' task that runs an executable.
The unit test involves some .NET remoting. And when the unit tests are run through the system command prompt, the software's window opens up, tests run and the process exits.
When I force a build through the web dashboard, the build hangs at the point where the unit test starts running. The software's window does not open up, but the executable is running. If the process is killed through the task explorer, the build goes through with a 'Failure' status. This happens when I run ccnet as a windows service.
If I run CCNet directly (not as a windows service) and force a build through the web dashboard, the build and unit tests go through fine as expected. (with the window of the software opening up.)
It looks like there is a deadlock in the case where CCNet is run as a windows service. I am guessing it is related to the standard output/error streams.
Is this is known problem?
What might be the problem going on?
Any suggestions on debugging this?
How can I get around it?
(I am using CCNet version 1.4.4 SP1)
When CCNet is running as a service it is not going to have access to the display, so don't expect to see anything on the screen in this configuration. The first thing I would check is the permissions - make sure the service runs as an account that has permissions to access whatever resources you need. You also have CCNet log files, which you can find via Dashboard.
On a side note, try TeamCity instead of CCNet, its 10 years ahead.
Maybe this answer will help :
delphi windows service can't download file from internet
You should know that when running CCNet as an application (the dosbox) it uses the environment variables and all rights from the logged account. So it may connect to a server, use cached passwords, get registry variables for this account.
BUT when ran as a service, the account is the one you provided : LocalSystem for exampe, where env. varibales are not the same.
So, what you can do is to change the CCNet service account for test. Change it to your user account (with password), and I'm sure it will work better !

How can I tell JWebUnit to contact specific Selenium servers

We want to run selenium backed jwebunit tests from our hudson server. We have a couple of selenium rc servers already on our network which I'd like to reuse.
However, how can I configure jwebunit to use those servers as I would like to avoid installing a slenium rc server on the hudson. Building is already work enough without starting/stopping firefoxes.
Have you tried Selenium Grid and then you just point your tests at the Selenium Grid Hub and your tests never have to know where the Selenium Remote Control servers are.
https://github.com/SeleniumHQ/selenium/wiki/Grid2
Ok, as far as i can see it cannot be done immediately : it is hardcoded in the implementation.
public void beginAt(URL aInitialURL, TestContext aTestContext) throws TestingEngineResponseException {
this.setTestContext(aTestContext);
selenium = new DefaultSelenium("localhost", port, "*chrome", aInitialURL.toString());
selenium.start();
gotoPage(aInitialURL);
}

Updating live server from VCS

I run all my Django sites as SCGI daemons. I won't get into the fundamentals of why I do this but this means that when a site is running, there is a set of processes running from the following command:
/websites/website-name/manage.py runfcgi method=threaded host=127.0.0.1 port=3036 protocol=scgi
All is fine until I want to roll out a new release from the VCS (Bazaar in my case). I made an alias script called up that does the following:
alias up='bzr up; killall manage.py'
It is this generic for one simple reason: I'm lazy. I want one command that I can use under any site to update it. I'm logged into the server most of the time anyway, so, I just hop into the root of the right site and call up. Site updates from BZR and restarts.
The first downside of this is it kills all the manage.py processes on the machine. Currently 6 sites and growing rapidly. The second (and potentially worse -- at least for end-users) is it's a severely non-graceful restart. If somebody was uploading an image or doing something else with a long connection time, their request would just die on the vine.
So what I'm looking for is suggestions for a single method that:
Is generic for lazy people like me (eg I can run it from any site root without having to remember which command I need to call; 'up' is perfect in name.
Only kills the current site. I'm only updating the current site, so only this one should die.
Does the restart in a graceful manner. If possible, it should wait until there are no more active connections. I've no idea how feasible this is.
Instead of killing everything with manage.py in the name, could you write a script for each site that only kills manage.py processes from that site? (Edit: just write the scripts and put them in the root of each site (which you cd to anyway) and run those – still only one command to remember)
I don't know enough about SCGI or Bazaar to suggest much more than that... My method (I'm lazy too) uses Mercurial and Fabric for deployment: http://stevelosh.com/blog/entry/2009/1/15/deploying-site-fabric-and-mercurial/ – maybe it will give you an idea you can use?