-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathloadtest.pl
executable file
·65 lines (58 loc) · 1.26 KB
/
loadtest.pl
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
#!/usr/bin/perl
$|=1;
my $site = "www.example.com";
my $user = "admin";
my $pass = "123qwe";
my $numUsers = 10;
my $minutesToRun = 3;
my $secondsBetweenClicks = 1;
use strict;
use WWW::Mechanize;
my @pids;
my $pid;
for (1..$numUsers) {
die "fork: $!" unless defined ($pid = fork());
if ($pid) {
push(@pids,$pid);
} else {
run();
exit;
}
}
sub run {
my $start = time();
while (time()-$start < $minutesToRun*60) {
print "\nATTENTION: Starting new worker.\n";
doWork();
}
}
sub doWork {
my $agent = WWW::Mechanize->new();
$agent->get("http://".$site."/");
waitForIt();
$agent->submit_form(
form_number=>1,
fields => {
username=>$user,
identifier=>$pass
}
);
waitForIt();
$agent->follow_link(text => "Turn Admin On!", n => "1");
waitForIt();
$agent->get("http://".$site."/index.pl/home?op=listUsers");
waitForIt();
$agent->follow_link(text => "Add a new user.", n => "1");
waitForIt();
$agent->get("http://".$site."/index.pl/home?op=listGroups");
waitForIt();
$agent->follow_link(text => "Add new group.", n => "1");
waitForIt();
$agent->get("http://".$site."/index.pl/home?op=manageSettings");
waitForIt();
$agent->follow_link(text => "Edit Profile Settings", n => "1");
waitForIt();
}
sub waitForIt {
sleep($secondsBetweenClicks);
}