-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathLoadTestingTest.class.php
More file actions
110 lines (90 loc) · 2.53 KB
/
LoadTestingTest.class.php
File metadata and controls
110 lines (90 loc) · 2.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<?php
/* Copyright: Bickel Advisory Services, LLC. */
require_once('LoadTestingSession.class.php');
/** Load Testing Test Exception */
class LoadTestingTestException extends Exception {};
/** Load Testing Test */
abstract class LoadTestingTest
{
/** @var LoadTestingSession Access to object to invoke requests to pages and wrap CURL. */
protected $session = null;
/** Verbose mode */
protected $verbose = false;
/** Ini settings */
protected $iniSettings = array();
/** Test Number */
protected $testNum = null;
/**
* Constructor
* @param int $testNum Test Number
* @param string $rand Random token for test
* @param string $resourceUrl Optional URL specifying host that resources will
* be loaded for. The hostname is grabbed from this URL.
*/
public function __construct($testNum, $rand, $resourceUrl = null)
{
// Set up session
$this->session = new LoadTestingSession($testNum, $rand);
// Save test number
$this->testNum = $testNum;
// Load resource only from base url
if ($resourceUrl && preg_match('/^(https?:\\/\\/[^\\/]+)(?:\\/.*)?$/', $resourceUrl, $match))
$this->session->loadableResourceBaseUrl = $match[1] . '/';
}
/** Enable resource loading */
public function enableResourceLoading() {
$this->session->enableResourceLoading();
}
/** Disable resource loading */
public function disableResourceLoading() {
$this->session->disableResourceLoading();
}
/**
* Set delay between page loads
* @param int $minDelayMs Minimum delay in ms
* @param int $maxDelayMs Maximum delay in ms
*/
public function setDelay($minDelayMs, $maxDelayMs) {
$this->session->setDelay($minDelayMs, $maxDelayMs);
}
/**
* Gets most recently used delay.
* @return int
*/
public function getDelay(){
return $this->session->getDelay();
}
/**
* Set ini settings
* @param array $iniSettings INI settings
*/
public function setIniSettings($iniSettings) {
$this->iniSettings = $iniSettings;
}
/**
* Get the iniSettings (hashmap)
* @return HashMap Settings for test
*/
public function getIniSettings(){
return $this->iniSettings;
}
/**
* Get the sesssion object, which wraps CURL for simple tests.
* @return LoadTestingSession Session object.
*/
public function getSession(){
return $this->session;
}
/** Verbose */
public function verbose() {
$this->verbose = true;
$this->session->verbose();
}
/** Non-verbose */
public function nonVerbose() {
$this->verbose = false;
$this->session->nonVerbose();
}
/** Start the test */
public abstract function startTest();
}