aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/share/perl/test
diff options
context:
space:
mode:
authorAdam Frisby2008-03-25 16:29:54 +0000
committerAdam Frisby2008-03-25 16:29:54 +0000
commit8c05b81d6860d8e0da4098cc6f59f630d7c53037 (patch)
tree3325e09660ee8ad5a12cc19c8da6c4bd8bff5c21 /share/perl/test
parent* On Ray casting. Now returning the face normal of the collision face. (diff)
downloadopensim-SC_OLD-8c05b81d6860d8e0da4098cc6f59f630d7c53037.zip
opensim-SC_OLD-8c05b81d6860d8e0da4098cc6f59f630d7c53037.tar.gz
opensim-SC_OLD-8c05b81d6860d8e0da4098cc6f59f630d7c53037.tar.bz2
opensim-SC_OLD-8c05b81d6860d8e0da4098cc6f59f630d7c53037.tar.xz
* Committing Lulurun's Cgi/Perl implementation of the UGAI servers.
* I love you long time.
Diffstat (limited to 'share/perl/test')
-rw-r--r--share/perl/test/OpenSimTest.pm53
-rw-r--r--share/perl/test/OpenSimTest/AssetTester.pm17
-rw-r--r--share/perl/test/OpenSimTest/Config.pm53
-rw-r--r--share/perl/test/OpenSimTest/GridTester.pm62
-rw-r--r--share/perl/test/OpenSimTest/InventoryTester.pm116
-rw-r--r--share/perl/test/OpenSimTest/UserTester.pm53
-rw-r--r--share/perl/test/PerformanceTest.pl78
-rw-r--r--share/perl/test/SingleTest.pl21
8 files changed, 453 insertions, 0 deletions
diff --git a/share/perl/test/OpenSimTest.pm b/share/perl/test/OpenSimTest.pm
new file mode 100644
index 0000000..a24ae22
--- /dev/null
+++ b/share/perl/test/OpenSimTest.pm
@@ -0,0 +1,53 @@
1package OpenSimTest;
2
3use strict;
4use PerformanceTest;
5use OpenSimTest::Config;
6use OpenSimTest::UserTester;
7use OpenSimTest::GridTester;
8use OpenSimTest::AssetTester;
9use OpenSimTest::InventoryTester;
10
11sub init {
12 UserTester::init();
13 GridTester::init();
14 AssetTester::init();
15 InventoryTester::init();
16}
17
18sub SingleTest {
19 my $url = shift;
20 my $methodname = shift;
21 my @ARGS = @_;
22
23 if (!$OpenSimTest::Config::HANDLER_LIST{$methodname}) {
24 Carp::croak("unknown handler name: [$methodname]");
25 } else {
26 my $handler = $OpenSimTest::Config::HANDLER_LIST{$methodname};
27 my $result = $handler->($url, @ARGS);
28 return $result;
29 }
30}
31
32sub PerformanceCompare {
33 my $server_name = shift;
34 my $count = shift;
35 my @args = @_;
36 my $test = new PerformanceTest();
37 {
38 my @params = @args;
39 unshift(@params, $OpenSimTest::Config::APACHE_SERVERS{$server_name});
40 $test->add_test("APACHE::$args[0]", \&OpenSimTest::SingleTest, \@params);
41 }
42 {
43 my @params = @args;
44 unshift(@params, $OpenSimTest::Config::OPENSIM_SERVERS{$server_name});
45 $test->add_test("OPENSIM::$args[0]", \&OpenSimTest::SingleTest, \@params);
46 }
47 $test->set_count($count);
48 $test->start();
49 print "\n\n";
50 #$test->bref_result();
51}
52
531;
diff --git a/share/perl/test/OpenSimTest/AssetTester.pm b/share/perl/test/OpenSimTest/AssetTester.pm
new file mode 100644
index 0000000..ba05205
--- /dev/null
+++ b/share/perl/test/OpenSimTest/AssetTester.pm
@@ -0,0 +1,17 @@
1package AssetTester;
2
3use strict;
4use XML::Serializer;
5use OpenSim::Utility;
6
7sub init {
8 &OpenSimTest::Config::registerHandler("get_asset", \&_get_asset);
9}
10
11sub _get_asset {
12 my $url = shift || $OpenSimTest::Config::ASSET_SERVER_URL;
13 my $asset_id = shift;
14 my $res = &OpenSim::Utility::HttpGetRequest($url . "/assets/" . $asset_id) . "\n";
15}
16
171;
diff --git a/share/perl/test/OpenSimTest/Config.pm b/share/perl/test/OpenSimTest/Config.pm
new file mode 100644
index 0000000..14ab3ed
--- /dev/null
+++ b/share/perl/test/OpenSimTest/Config.pm
@@ -0,0 +1,53 @@
1package OpenSimTest::Config;
2
3use strict;
4
5my $apache_server_host = "localhost";
6my $opensim_server_host = "localhost";
7
8# REGION
9our $SIM_RECV_KEY = "";
10our $SIM_SEND_KEY = "";
11# ASSET
12#our $ASSET_SERVER_URL = "http://127.0.0.1:8003/";
13our $ASSET_SERVER_URL = "http://$apache_server_host/opensim/asset.cgi";
14our $ASSET_RECV_KEY = "";
15our $ASSET_SEND_KEY = "";
16# USER
17#our $USER_SERVER_URL = "http://127.0.0.1:8001/";
18our $USER_SERVER_URL = "http://$apache_server_host/opensim/user.cgi";
19our $USER_RECV_KEY = "";
20our $USER_SEND_KEY = "";
21# GRID
22#our $GRID_SERVER_URL = "http://127.0.0.1:8001/";
23our $GRID_SERVER_URL = "http://$apache_server_host/opensim/grid.cgi";
24our $GRID_RECV_KEY = "";
25our $GRID_SEND_KEY = "";
26# INVENTORY
27#our $INVENTORY_SERVER_URL = "http://127.0.0.1:8004";
28our $INVENTORY_SERVER_URL = "http://$apache_server_host/opensim/inventory.cgi";
29# handler list
30our %HANDLER_LIST = ();
31
32our %APACHE_SERVERS = (
33 user => "http://$apache_server_host/opensim/user.cgi",
34 grid => "http://$apache_server_host/opensim/grid.cgi",
35 asset => "http://$apache_server_host/opensim/asset.cgi",
36 inventory => "http://$apache_server_host/opensim/inventory.cgi",
37);
38
39our %OPENSIM_SERVERS = (
40 user => "http://$opensim_server_host:8002",
41 grid => "http://$opensim_server_host:8001",
42 asset => "http://$opensim_server_host:8003",
43 inventory => "http://$opensim_server_host:8004",
44);
45
46sub registerHandler {
47 my ($name, $func) = @_;
48 $HANDLER_LIST{$name} = $func;
49}
50
51
521;
53
diff --git a/share/perl/test/OpenSimTest/GridTester.pm b/share/perl/test/OpenSimTest/GridTester.pm
new file mode 100644
index 0000000..61fef6b
--- /dev/null
+++ b/share/perl/test/OpenSimTest/GridTester.pm
@@ -0,0 +1,62 @@
1package GridTester;
2
3use strict;
4use OpenSim::Utility;
5
6sub init {
7 &OpenSimTest::Config::registerHandler("simulator_login", \&_simulator_login);
8 &OpenSimTest::Config::registerHandler("simulator_data_request", \&_simulator_data_request);
9 &OpenSimTest::Config::registerHandler("simulator_after_region_moved", \&_simulator_after_region_moved);
10 &OpenSimTest::Config::registerHandler("map_block", \&_map_block);
11}
12
13sub _simulator_login {
14 my $url = shift || $OpenSimTest::Config::GRID_SERVER_URL;
15 my @param = @_;
16 my %xml_rpc_param = (
17 "authkey" => "null",
18 "UUID" => $param[0],
19 "sim_ip" => $param[1],
20 "sim_port" => $param[2],
21 "region_locx" => 1000,
22 "region_locy" => 1000,
23 "sim_name" => "OpenTest",
24 "http_port" => 9000,
25 "remoting_port" => 8895,
26 "map-image-id" => "0e5a5e87-08d9-4b37-9b8e-a4c3c4e409ab",
27 );
28 return &OpenSim::Utility::XMLRPCCall($url, "simulator_login", \%xml_rpc_param);
29}
30
31sub _map_block {
32 my $url = shift || $OpenSimTest::Config::GRID_SERVER_URL;
33 my @param = @_;
34 my %xml_rpc_param = (
35 xmin => $param[0],
36 ymin => $param[1],
37 xmax => $param[2],
38 ymax => $param[3],
39 );
40 return &OpenSim::Utility::XMLRPCCall($url, "map_block", \%xml_rpc_param);
41}
42
43sub _simulator_data_request {
44 my $url = shift || $OpenSimTest::Config::GRID_SERVER_URL;
45 my @param = @_;
46 my %xml_rpc_param = (
47 region_handle => $param[0],
48 authkey => undef,
49 );
50 return &OpenSim::Utility::XMLRPCCall($url, "simulator_data_request", \%xml_rpc_param);
51}
52
53sub _simulator_after_region_moved {
54 my $url = shift || $OpenSimTest::Config::GRID_SERVER_URL;
55 my @param = @_;
56 my %xml_rpc_param = (
57 UUID => $param[0],
58 );
59 return &OpenSim::Utility::XMLRPCCall($url, "simulator_after_region_moved", \%xml_rpc_param);
60}
61
621;
diff --git a/share/perl/test/OpenSimTest/InventoryTester.pm b/share/perl/test/OpenSimTest/InventoryTester.pm
new file mode 100644
index 0000000..76615b1
--- /dev/null
+++ b/share/perl/test/OpenSimTest/InventoryTester.pm
@@ -0,0 +1,116 @@
1package InventoryTester;
2
3use strict;
4use XML::Serializer;
5use OpenSim::Utility;
6
7sub init {
8 &OpenSimTest::Config::registerHandler("create_inventory", \&_create_inventory);
9 &OpenSimTest::Config::registerHandler("root_folders", \&_root_folders);
10 &OpenSimTest::Config::registerHandler("get_inventory", \&_get_inventory);
11 &OpenSimTest::Config::registerHandler("new_item", \&_new_item);
12 &OpenSimTest::Config::registerHandler("new_folder", \&_new_folder);
13}
14
15sub _apache_flag {
16 my $url = shift;
17 return $url =~ /inventory.cgi/ ? 1 : 0;
18}
19
20sub _new_folder {
21 my $url = shift || $OpenSimTest::Config::INVENTORY_SERVER_URL;
22 my $post_data =<<"POSTDATA";
23<InventoryFolderBase>
24<name>New Folder</name>
25 <agentID>
26<UUID>b9cb58e8-f3c9-4af5-be47-029762baa68f</UUID>
27</agentID>
28 <parentID>
29<UUID>500ea141-2967-49e2-9e18-fcdedffe68df</UUID>
30</parentID>
31 <folderID>
32<UUID>aa6f9220-c945-0b23-6141-43c9ef734100</UUID>
33</folderID>
34<type>-1</type>
35<version>0</version>
36</InventoryFolderBase>
37POSTDATA
38 if (&_apache_flag($url)) {
39 $post_data = "POSTDATA=" . $post_data; # TODO: bad temporary solution
40 }
41 my $res = &OpenSim::Utility::HttpPostRequest($url . "/NewFolder/", $post_data) . "\n";
42}
43
44sub _new_item {
45 my $url = shift || $OpenSimTest::Config::INVENTORY_SERVER_URL;
46 my $post_data =<<"POSTDATA";
47<InventoryItemBase>
48 <inventoryID>
49<UUID>f975d038-3bd7-4e8b-a945-f46b0c962ee3</UUID>
50</inventoryID>
51 <assetID>
52<UUID>5f50f162-1cc6-4907-99be-a4c81d7f5e10</UUID>
53</assetID>
54<assetType>6</assetType>
55<invType>6</invType>
56 <parentFolderID>
57<UUID>7018dc23-43a9-493f-b3f7-869a6bbad0f3</UUID>
58</parentFolderID>
59 <avatarID>
60<UUID>b9cb58e8-f3c9-4af5-be47-029762baa68f</UUID>
61</avatarID>
62 <creatorsID>
63<UUID>b9cb58e8-f3c9-4af5-be47-029762baa68f</UUID>
64</creatorsID>
65<inventoryName>Primitive</inventoryName>
66<inventoryDescription/>
67<inventoryNextPermissions>2147483647</inventoryNextPermissions>
68<inventoryCurrentPermissions>526053692</inventoryCurrentPermissions>
69<inventoryBasePermissions>2147483647</inventoryBasePermissions>
70<inventoryEveryOnePermissions>0</inventoryEveryOnePermissions>
71</InventoryItemBase>
72POSTDATA
73 if (&_apache_flag($url)) {
74 $post_data = "POSTDATA=" . $post_data;
75 }
76 my $res = &OpenSim::Utility::HttpPostRequest($url . "/NewItem/", $post_data) . "\n";
77}
78
79sub _get_inventory {
80 my $url = shift || $OpenSimTest::Config::INVENTORY_SERVER_URL;
81 my $uuid = shift;
82 my $serializer = new XML::Serializer($uuid, "guid");
83 my $post_data = $serializer->to_string(XML::Serializer::WITH_HEADER);
84 if (&_apache_flag($url)) {
85 $post_data = "POSTDATA=" . $post_data;
86 }
87 my $res = &OpenSim::Utility::HttpPostRequest($url . "/GetInventory/", $post_data) . "\n";
88 return 1;
89}
90
91sub _create_inventory {
92 my $url = shift || $OpenSimTest::Config::INVENTORY_SERVER_URL;
93 my $uuid = shift;
94 my $serializer = new XML::Serializer($uuid, "guid");
95 my $post_data = $serializer->to_string(XML::Serializer::WITH_HEADER);
96 if (&_apache_flag($url)) {
97 $post_data = "POSTDATA=" . $post_data;
98 }
99 my $res = &OpenSim::Utility::HttpPostRequest($url . "/CreateInventory/", $post_data) . "\n";
100 return 1;
101}
102
103sub _root_folders {
104 my $url = shift || $OpenSimTest::Config::INVENTORY_SERVER_URL;
105 my $uuid = shift;
106 my $serializer = new XML::Serializer($uuid, "guid");
107 my $post_data = $serializer->to_string(XML::Serializer::WITH_HEADER);
108 if (&_apache_flag($url)) {
109 $post_data = "POSTDATA=" . $post_data;
110 }
111 my $res = &OpenSim::Utility::HttpPostRequest($url . "/RootFolders/", $post_data) . "\n";
112 return 1;
113}
114
1151;
116
diff --git a/share/perl/test/OpenSimTest/UserTester.pm b/share/perl/test/OpenSimTest/UserTester.pm
new file mode 100644
index 0000000..194102a
--- /dev/null
+++ b/share/perl/test/OpenSimTest/UserTester.pm
@@ -0,0 +1,53 @@
1package UserTester;
2
3use strict;
4use Digest::MD5;
5use OpenSim::Utility;
6
7my $user_server_url;
8
9sub init {
10 &OpenSimTest::Config::registerHandler("login_to_simulator", \&_login_to_simulator);
11 &OpenSimTest::Config::registerHandler("get_user_by_name", \&_get_user_by_name);
12 &OpenSimTest::Config::registerHandler("get_user_by_uuid", \&_get_user_by_uuid);
13 &OpenSimTest::Config::registerHandler("get_avatar_picker_avatar", \&_get_avatar_picker_avatar);
14}
15
16sub _login_to_simulator {
17 my $url = shift || $OpenSimTest::Config::USER_SERVER_URL;
18 my @param = @_;
19 my %xml_rpc_param = (
20 first => $param[0],
21 last => $param[1],
22 passwd => "\$1\$" . Digest::MD5::md5_hex($param[2]),
23 start => "last",
24 version => "1.18.3.5",
25 mac => "cc82e1e2bfd24e5424d66b4fd3f70d55",
26 );
27 return &OpenSim::Utility::XMLRPCCall($url, "login_to_simulator", \%xml_rpc_param);
28}
29
30sub _get_user_by_name {
31 my $url = shift || $OpenSimTest::Config::USER_SERVER_URL;
32 my @param = @_;
33 my %xml_rpc_param = (
34 avatar_name => $param[0],
35 );
36 return &OpenSim::Utility::XMLRPCCall($url, "get_user_by_name", \%xml_rpc_param);
37}
38
39# sample uuid:
40# db836502-de98-49c9-9edc-b90a67beb0a8
41sub _get_user_by_uuid {
42 my $url = shift || $OpenSimTest::Config::USER_SERVER_URL;
43 my @param = @_;
44 my %xml_rpc_param = (
45 avatar_uuid => $param[0],
46 );
47 return &OpenSim::Utility::XMLRPCCall($url, "get_user_by_uuid", \%xml_rpc_param);
48}
49
50sub _get_avatar_picker_avatar {
51}
52
531;
diff --git a/share/perl/test/PerformanceTest.pl b/share/perl/test/PerformanceTest.pl
new file mode 100644
index 0000000..5f570e8
--- /dev/null
+++ b/share/perl/test/PerformanceTest.pl
@@ -0,0 +1,78 @@
1#!/usr/bin/perl
2
3# Usage:
4# ./PerformanceTest.pl
5# 2 variables should be changed:
6# Line 14: $fork_limit
7# Line 13: $benchmark_loop_count
8#
9
10use strict;
11use OpenSimTest;
12
13my $script = "./PerformanceTest.pl";
14my $fork_limit = 50; # the number of process
15my $benchmark_loop_count = 10000; # the number of requests sent by each process
16
17my @child_pid = ();
18
19for(1..$fork_limit) {
20 my $pid = fork;
21 if ($pid) {
22 &parent_do($pid);
23 } elsif ($pid == 0) {
24 &child_do;
25 exit(0);
26 } else {
27 die "could not fork";
28 }
29}
30
31foreach (@child_pid) {
32 waitpid($_, 0);
33}
34
35
36sub parent_do {
37 my $pid = shift;
38 push(@child_pid, $pid);
39}
40
41sub child_do {
42 #for(1..10000) {
43 # print "$_ ";
44 #}
45 &OpenSimTest::init();
46 # user
47 &OpenSimTest::PerformanceCompare("user", $benchmark_loop_count, "get_user_by_name", "Test User");
48 &OpenSimTest::PerformanceCompare("user", $benchmark_loop_count, "get_user_by_uuid", "db836502-de98-49c9-9edc-b90a67beb0a8");
49 # grid
50 &OpenSimTest::PerformanceCompare("grid", $benchmark_loop_count, "simulator_login", "3507f395-88e5-468c-a45f-d4fd96a1c668", "10.8.1.148", 9000);
51 &OpenSimTest::PerformanceCompare("grid", $benchmark_loop_count, "simulator_data_request", "1099511628032000");
52 &OpenSimTest::PerformanceCompare("grid", $benchmark_loop_count, "map_block", 999, 999, 1001, 1001);
53 # asset
54 &OpenSimTest::PerformanceCompare("asset", $benchmark_loop_count, "get_asset", "00000000000022223333000000000001");
55 # inventory
56 &OpenSimTest::PerformanceCompare("inventory", $benchmark_loop_count, "root_folders", "b9cb58e8-f3c9-4af5-be47-029762baa68f");
57 &OpenSimTest::PerformanceCompare("inventory", $benchmark_loop_count, "get_inventory", "b9cb58e8-f3c9-4af5-be47-029762baa68f");
58}
59
60__END__
61my $count = 10000;
62
63&OpenSimTest::init();
64# user
65#&OpenSimTest::PerformanceCompare("user", $count, "get_user_by_name", "Test User");
66#&OpenSimTest::PerformanceCompare("user", $count, "get_user_by_uuid", "db836502-de98-49c9-9edc-b90a67beb0a8");
67# grid
68#&OpenSimTest::PerformanceCompare("grid", $count, "simulator_login", "3507f395-88e5-468c-a45f-d4fd96a1c668", "10.8.1.148", 9000);
69#&OpenSimTest::PerformanceCompare("grid", $count, "simulator_data_request", "1099511628032000");
70#&OpenSimTest::PerformanceCompare("grid", $count, "map_block", 999, 999, 1001, 1001);
71# asset
72&OpenSimTest::PerformanceCompare("asset", $count, "get_asset", "00000000000022223333000000000001");
73# inventory
74#&OpenSimTest::PerformanceCompare("inventory", $count, "create_inventory", "b9cb58e8-f3c9-4af5-be47-029762baa68f");
75#&OpenSimTest::PerformanceCompare("inventory", $count, "root_folders", "b9cb58e8-f3c9-4af5-be47-029762baa68f");
76#&OpenSimTest::PerformanceCompare("inventory", $count, "get_inventory", "b9cb58e8-f3c9-4af5-be47-029762baa68f");
77#&OpenSimTest::PerformanceCompare("inventory", $count, "new_item");
78#&OpenSimTest::PerformanceCompare("inventory", $count, "new_folder");
diff --git a/share/perl/test/SingleTest.pl b/share/perl/test/SingleTest.pl
new file mode 100644
index 0000000..e6be081
--- /dev/null
+++ b/share/perl/test/SingleTest.pl
@@ -0,0 +1,21 @@
1#!/usr/bin/perl
2
3# usage:
4# ./SingleTest.pl $URL $METHOD @PARAMETERS
5# example
6# ./SingleTest.pl http://127.0.0.1/user.cgi get_user_by_name "Test User"
7# ./SingleTest.pl http://127.0.0.1/grid.cgi simulator_login 3507f395-88e5-468c-a45f-d4fd96a1c668 10.8.1.148 9000
8# ./SingleTest.pl http://127.0.0.1/grid.cgi map_block 999 999 1001 1001
9# ./SingleTest.pl http://127.0.0.1/asset.cgi get_asset 00000000000022223333000000000001
10#
11
12use strict;
13use Data::Dump;
14use OpenSimTest;
15
16&OpenSimTest::init();
17my $url = shift @ARGV;
18#my $url = "http://localhost:8002";
19my $result = &OpenSimTest::SingleTest($url, @ARGV);
20Data::Dump::dump($result);
21