yegor256 / phprack

phpRack Integration Testing Framework
www.phprack.com
Other
24 stars 5 forks source link

to implement Quality-Of-Service assertions (latency) #72

Closed yegor256 closed 11 years ago

yegor256 commented 11 years ago

migrated from Trac, where originally posted by yegor256 on 22-Aug-2010 8:01am

Would be nice to have latency test:

<?php
class QosTest extends PhpRack_Test
{
    public function testLatency()
    {
        $this->assert->qos->latency(
            'http://www.example.com'
        );
    }
}

This way we can implement self-testable platforms.

yegor256 commented 11 years ago

migrated from Trac, where originally posted by yegor256 on 22-Aug-2010 8:02am

Adrian, what do you think? Can you implement it in 2 hours? If yes, please go ahead.

yegor256 commented 11 years ago

migrated from Trac, where originally posted by yegor256 on 23-Aug-2010 4:44am

More extensive example:

<?php
class QosTest extends PhpRack_Test
{
    public function testLatency()
    {
        $this->assert->qos->latency(
            array(
                'scenario' => array(
                    'http://www.example.com',
                    '/index',
                    '/user-profile/' .  rand(1, 99),
                ),
                'averageMs' => 500, // 500ms average per request
                'peakMs' => 2000, // 2s maximum per request
            ),
        );
    }
}
yegor256 commented 11 years ago

migrated from Trac, where originally posted by yegor256 on 23-Aug-2010 4:47am

latency() accepts one argument, which is either a string (URL of the web page to test), or an array with parameters (default values are in squared brackets):

yegor256 commented 11 years ago

migrated from Trac, where originally posted by netcoderpl on 24-Aug-2010 2:11pm

I have two questions

In "scenario" first url is absolute, and next are relative. It will be always true? How we will determine correct host if first url is relative?

"testsTotal" - It mean requests or cycles? Each url should be checked by default 50 times or our method should make totally 50 requests?

yegor256 commented 11 years ago

migrated from Trac, where originally posted by yegor256 on 26-Aug-2010 5:19am

Let's skip the relative URLs. All URLs should be absolute. If not, we will throw an exception.

testsTotal means the total amount of requests made. testsTotal=50 means that we will make 50 HTTP requests in total. If there are two URLs, every one of them will receive 25 requests.

yegor256 commented 11 years ago

migrated from Trac, where originally posted by netcoderpl on 26-Aug-2010 3:52pm

In [652]:

#CommitTicketReference repository="" revision="652"
refs #72 - new branch created
yegor256 commented 11 years ago

migrated from Trac, where originally posted by netcoderpl on 26-Aug-2010 3:53pm

In [653]:

#CommitTicketReference repository="" revision="653"
refs #72 - implemented
yegor256 commented 11 years ago

migrated from Trac, where originally posted by netcoderpl on 26-Aug-2010 3:54pm

Please review.

yegor256 commented 11 years ago

migrated from Trac, where originally posted by yegor256 on 27-Aug-2010 8:25am

In [654]:

#CommitTicketReference repository="" revision="654"
refs #72 - implemented in branch and merged into trunk
yegor256 commented 11 years ago

migrated from Trac, where originally posted by yegor256 on 27-Aug-2010 8:26am

In [655]:

#CommitTicketReference repository="" revision="655"
refs #72 - phpcs fixes
yegor256 commented 11 years ago

migrated from Trac, where originally posted by yegor256 on 27-Aug-2010 8:35am

[wiki:Assertions@21] updated

yegor256 commented 11 years ago

migrated from Trac, where originally posted by yegor256 on 27-Aug-2010 8:35am

In [656]:

#CommitTicketReference repository="" revision="656"
closes #72 - branch closed
yegor256 commented 11 years ago

migrated from Trac, where originally posted by yegor256 on 27-Aug-2010 8:36am

many thanks!