A
A
ADamCarraway2021-11-16 17:31:26
Nginx
ADamCarraway, 2021-11-16 17:31:26

Server gives timeout after 350 requests in phpunit tests, what could be the problem?

The project has 1000+ tests. When I run all the tests, then after 350 tests, the rest of the tests start to issue timeout. Regardless of order. If the test is run separately, then everything is fine.
Created a simple test with dataProvider (it has 500 items):

/** @test
     *@dataProvider getItems
     */
    public function it_update_role($i)
    {
        $this->signInAdmin()
            ->putJson(route('admin.roles.update', 1), [])
            ->assertOk();

        $this->assertTrue(true);
    }

This test starts issuing timeout after 345 iterations.
And if you run such a test, then everything is fine:
/** @test*/
    public function it_update_role()
    {
     for ($i = 0; $i < 500; $i++){
        $this->signInAdmin()
            ->putJson(route('admin.roles.update', 1), [])
            ->assertOk();
       }
        $this->assertTrue(true);
    }

What could be the problem ? Maybe something in nginx is not configured or misconfigured?
Here is the nginx config
#user  nobody;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;

events {
    worker_connections  768;
}

http {
    include       mime.types;
    default_type  application/octet-stream;

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  63;
    server_names_hash_bucket_size  64;
    #gzip  on;

    include /Users/user/Work/servers;
}

Answer the question

In order to leave comments, you need to log in

2 answer(s)
K
ky0, 2021-11-16
@ky0

First, look in the logs to see who issues the timeout - nginx or whatever is behind it. Wangyu that there will be a second option - and therefore, it will be useful to remove the corresponding tag from the question, changing it to what you have inside.

V
VA_ic2b, 2021-11-16
@VA_ic2b

The default timeout in nginx is 60 sec.
Estimate the time required for testing.
Increase timeout to the required value in /etc/nginx/nginx.conf
in the http section:
http{
...
proxy_read_timeout 600;
proxy_connect_timeout 600;
proxy_send_timeout 600;
...
}
In the above example, 600 sec.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question