]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
These are used to run test scenarios against snom phones for automated testing
authorBrian West <brian@freeswitch.org>
Fri, 4 Jan 2008 18:24:00 +0000 (18:24 +0000)
committerBrian West <brian@freeswitch.org>
Fri, 4 Jan 2008 18:24:00 +0000 (18:24 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@7082 d0543943-73ff-0310-b7d9-9358b9ac24b2

scripts/scenario/attended_transfer.button [new file with mode: 0644]
scripts/scenario/blind_transfer.button [new file with mode: 0644]
scripts/scenario/offhook.button [new file with mode: 0644]
scripts/scenario/phones.cfg [new file with mode: 0644]
scripts/scenario/runscenario.pl [new file with mode: 0755]

diff --git a/scripts/scenario/attended_transfer.button b/scripts/scenario/attended_transfer.button
new file mode 100644 (file)
index 0000000..c46e79a
--- /dev/null
@@ -0,0 +1,14 @@
+Snom_300,key,CANCEL
+Snom_360,key,CANCEL
+Snom_370,key,CANCEL
+Snom_300,key,ONHOOK
+Snom_360,key,ONHOOK
+Snom_370,key,ONHOOK,1
+Snom_300,number,1006,1
+Snom_360,key,OFFHOOK, 1
+Snom_360,key,F_HOLD, 1
+Snom_360,number,1007,2
+Snom_370,key,OFFHOOK,1
+Snom_360,key,F_TRANSFER,2
+Snom_360,key,ONHOOK
+
diff --git a/scripts/scenario/blind_transfer.button b/scripts/scenario/blind_transfer.button
new file mode 100644 (file)
index 0000000..71f3ea8
--- /dev/null
@@ -0,0 +1,11 @@
+Snom_300,key,CANCEL
+Snom_360,key,CANCEL
+Snom_370,key,CANCEL
+Snom_300,key,ONHOOK
+Snom_360,key,ONHOOK
+Snom_370,key,ONHOOK,1
+Snom_300,number,1006,1
+Snom_360,key,OFFHOOK,1
+Snom_360,key,F_TRANSFER,1
+Snom_360,number,1007,2
+Snom_370,key,OFFHOOK,1
diff --git a/scripts/scenario/offhook.button b/scripts/scenario/offhook.button
new file mode 100644 (file)
index 0000000..79d61d5
--- /dev/null
@@ -0,0 +1,8 @@
+Snom_300,key,OFFHOOK
+Snom_320,key,OFFHOOK
+Snom_360,key,OFFHOOK
+Snom_370,key,OFFHOOK
+Snom_300,key,ONHOOK
+Snom_320,key,ONHOOK
+Snom_360,key,ONHOOK
+Snom_370,key,ONHOOK
diff --git a/scripts/scenario/phones.cfg b/scripts/scenario/phones.cfg
new file mode 100644 (file)
index 0000000..ef86948
--- /dev/null
@@ -0,0 +1,4 @@
+Snom_300,10.0.1.241,1000
+Snom_320,10.0.1.242,1002
+Snom_360,10.0.1.243,1006
+Snom_370,10.0.1.244,1007
diff --git a/scripts/scenario/runscenario.pl b/scripts/scenario/runscenario.pl
new file mode 100755 (executable)
index 0000000..14b7515
--- /dev/null
@@ -0,0 +1,59 @@
+#!/usr/bin/perl
+#
+#  Scenario Test Execution.
+#
+use LWP::UserAgent;
+use Data::Dumper;
+
+$| =1;
+
+our $ua = LWP::UserAgent->new;
+my $phone = load_config();
+
+if(-f $ARGV[0]) {
+  run_scenario($ARGV[0]);
+} else {
+  print "No Scenario File?\n";
+  exit;
+}
+
+sub run_scenario($$) {
+  $file = shift;
+  open(SCENARIO,"<$file");
+  @commands = <SCENARIO>;
+  print Dumper $info;
+  foreach $command (@commands) {
+    chomp $command;
+    my($target, $type, $button, $delay) = split(",",$command);
+    &push_button($phone->{$target}, "$type", "$button", $delay);
+
+  }
+}
+
+sub push_button ($$$) {
+  $info = shift;
+  $type = shift;
+  $button = shift;
+  $delay = shift;
+
+  if($delay) {
+    sleep($delay);
+  } else {
+    $delay = 0;
+  }
+  print "$info->{name} -> $type => $button with delay $delay\n";
+
+  $request = HTTP::Request->new("GET", "http://$info->{ip}/command.htm?$type=$button");
+  $return = $ua->request($request);
+}
+
+sub load_config {
+  open(CFG,"<phones.cfg");
+  @phones = <CFG>;
+  foreach $line (@phones) {
+    chomp $line;
+    my($name,$ip,$extension) = split(",", $line);
+    $phone->{$name} = {name => $name, ip => $ip, extension => $extension}
+  }
+  return $phone;
+}